Definition · Technical Analysis

Exponential Moving Average (EMA): Formula, Lengths and Uses

The exponential moving average follows price more closely than a simple average because each new close carries more weight. One multiplier, k, sets how much, and it also sets how long old closes linger.

AI-assisted, reviewed by the TrueMoneyTrading human editor: James T. → 7 min read Published

DefinitionSeen on: Chart

Exponential moving average A moving average that weights recent closes more heavily than older ones, so it turns sooner than a simple moving average of the same length when price changes direction.

Also called EMA, exponentially weighted moving average.

Why would a 20-day EMA still hold a trace of a close from three months ago? Nothing ever drops out of it. A simple moving average forgets the oldest close the moment a new one arrives, while an exponential average lets every old close fade by the same fraction each day, so the label “20-day” describes how fast the line forgets, and the latest 20 closes carry most of the weight without ever carrying all of it.

The EMA formula and the multiplier

EMA today = (close today - EMA yesterday) x k + EMA yesterday, where k = 2 / (N + 1) and N is the number of periods.

Read it as a correction. Take the gap between today’s close and yesterday’s average. Move the average part of the way toward the close. The multiplier k is the share of the gap it covers each day, so a 10-day EMA (k = 0.1818) moves about 18% of the way, a 50-day EMA (k = 0.0392) moves about 4%, and a 200-day EMA (k = 0.0100) moves about 1%, which is why the long averages look almost straight on a daily chart while the short ones bend with every swing.

The close jumped $2.20. The average moved 40 cents. To run other lengths and prices, use the moving average calculator.

Seeding the first value with an SMA

An EMA needs a yesterday. On the first bar there isn’t one. The common fix is to take the simple average of the first N closes, call that the starting EMA, and apply the formula from the next close onward. Some software seeds with the first close alone. Both methods are legitimate. They produce different early values.

Seed with the first close and the line starts at $20, so it spends its early bars climbing toward a level the SMA seed reached on day five. The gap between the two versions shrinks every bar. It never quite reaches zero.

How much history an N-day EMA really uses

Each close keeps a share of the average that shrinks by the factor 1 - k for every bar it ages. Add up the weights on the most recent N closes and the total comes to roughly 86.5% for any length you are likely to chart. The remaining 13.5% or so belongs to older closes. It thins out the further back it goes.

The 2 / (N + 1) choice is about lag. With that multiplier, the average age of the data inside an N-day EMA works out to (N - 1) / 2 bars, exactly the average age inside an N-day simple average, so a 20-day EMA and a 20-day SMA both look at closes that are 9.5 bars old on average. They spread the weight differently. The EMA piles it on the last few bars, goes lighter through the middle and keeps a thin tail that the SMA cuts off.

The same arithmetic tells you how much history a chart needs. The seed’s leftover weight after t bars is (1 - k) raised to the power t.

At three times the length, two correct calculations started on different dates draw what looks like the same line. For a 200-day EMA that means 600 daily bars, which is more than two years of trading, and a chart that loads a single year of history is drawing a 200-day EMA that still leans on wherever the data happened to begin. If the chart does not show at least three times the EMA’s length before the date you care about, treat the early part of the line as approximate.

EMA vs SMA

EMA SMA
Weighting Heaviest on the latest close, fading by 1 - k per bar Equal on every close in the window
Old closes Fade and never fully leave Drop out after N bars
After a reversal Turns sooner Turns later
Drop-off effect None A large close leaving the window can move the line on a quiet day
Average age of the data (N - 1) / 2 bars (N - 1) / 2 bars

An EMA turns sooner after a reversal, which gets you in or out earlier. The cost shows up in flat, choppy markets, where a fast line crosses back and forth through price every few days and each cross looks like a signal, so you pay for the early turns with a run of small losing trades that a slower average would have sat through. The SMA is steadier. It is also later.

Common EMA lengths: 9, 12, 20, 26, 50 and 200

Length k Where it shows up
9 0.2000 The MACD signal line; short-term charts
12 0.1538 The fast line inside MACD
20 0.0952 Swing charts, as a pullback reference
26 0.0741 The slow line inside MACD
50 0.0392 The intermediate trend
200 0.0100 The long-term trend filter

