Concept

Zero-lag MACD

Zero-lag MACD is a Momentum & Oscillators concept. The Library holds 1 implementation — a working definition you can pull into Quant.

Top Zero-lag MACD indicator

The top custom implementation, built on the original standard Zero-lag MACD formula.

1 total

This Zero-lag MACD implementation is strategy-ready: open it in Quant, set your rules, and it backtests automatically.

What is the Zero-lag MACD?

The Zero-lag MACD is MACD rebuilt on de-lagged averages. Standard MACD subtracts a 26-period EMA from a 12-period EMA and smooths the difference into a 9-period signal line; each EMA trails price, so crossovers arrive late. The zero-lag variant error-corrects those averages. The most common construction takes twice the EMA minus an EMA of that EMA (the correction behind DEMA); others pre-shift the input by adding the difference between the current price and the price roughly half a period back before smoothing, the idea behind ZLEMA.

The corrections have identifiable authors. Patrick Mulloy introduced the double-EMA idea in a 1994 Technical Analysis of Stocks & Commodities article on faster moving averages, and John Ehlers and Ric Way described their error-correcting filter in 2010. Community scripts then bolted these averages into the MACD architecture, which is why the zero-lag MACD exists as a family of open-source indicators rather than a single canonical study; popular platform versions differ in exactly which averages they correct.

The name overpromises, and the best-known treatment admits it in its title: Ehlers and Way called their paper "Zero Lag (Well, Almost)", because a filter that only sees past data cannot have zero lag. What the correction buys is earlier crossovers and a histogram that turns nearer the actual price turn, paid for with overshoot and extra false crosses in chop. Implementations also differ on which lines get de-lagged (fast, slow, signal, or all three), so two charts with the same label can disagree on the same bar.

The variant is best understood as one point on the smoothness-versus-timeliness line every momentum tool sits on. Raw measures such as ROC respond instantly but shake violently; heavily smoothed tools respond late but rarely whipsaw. De-lagging shifts MACD toward the responsive end without abandoning its structure, and unlike bounded oscillators such as RSI or the Stochastic Oscillator it stays unbounded, so there are no fixed overbought or oversold lines to read, only crossovers, the zero line, and divergences.

How to identify a zero-lag MACD on a chart

The variant looks like a standard MACD pane; the differences show up in behavior around turns.

  1. 1Add a zero-lag MACD script below price, keeping the familiar 12/26/9 defaults so comparisons stay clean.
  2. 2Plot a classic MACD with the same settings alongside it: the zero-lag lines hug price turns more tightly and cross a few bars earlier on most swings.
  3. 3Check the script's inputs or source to see which components are de-lagged, since fast-and-slow-only versions behave differently from ones that also correct the signal line.
  4. 4Watch a sharp reversal: visible overshoot beyond where the standard MACD turns, followed by a snap back, is the error-correction working as designed.
  5. 5Observe a sideways stretch: the histogram flipping sign noticeably more often than the classic version confirms you are looking at the more responsive construction.

How it's calculated

A MACD whose fast, slow, and signal averages are de-lagged so the lines turn with less delay.

FastZLt=2×EMA(P,nfast)EMA(EMA(P,nfast),nfast)\operatorname{FastZL}_t = 2 \times \operatorname{EMA}(P, n_{\text{fast}}) - \operatorname{EMA}(\operatorname{EMA}(P, n_{\text{fast}}), n_{\text{fast}})
SlowZLt=2×EMA(P,nslow)EMA(EMA(P,nslow),nslow)\operatorname{SlowZL}_t = 2 \times \operatorname{EMA}(P, n_{\text{slow}}) - \operatorname{EMA}(\operatorname{EMA}(P, n_{\text{slow}}), n_{\text{slow}})
MACDt=FastZLtSlowZLt\operatorname{MACD}_t = \operatorname{FastZL}_t - \operatorname{SlowZL}_t
Signalt=2×EMA(MACD,nsig)EMA(EMA(MACD,nsig),nsig)\operatorname{Signal}_t = 2 \times \operatorname{EMA}(\operatorname{MACD}, n_{\text{sig}}) - \operatorname{EMA}(\operatorname{EMA}(\operatorname{MACD}, n_{\text{sig}}), n_{\text{sig}})
Histt=MACDtSignalt\operatorname{Hist}_t = \operatorname{MACD}_t - \operatorname{Signal}_t
P: input price series (usually close)
t: bar index of the current bar
EMA(x, n): exponential moving average of series x over n bars
n_fast: fast length (commonly 12)
n_slow: slow length (commonly 26)
n_sig: signal length (commonly 9)
FastZL_t: de-lagged fast average at bar t
SlowZL_t: de-lagged slow average at bar t
MACD_t: zero-lag MACD line at bar t
Signal_t: de-lagged signal line at bar t
Hist_t: histogram at bar t

