
The Multiple EMA Reversion MACD Trend Confirmation Strategy is a trend trading system that combines a multi-EMA approach, price reversion, and MACD indicator. The core concept involves seeking trading opportunities when price reverts to the vicinity of a long-term moving average (200⁄250 EMA) and using the MACD indicator as an entry confirmation signal. The strategy also employs multiple hidden EMAs as auxiliary filtering conditions, along with ATR-based dynamic stop-loss and a fixed risk-reward ratio setup, forming a complete trading system.
This strategy executes trades based on the following core principles: 1. Trend Determination: Uses the relative position of the 20 EMA to the 250 EMA to determine the overall market trend. When the 20 EMA is above the 250 EMA, the market is considered to be in an uptrend; when the 20 EMA is below the 250 EMA, the market is considered to be in a downtrend. 2. Price Reversion: The strategy only looks for entry opportunities when the price reverts to the vicinity of the long-term moving average (250-day EMA), based on the mean reversion theory that “prices eventually return to their mean.” 3. Entry Conditions: Uses MACD crossovers as entry trigger signals, combined with EMA positioning filters. 4. Hidden EMA Filtering: The strategy uses three additional “hidden EMAs” (2-day, 100-day, and 300-day EMAs) to create an entry window, requiring the price to be between specific EMAs. 5. Risk Management: Uses ATR-based dynamic stop-loss, defaulting to 5 times the ATR value, and automatically calculates profit targets using a preset risk-reward ratio (default 1.5).
Long Entry Conditions: - 20 EMA is above the 250 EMA (confirming uptrend) - 2-day EMA is above the 300-day EMA and the 2-day EMA is below the 100-day EMA (confirming price reversion zone) - MACD line crosses above the signal line (confirming momentum shift)
Short Entry Conditions: - 20 EMA is below the 250 EMA (confirming downtrend) - 2-day EMA is below the 300-day EMA and the 2-day EMA is above the 100-day EMA (confirming price reversion zone) - MACD line crosses below the signal line (confirming momentum shift)
The Multiple EMA Reversion MACD Trend Confirmation Strategy is a comprehensive trading system that integrates multiple technical analysis methods. Its core advantages lie in combining trend determination, price reversion theory, momentum confirmation, and systematic risk management. The strategy identifies overall trend direction through the EMA system, seeks high-probability entry points through price reversion to long-term EMAs, and uses MACD as a momentum confirmation signal to reduce false signals.
This strategy is particularly suitable for medium to long-term trending markets, capturing opportunities for price pullbacks to continue developing along the trend direction in strong trend environments. However, the strategy also faces potential risks such as EMA lag and scarce trading opportunities, which need to be optimized through market environment filtering, dynamic risk management, and other methods.
By adding market environment filtering mechanisms, dynamically adjusting risk-reward ratios, and improving the EMA system, this strategy has the potential to further enhance stability and adaptability, becoming a more comprehensive and effective trading system. For investors pursuing systematic trading, this strategy, which combines multiple technical indicators and possesses complete risk management mechanisms, provides a trading framework worth considering.
/*backtest
start: 2025-01-01 00:00:00
end: 2025-03-27 00:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"ETH_USDT"}]
*/
//@version=5
strategy("Price Near 200 EMA", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=100)
// === User Inputs ===
ema1Length = input(20, title="EMA 1 Length") // Main EMA (Trend)
ema2Length = input(250, title="EMA 2 Length") // Long-term EMA
macdFastLength = input(12, title="MACD Fast Length")
macdSlowLength = input(26, title="MACD Slow Length")
macdSignalLength = input(9, title="MACD Signal Length")
rrRatio = input.float(1.5, title="Risk to Reward Ratio", minval=1, step=0.1)
atrMultiplier = input.float(5, title="ATR Multiplier for SL", minval=1, step=0.1) // Default to 5x ATR
atrLength = input(14, title="ATR Length") // User-defined ATR length
// === Hidden EMA Lengths (Hardcoded) ===
ema3Length = 2 // Fast EMA (Hidden)
ema4Length = 100 // Medium EMA (Hidden)
ema5Length = 300 // Long EMA (Hidden)
// === EMA Calculations ===
ema1 = ta.ema(close, ema1Length) // 20 EMA
ema2 = ta.ema(close, ema2Length) // 250 EMA
ema3 = ta.ema(close, ema3Length) // 2 EMA (Hidden)
ema4 = ta.ema(close, ema4Length) // 100 EMA (Hidden)
ema5 = ta.ema(close, ema5Length) // 300 EMA (Hidden)
// === MACD Calculation ===
[macdLine, signalLine, _] = ta.macd(close, macdFastLength, macdSlowLength, macdSignalLength)
macdBullish = ta.crossover(macdLine, signalLine)
macdBearish = ta.crossunder(macdLine, signalLine)
// === ATR for Dynamic Stop Loss ===
atrValue = ta.atr(atrLength)
// === Long Conditions ===
bullishCondition1 = ema1 > ema2
bullishCondition2 = ema3 > ema5 and ema3 < ema4
bullishEntry = bullishCondition1 and bullishCondition2 and macdBullish
// === Short Conditions ===
bearishCondition1 = ema1 < ema2
bearishCondition2 = ema3 < ema5 and ema3 > ema4
bearishEntry = bearishCondition1 and bearishCondition2 and macdBearish
// === Calculate Stop Loss and Target Using ATR ===
longStopLoss = close - atrValue * atrMultiplier
longTargetPrice = close + (close - longStopLoss) * rrRatio
shortStopLoss = close + atrValue * atrMultiplier
shortTargetPrice = close - (shortStopLoss - close) * rrRatio
// === Entry and Exit Logic ===
if bullishEntry
strategy.entry("Buy", strategy.long)
strategy.exit("TP Long", "Buy", limit=longTargetPrice, stop=longStopLoss, comment="SL/TP Long")
if bearishEntry
strategy.entry("Sell", strategy.short)
strategy.exit("TP Short", "Sell", limit=shortTargetPrice, stop=shortStopLoss, comment="SL/TP Short")
// === Plotting Only Visible EMAs ===
plot(ema1, title="EMA 1", color=color.blue)
plot(ema2, title="EMA 2", color=color.red)
// === Background Highlight for Entries ===
bgcolor(bullishEntry ? color.new(color.green, 90) : na, title="Bullish Background")
bgcolor(bearishEntry ? color.new(color.red, 90) : na, title="Bearish Background")