Exponential Moving Average: The Seed, the Alpha, and What It Returned
An exponential moving average is a recurrence, not a window. Each bar's value is a blend of today's close and yesterday's average, mixed in a fixed ratio, so every close that has ever printed still contributes something — shrinking geometrically, never reaching zero.
Our engine computes it as batch_ema. This page gives the exact recurrence, the one number in it that nobody agrees on, and what 84,172 real crossings of price through this line returned when they were scored against forward bars and against the simple moving average of the same length.
What an exponential moving average actually is
Weight the newest close by alpha. Weight everything you already had by one minus alpha. Add them.
That single line produces the whole shape people describe. Because yesterday's value already contained the day before, and so on backwards forever, the weights decay geometrically into the past: sharp at the front, a long thin tail behind. A twenty-period version puts about 9.5% of its weight on today's close and spreads the rest across every bar that came before.
Two consequences follow, and they are opposites. The line reacts faster than a plain window average, since recent bars dominate the mix. And it never fully discards anything, so an old shock lingers as a fading contribution rather than dropping out cleanly the way it does from a fixed frame.
The exact EMA formula our engine runs
Here is the whole computation, straight out of the crate, with the parts most descriptions leave vague made explicit:
alpha = 2 / (n + 1). The value at index n − 1 is the **plain arithmetic mean of the first n closes** — an SMA seed. From index n onward,ema[i] = alpha × c[i] + (1 − alpha) × ema[i−1]. Nothing whatsoever is emitted before index n − 1, and a series shorter than n returns no values at all.
Three details there are load-bearing. The smoothing constant is derived from a period rather than chosen directly, which is why a "20-period EMA" means alpha = 0.0952 and not 0.05. The recurrence is written in exactly that algebraic form, because the crate's streaming implementation is asserted bit-identical to the batch one and prev + alpha × (close − prev) is only equal in algebra, not in floating point. And the warm-up is empty, not partial.
That last choice is the one worth arguing about, so the next section measures what it costs rather than defending it.
Where the seed changes the number
Every implementation agrees on alpha. Almost none agree on how to start, and the disagreement is larger than anybody expects.
Our engine takes those opening n closes, averages them plainly, and prints nothing before that bar. The other common convention — the one behind pandas.ewm(adjust=True) and several charting packages — builds a fully weighted average from bar one, so it draws a value on the very first candle. Both are defensible. Neither is wrong. They simply are not the same series.
I've measured the gap on this sample rather than repeating the folklore. On Bitcoin's daily bars at length 50, the two conventions sat 0.95% apart at the seed bar, 0.60% apart at bar 100, and 0.02% apart at bar 200; by bar 500 they agreed to every printed digit. Across all 282 symbols and four lengths, the median series needed 147 bars past the seed before the two stayed within 0.1% of each other for good, and the slowest needed 930.
What that costs in decisions. Over the 1,338,088 bars where our kernel emits a value, the two conventions disagree about whether the close is above the average on 6,077 of them — 0.454%. Restricted to crossings, where the difference actually fires something, 7,055 of 96,316 decisions differ: 7.32%. The seed is not a rounding detail. It is roughly one crossing in fourteen, on a chart that looks identical to the eye.
Against the Python implementation this kernel was ported from — same seed, same alpha, same form — the match is exact: 0.000e+00 across all 1,338,088 values, with the warm-up masks agreeing bar for bar. The divergence above is a convention, not a bug in either one.
EMA versus SMA: the responsiveness, measured
Everybody knows the exponential version responds faster. The interesting question is how much faster, in bars, on the decision that people actually take.
Each average was run at 20, 50, 100 and 200 over the same 282 symbols, and every crossing of the close through one was paired with its twin within ten bars. At length 50 the faster line arrived earlier on 26.6% of pairs, on the same bar for 54.3%, and later on 19.2% — a mean lead of 0.22 bars and a median of exactly zero. Length 20 was thinner still: 19.3% earlier, 66.9% identical. Only at length 200 does the lead become visible, and even there it is 0.45 bars on average.
Where the difference is real is distance. The 20-period exponential line sat a mean 8.92% away from the close against the simple average's 10.24%, and at length 50 it was 16.45% against 18.45%. It tracks price more closely — that part of the reputation survives measurement — but tracking closely and signalling earlier turn out to be different properties.
The price of that closeness shows up in count. At every length the faster average produced more crossings (22,185 against 19,687 at length 50) and had more of them undone within five bars: 61% against 58%.
What crossing the EMA actually returned
Scoring used the identical rig as the simple moving average page — same universe, same 298,285 eligible bars, same symmetric ±10% bracket resolved first-touch over twenty bars — so the two are directly comparable rather than merely adjacent.
At length 50, up-crossings resolved 49.3% and down-crossings 52.6%, against base rates of 50.2% long and 49.0% short for entering on an arbitrary bar. So the down side carried +3.6 points and the up side gave back 0.9. Its slower twin returned +1.0 and +1.9 on the same bars.
Read across all four lengths, the honest summary is that the two are indistinguishable: sometimes one wins by a point, sometimes the other, and no length produced an edge that would survive fees on tens of thousands of signals. Whichever average you draw, the crossing itself is doing almost none of the work.
I stopped switching between them years ago for exactly this reason, and I would rather see somebody change their holding period than their smoothing constant.
Where the exponential moving average fails
Both failures shown here are real crossings this rule produced, and the faster average fails in a specifically faster way.
ADX crossed up and shed 23.3% before it gained anything. ETH crossed down and rose 11.5% instead. Neither is unusual: 30.3% of the length-50 crossings in this scan had no crossing of the slower average within three bars either way, which means nearly a third of these signals exist only because of the weighting choice — and those are precisely the marginal ones.
A subtler failure lives in the tail. Because nothing is ever fully forgotten, a violent bar keeps influencing the line for months at a decaying weight, which makes this form behave oddly right after a crash or a listing spike. A window average simply drops the shock once it falls out the back. When I audit a newly listed pair now, the first few hundred bars get checked separately for exactly that reason.
Is it the same as Wilder's smoothing?
No, and this confusion has cost more people more money than any other detail on this page.
Wilder's smoothing uses alpha = 1 ÷ n rather than 2 ÷ (n + 1), which makes a 14-period Wilder average decay at the rate a 27-period exponential one does. Our engine keeps it as a separate kernel, and it is what RSI and ATR are built on — not batch_ema. Platforms that label the Wilder version "EMA" produce a visibly different line from platforms that do not.
Both are recurrences, both seed from a simple mean here, and both are frequently called exponential averages in the same paragraph by the same author. When two charts disagree and the periods match, this is the second thing to check after the seed.
Frequently asked questions
How is the EMA calculated? Multiply today's close by alpha, multiply yesterday's average by one minus alpha, and add them. Our alpha is 2 ÷ (n + 1), and the very first value is a plain mean of the opening n closes.
Is the EMA better than the SMA? Not measurably. Across 282 symbols the hit rates were within a point or two of each other in both directions, and the faster line generated more signals and more whipsaws to get there.
What EMA lengths should I use? Twenty, fifty and two hundred are the conventional settings, and all three were measured here. None distinguished itself enough to justify a preference on this evidence.
Why does my platform show a different EMA value? Usually the seed. A fully weighted start disagrees with a mean-seeded one for a median of 147 bars, and the two flip 7.32% of crossing decisions while looking identical on screen.
Does the EMA remove lag? It reduces the distance to price, not the lag in the signal. On this sample the crossing arrived on the same bar as the simple average's more than half the time, and the MACD page shows what stacking two of them does to that delay.
This is educational material, not financial advice. Every figure here was measured on past bars, past behavior generalizes poorly to future bars, and trading carries real risk of loss — size any position so that being wrong stays survivable.