This strategy mainly utilizes the reversal feature of prices after continuously closing above or below the 5-day simple moving average for 8 days to capture the momentum effect in medium and short term. It goes long when the closing price crosses above the 5-day line again after continuously closing below the 5-day line for 8 days; it goes short when the closing price crosses below the 5-day line again after continuously closing above the 5-day line for 8 days.
Can optimize SMA parameters, improve entry criteria to prevent false breakout, combine with trend indicators to strengthen the strategy.
The strategy captures the price movement from breakout to pullback by judging the momentum, implements the trading logic of avoiding whipsaws and trend following. The keys are strict parameter settings and robust entry criteria to prevent noise; reasonable stop loss to limit losses. Combining with trend indicators can achieve better results. The strategy logic is simple and clean. It is worthwhile to explore further optimization.
/*backtest start: 2023-11-04 00:00:00 end: 2023-12-04 00:00:00 period: 1h basePeriod: 15m exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Marcuscor //@version=5 // Inpsired by Linda Bradford Raschke: a strategy for trading momentum in futures markets strategy("8D Run", initial_capital = 50000, commission_value = 0.0004) SMA = ta.sma(close,5) TrendUp = close >= SMA TrendDown = close <= SMA //logic to long TriggerBuy = ta.barssince(close < SMA) >= 8 Buy = TriggerBuy[1] and TrendDown strategy.entry("EL", strategy.long, when = Buy) strategy.close(id = "EL", when = close > SMA) // 1) color background when "run" begins and 2) change color when buy signal occurs bgcolor(TriggerBuy? color.green : na, transp = 90) bgcolor(Buy ? color.green : na, transp = 70) // logic to short TriggerSell = ta.barssince(close > SMA) >= 8 Sell = TriggerSell[1] and TrendUp strategy.entry("ES", strategy.short, when = Sell) strategy.close(id = "ES", when = close < SMA) // 1) color background when "run" begins and 2) change color when sell signal occurs bgcolor(TriggerSell ? color.red : na, transp = 90) bgcolor(Sell ? color.red : na, transp = 70)