◆ New — Strategy Validator, Code Fixer & Prop Compliance Checker are live. Try one free →
Home / Indicators / EMA vs SMA
Moving Averages indicator

EMA vs SMA

Two ways of averaging the same prices — equal weights versus exponentially fading weights — with a measurable lag-versus-smoothness trade-off and no 'better' answer.

Illustrative diagram — not live market data.

What it is

EMA versus SMA is the most-asked moving-average question, and the honest answer is that neither is better — they are two weighting schemes applied to the same data, each buying a different position on the lag-versus-smoothness trade-off. A Simple Moving Average (SMA) gives every bar in the lookback window an identical weight: a 20-bar SMA weights each of the last 20 closes at exactly 1/20. An Exponential Moving Average (EMA) weights the most recent bar most heavily and fades older bars geometrically, using a smoothing factor of 2/(length+1), so a 20-bar EMA gives the newest close about 9.5% of the weight and never fully forgets old data. Because recent prices count more, an EMA of the same length turns sooner and hugs price more closely; the SMA is steadier but slower. Both are lagging, descriptive summaries of past price — neither predicts anything, and choosing between them cannot create an edge by itself. This is educational material, not financial advice, and all trading involves risk of loss.

How it works

The mechanical difference is easiest to see as an impulse response — what each average does when price makes a single sudden jump and then stays flat. An SMA ignores nothing and forgets abruptly: the jump lifts the average by an equal step on each of the next N bars, and exactly N bars later the jump drops out of the window all at once, producing a second artificial move in the average long after price stopped doing anything. An EMA responds immediately — the new price gets the largest single weight — then decays smoothly, with the jump's influence fading geometrically and never producing a delayed echo. Formally, the SMA's weights are a flat block of 1/N; the EMA's weights are α, α(1−α), α(1−α)², … with α = 2/(length+1). This gives each a well-defined 'effective lag': a linear-weighted measure puts the SMA's center of mass at (N−1)/2 bars in the past, while an EMA of the same nominal length has a shorter average age of data, which is precisely why it reacts faster and also why it wiggles more. Same inputs, different weights, a deterministic trade-off — nothing about market prediction enters the mathematics at any point.

How traders read it

Common settings

Both are used at the same conventional lengths: 9-21 for short-term reads, 50 for intermediate context, 100/200 for long-term reference. EMAs are more common at short lengths where responsiveness is wanted (the 9 and 21 EMA are popular intraday); SMAs dominate the widely watched 50/200 levels, largely by convention. The source is usually the close. There is no correct choice — the honest framing is that you are choosing a point on the lag/smoothness curve, and any claim that one setting 'works best' is a backtest artifact until proven otherwise on unseen data.

Strengths

Pitfalls to watch

Pine v6 example

//@version=6
indicator("EMA vs SMA Comparison", overlay = true)

length = input.int(20, "Length", minval = 1)
src    = input.source(close, "Source")

emaLine = ta.ema(src, length)
smaLine = ta.sma(src, length)

plot(emaLine, "EMA", color = color.orange, linewidth = 2)
plot(smaLine, "SMA", color = color.blue,   linewidth = 2)

// Gap between the two: how far recent weighting pulls the EMA
// away from the equal-weight SMA on identical data.
plot(emaLine - smaLine, "EMA-SMA Gap", color = color.gray, display = display.data_window)

Pro tip: Run your own impulse-response test: on any chart, find a single large bar and watch a 20 SMA versus a 20 EMA around it — the EMA jumps immediately and fades smoothly, while the SMA steps up gradually and then moves again 20 bars later when the shock leaves its window, with no new price action at all. Once you have seen that, the EMA-vs-SMA debate stops being about which is 'better' and becomes a conscious choice of weighting. Be equally deliberate about the folklore: a correctly computed crossover is still just a lagging description, and correctness is not profitability. Educational only — no moving average predicts price, and trading involves risk of loss.

Built an indicator from this? Run it through the Validator to catch look-ahead bias and repainting, or convert a strategy to Pine Script.

Educational only — not financial advice, not a recommendation to trade. No indicator is predictive; trading involves substantial risk of loss.

Catch the bug that compiles.Run auditGet Pro