The de-lag step 2 × EMA - EMA(EMA) is the DEMA formula, so this variant is a MACD built from DEMAs.

Other versions build the lines from ZLEMA (price plus its lag-corrected difference) instead; defaults mirror the standard MACD 12, 26, 9.

How traders use it

  • With the standard MACD grammar, shifted earlier: line/signal crossovers, zero-line crosses for bias, and histogram inflections for acceleration, each firing a few bars sooner than the classic version.
  • As the trigger in a two-speed setup, where a slower tool sets direction and the zero-lag MACD times entries in that direction, offsetting its higher false-signal rate.
  • For divergence work, where the reduced lag places oscillator peaks closer in time to the price swings being compared; the same logic applies to hidden divergence in continuation setups.
  • As a drop-in replacement in existing MACD systems to test whether earlier signals actually help; the answer differs by market and regime, and earlier is not automatically better.
  • In confluence with bounded oscillators: direction and timing from the zero-lag MACD with a stretch filter from a bounded tool is a common way to avoid buying every early crossover into an exhausted move.

Zero-lag MACD vs. other momentum tools

MACD: Same architecture, different averages: MACD uses plain EMAs and accepts their lag, while the zero-lag variant error-corrects each average to fire earlier at the cost of overshoot and extra signals in chop.

Volume-weighted MACD: The volume-weighted variant changes what is averaged, weighting price by volume so heavily traded bars matter more. It attacks input quality; the zero-lag version attacks response time. The two modifications are independent and occasionally combined.

ROC: ROC is momentum with no smoothing at all: the percentage change over n bars, instantaneous but jagged. The zero-lag MACD keeps smoothing for readability and then corrects the delay, landing between raw ROC and the classic MACD in responsiveness.

Concept family

Momentum & Oscillators

91 concepts mapped · 91 in the Library

Zero-lag MACD FAQ

Does the zero-lag MACD really have zero lag?

No. Any indicator computed from past prices lags; the error correction only reduces it. Ehlers and Way, whose filter inspired many versions, titled their paper "Zero Lag (Well, Almost)" for exactly this reason. Expect crossovers a few bars earlier than classic MACD, with more overshoot near sharp turns, not a lag-free signal.

How is the zero-lag MACD calculated?

Take fast and slow de-lagged EMAs (commonly 12 and 26 periods), most often corrected as twice the EMA minus the EMA of that EMA; their difference is the MACD line. A signal line (commonly 9 periods, often de-lagged the same way) and a histogram complete it. Constructions vary between implementations, so verify the exact code you use.

When is the zero-lag MACD worse than the regular MACD?

In choppy, range-bound conditions. The de-lag correction amplifies recent movement, so sideways noise generates more crossovers, and each is acted on earlier. Classic MACD's extra lag works as an accidental filter there. The zero-lag version tends to look best in cleanly trending phases where turns are worth catching early.

What are the best settings for a zero-lag MACD?

Most implementations default to the classic 12/26/9, which keeps comparisons with standard MACD meaningful. Shortening the periods compounds responsiveness and noise on top of the de-lag correction, so it is usually the second lever rather than the first. No setting is best across markets; the honest approach is testing on the instrument and timeframe you trade.

Is the zero-lag MACD the same as a DEMA MACD?

Frequently, yes. Many published scripts build the fast and slow lines from the double-EMA correction, which makes them DEMA MACDs under another name. Others use ZLEMA-style constructions that shift the input series before smoothing, and some also de-lag the signal line. The label is loose, so the source code is the only reliable description.

Does the zero-lag MACD repaint?

The standard constructions do not: every value is computed from completed bars and stays fixed once its bar closes. Like any indicator, the current bar's value moves until the bar closes, which can make a forming crossover appear and vanish intra-bar. Acting on closed-bar signals removes that effect; genuine repainting would require a script that references future data.

Can you use the zero-lag MACD with RSI or other oscillators?

Yes, and pairing is common: the unbounded zero-lag MACD supplies direction and early timing, while a bounded oscillator supplies overbought or oversold context so early signals into exhausted moves can be skipped. The main caution is redundancy: both derive from the same price series, so their agreement is weaker evidence than agreement with something independent such as volume or structure.

Turn Zero-lag MACD into a trading strategy.

Take the implementation from this page into Quant, then build on it, backtest it on real data, and keep refining it with AI.