Overview
This is a comprehensive quantitative trading strategy that combines multiple technical indicators, primarily based on EMA crossover signals, SMA trend confirmation, RSI overbought/oversold judgment, and ATR dynamic stop-loss and take-profit mechanisms. The core idea of the strategy is to generate initial trading signals through the crossover of short-term EMA and long-term EMA, then confirm the overall market trend direction through the 200-day SMA, filter weak signals using the RSI indicator, and finally set dynamic stop-loss and take-profit levels using the ATR indicator to construct a relatively complete trading system.
Strategy Principles
The operating principles of this strategy include four key components:
Moving Average Crossover Signal System: Uses the crossover of 9-period and 21-period Exponential Moving Averages (EMA) to generate initial trading signals. When the 9-period EMA crosses above the 21-period EMA, a buy signal is generated; when the 9-period EMA crosses below the 21-period EMA, a sell signal is generated.
Trend Confirmation Filter: Uses the 200-period Simple Moving Average (SMA) as the primary trend indicator. Long positions are only considered when the price is above the 200-period SMA; short positions are only considered when the price is below the 200-period SMA. This ensures that the trading direction is consistent with the overall market trend.
Momentum Confirmation Mechanism: Uses the 14-period Relative Strength Index (RSI) as an additional filtering condition. Long trades are only executed when the RSI value is greater than 50; short trades are only executed when the RSI value is less than 50. This helps identify trading opportunities supported by sufficient momentum.
Risk Management System: Dynamically sets stop-loss and take-profit levels based on the 14-period Average True Range (ATR). For long trades, the stop-loss is set at 1.5 times ATR below the entry price, and the take-profit is set at 2.0 times ATR above the entry price; for short trades, it's the opposite. This method adaptively adjusts risk parameters based on market volatility.
Combining these four components, the strategy forms a complete trading decision system: first identifying potential trading signals through moving average crossovers, then confirming signal validity through trend and momentum filters, and finally executing trades with dynamic risk management parameters.
Strategy Advantages
Multi-level Signal Confirmation: The strategy constructs a triple filtering mechanism by combining short-term EMA crossover, long-term SMA trend confirmation, and RSI momentum validation, significantly reducing false signals and improving the reliability of trading signals.
Trend-Following Framework: By using the 200-period SMA to determine the overall market trend, the strategy ensures that the trading direction is consistent with the main trend, avoiding the high risk of counter-trend trading. This trend-following approach can improve the strategy's long-term profitability.
Dynamic Risk Management: The ATR-based stop-loss and take-profit settings automatically adjust according to current market volatility, providing wider stop-loss space in high-volatility markets and tightening risk exposure in low-volatility markets, achieving adaptive risk management.
Strong Parameter Adjustability: The various parameters of the strategy (such as EMA periods, RSI threshold, ATR multipliers, etc.) can be adjusted according to different market environments and personal risk preferences, giving the strategy strong adaptability and customization capabilities.
Clear and Explainable Logic: Each component of the strategy is supported by clear market logic, not simply the result of mathematical optimization. This allows traders to understand the principles behind each trade, conducive to building trading confidence and continuous strategy improvement.
Strategy Risks
Moving Average Lag Issue: As lagging indicators, EMA and SMA may not capture rapid market changes in a timely manner, potentially causing delayed entries or exits in rapidly reversing markets, resulting in larger drawdowns.
Poor Performance in Ranging Markets: In range-bound markets, frequent moving average crossovers will generate numerous false signals. Although RSI filtering can partially alleviate this problem, the strategy's performance in sideways markets may still be unsatisfactory.
Limitations of Fixed RSI Threshold: The strategy uses a fixed RSI threshold (50) as a filtering condition, but different markets and timeframes may require different RSI thresholds for optimal results, making the fixed threshold potentially inflexible.
ATR Stop-Loss May Be Too Large: In some highly volatile markets, even a 1.5x ATR multiplier may set too large a stop-loss distance, resulting in excessive single-trade losses; while in low-volatility markets, ATR stops may be too tight and easily triggered by market noise.
Lack of Volume Confirmation: The strategy makes judgments based solely on price data without incorporating volume analysis, potentially failing to identify false breakouts or reversals, increasing the risk of misjudgment.
Solutions include: dynamically adjusting EMA parameters to adapt to different market states; adding sideways market identification mechanisms to pause trading when range-bound markets are detected; implementing adaptive RSI threshold systems; dynamically adjusting ATR multipliers based on market characteristics; adding volume confirmation conditions as additional filters.
Strategy Optimization Directions
Adaptive Parameter System: Design an adaptive system that dynamically adjusts EMA periods, RSI thresholds, and ATR multipliers based on market volatility and trend strength. For example, use longer EMA periods in high-volatility markets to reduce noise, and shorter EMA periods in low-volatility markets to improve responsiveness.
Market Environment Classification: Introduce market type identification mechanisms to distinguish between trending and ranging markets. The current market environment can be assessed through indicators like ADX or Bollinger Band width, with different trading rules applied to different market types.
Multi-timeframe Analysis: Integrate multi-timeframe analysis to ensure trading direction is consistent with higher timeframe trends. Check trend directions on daily, weekly, or even monthly charts, executing trades only when trends align across multiple timeframes.
Dynamic Stop-Loss Mechanism: Implement more sophisticated stop-loss strategies, such as trailing stops or support/resistance-based stops, rather than relying solely on fixed-multiple ATR. In particular, consider moving stops to breakeven after profits are secured to protect gains.
Volume Confirmation: Add volume analysis to verify the validity of price breakouts. Require trading volume to be above recent average levels when forming trading signals to confirm market participation.
Optimize Position Management: Implement a dynamic position management system based on volatility and risk, increasing position sizes with high-conviction signals and reducing them with weaker signals, optimizing capital efficiency and risk-reward ratios.
Seasonality or Time Filters: Analyze potential seasonal patterns or time effects in historical data, avoiding specific time periods when the strategy performs poorly to improve overall win rates.
These optimization directions can not only improve the strategy's robustness and profitability but also enhance its adaptability in different market environments, reducing the risk of strategy failure.
Summary
The Multi-Dimensional Quantitative Trading Strategy Combining EMA, SMA Trend Following with RSI and ATR is a structurally complete and logically clear quantitative trading system. By combining the advantages of multiple technical indicators, it constructs a comprehensive strategy framework with signal generation capabilities, trend confirmation, and risk control mechanisms.
The strategy's greatest advantages lie in its multi-layer filtering mechanism and dynamic risk management capabilities, enabling it to effectively capture medium to long-term trends in trending markets while controlling risk through the ATR dynamic stop-loss and take-profit system. However, the strategy also faces inherent limitations such as moving average lag and poor performance in range-bound markets.
To address these limitations, we've proposed various optimization directions, including adaptive parameter systems, market environment classification, and multi-timeframe analysis. These optimizations can not only enhance the strategy's performance but also strengthen its adaptability in different market environments.
Overall, this is a quantitative trading strategy with solid foundations and clear thinking, suitable as a core framework for trading systems. Through further parameter optimization and functional extensions, it has the potential to become a robust and efficient trading tool. The modular design of the strategy also makes it easy for traders to make personalized adjustments based on individual experience and market understanding, enabling continuous evolution and refinement of the strategy.
Strategy source code
/*backtest
start: 2024-06-19 00:00:00
end: 2025-06-17 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// === Inputs ===
emaShort = input.int(9, title="Short EMA")
emaLong = input.int(21, title="Long EMA")
smaTrend = input.int(200, title="200 SMA")
rsiPeriod = input.int(14, title="RSI Period")
rsiThreshold = input.int(50, title="RSI Threshold")
atrPeriod = input.int(14, title="ATR Period")
atrMultiplierSL = input.float(1.5, title="ATR Multiplier (Stop Loss)")
atrMultiplierTP = input.float(2.0, title="ATR Multiplier (Take Profit)")
// === Indicators ===
ema9 = ta.ema(close, emaShort)
ema21 = ta.ema(close, emaLong)
sma200 = ta.sma(close, smaTrend)
rsi = ta.rsi(close, rsiPeriod)
atr = ta.atr(atrPeriod)
// === Conditions ===
bullishCrossover = ta.crossover(ema9, ema21)
bearishCrossover = ta.crossunder(ema9, ema21)
isUpTrend = close > sma200
isDownTrend = close < sma200
rsiBull = rsi > rsiThreshold
rsiBear = rsi < rsiThreshold
// === Entry and Exit Logic ===
longCondition = bullishCrossover and isUpTrend and rsiBull
if longCondition
strategy.entry("Long", strategy.long)
strategy.exit("Exit Long", from_entry="Long", stop=close - atr * atrMultiplierSL, limit=close + atr * atrMultiplierTP)
shortCondition = bearishCrossover and isDownTrend and rsiBear
if shortCondition
strategy.entry("Short", strategy.short)
strategy.exit("Exit Short", from_entry="Short", stop=close + atr * atrMultiplierSL, limit=close - atr * atrMultiplierTP)
// === Plotting ===
plot(ema9, color=color.orange, title="EMA 9")
plot(ema21, color=color.blue, title="EMA 21")
plot(sma200, color=color.gray, title="SMA 200")
// © edigar75
//@version=6
strategy("My script")
plot(close)
Strategy parameters
The original address: Multi-Dimensional Quantitative Trading Strategy Combining EMA, SMA Trend Following with RSI and ATR
Great strategy! I like how you combined EMA/SMA trend-following with RSI and ATR for better signal confirmation. It’s a balanced mix of momentum and volatility—looking forward to testing it out. Thanks for sharing!