This strategy calculates SMA lines of different periods to implement golden cross and death cross patterns, thereby generating buy and sell signals. It is a typical trend following strategy.
Take the crossover between the 5-day line and the 200-day line as an example. When the 5-day line crosses above the 200-day line, it means that the market has entered a short-term bullish outlook and a buy signal is generated. When the 5-day line crosses below the 200-day line, it means the market has entered a short-term bearish outlook and a sell signal is generated. By capturing the cross pattern of moving averages of different cycles, market trends can be captured accordingly.
Add other indicators for filtration. When the moving average crossover signal appears, also refer to indicators like MACD and KDJ to avoid generating wrong signals in volatile markets.
Combine with trend judgment indicators. For example, use 5-day line and 200-day line to build buy and sell points in this instance. Also combine ADX indicator to judge trend strength and only execute signals when trend is strong enough.
Use adaptive moving average. Adjust moving average parameters in real time based on market conditions and volatility, making trading signals more practical.
Combination across varieties. Apply the strategy to different types of stocks and foreign exchange products to improve overall strategy performance.
This strategy judges market trend simply through SMA crossover patterns, implementing a typical trend following strategy. The advantage lies in its simplicity to operate and ability to effectively capture major trends. While the disadvantage is that it easily generates wrong signals and cannot cope with huge market swings. Future improvements can be made in areas like signal filtration and parameter optimization.
/*backtest start: 2024-01-04 00:00:00 end: 2024-01-11 00:00:00 period: 1m basePeriod: 1m exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=4 strategy("SMA Crossover Strategy", overlay=true) // Define SMAs sma5 = sma(close, 5) sma10 = sma(close, 10) sma20 = sma(close, 20) sma50 = sma(close, 50) sma130 = sma(close, 130) sma200 = sma(close, 200) // Plot SMAs on the chart plot(sma5, color=color.blue, title="5 SMA") plot(sma10, color=color.orange, title="10 SMA") plot(sma20, color=color.red, title="20 SMA") plot(sma50, color=color.green, title="50 SMA") plot(sma130, color=color.purple, title="130 SMA") plot(sma200, color=color.black, title="200 SMA") // Generating the buy and sell signals buySignal = crossover(sma5, sma200) sellSignal = crossunder(sma5, sma200) // Execute trades based on signals if (buySignal) strategy.entry("Buy", strategy.long) if (sellSignal) strategy.close("Sell")