This strategy trades based on golden cross and dead cross of 3 simple moving averages. It goes long when the fast SMA crosses above mid SMA and mid SMA crosses above slow SMA; It goes short when the reverse crossover happens.
Specifically, it utilizes the crossovers between 3 SMAs of different periods to trade. The fast SMA represents short term trend, mid SMA represents medium term trend, and slow SMA represents long term trend. When the three SMAs crossover upward in sequence, it signals an uptrend to go long. When downward crossover happens, it signals a downtrend to go short. Entry delay can also be set to avoid short term false breakouts.
Risks can be managed through position sizing, SMA optimization, stop loss strategies etc.
This strategy holds positions based on 3 SMA crossovers to determine trend direction. Pros are simple clear signals and configurability; Cons are lagging signals and parameter dependency. Performance can be improved and risks controlled through parameter optimization, stop loss etc. It helps traders master using SMA and crossover strategies.
/*backtest start: 2023-08-21 00:00:00 end: 2023-09-20 00:00:00 period: 3h basePeriod: 15m exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ // © DaynTrading //@version=4 // strategy( // title="Simple Moving Average Cross", // overlay=true, // initial_capital=5000, // default_qty_type=strategy.percent_of_equity, // default_qty_value=2, // commission_type=strategy.commission.percent, // commission_value=0.075, // pyramiding=0 // ) sma_top_input = input(title="SMA Top", type=input.integer, defval=20) sma_mid_input = input(title="SMA Mid", type=input.integer, defval=50) sma_low_input = input(title="SMA Low", type=input.integer, defval=200) bars_long = input(title="Long: After trigger, how many bars to wait?", type=input.integer, defval=5) bars_short = input(title="Short: After trigger, how many bars to wait?", type=input.integer, defval=5) sma_top = sma(close, sma_top_input) sma_mid = sma(close, sma_mid_input) sma_low = sma(close, sma_low_input) long = sma_top > sma_mid and sma_mid > sma_low short = sma_top < sma_mid and sma_mid < sma_low long_condition = long and long[bars_long] and not long[bars_long + 1] short_condition = short and short[bars_short] and not short[bars_short + 1] close_long = sma_top < sma_mid and sma_mid < sma_low and not long[bars_long + 1] close_short = sma_top > sma_mid and sma_mid > sma_low and not short[bars_short + 1] plot(sma_top, title="SMA Top", color=#95f252, linewidth=2) plot(sma_mid, title="SMA Mid", color=#FF1493, linewidth=2) plot(sma_low, title="SMA Low", color=#6a0dad, linewidth=2) strategy.entry("LongPosition", strategy.long, when = long_condition) strategy.entry("ShortPosition", strategy.short, when = short_condition) strategy.close("LongPosition", when = close_short) strategy.close("ShortPosition", when = close_long)