Exponential Moving Average (EMA)

An exponential moving average is a moving average that counts the latest prices more than older ones. Because recent moves carry the most weight, the EMA turns sooner than a simple moving average of the same length, which is why short-term traders use it for entries and exits, and why it is the building block of MACD and many other indicators.

What is an exponential moving average?

Like any moving average, the EMA smooths a series of closing prices into a single line that shows the direction of the trend. The difference is in the weighting. A simple moving average counts every close in its window equally; an exponential moving average gives the newest close the largest weight, the one before it a little less, and so on, with the weights shrinking by the same factor at every step.

The result is a line that hugs price more closely. When a stock changes direction, a 21-period EMA starts to turn within a few bars, while a 21-period SMA keeps going the old way until enough old prices have dropped out of its window.

EMA formula

Every EMA value is built from today’s close and yesterday’s EMA, using a smoothing factor α (alpha) that depends on the period n:

EMA(t) = α · Pt + (1 − α) · EMA(t−1) α = 2n + 1

Pt = closing price of bar t  ·  n = number of periods (for example 9 or 21)  ·  α = smoothing factor

The same formula is often written in a form that is easier to read: the EMA moves a fixed fraction α of the way from its previous value toward today’s price.

EMA(t) = EMA(t−1) + α · ( Pt − EMA(t−1) )

There is no earlier EMA for the very first bar, so the calculation is usually seeded with the simple moving average of the first n closes. Charting packages differ slightly in how they seed, so EMA values from two sources can differ by a few cents early in a chart; the difference fades away after a few dozen bars.

Period nSmoothing factor αWeight on today’s closeWeight on the last n bars
92 / 10 = 0.20020.0%86.6%
122 / 13 = 0.15415.4%86.5%
212 / 22 = 0.0919.1%86.5%
262 / 27 = 0.0747.4%86.5%
502 / 51 = 0.0393.9%86.5%
2002 / 201 = 0.0101.0%86.5%

The last column shows a useful property: whatever the period, about 86% of an EMA’s weight sits on the latest n bars and about 14% on everything older. So an “n-period” EMA really is mostly about the last n bars, even though, in theory, it never fully forgets any price.

Worked example: a 5-day EMA

Take the same seven closes used on the SMA page and calculate a 5-day EMA. With n = 5 the smoothing factor is α = 2 / 6 = 1/3, so each day the EMA moves one third of the way toward the close.

DayClose5-day EMA5-day SMAEMA calculation
1–4$20 – $23––not enough data
5$24.00$22.00$22.00seed: SMA of days 1–5 = 110 / 5
6$26.00$23.33$23.2022.00 + (26 − 22.00) / 3
7$25.00$23.89$24.0023.33 + (25 − 23.33) / 3

On day 6 the $26 jump pulls the EMA up to $23.33, more than the SMA’s $23.20: the newest close counts for a third of the EMA but only a fifth of the SMA. On day 7 the order flips. The SMA jumps to $24.00 only because the low $21 close drops out of its window, while the EMA, which has no window to drop out of, simply moves a third of the way from $23.33 toward $25. That is the EMA’s other advantage: it changes because of today’s price, not because of a price from n days ago.

Reading the EMA on a chart: Clorox (CLX)

The daily chart of The Clorox Company (CLX) below covers one year with the 9-period EMA (green) and the 21-period EMA (red), a pair widely used by swing traders.

Clorox (CLX) daily candlestick chart over one year with the 9-period EMA in green and the 21-period EMA in red, showing trend rallies, a sideways stretch with repeated crossovers and a recent rally
CLX daily chart, 1 year: close $104.73. 9-period EMA $105.40, 21-period EMA $100.64. Open the live CLX chart to add the same averages.
Close$104.73
9-period EMA$105.40 −0.6%
21-period EMA$100.64 +4.1%

What the two lines say about this chart:

  • Trending phases: the 9 stays on the right side of the 21. In the January–February rally from about $97 to nearly $128, the green 9-EMA stayed above the red 21-EMA the whole way and dips stopped at or near the lines. In the March–May decline back toward $86 the order reversed, and every bounce stalled at the 21-EMA, which acted as resistance.
  • Crossovers mark the turns. The 9 crossed below the 21 in early March, a few days after the top, and crossed back above it in mid-October near the $82–$85 low. Both crossings came late compared with the exact turning point, but early compared with an SMA of the same length.
  • Sideways phases: the lines tangle. From June through July CLX moved in a range between roughly $90 and $100. The two EMAs flattened, ran close together and crossed several times without a lasting move in either direction, the classic whipsaw zone where crossover signals don’t work.
  • Gaps outrun the EMA. The sharp drops in early May and early September came on volume spikes and opened a wide gap between price and both lines; the EMAs needed days to catch up. No moving average can warn of a gap.
  • At the right edge of the chart. After a fast November rally to about $110, CLX has pulled back to its 9-EMA ($105.40) while staying well above a still-rising 21-EMA ($100.64). The 9 is above the 21, so the short-term trend is up; a close below the 21-EMA would be the first sign that the rally has failed.

