This strategy is a trend-following trading system based on multiple Exponential Moving Averages (EMAs) and Average True Range (ATR). It uses three EMAs (20, 50, and 100 periods) in conjunction with ATR for dynamic risk management and profit targeting. This approach ensures systematic trading while maintaining dynamic risk control.
The core logic is built on the interaction between price and multiple EMAs:
This strategy combines multiple EMAs and ATR-based dynamic risk control to create a trading system that features both trend-following and swing trading characteristics. Its strengths lie in systematic approach and controllable risk, but practical application requires attention to market adaptability and specific optimizations based on actual conditions. Through proper parameter settings and strict risk control, the strategy has the potential to achieve stable trading results across most market environments.
/*backtest start: 2019-12-23 08:00:00 end: 2024-12-18 08:00:00 period: 1d basePeriod: 1d exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=6 strategy("EMA Swing Strategy with ATR", overlay=true) // Inputs emaShort = input.int(20, "Short EMA") emaMid = input.int(50, "Mid EMA") emaLong = input.int(100, "Long EMA") rrRatio = input.float(1.5, "Risk-Reward Ratio") contracts = input.int(5, "Number of Contracts") // Calculations ema20 = ta.ema(close, emaShort) ema50 = ta.ema(close, emaMid) ema100 = ta.ema(close, emaLong) atr = ta.atr(14) // Conditions longCondition = ta.crossover(close, ema20) and close > ema50 shortCondition = ta.crossunder(close, ema20) and close < ema50 // Variables for trades var float entryPrice = na var float stopLoss = na var float takeProfit = na // Long Trades if (longCondition) entryPrice := close stopLoss := close - atr takeProfit := close + atr * rrRatio strategy.entry("Long", strategy.long, contracts) strategy.exit("Exit Long", from_entry="Long", stop=stopLoss, limit=takeProfit) // Short Trades if (shortCondition) entryPrice := close stopLoss := close + atr takeProfit := close - atr * rrRatio strategy.entry("Short", strategy.short, contracts) strategy.exit("Exit Short", from_entry="Short", stop=stopLoss, limit=takeProfit) // Plot EMAs plot(ema20, color=color.green, title="EMA 20") plot(ema50, color=color.red, title="EMA 50") plot(ema100, color=color.white, title="EMA 100") // Visualization for Entries plotshape(series=longCondition, style=shape.labelup, color=color.green, location=location.belowbar, title="Long Entry") plotshape(series=shortCondition, style=shape.labeldown, color=color.red, location=location.abovebar, title="Short Entry")