02 — Moving Averages

Exponential Moving Average#

Debated1 min read
◆ The PatternTrust recent data more than old, with weights that fade exponentially, as in smoothing and optimizer momentum

The Exponential Moving Average applies an exponential smoothing factor that weights recent prices more heavily.

Multiplier k = 2 / (N + 1)
EMA = (Close − EMA_prev) × k + EMA_prev

Because each new EMA is built on the previous, all past prices influence the result — but their weight decays exponentially.

Key pair: The 12-period and 26-period EMAs form the foundation of the MACD indicator.

More responsive than SMA to sudden price changes — preferred in faster-moving markets.

Worked example

Five-day EMA, so k = 2 / (5 + 1) = 1/3. On day 14 the EMA is 101.80; day 15 closes at 104, so EMA = 101.80 + (104 − 101.80) × 1/3 = 102.53. That is already above the five-day SMA (102.0): today’s close carries a third of the weight.

The example data: 15 days, used in every indicator here
DayHighLowCloseVolume
11019910050,000
210310010262,000
310310010148,000
410510110470,000
510810410785,000
610810510660,000
711010610990,000
811010710872,000
910810410580,000
1010510210366,000
1110510210455,000
1210410110275,000
13102989995,000
141029910164,000
1510510110471,000
Where it misleads
  • It still lags, only less: it reacts faster than the SMA but still turns after the price has.
  • Faster also means noisier — more crossovers, and more false ones, in a choppy market.
  • The starting value matters. Seeded from the first close (as here) or from a simple average, the first values differ until the old weight has faded.
In code
df['ema5'] = df['close'].ewm(span=5, adjust=False).mean()   # k = 2/(5+1)
Python, in your browser — edit the code and run it again

Assumes import numpy as np, import pandas as pd, and a DataFrame df with columns high, low, close and volume — the 15 days above.

Sources
  • J. S. Hunter, “The Exponentially Weighted Moving Average”, Journal of Quality Technology 18(4), 1986 — the same smoother in industrial process control
  • Technical Analysis of the Financial Markets, J. J. Murphy, New York Institute of Finance, 1999

Last reviewed October 2026 · How this site checks its content · Report a mistake

Pattern bridge: Exponential weighting of recent data is exactly how Adam’s momentum tracks gradient history.
Linked from 5
← Previous
Simple Moving Average
Open in the full reader, with the topic sidebar