Every moving average is late. That is the price you pay for smoothing. The zero lag exponential moving average is one of the more popular attempts to claw back some of that delay without throwing away the smoothing altogether. It shows up on most charting platforms under names like ZLEMA, Zero Lag EMA or EC, and traders on Indian charts often add it next to a regular EMA hoping to catch turns a few candles earlier.
The catch is that “zero lag” is a marketing label more than a promise. Even the people who designed it titled their paper “Zero Lag (well, almost)”. In this piece we will work through what the indicator actually calculates, run the numbers by hand on a simple example, and look at what you give up in exchange for the speed.
In this article
- Why a normal EMA lags in the first place
- Two different indicators share the zero lag exponential moving average name
- A worked example: one clean jump from ₹100 to ₹110
- How Ehlers and Way actually used it
- What the speed costs you
- Putting it on an Indian stock chart sensibly
- How it compares with other “faster” tools
Why a normal EMA lags in the first place
An exponential moving average takes a fraction of today’s close and adds it to the rest of yesterday’s EMA. That fraction is the smoothing factor, usually written as alpha. For an N-period EMA, alpha is 2 / (N + 1). StockCharts’ ChartSchool gives the standard example: a 10-period EMA puts 18.18% weight on the latest price, and a 20-period EMA puts 9.52% on it.
So on a 20-period EMA, more than 90% of today’s value is just yesterday’s EMA carried forward. When price jumps, the average crawls after it. That is fine when you want to ignore noise. It hurts when the move is real and you are waiting for the line to confirm it.
John Ehlers and Ric Way put it bluntly at the start of their paper: all smoothing filters have lag, and removing all of it is not even desirable, because a filter with no lag would simply trace the price you were trying to smooth. Their point is that the amount of lag you remove is a trade-off against the smoothing you are willing to give up. Keep that sentence in mind. It explains almost every quirk of the indicator.
Two different indicators share the zero lag exponential moving average name
This is where a lot of confusion starts. When you pick “ZLEMA” on a platform, you may get one of two quite different calculations.
Version 1: EMA of “de-lagged” prices
The version you will find in many libraries works like this. The documentation for R’s TTR package describes ZLEMA as an EMA that tries to remove lag by subtracting data from (n – 1) / 2 periods earlier. Written out:
- Lag = (Period – 1) / 2
- De-lagged price = Price + (Price – Price from “Lag” bars ago)
- ZLEMA = EMA of the de-lagged price, using the same Period
The idea is simple. If price has been climbing, today’s price minus the price a few bars ago is positive, so you add that momentum on top before smoothing. The EMA is fed a series that is already “ahead” of the real one, which pulls the average closer to current price.
Version 2: Ehlers and Way’s error-correcting EMA
The original Ehlers and Way paper describes something different. They accept that the EMA has an error term, the gap between today’s price and the previous value of the filter, and feed a multiple of that error back into the calculation. They call the result EC, for Error Correcting.
In their EasyLanguage code the line is:
EC = alpha*(EMA + Gain*(Close - EC[1])) + (1 - alpha)*EC[1]
The clever bit is that Gain is not fixed. On every bar, the code tries every gain between minus and plus a limit, in steps of 0.1, and keeps the one that leaves the smallest gap between Close and EC. The user input “GainLimit” is ten times the actual gain, so a GainLimit of 50 means the code searches gains from -5.0 to +5.0. If the gain is zero, EC collapses back into a plain EMA. If the gain is allowed to be large enough, EC tracks price almost exactly, with no smoothing left.
The GainLimit input is really a dial between “plain EMA” at one end and “just the closing price” at the other. Everything interesting happens in the middle.
A worked example: one clean jump from ₹100 to ₹110
Numbers make this click. Take a made-up stock that sits at ₹100 for a while and then gaps up to ₹110 and stays there. These prices are hypothetical, chosen only to show how each line reacts. We will use a 9-period setting for all three lines, so alpha = 2 / (9 + 1) = 0.2.
Plain 9-period EMA
On the first bar at ₹110: EMA = 0.2 x 110 + 0.8 x 100 = 102.0. Next bar: 0.2 x 110 + 0.8 x 102 = 103.6. Then 104.88, then 105.90. It takes until the 11th bar after the jump for the EMA to get above ₹109 (it reads about 109.14 there). That is the lag we are trying to fix.
ZLEMA (de-lagged version)
Lag = (9 – 1) / 2 = 4 bars. On the first bar after the jump, the price four bars ago was still ₹100, so the de-lagged price is 110 + (110 – 100) = 120.
- Bar 1: ZLEMA = 0.2 x 120 + 0.8 x 100 = 104.0
- Bar 2: 0.2 x 120 + 0.8 x 104 = 107.2
- Bar 3: 0.2 x 120 + 0.8 x 107.2 = 109.76
- Bar 4: 0.2 x 120 + 0.8 x 109.76 = 111.81
- Bar 5: now the price four bars ago is ₹110, so the de-lagged price drops back to 110, and ZLEMA eases to 111.45
Look at bar 4. The line has gone past ₹110 to about ₹111.81 even though price never traded above ₹110. That is overshoot, and it comes straight from the momentum term. In our run it stays above ₹110 for the rest of the 15 bars we tracked, still reading about 110.16 at bar 15. So ZLEMA got to the new level roughly in three bars instead of eleven, but it also painted a level the stock never touched.
Ehlers and Way EC, GainLimit 50
On the first bar: alpha = 0.2, the EMA is 102, EC from the previous bar is 100, and Close – EC[1] = 10. Plugging in, EC = 0.2 x (102 + Gain x 10) + 0.8 x 100 = 100.4 + 2 x Gain. The gain that brings EC closest to the close of 110 is 4.8, which sits inside the -5 to +5 search range. So EC = 110.0 on the very first bar.
That looks magical until you remember what Ehlers and Way warned: with a high enough gain limit, EC just follows price. On real closing data, they note, a high gain limit is of no value because the line faithfully tracks the closes. In our example the EC line then wobbles a little (about 108.72 on bar 2 and 109.23 on bar 3) before settling just under 110.
Same EC, GainLimit 10
Now cap the gain at 1.0. On bar 1, the best the code can do is EC = 100.4 + 2 x 1.0 = 102.4. The following bars read about 104.16, 105.47 and 106.46, compared with 103.6, 104.88 and 105.90 for the plain EMA. A small head start, with most of the smoothing intact.
Put the four first-bar readings side by side and the trade-off is obvious: plain EMA 102.0, EC with a small gain 102.4, ZLEMA 104.0, EC with a big gain 110.0. Faster means closer to raw price, and raw price is noisy.
How Ehlers and Way actually used it
The paper does not suggest reading EC alone. It plots EC against the plain EMA. When EC is above the EMA the stock is treated as being in bull mode, and when EC is below the EMA it is treated as bearish. Crossovers of the two lines become the signals.
They also flagged the obvious problem. When the smallest error found in the gain search is tiny, EC and EMA are nearly on top of each other and the crossovers turn into whipsaws. Their fix was a threshold: only take a crossover when the least error, expressed as a percentage of the close, is above a set value. In their code that is 100*LeastError / Close > Thresh.
For the record, they ran this on five years of MSFT with 100 shares, using Length 32, GainLimit 22 and Thresh 0.75, and reported hypothetical results of 20 trades, 60% of them profitable, a net profit of $3,107 and a profit factor of 4.1. Two things to notice. Twenty trades in five years is a slow, trend-following system, not an intraday tool. And these are the authors’ own hypothetical backtest numbers on one US stock, so treat them as an illustration of the method, not evidence that it will work on Nifty stocks.
A faster line does not give you more information. It gives you the same price, smoothed less, with the noise turned back up.
What the speed costs you
Here is the honest list, all of it visible in the example above.
- Overshoot. The de-lagged ZLEMA pushed past the real price level in our example. On a chart, that can look like the line “confirming” a breakout above a level that price itself never cleared.
- More whipsaws. Less smoothing means the line flips direction more often in a sideways market. That is exactly why Ehlers and Way added a threshold filter.
- Settings matter a lot. With EC, GainLimit changes the character of the line completely. A GainLimit of 10 and one of 50 gave first-bar readings of 102.4 and 110.0 on the same data. If you copy someone’s settings without knowing which version they use, your chart will not match theirs.
- Name confusion. A “ZLEMA 20” on one platform may be the de-lagged version, and on another it may be closer to the EC filter. Before trusting any signal, check the platform’s formula notes.
Putting it on an Indian stock chart sensibly
If you want to try it, we would keep it boring and testable.
- Pair it with the matching EMA. Plot a ZLEMA or EC and a plain EMA of the same length. The gap between them tells you how much “lead” the indicator is claiming. A big gap in a choppy stock is a warning, not an opportunity.
- Pick a timeframe and stick to it. The paper’s own test produced a handful of trades over years on daily data. Dropping the same idea on a 5-minute Bank Nifty chart is a different system with different noise, and it needs its own testing.
- Add a filter. Ehlers and Way used a minimum-error threshold. You can also require that price closes beyond a recent swing high or low, or that a broader trend filter agrees, before acting on a crossover.
- Backtest before you trust it. Our example used a perfect step, which flatters every fast filter. Real stocks drift, gap, and reverse. Run it on a few years of the stocks you actually trade, including the sideways phases.
- Decide your exit first. A fast line will flip often. Know whether a flip means “exit”, “tighten stop” or “ignore unless the threshold is met” before the trade, not during it.
How it compares with other “faster” tools
ZLEMA is part of a wider family of attempts to fight lag. TRIX goes the other way and triple-smooths an EMA to filter noise, accepting more delay; we covered its logic in our guide to the TRIX indicator. Ehlers himself built a whole set of cycle-based tools, one of which we broke down in the Ehlers sinewave indicator explainer. If you are new to how these overlays fit together, start with our technical analysis for Indian stocks guide and come back to ZLEMA after that.
The takeaway is simple. The zero lag exponential moving average is a useful way to see how much of a move an ordinary EMA is still catching up on. Used as a comparison line with a filter, it can tighten your timing. Used on its own as a magic early-warning signal, it mostly gives you the noise you were trying to smooth out in the first place.
Disclaimer: This article is for educational purposes only and is not investment advice. Prices in the worked example are hypothetical and chosen only to illustrate the calculation; backtest figures are the original authors’ hypothetical results. Please consult a SEBI-registered investment adviser before making investment decisions.





Leave a Reply
Join the conversation
Commenting is open to registered readers. Sign up with just your email — no password needed, and it takes under a minute.
Sign up to comment Log in