0bps

Strategy vault / Breakout

Breakthrough Moving Average Trend Tracking Strategy

This strategy combines moving average, amplitude index and parabolic SAR indicator to judge the trend and confirm breakthrough points. It belongs to a typical trend following strategy. It will establish long position…

Author
ChaoZhang
Complexity
Intermediate · 45 lines
Parameters
7
Backtest bar
1h · intraday
Tested on
BTC/USDT · futures

IMG

Overview

This strategy combines moving average, amplitude index and parabolic SAR indicator to judge the trend and confirm breakthrough points. It belongs to a typical trend following strategy. It will establish long position to track the trend when identifying an uptrend and price breakthrough. It will close position for stop loss when judging trend reversal.

Principles

The strategy uses double EMA to judge price trend and uses SMA as assistance. When fast EMA is above slow EMA and fast SMA is above slow SMA, it considers there is an uptrend.

It uses parabolic SAR indicator to judge price reversal points. When PSAR goes below the highest price, it means price may reverse downwards. At this time it will close position for stop loss.

When judging an uptrend and PSAR goes above highest price, it means price keeps going up. At this time it will long to track the trend.

Advantages

  • Use double EMA with SMA to judge trend, which can filter false breakthrough.
  • PSAR can effectively determine reversal points for quick stop loss.
  • Can effectively identify trend reversal points for timely establishing position to track.
  • Simple and clear rules.

Risks

  • Trend judgement may be wrong.
  • The strategy needs parameter optimization for different products, otherwise chasing risk may be high.
  • No consideration for trading cost.

Solutions:

  • Optimize EMA and SMA parameters to improve judgement accuracy.
  • Optimize PSAR parameters for different products.
  • Add in trading cost.

Optimization

  • Add more indicators like BOLL, MACD etc to judge trend.
  • Train and optimize parameters for different products.
  • Consider adding stop loss strategy.
  • Optimize logics for opening position and stop loss.

Summary

The strategy belongs to a typical trend following strategy. The advantages are clear and simple rules and ability to identify trend reversal for timely position opening. The disadvantages are sensitivity to parameters and certain chasing risk. Overall it is worth further optimization and adjustment for live trading verification. The main optimization directions are parameter optimization, adding stop loss strategy etc.

Parameters

NameDefaultWhat it controls
v_input_10.02PSAR_start
v_input_20.02PSAR_increment
v_input_30.2PSAR_maximum
v_input_420EMA_fast
v_input_540EMA_slow
v_input_6100SMA_fast
v_input_7200SMA_slow

Source Pine Script

/*backtest
start: 2023-11-27 00:00:00
end: 2023-12-27 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=3
strategy("Buy Dip MA & PSAR", overlay=true)

PSAR_start = input(0.02)
PSAR_increment = input(0.02)
PSAR_maximum = input(0.2)

EMA_fast = input(20)
EMA_slow = input(40)
SMA_fast = input(100)
SMA_slow = input(200)

emafast = ema(close, EMA_fast)
emaslow = ema(close, EMA_slow)
smafast = sma(close, SMA_fast)
smaslow = sma(close, SMA_slow)

psar = sar(PSAR_start, PSAR_increment, PSAR_maximum)
uptrend = emafast > emaslow and smafast > smaslow
breakdown = not uptrend

if (psar >= high and uptrend)
    strategy.entry("Buy", strategy.long, stop=psar, comment="Buy")
else
    strategy.cancel("Buy")

if (psar <= low)
    strategy.exit("Close", "Buy", stop=psar, comment="Close")
else
    strategy.cancel("Close")

if (breakdown)
    strategy.close("Buy")


plot(emafast, color=blue)
plot(emaslow, color=red)

Published by ChaoZhang on the FMZ strategy square · last modified 2023-12-28. Collected in the Quant Trading Vault. Unvalidated research: re-test with your own data and costs before trusting it.

Build this with AgenKit

A spec is not a trading system. Paste this into your coding agent and AgenKit runs a specialist team — architecture, test-first build, risk gates, review — with paper trading on by default.

in Claude Code, Cursor, Codex & 4 more
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/Breakthrough-Moving-Average-Trend-Tracking-Strategy.md
  1. npx agenkit install engineering-kit in your project
  2. Paste the command into your agent and approve each phase
  3. Get tests, backtest, risk controls and a paper-trading switch

Understand it first

Before you run this, read the lesson behind the idea and how to backtest it honestly. Specs like this one are the survivors of an unknown number of trials; deflate their results accordingly.

Related specs

esc

Try , , or .

↑↓ move↵ open