Popular EMA periods

PeriodsHorizonTypical use
8, 9 or 10Very short termFast signal line; trailing stop for strong trends
9 and 21Short termSwing-trading crossover pair, as on the CLX chart
12 and 26Short to mediumThe two EMAs inside MACD; MACD’s signal line is a 9-period EMA of their difference
20~1 monthShort-term trend and pullback level; middle of Keltner Channels
50Medium termIntermediate trend
200Long termLong-term trend; a faster alternative to the 200-day SMA

On intraday charts the same numbers apply to bars, not days: a 9-period EMA on a 5-minute chart covers the last 45 minutes or so.

How traders use the EMA

1. Trend direction and slope

A rising EMA with price above it describes an uptrend; a falling EMA with price below it describes a downtrend. Because the EMA turns quickly, its slope is often the first visible sign that momentum is changing.

2. Fast/slow crossovers

A cross of the faster EMA above the slower one (9 over 21, or 12 over 26) signals that short-term momentum has turned up; a cross below signals it has turned down. Crossovers work best in trending markets and should be filtered, for example by taking only long signals while price is above the 50 or 200-day average.

3. Pullback entries

In a strong trend, pullbacks often find support at the 9, 20 or 21-period EMA. Traders who missed the breakout use the first test of the EMA as a lower-risk entry, with a stop just beyond the line.

4. Trailing stop

Because it follows price closely, a short EMA works as a trailing exit: hold while closes stay above the 9 or 21-EMA, exit on the first close below. The shorter the EMA, the tighter the stop.

5. Building block for other indicators

Many indicators are made from EMAs: MACD (12 and 26-period EMAs plus a 9-period signal line), the Keltner Channels midline, the smoothing inside the RSI and ADX calculations, and the TRIX and PPO oscillators. Understanding the EMA makes all of them easier to read.

EMA vs SMA

EMASMA
WeightingNewest close weighs most; weights shrink geometricallyEvery close in the window counts equally
SpeedTurns sooner after a change in trendTurns later; smoother line
False signalsMore whipsaws in sideways marketsFewer whipsaws, but later entries and exits
Drop-off effectNone: moves only on today’s closeCan move when an old price leaves the window
Most used forShort-term trading, MACD, 9/21 and 12/26 pairsLong-term trend, 50 and 200-day averages

Many traders combine both: short EMAs for timing, and the 50 and 200-day SMAs for the big picture.

Limitations of the EMA

  • It still lags. The EMA reacts faster than the SMA, but it is still built from past prices and always confirms a move after it starts.
  • More whipsaws. The speed that helps in trends hurts in ranges: in sideways markets, short EMAs cross price and each other again and again.
  • Sensitive to single bars. One unusually large candle moves a short EMA a long way, which can trigger a signal that the next day reverses.
  • Values depend on the start. Because each value includes all earlier ones, the EMA depends slightly on where the calculation began and how it was seeded.
  • No prediction. An EMA describes where price has been. Confirm its signals with volume, price action and other indicators, and with the company’s fundamentals.

Frequently asked questions

What is an exponential moving average?

An exponential moving average (EMA) is a moving average that gives the most weight to the latest price and progressively less to older prices. It turns faster than a simple moving average of the same length, so it shows changes in trend sooner.

How do you calculate an EMA?

First compute the smoothing factor α = 2 / (n + 1). Then each new EMA = previous EMA + α × (today’s close − previous EMA). The first EMA is usually seeded with the simple moving average of the first n closes.

What does a 9 and 21 EMA crossover mean?

When the faster 9-period EMA crosses above the slower 21-period EMA, short-term momentum has turned up and many swing traders read it as a buy signal. A cross below is read as a sell signal. The signal works best in trending markets and gives many false signals when price moves sideways.

Is the EMA better than the SMA?

Neither is better in every case. The EMA reacts faster and suits short-term trading, but it whipsaws more in sideways markets. The SMA is smoother and is the standard for the long-term 50 and 200-day averages.

Which EMA periods are most popular?

The 9 and 21-period EMAs are popular with swing traders, the 12 and 26-period EMAs are the basis of MACD, and the 50 and 200-day EMAs are used for the medium and long-term trend.

Does the EMA use all past prices?

In principle yes, because each EMA value includes the previous one, but the weights shrink quickly. For any period n, roughly 86% of the total weight falls on the most recent n bars, so very old prices have almost no effect.

For information and education only, not investment advice. Indicators describe past prices and do not guarantee future results.

More on Quotelinks: All technical indicators · Moving Averages guide · Simple Moving Average · Weighted Moving Average · MACD · CLX chart · CLX stock overview · Candlestick charts · Stock Screener