This strategy uses simple moving average crossovers and average true range indicator to generate buy and sell signals. It belongs to trend following strategies. It mainly uses 50-day and 100-day moving average crossovers to determine the trend and sets stop loss based on ATR to control risks.
It can be seen that this strategy mainly relies on the trend judging capability of moving averages and the risk control capability of ATR. The logic is simple and easy to understand and implement.
Risk Management:
This is a typical trend following strategy, using moving averages to determine trend direction and ATR stop loss to control risks. The logic is simple and easy to grasp. But it has certain lagging and false signal risks. Improvements can be made through parameter tuning, indicator optimization, incorporating more factors etc. to make the strategy more adaptive. Overall this strategy is suitable for beginner practice and optimization, but need to be careful when apply it in actual trading.
/*backtest start: 2023-12-27 00:00:00 end: 2024-01-03 00:00:00 period: 1m basePeriod: 1m exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=5 strategy("SMA and ATR Strategy", overlay=true) // Step 1. Define strategy settings lengthSMA1 = input.int(50, title="50 SMA Length") lengthSMA2 = input.int(100, title="100 SMA Length") atrLength = input.int(14, title="ATR Length") atrMultiplier = input.int(4, title="ATR Multiplier") // Step 2. Calculate strategy values sma1 = ta.sma(close, lengthSMA1) sma2 = ta.sma(close, lengthSMA2) atr = ta.atr(atrLength) // Step 3. Output strategy data plot(sma1, color=color.blue, title="50 SMA") plot(sma2, color=color.red, title="100 SMA") // Step 4. Determine trading conditions longCondition = ta.crossover(sma1, sma2) shortCondition = ta.crossunder(sma1, sma2) longStopLoss = close - (atr * atrMultiplier) shortStopLoss = close + (atr * atrMultiplier) // Step 5. Execute trades based on conditions if (longCondition) strategy.entry("Buy", strategy.long) strategy.exit("Sell", "Buy", stop=longStopLoss) if (shortCondition) strategy.entry("Sell", strategy.short) strategy.exit("Buy", "Sell", stop=shortStopLoss)