This is a quantitative trading strategy that combines Exponential Moving Average (EMA) crossovers with an Average True Range (ATR) filter. The strategy aims to identify strong trends and execute trades in high-volatility market conditions, effectively improving the Sharpe ratio and overall performance. It utilizes 50-period and 200-period EMAs to capture medium to long-term trends, while using the ATR indicator to assess market volatility, only trading when volatility exceeds a specific threshold.
The core logic consists of two main components: trend determination and volatility filtering. For trend determination, the strategy uses a 50-period EMA as the fast line and a 200-period EMA as the slow line, generating long signals when the fast line crosses above the slow line and short signals when it crosses below. For volatility filtering, the strategy calculates the 14-period ATR value and converts it to a percentage of price, only allowing positions when the ATR percentage exceeds a preset threshold (default 2%). This design ensures that the strategy only trades in markets with sufficient volatility, effectively reducing false signals in ranging markets.
This strategy combines classic technical indicators with modern risk management concepts. By using EMA crossovers to capture trends while employing an ATR filter to control trade timing, the strategy maintains simplicity while achieving strong practicality. While some inherent risks exist, the strategy still holds good application value through proper optimization and risk management measures. Traders are advised to adjust parameters according to specific market characteristics and their own risk preferences in practical applications.
/*backtest start: 2019-12-23 08:00:00 end: 2024-11-27 08:00:00 period: 1d basePeriod: 1d exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=5 strategy("EMA Crossover with ATR Filter", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=10) // Inputs for Moving Averages fastLength = input.int(50, title="Fast EMA Length") slowLength = input.int(200, title="Slow EMA Length") // Inputs for ATR Filter atrLength = input.int(14, title="ATR Length") atrMultiplier = input.float(1.5, title="ATR Multiplier") atrThreshold = input.float(0.02, title="ATR Threshold (%)") // Calculate EMAs fastEMA = ta.ema(close, fastLength) slowEMA = ta.ema(close, slowLength) // Calculate ATR atr = ta.atr(atrLength) // Convert ATR to a percentage of price atrPct = atr / close // Define Long Condition (Cross and ATR filter) longCondition = ta.crossover(fastEMA, slowEMA) and atrPct > atrThreshold / 100 // Define Short Condition shortCondition = ta.crossunder(fastEMA, slowEMA) and atrPct > atrThreshold / 100 // Define Exit Conditions exitConditionLong = ta.crossunder(fastEMA, slowEMA) exitConditionShort = ta.crossover(fastEMA, slowEMA) // Long Entry if (longCondition) strategy.entry("Long", strategy.long) // Short Entry if (shortCondition) strategy.entry("Short", strategy.short) // Long Exit if (exitConditionLong) strategy.close("Long") // Short Exit if (exitConditionShort) strategy.close("Short") // Plot EMAs for visual reference plot(fastEMA, title="50 EMA", color=color.blue) plot(slowEMA, title="200 EMA", color=color.red) // Plot ATR for reference plot(atrPct, title="ATR Percentage", color=color.orange, style=plot.style_line) hline(atrThreshold / 100, "ATR Threshold", color=color.green)