This strategy is a trading system based on Exponential Moving Average (EMA) crossovers, combined with Average True Range (ATR) for dynamic risk management. The strategy uses short-term and long-term EMA lines to capture momentum changes in price trends, while utilizing ATR to dynamically set take-profit and stop-loss levels, achieving precise control over trading risks.
The core logic of the strategy is based on crossover signals between two EMAs of different periods (9 and 21). A buy signal is generated when the short-term EMA crosses above the long-term EMA, while a sell signal is generated when the short-term EMA crosses below the long-term EMA. To better manage risk, the strategy incorporates a dynamic take-profit and stop-loss mechanism based on 14-period ATR, with take-profit levels set at 2x ATR and stop-loss levels at 1x ATR, ensuring sufficient profit potential while maintaining timely risk control.
This strategy creates a comprehensive trading system by combining the classic EMA crossover system with dynamic ATR risk management. Its main strengths lie in dynamic risk management capabilities and effective trend-following characteristics. Through the suggested optimization directions, there is room for further improvement. For live trading implementation, it is recommended to conduct thorough backtesting and parameter optimization, with appropriate adjustments based on specific market characteristics.
/*backtest start: 2019-12-23 08:00:00 end: 2025-01-04 08:00:00 period: 1d basePeriod: 1d exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=5 strategy("Improved EMA Crossover Strategy", overlay=true) // User-defined inputs for EMAs shortTermLength = input(9, title="Short-Term EMA Length") longTermLength = input(21, title="Long-Term EMA Length") // Dynamic Take Profit and Stop Loss atrLength = input(14, title="ATR Length") atrMultiplierTP = input(2.0, title="ATR Multiplier for Take Profit") atrMultiplierSL = input(1.0, title="ATR Multiplier for Stop Loss") // Calculate EMAs and ATR shortTermEMA = ta.ema(close, shortTermLength) longTermEMA = ta.ema(close, longTermLength) atr = ta.atr(atrLength) // Plot the EMAs plot(shortTermEMA, color=color.blue, title="Short-Term EMA") plot(longTermEMA, color=color.red, title="Long-Term EMA") // Generate Entry Conditions longCondition = ta.crossover(shortTermEMA, longTermEMA) shortCondition = ta.crossunder(shortTermEMA, longTermEMA) // Optional Debugging: Print conditions (you can remove this later) var label longLabel = na var label shortLabel = na if longCondition longLabel := label.new(bar_index, high, "Buy Signal", color=color.green, style=label.style_label_down, textcolor=color.white) if shortCondition shortLabel := label.new(bar_index, low, "Sell Signal", color=color.red, style=label.style_label_up, textcolor=color.white) if (longCondition) strategy.entry("Long", strategy.long) strategy.exit("Long Exit", "Long", limit=close + atr * atrMultiplierTP, stop=close - atr * atrMultiplierSL) if (shortCondition) strategy.entry("Short", strategy.short) strategy.exit("Short Exit", "Short", limit=close - atr * atrMultiplierTP, stop=close + atr * atrMultiplierSL)