Maths⏱ 5 min read

How to Calculate Moving Averages (SMA, EMA, and WMA)

Moving averages smooth noisy data to reveal trends. Here is how to calculate simple, exponential, and weighted moving averages — and when to use each.

Moving averages are used everywhere from financial charts to epidemiology to manufacturing quality control. Understanding the three main types and their calculations lets you apply the right tool for any smoothing problem.

Simple Moving Average (SMA)

SMA = Sum of values over N periods / N Equal weight given to all periods in the window. Data: daily temperatures: 15, 17, 14, 18, 20, 19, 22 (°C) 5-day SMA (day 5): (15+17+14+18+20) / 5 = 84/5 = 16.8°C 5-day SMA (day 6): (17+14+18+20+19) / 5 = 88/5 = 17.6°C 5-day SMA (day 7): (14+18+20+19+22) / 5 = 93/5 = 18.6°C SMA lag: always responds slowly to recent changes. A 200-day SMA on stock prices moves very slowly. Advantage: removes noise and short-term volatility. Disadvantage: slow to signal real trend changes.

Exponential Moving Average (EMA)

EMA gives more weight to recent data. Smoothing factor: k = 2 / (N + 1) EMA_today = Price_today x k + EMA_yesterday x (1 - k) For a 5-period EMA: k = 2/(5+1) = 0.333 Using same data: 15, 17, 14, 18, 20, 19, 22 Start: EMA at period 1 = 15 (first value) Period 2: 17 x 0.333 + 15 x 0.667 = 5.66 + 10.00 = 15.66 Period 3: 14 x 0.333 + 15.66 x 0.667 = 4.66 + 10.44 = 15.10 Period 4: 18 x 0.333 + 15.10 x 0.667 = 5.99 + 10.07 = 16.06 Period 5: 20 x 0.333 + 16.06 x 0.667 = 6.66 + 10.71 = 17.37 Period 6: 19 x 0.333 + 17.37 x 0.667 = 6.33 + 11.58 = 17.91 Period 7: 22 x 0.333 + 17.91 x 0.667 = 7.33 + 11.95 = 19.27

Weighted Moving Average (WMA)

WMA assigns linearly increasing weights to more recent data. For N periods, weights are: 1, 2, 3, ... N (most recent gets weight N) Sum of weights = N x (N+1) / 2 5-period WMA for days 3-7: 14, 18, 20, 19, 22 Weights: 1, 2, 3, 4, 5 (5 is most recent) Sum of weights: 5 x 6 / 2 = 15 WMA = (14x1 + 18x2 + 20x3 + 19x4 + 22x5) / 15 = (14 + 36 + 60 + 76 + 110) / 15 = 296 / 15 = 19.73

When to Use Which

TypeBest ForKey Characteristic
SMALong-term trend, less noiseEqual weight, most lag
EMAShort/mid-term signalsExponential weight, less lag
WMAMedium-term, smoother than EMALinear weight, moderate lag
📊
Try it yourself — free
Statistics Calculator · no sign-up, instant results
Open Statistics Calculator →
← All Articles