All indicators

MACD EMA Strategy

Jun 6, 2021

Static chart image
SignalsOscillatorsMoving Averages

The MACD EMA Strategy indicator provides a systematic approach to trend-following trading by combining moving average convergence divergence (MACD) crossovers with exponential moving average (EMA) filters to identify high-probability entries.

Usage

The indicator identifies trade setups based on the confluence of trend direction and momentum shifts. A long position is triggered when the price is trading above the EMA and the MACD line crosses above the signal line while below the zero line. Conversely, a short position is initiated when the price is below the EMA and the MACD line crosses below the signal line while above the zero line.

The strategy uses dynamic exit logic:

  • Stop Loss (SL): For long positions, the SL is set at the lowest low of a specific lookback period. For short positions, the SL is set at the highest high of the lookback period.
  • Take Profit (TP): The TP is calculated using a risk-to-reward factor applied to the distance between the entry price and the stop loss.

Details

The script utilizes a higher-timeframe EMA to establish the primary trend bias, ensuring trades are only taken in the direction of the prevailing momentum. The MACD component acts as an oscillator to find internal pullbacks within that trend. By requiring the MACD crossover to occur on a specific side of the zero line (histogram), the strategy attempts to enter at points where the counter-trend momentum is exhausted. The visual interface includes red lines to denote the active stop loss levels and shapes to highlight entry signals.

Settings

EMA Inputs

  • EMA Timeframe: Determines the timeframe used for the trend-filtering EMA.
  • EMA Length: Sets the lookback period for the exponential moving average.

MACD Inputs

  • Fast Length: The period for the shorter moving average in the MACD calculation.
  • Slow Length: The period for the longer moving average in the MACD calculation.
  • Source: The price data used for MACD calculations (e.g., Close).
  • Signal Smoothing: The period for the signal line.
  • Simple MA (Oscillator): If enabled, uses SMA instead of EMA for the MACD line calculation.
  • Simple MA (Signal Line): If enabled, uses SMA instead of EMA for the signal line calculation.

Strategy Conditions

  • Enable long?: Toggles the execution of long trades.
  • Enable short?: Toggles the execution of short trades.

Exit Conditions Inputs

  • SL Buffer: An additional price offset added to the stop loss for breathing room.
  • ProfitfactorLong: The multiplier used to determine the take profit level for long trades based on risk.
  • Lowest Low Lookback: The number of bars used to determine the stop loss for long entries.
  • ProfitfactorShort: The multiplier used to determine the take profit level for short trades.
  • highest high lookback: The number of bars used to determine the stop loss for short entries.

FAQ

How do I access MACD EMA Strategy?

You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.

Which markets does this strategy work best on?

While initially designed and tested for volatile markets like ETH/USDT on a 15-minute chart, the adjustable EMA and MACD settings allow it to be optimized for various assets.

Can I change the risk-to-reward ratio?

Yes, you can adjust the "Profitfactor" settings in the strategy inputs to increase or decrease the target reward relative to the calculated stop loss.

Free indicator

Get free access to this indicator on the platforms below.

TradingView
NinjaTrader
MetaTrader 4/5

Unlock the entire LuxAlgo Library

Every indicator, every strategy, full charts, and complete access to Quant — our AI agent.