Zero Lag Exponential Moving Average

The Zero Lag Exponential Moving Average (ZLEMA) of John Ehlers and Ric Way (2010) removes the lag of the EMA by feeding it the price extrapolated by the lag the EMA would otherwise have.

The formula for the Zero Lag Exponential Moving Average first sets that lag from the number of periods n, rounded down to a whole period:

\[\text{Lag} = \left\lfloor \frac{n - 1}{2}\right\rfloor\]

The EMA over n periods then runs on the close plus its change over that lag, which cancels the lag:

\[\text{ZLEMA} = \text{EMA}(2 \cdot \text{Close} - \text{Close}_{t-\text{Lag}}, n)\]

Where Close(t-Lag) is the close Lag periods ago and EMA(x, n) the exponential moving average of x over n periods, with \(\alpha = 2 / (n + 1)\). The ZLEMA turns with the price, almost without lag, but the extrapolation makes it noisier than the EMA.

A moving average smooths the price by averaging it over the last n periods, so that the trend shows through the noise of single periods. It is the oldest and most widely used trend indicator: the direction of the average shows the direction of the trend, the price above (below) it an uptrend (downtrend), and other indicators, from the MACD to the Bollinger Bands, are built on it. Every moving average trades smoothness against lag: the more periods it averages, the smoother it is and the later it turns after the price. The averages differ in how they weight the prices within the window and whether they adapt their speed to the market, each a different answer to that trade-off.

Also known as: ZLEMA, ZLMA, zero lag moving average.

In the Finance Toolkit this is get_moving_average with method="zero_lag", the same function as Moving Average.

Example · ^GSPC · 2021 to 2025

Install the Finance Toolkit with pip install financetoolkit -U, then call get_moving_average:

from financetoolkit import Toolkit

toolkit = Toolkit(
    tickers=["^GSPC"],
    api_key="FINANCIAL_MODELING_PREP_KEY",
    start_date="2021-01-01",
    end_date="2025-12-31",
)

toolkit.technicals.get_moving_average(method="zero_lag", window=50)

Which returns:

References

  • Paper Ehlers, J.F. & Way, R. (2010). “Zero Lag (Well, Almost).” Technical Analysis of Stocks & Commodities, November 2010.
  • Library Referenced against TA-Lib’s ZLEMA (Zero Lag Exponential Moving Average)
Share