Type/to search

Trend Breakout Moving Average Tracking Strategy

Cryptocurrency
Created: 2023-11-03 15:57:11
Last modified: 3 years ago
1
Follow
1779
Followers

img

Overview

This strategy identifies trend direction by golden cross and dead cross of simple moving averages, goes long or short with full position size at the beginning of a trend, and sets up stop loss and take profit orders to control risks. After entering the position, it keeps tracking the trend using moving averages and cuts loss in time when there is trend reversal. This strategy also has configurable modules for stop loss, take profit and position sizing, which allows flexible adjustment of parameters for different products.

Strategy Logic

The core of this strategy is to determine trend start and end using golden cross and dead cross of simple moving averages. It first identifies trend direction based on the relationship between fast SMA (e.g. 21-period) and slow SMA (e.g. 49-period). When fast SMA crosses above slow SMA, it signals an uptrend, and the strategy will go long. When fast SMA crosses below slow SMA, it signals a downtrend, and the strategy will go short.

After entering the position, the strategy keeps monitoring the price relative to SMA in real time. It will close long position when price breaks SMA from above, and close short position when price breaks SMA from below, as trend reversal signals.

To control risks, the strategy sets up stop loss and take profit orders simultaneously when opening position. Stop loss distance is based on ATR, while take profit distance can be configured as percentage or ATR multiples. After opening position, stop loss keeps tracking price to realize trend following. When take profit is touched, it closes partial position first while keeping the rest to continue tracking until fully closed.

The strategy also has position sizing module to limit funds utilized for each trade and control per trade risk exposure. In addition, max drawdown limit helps restrict overall strategy risk.

Advantages

  • Simple to understand, using SMA cross to determine trend direction
  • Real-time tracking of stop loss after entering can lock in most profits
  • Customizable stop loss and take profit for different products
  • Per trade risk controllable, no full position trading
  • Max drawdown limit to restrict total loss

Risks and Solutions

  • SMA cross has some lag, may miss best entry at trend start
  • Need repeated adjustment of parameters and testing of different SMA periods
  • SMA cross has some whipsaws, entry accuracy cannot be 100%
  • Trailing stop loss may be hit easily, unable to lock entire profit
  • Need reasonable stop loss distance for price retracement
  • Max drawdown limit may be too conservative, missing upside potential
  • Can relax max drawdown allowance for more strategy tolerance

Enhancement Opportunities

  • Test different parameter combinations to find optimal SMA periods
  • Add trend strength indicator to improve entry accuracy
  • Optimize stop loss strategy to chase uptrend and downtrend as much as possible
  • Test different take profit strategies to find optimal exit points
  • Refine position sizing scheme to improve capital utilization
  • Adjust max drawdown setting to balance return vs risk

Conclusion

In summary, this is a very suitable starter strategy for beginners, with simple logic and easy understanding. It also has proper risk control capabilities to reduce large losses. Good results can be achieved through parameter tuning. But its intrinsic weaknesses also determine that it cannot operate with high precision. It is recommended for beginners to practice, but may not suit advanced traders pursuing high efficiency and win rate. To obtain better trading performance, strategies with stronger predictive power should be sought.

Source
Pine
/*backtest
start: 2023-01-01 00:00:00
end: 2023-11-02 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
//
// ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ 
//  -----------------------------------------------------------------------------
Strategy parameters
Strategy parameters
Filters
From
fromDate
To 
toDate
Long Trades
Short Trades
EMA Filter
EMA Res/Len/Src
emaLength
emaSrc
EMA ATR Band
EMA ATR Len/Mul
filterAtrMul
Plot
Show EMA Line
Show EMA Band
Show Position Highlighter
Strategy
Fast/Slow SMA Length
slowMALen
General
ATR Length
Entry
Enable Trailing
Deviation Method
Deviation %
Deviation ATR Mul
Long/Short Entry Control
ctrShortEntrySrc
Exit
Enable Trailing
Deviation Method
Deviation %
Deviation ATR Mul
Long/Short Exit Control
ctrShortExitSrc
Stop Loss - Target
Stop Loss Method
Long/Short Stop Loss %
shortTrailingStopLossPerc
ATR Long/Short Mul 
shortStopLossAtrMul
Stop Loss - Trailing
Enable Trailing
Break Even
Take Profit - Target
Take Profit Method
Long/Short Take Profit %
shortTakeProfitPerc
ATR Long/Short Mul 
shortTakeProfitAtrMul
Long/Short RR Ratio 
shortRiskRewardRatio
Take Profit - Trailing
Enable Trailing
Deviation Method
Deviation %
Deviation ATR Mul
Quantity/Risk Management
Take Profit Quantity %
Capital at Risk %
Minimum Trade Price
Leverage Long/Short 
shortLeverage
Max Drawdown %
Alert Messages
Open Long/Short
msgOpenShort
Close Long/Short
msgCloseShort
TP/SL Long/Short
msgTPSLShort
SL Long/Short 
msgSLShort
Max Drawdown
Comment
All comments (0)
No data
No data
  • 1
iPhone Download
Forums
PINE Language
© 2015 - ∞ INVENTOR PTE LTD (SG)