# ZLEMA

Also known as: zero-lag EMA.
A Trend concept (Moving-average lineage) in the LuxAlgo Library, with 1 indicator implementation.

## What is a ZLEMA?

A ZLEMA (zero-lag exponential moving average) is an [EMA](https://www.luxalgo.com/library/concept/ema/) applied to a de-lagged version of price rather than to price itself. The construction works like this: compute a lag of (length minus 1) divided by 2 bars, build a modified input equal to twice the current price minus the price from that many bars back, then run a normal EMA of the chosen length over the modified series. Adding the recent change back into price cancels much of the phase delay ordinary smoothing introduces.

The technique is usually credited to John Ehlers and Ric Way, whose article "Zero Lag (Well, Almost)" ran in Technical Analysis of Stocks & Commodities in 2010. Ehlers, an engineer who spent decades applying digital signal processing to markets, produced the [Ehlers SuperSmoother](https://www.luxalgo.com/library/concept/ehlers-supersmoother/) and several predictive averages from the same body of work. Their article built its version around an error-correcting feedback loop, while the simpler de-lagged-input recipe above is what most implementations ship as ZLEMA. The plumbing differs; the goal is the same.

The cancellation is really extrapolation: the modified input assumes the move of the last half-window continues, so a ZLEMA hugs trends closely and turns quickly, at the price of overshooting when the market snaps back. The article that popularized zero-lag smoothing carried the qualifier "well, almost" in its own title, which is the honest way to read the name. Lag is reduced, not eliminated, and the reduction is paid for with false turns a slower average would have smoothed through.

The lag figure is not arbitrary. An [SMA](https://www.luxalgo.com/library/concept/sma/) of N bars describes the market as it stood roughly (N minus 1) divided by 2 bars ago, an EMA of nominal length N carries the same average delay, and the ZLEMA's correction term is sized to cancel exactly that amount. The idea also travels: the ZLSMA applies a comparable correction to a least squares moving average, and zero-lag MACD variants rebuild both of that oscillator's averages from de-lagged inputs. Relatives such as DEMA, which doubles an EMA and subtracts an EMA of the EMA, and the Hull moving average, built from weighted averages with a square-root-length final pass, attack lag inside the smoother instead; all share the family trait of less lag traded for more overshoot.

## How to calculate a ZLEMA

The construction de-lags the input first, then smooths it. For a chosen length N:

1. Compute the lag as (N minus 1) divided by 2, rounded to a whole number of bars.
2. Build the de-lagged input: two times the current price, minus the price from lag bars ago.
3. Apply a standard EMA of length N to that de-lagged series and plot the result.
4. Sanity-check against a plain EMA of the same length: the ZLEMA should sit closer to price in trends and cross earlier at turns, including some turns that never follow through.

## How it's calculated

An EMA computed on a de-lagged price series, so it follows price more closely than a standard EMA of the same length.

```
lag = (n - 1) / 2
D_t = 2 × P_t - P_(t-lag)
α = 2 / (n + 1)
ZLEMA_t = α × D_t + (1 - α) × ZLEMA_(t-1)

  P_t: input price at bar t (usually close)
  t: bar index (t-1 and t-lag reference earlier bars)
  n: length in bars (varies by platform, commonly 14 to 21)
  lag: de-lag offset, rounded to the nearest whole bar
  D_t: de-lagged price at bar t
  α: EMA smoothing factor
  ZLEMA_t: zero-lag EMA value at bar t
```

Attributed to John Ehlers and Ric Way (2010).

Adding P_t - P_(t-lag) back to price cancels roughly the EMA's built-in lag, at the cost of some overshoot at sharp reversals.

Seed the recursion with the first de-lagged value or an SMA, as with a normal EMA.

## How traders use it

- In [crossover setups](https://www.luxalgo.com/library/concept/moving-average-crossovers/) where EMA lag is the main complaint: price/ZLEMA or fast/slow ZLEMA pairs signal earlier, at the cost of more failed crosses.
- As a drop-in smoother inside other indicators; the zero-lag MACD is the best-known example, rebuilding both of MACD's averages from de-lagged inputs.
- As a tighter trend baseline for pullback entries and trailing logic, with the line's [slope](https://www.luxalgo.com/library/concept/ma-slope-filter/) doubling as a quick regime read that flips sooner than an equal-length EMA's.
- As [dynamic support and resistance](https://www.luxalgo.com/library/concept/dynamic-s-r-via-ma/) in strong trends, where the reduced lag keeps the line close enough for ordinary pullbacks to reach it, at the cost of more incidental touches.
- For earlier [breakout](https://www.luxalgo.com/library/concept/breakout/) confirmation, treating a ZLEMA thrust through the broken level as momentum evidence, gated by a regime filter such as [Supertrend](https://www.luxalgo.com/library/concept/supertrend/) to screen out range chop.

## ZLEMA vs other moving averages

- **EMA** (https://www.luxalgo.com/library/concept/ema/): The EMA smooths raw price and accepts the resulting lag. The ZLEMA keeps the same smoother but feeds it a momentum-augmented input, so it tracks tighter and turns sooner while carrying overshoot risk the EMA does not have.
- **Ehlers SuperSmoother** (https://www.luxalgo.com/library/concept/ehlers-supersmoother/): From the same signal-processing tradition, the SuperSmoother attacks noise rather than lag: it strips short-cycle chop with less delay than comparable smoothers but never extrapolates, so it avoids the ZLEMA's overshoot at sharp turns while keeping some honest lag.
- **Adaptive-lookback MA** (https://www.luxalgo.com/library/concept/adaptive-lookback-ma/): Adaptive averages fight lag by shortening their window when conditions speed up instead of extrapolating a fixed one. The aim is the same but the failure modes differ: adaptation can misjudge a regime shift, while de-lagging overshoots sharp reversals.

## FAQ

### Is the ZLEMA really zero lag?

No, and its popularizers said so: the article that spread the technique carried the qualifier "well, almost" in its title. The de-lagging step removes much of the phase delay by extrapolating the last half-window's change forward, which works while the move persists and overshoots when it reverses sharply. Expect reduced lag rather than none, and more false turns than a plain EMA.

### When should I use a ZLEMA instead of an EMA?

When lateness costs you more than noise. ZLEMA crossovers and slope changes arrive earlier, which helps in fast, trending conditions; the same sensitivity produces extra whipsaw in ranges. A common compromise is using the ZLEMA where speed matters most, such as exits or trailing, keeping a calmer average for regime, and testing both on your market.

### Can a ZLEMA be used inside MACD or other indicators?

Yes. Because it is just an EMA of a modified input, a ZLEMA can replace the EMA anywhere one appears: MACD lines, signal lines, oscillator smoothing, or band centers. Zero-lag MACD variants are the most common application. The swap speeds every signal up and raises the false-positive rate, so re-test any system after making it.

### What length should I use for a ZLEMA?

There is no standard setting; traders typically start from the EMA lengths they already use. Because de-lagging makes any length behave faster, a ZLEMA at the same setting flips more often than the EMA it replaced, so some traders lengthen it to restore a comparable signal rate, then re-test on their own market and timeframe.

### Does a ZLEMA repaint?

No. Each value uses only current and past prices; the extrapolation projects the previous half-window's change forward rather than peeking ahead, and once a bar closes its value is fixed. It still moves while the live bar forms, which is normal real-time behavior, not repainting.

### Does a ZLEMA work in ranging markets?

Poorly, as a standalone signal source. The sensitivity that makes it useful in trends produces streams of failed crosses and premature [reversal](https://www.luxalgo.com/library/concept/reversal/) reads in chop. Common fixes are requiring a minimum slope before acting, gating signals with a regime filter, or standing aside inside obvious ranges.

## Implementations in the Library

- ZLEMA (LuxAlgo): https://www.luxalgo.com/library/indicator/zlema/

## Related concepts

- SMA: https://www.luxalgo.com/library/concept/sma/
- EMA: https://www.luxalgo.com/library/concept/ema/
- Adaptive-lookback MA: https://www.luxalgo.com/library/concept/adaptive-lookback-ma/
- MA Envelope: https://www.luxalgo.com/library/concept/ma-envelope/
- SWMA: https://www.luxalgo.com/library/concept/swma/
- RMA: https://www.luxalgo.com/library/concept/rma/
- HMA: https://www.luxalgo.com/library/concept/hma/
- KAMA: https://www.luxalgo.com/library/concept/kama/
- JMA: https://www.luxalgo.com/library/concept/jma/
- T3: https://www.luxalgo.com/library/concept/t3/

---

Source: https://www.luxalgo.com/library/concept/zlema/ (LuxAlgo Library, the encyclopedia of trading & technical analysis). Free to use with attribution: https://www.luxalgo.com/library/license/