These numbers are conventions. A 20-day and a 21-day EMA draw nearly the same line. Scanning old charts for the length that fit best mostly fits the past, so choose a length that matches how long you hold a trade and keep it fixed. The arithmetic does not care what the price represents. A 50-day EMA reads the same way on a single stock, an index fund or a bullion trust from the gold ETF list, provided the chart carries enough history.

EMA crossovers

A crossover is a fast EMA crossing a slow one. Fast crossing above slow is read as bullish. Fast crossing below slow is read as bearish. The 50-day and 200-day pair gives the golden cross and the death cross, which some charts draw with simple averages and others with exponential ones.

Every cross arrives after the move has started, because both lines are built from closes that already printed, and the slower the pair, the later the signal. In a sideways market the lines tangle. If the fast and slow EMAs have crossed back and forth over the past few weeks, treat the next cross as noise until price closes clearly away from both.

Crossovers on an inverse ETF need extra care. The fund resets its exposure every day, so over weeks its price drifts away from a mirror image of the index, and an EMA cross on the fund can land on a different day from the opposite cross on the index it tracks. Take the signal from the index chart and place the order on the fund.

The EMA inside MACD

The MACD is built entirely from EMAs. Its main line subtracts the 26-period EMA from the 12-period EMA. Its signal line is a 9-period EMA of that difference. The histogram is the gap between the two.

Because the signal line is an EMA of a difference of EMAs, it lags more than either average alone. A positive histogram says only that the MACD line sits above its own recent average.

How to use an EMA on a chart

On a chart the EMA is a single line laid over the price bars, usually labeled with its length, such as “EMA 20”. Most charts build it from the close by default and let you switch to another price, such as the high, the low or an average of the bar, and that choice changes the values. Traders often run a short EMA and a long one together. The short one hugs price. The long one describes the trend underneath.

  • As a trend filter: if price closes above a rising 50-day EMA, look for long setups only; if it closes below a falling one, stand aside or look short.
  • As a pullback reference: in an uptrend, a dip that holds near a rising 20-day EMA is a common place to look for an entry.
  • As a trailing exit: hold while closes stay above a short EMA and sell on the first close below it.

The rules, entries and failures behind these uses are worked through in moving averages as a trend filter.

Options sellers read the line too. If you write a covered call on shares trading under a falling 50-day EMA, the premium arrives in a downtrend, where the short call caps any rebound and the shares carry the fall cushioned only by what the call paid.

Limits of the EMA

The EMA summarizes closes that already printed. It predicts nothing.

Most mistakes with it come straight from the math. A trader hunting for the perfect length forgets that 20 and 21 draw nearly the same line. Two charts that disagree by a few cents are usually seeded on different dates, loaded with different amounts of history or built from different prices, and both can be right. On a recent listing, a long EMA is still mostly its seed. A crossover can confirm a turn that has already begun, and that is all it can do.

The simple moving average is the equal-weight version, and the weighted moving average uses straight-line weights that fall to zero at the end of the window. The golden cross and death cross are crossovers of the 50-day and 200-day averages, drawn either way.

Questions traders ask next

What does the 200 EMA tell you on a daily chart?

It summarizes a long run of daily closes, leaning toward the latest months, with an average data age of about 100 trading days. Price above a rising 200-day line describes a long-term uptrend, and price below a falling one describes a downtrend. The line turns slowly, so it confirms a trend after it is underway and will not flag a top or a bottom early.

Why is my EMA a little different from the one on another chart?

The usual causes are a different starting point, a different seed, or a different price source. One chart may seed with a simple average and another with the first close, and one may load far less history. Both lines can be correct. Give both charts history worth three times the EMA's length ahead of the bar you are comparing and the gap usually shrinks to almost nothing.

Should I use the EMA or the SMA?

Pick by the job. The EMA turns sooner after a reversal and pays for that with more false turns when price moves sideways. The SMA is steadier and later. A common pairing is a short EMA for timing entries and exits and a long average for the background trend. Whichever you choose, test it on the stocks you trade and keep the length fixed.