Your EMA Is an IIR Filter
Why the Exponential Moving Average Is a Low-Pass Filter — and What That Changes in a Trading System
Traders call it an indicator.
Engineers call it a filter.
It is the same equation.
The exponential moving average (EMA) is on almost every chart and inside almost every trading system. It is usually described with vague words: smoother, faster, more reactive.
Digital signal processing has precise words for the same thing: order, pole, group delay, cutoff frequency.
This article shows that the EMA is a first-order IIR low-pass filter, derives its lag and its frequency response, and explains what that means when you build, backtest and deploy a trading system.
The Equation Traders Use
Every platform computes the EMA with the same recursion:

Where:
Pₜ = price of the current bar
EMAₜ₋₁ = previous value of the average
N = the “period” you type into the platform
α = smoothing factor, between 0 and 1
For N = 20, α ≈ 0.095. Each new bar contributes 9.5% of the output. The remaining 90.5% is the past.
The Same Equation in DSP Notation
Rename price as the input x[n] and the average as the output y[n]:
![IIR difference equation of the EMA: y[n] = alpha * x[n] + (1 - alpha) * y[n-1]](https://static.wixstatic.com/media/5380f6_0277fa6756694c28b517c57035968719~mv2.png/v1/fill/w_980,h_192,al_c,q_85,usm_0.66_1.00_0.01,enc_avif,quality_auto/5380f6_0277fa6756694c28b517c57035968719~mv2.png)
This is a textbook difference equation. The output depends on the current input and on the previous output. That feedback term is what makes it recursive.
Its transfer function is:

One pole, located at z = 1 − α. No zeros away from the origin.
That is the definition of a first-order IIR filter (Infinite Impulse Response). Since 0 < α ≤ 1, the pole sits inside the unit circle and the filter is stable. The gain at zero frequency is exactly 1: a constant price comes out unchanged.
The EMA is not similar to a filter. It is one — the simplest recursive low-pass filter that exists.
SMA vs EMA: Finite Memory vs Infinite Memory
The simple moving average (SMA) is a different kind of filter:
![Simple moving average as an FIR filter: y[n] = (1/N) * sum of x[n-k] for k = 0 to N-1](https://static.wixstatic.com/media/5380f6_89cfaf51616a488187ebac7aeb128041~mv2.png/v1/fill/w_883,h_370,al_c,q_85,enc_avif,quality_auto/5380f6_89cfaf51616a488187ebac7aeb128041~mv2.png)
No feedback. N equal weights, then nothing. This is an FIR filter (Finite Impulse Response).
Unroll the EMA recursion and you get a sum too — but one that never ends:
![EMA as an infinite weighted sum: y[n] = sum of alpha * (1 - alpha)^k * x[n-k]](https://static.wixstatic.com/media/5380f6_d8c17102f66b4b59ae736647e91e4699~mv2.png/v1/fill/w_980,h_300,al_c,q_85,usm_0.66_1.00_0.01,enc_avif,quality_auto/5380f6_d8c17102f66b4b59ae736647e91e4699~mv2.png)
The weights decay geometrically and never reach zero.

Two practical consequences:
An SMA(20) forgets a bar completely after 20 bars. An EMA(20) never fully forgets it.
In an EMA(N), the most recent N bars carry about 86.5% of the total weight. The remaining 13.5% comes from older history.
“EMA 20” does not mean “the last 20 bars”. It means “a pole at 0.905”.
Lag Is Not a Bug. It Is Group Delay.
Every trader complains about lag. In filter theory, lag has a name and a formula: group delay.
For slow price movements — the trend you are trying to follow — the delay of the two averages is:

This is where the strange constant α = 2/(N+1) comes from. It is chosen so that an EMA(N) has the same average delay as an SMA(N).
N = 10 → 4.5 bars of delay
N = 20 → 9.5 bars
N = 50 → 24.5 bars
N = 200 → 99.5 bars

Same average delay, different shape. The EMA reacts faster in the first bars and then takes much longer to finish. The SMA is slower to start but is done after exactly N bars.
You do not choose a period. You choose how many bars late you are willing to be.
The Frequency Response: What the EMA Actually Removes
A price series can be read as a sum of cycles of different lengths. A filter is defined by what it does to each of them.
For the EMA, the cutoff frequency (the −3 dB point) is given by:

For N = 20, the cutoff corresponds to a period of about 63 bars:
Cycles longer than ~63 bars pass almost untouched
A 40-bar cycle is reduced to 54% of its amplitude
A 10-bar cycle is reduced to 16%

The SMA behaves very differently. It erases completely any cycle whose length divides its window (20, 10, 6.7 bars…) and lets through part of what lies in between. The EMA has no nulls and no ripples: just a smooth, gentle roll-off of 6 dB per octave.
Neither is “better”. They are two different filters with two different sets of trade-offs.
What This Changes in a Trading System
1. There is no smoothing without lag
For a first-order filter, smoothness and delay are controlled by the same parameter: the pole. Move it toward 1 and you get less noise and more lag. Always both.
“Zero-lag” averages do not escape this rule. They reduce delay by amplifying part of the spectrum, and you pay for it in overshoot and noise.
2. An EMA needs a warm-up
An IIR filter has state. The first value you feed it is an arbitrary initial condition, and its effect decays as (1 − α)ⁿ.
For an EMA(20), it takes about 46 bars for that error to fall below 1%. As a rule of thumb: about 2.3 × N bars.
This is why the same EMA can show different values on two platforms, or in backtest and in live trading: different history length, different seed, different output. In a system, a signal generated before the warm-up is over is a bug, not a trade.
3. A moving average crossover is a band-pass filter
Fast EMA minus slow EMA is the difference of two low-pass filters. It rejects the slowest component (the price level) and the fastest ones (the noise), and keeps the band in the middle.
The MACD line is exactly this. Its signal line is one more low-pass filter on top.
When you optimise the two periods of a crossover, you are tuning the band of market cycles your system listens to. If the market stops producing cycles in that band, the edge disappears.
4. It is the cheapest filter you can run
One state variable and one multiplication per bar. With α = 1/2^K, not even a multiplication — just a shift. This is how the same filter is implemented on a microcontroller without an FPU:
#define K 4 /* alpha = 1/16 -> N = 31 */
static int64_t acc; /* EMA state, scaled by 2^K */
int32_t ema_update(int32_t x)
{
acc += x - (acc >> K); /* y += alpha * (x - y) */
return (int32_t)(acc >> K);
}The state is kept scaled on purpose: truncating it at every step would create a dead band where the filter stops converging. The same care applies to an EMA running tick by tick inside a trading engine.
What Filter Theory Does Not Tell You
Filter theory describes exactly what an indicator does to the data.
It does not tell you whether the data contain an edge.
Prices are not stationary signals. Cycles appear, drift and vanish. A perfectly designed filter applied to a market with no structure in its pass-band produces perfectly smoothed noise.
That is why, in D² Trading, an indicator is only the front-end. Expectancy, Monte Carlo survivability and drawdown analysis decide whether a system deserves capital.
Final Thought
An EMA is not a line on a chart.
It is a pole on the z-plane.
Once you see it that way, period, lag, warm-up and crossover stop being opinions and become design parameters.
Trade like an engineer: know what your filters do before you trust what they show.
This article is for educational purposes only and is not investment advice.



Commenti