Concept

EMA

EMA, also known as exponential moving average, is a Trend concept. The Library holds 2 implementations, each one a working definition you can pull into Quant.

Top EMA indicators

The top custom implementations, built on the original standard EMA formula.

2 total

Every EMA implementation here is strategy-ready: open one in Quant, set your rules, and it backtests automatically.

What is an EMA?

An EMA (exponential moving average) is a weighted average of price in which the weights decay exponentially with age: the newest bar counts most, and each older bar counts a fixed fraction less. In its recursive form, each new EMA value equals a smoothing factor alpha times the current price, plus (1 minus alpha) times the previous EMA value. Charting convention sets alpha to 2 divided by (length + 1), so a 20-period EMA uses an alpha of roughly 0.095.

The exponential weighting is what separates it from an SMA, which weights every bar in its window equally and drops the oldest bar entirely. An EMA never fully drops anything: old data fades smoothly rather than falling off a cliff, and the stated length is really a convention for choosing alpha, not a hard window. The result is a smoother roll and a faster response to new prices at the same nominal length. Exponential smoothing was not invented for markets; it came out of 1950s forecasting and inventory research before technical analysts adopted it.

The EMA matters because it is the workhorse smoother of technical analysis. It defines trend direction and dynamic support in countless templates, and it sits inside other indicators: MACD is the difference between two EMAs, and many oscillator signal lines are EMAs of the oscillator. Its lag-versus-smoothness tradeoff also spawned a whole lineage of successors, from DEMA and TEMA to adaptive designs like KAMA.

How to calculate an EMA

The EMA is a one-line recursion; the only real decisions are the length and the seed:

  1. 1Choose a length N and convert it to the smoothing factor: alpha = 2 / (N + 1). A 9-period EMA uses alpha of 0.2; a 200-period EMA uses roughly 0.01.
  2. 2Seed the series. Most platforms start the EMA at the first available price or at the simple average of the first N bars; the choice only affects early values, because the seed's influence decays exponentially.
  3. 3Update recursively on every bar: the new EMA equals alpha times the current close plus (1 minus alpha) times the prior EMA.
  4. 4Read it like any moving average: slope for direction, price's position above or below the line for bias, and distance from the line for stretch.

How it's calculated

An EMA is a moving average whose weights decay exponentially, so recent bars count more than older ones.

α=2n+1\alpha = \frac{2}{n + 1}
EMAt=α×Pt+(1α)×EMAt1\operatorname{EMA}_t = \alpha \times P_t + (1 - \alpha) \times \operatorname{EMA}_{t-1}
Seed: EMA1=P1 (or the simple average of the first n values)\text{Seed: } \operatorname{EMA}_1 = P_1 \text{ (or the simple average of the first } n \text{ values)}
P_t: source price of bar t (close by default)
t: bar index
n: EMA length (no single default; 9, 20, 50, and 200 are common)
alpha: smoothing factor
EMA_t: EMA value of bar t

The two seeding conventions only differ on early bars and converge quickly.

Wilder's smoothing (RMA) is the same recursion with alpha = 1 / n, so a 14-bar RMA weights history like a 27-bar EMA.

How traders use it

  • As a trend filter: price holding above a rising EMA frames a long bias, price below a falling one frames a short bias. The 9, 20/21, and 50 lengths are common intraday and swing choices, with the 200 serving as the classic long-horizon reference.
  • As dynamic support and resistance: trending markets often pull back to a widely watched EMA and react there, the behavior covered under dynamic S/R via MA. The line is a zone of interest, not a guarantee.
  • In crossover systems: a fast EMA crossing a slow one is the standard trend-change trigger, formalized in moving average crossovers and extended into an MA ribbon when many lengths are plotted at once.
  • As a building block: EMAs smooth other series as often as they smooth price. MACD, signal lines, and smoothed oscillators all reuse the same recursion, and Wilder's indicators run on the closely related RMA.

EMA vs similar moving averages

SMA: Equal weights across a fixed window versus exponentially decaying weights. The SMA drops its oldest bar abruptly, which can kink the line when a large bar exits the window; the EMA fades old data smoothly and turns faster at the same stated length.

WMA: Both front-weight recent prices, but the WMA's weights decline linearly toward zero across a hard window, while the EMA's decline geometrically and never quite reach zero. The WMA is fully window-bound; the EMA carries a long, fading memory.

RMA: Wilder's smoothing is the same recursion with alpha = 1/N instead of 2/(N+1), so it is heavier and slower at the same stated length. RSI and ATR are built on it, which is why they feel smoother than an EMA-based equivalent of the same period.

DEMA: The DEMA combines an EMA with an EMA of that EMA to cancel lag rather than merely shorten it. It hugs price more tightly in trends but overshoots more at turns; the plain EMA is the more conservative default.

Concept family

Trend

100 concepts mapped · 100 in the Library

EMA FAQ

Turn EMA into a trading strategy.

Take any implementation from this page into Quant, then build on it, backtest it on real data, and keep refining it in conversation.