MACD/EMA Long Strategy
Jan 23, 2019

The MACD/EMA Long Strategy indicator is a trend-following tool that combines the 200 SMA, 20 EMA, and MACD to provide a conservative method for identifying market entries and exits.
Usage
The Usage section describes how the script can be used to navigate different market regimes.
Bullish Market Conditions (Price > 200 SMA)
When the price is above the 200 SMA, the market is considered to be in a long-term uptrend. In this scenario:
- Buy Condition: Triggered solely on a bullish MACD cross (Histogram > 0) at the close of a candle.
- Sell Condition: To prevent premature exits, the strategy requires both a bearish MACD cross AND a candle close below the 20 EMA.
Bearish Market Conditions (Price < 200 SMA)
When the price is below the 200 SMA, the strategy adopts a more conservative "risk-off" approach:
- Buy Condition: Requires both a bullish MACD cross AND a candle close above the 20 EMA to confirm a potential reversal.
- Sell Condition: Triggered immediately upon a bearish MACD cross (Histogram < 0) to protect capital.
Details
This strategy is designed to filter out market noise by dynamically adjusting its sensitivity based on the primary trend (200 SMA). By requiring extra confirmation from the 20 EMA when the market is below the 200 SMA, it seeks to avoid "fakeouts" during downtrends. Conversely, during uptrends, it uses the 20 EMA as a trailing filter to stay in winning trades longer. Note that this strategy is most effective in trending markets and may underperform or produce "whipsaws" in sideways or range-bound environments.
Settings
- SMA Length: Sets the lookback period for the Simple Moving Average used to determine the primary trend bias (default is 200).
- EMA Length: Sets the lookback period for the Exponential Moving Average used for secondary confirmation and exit filtering (default is 20).
- MACD Fast Length: The short-term period for the MACD calculation (default is 12).
- MACD Slow Length: The long-term period for the MACD calculation (default is 26).
- MACD Signal Length: The smoothing period for the MACD signal line (default is 9).
FAQ
How do I use the MACD/EMA Long Strategy?
You can use it to automate or manually signal entries based on whether the price is above or below the 200 SMA, ensuring your trades align with the prevailing market momentum.
On which timeframes is this strategy effective?
While the logic is universal, it is typically most effective on higher timeframes (1H, 4H, Daily) where the 200 SMA and MACD provide more reliable trend signals.
How do I access this indicator?
You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.
Free indicator
Get free access to this indicator on the platforms below.
Unlock the entire LuxAlgo Library
Every indicator, every strategy, full charts, and complete access to Quant — our AI agent.