Indicators

MACD

Difference between two EMAs, smoothed by a signal line. Trend + momentum in one indicator.

1 min readUpdated Jun 19, 2026

MACD measures the gap between a fast and a slow EMA, then smooths that gap with a third EMA called the signal line. The difference between the gap and the signal is the histogram, which is the most commonly traded value.

Formula

macd_line   = EMA(close, fast) - EMA(close, slow)
macd_signal = EMA(macd_line, signal)
macd_hist   = macd_line - macd_signal

Params

  • fast - fast EMA period. Default 12.
  • slow - slow EMA period. Default 26.
  • signal - signal-line EMA period. Default 9.

Output

Three columns:

  • {name}_line - the raw MACD line
  • {name}_signal - the smoothed signal line
  • {name}_hist - the histogram (line - signal)

Common signals

  • Histogram crosses zero - momentum flip. Long when hist goes positive, short when it goes negative.
  • Line crosses signal - earlier than the zero-cross. Use a crossover condition between MACD line and MACD signal line.
  • Divergence - price makes new high, MACD does not. Classic reversal cue. LucraX does not detect divergence automatically; use a custom condition or wait for a manual flag.

Pitfalls

  • Default 12/26/9 is calibrated for daily bars. On intraday timeframes you may want to scale up. There's no universal rule - backtest the variant.
  • MACD lags by design because it's built on EMAs. In choppy markets the histogram flips frequently and produces whipsaws. Combine with a regime filter like ADX.
MACD | Help Center | LucraX · LucraX