Moving Average Calculator

Moving Average Calculator

Smooth a time series with a simple, weighted or exponential moving average of any window length, and see the trend drawn over the raw data.

SMA = (xₜ + xₜ₋₁ + … + xₜ₋ₖ₊₁) ÷ k

Enter a series of values in time order

What Is a Moving Average?

A moving average replaces each point in a time series with the average of a window of recent points, smoothing out short-term ups and downs so the underlying trend is easier to see. As each new value arrives, the window slides forward.

A simple moving average weights every point in the window equally. A weighted moving average gives more weight to recent points. An exponential moving average gives every past point some weight, shrinking geometrically with age, so it reacts quickly while still remembering the past.

The window length sets the trade-off. Longer windows smooth more but lag further behind turning points; shorter windows follow the data closely but leave more noise. A window matching a seasonal cycle, such as 7 days or 12 months, removes that cycle entirely.

Moving Average Formulas

As given in the NIST/SEMATECH e-Handbook, sections 6.4.2.1 and 6.4.3.1, and Hyndman & Athanasopoulos, Forecasting: Principles and Practice. See Sources.

1. Simple (SMA)

SMAₜ = (xₜ + xₜ₋₁ + … + xₜ₋ₖ₊₁) ÷ k

2. Weighted (WMA)

WMAₜ = (k·xₜ + (k−1)·xₜ₋₁ + … + 1·xₜ₋ₖ₊₁) ÷ (k(k + 1)/2)

3. Exponential (EMA)

EMAₜ = α·xₜ + (1 − α)·EMAₜ₋₁, α = 2 ÷ (k + 1)

The EMA here starts from the simple average of the first k values, the usual convention in finance software.

Worked Example: Smoothing Weekly Café Sales

Given:
A café's takings over 12 weeks (£): 420, 455, 390, 510, 480, 530, 495, 560, 610, 575, 640, 620. The owner wants a 4-week average.
Step 1:
First simple average (weeks 1–4):
(420 + 455 + 390 + 510) ÷ 4 = 443.75
Step 2:
Slide forward to the latest window (weeks 9–12):
(610 + 575 + 640 + 620) ÷ 4 = 611.25
Step 3:
Compare the three types at week 12:
SMA 611.25 · WMA 616 · EMA 604.25
Result:
A clear upward trend, from £444 to £611 a week

The raw figures bounce by up to £120 from week to week, which hides the steady climb. The smoothed line shows takings rising about 37% over the period.

Simple, Weighted and Exponential Compared

The café data with a 4-week window, weeks 4 to 12.

Three moving averages of the café data
WeekSalesSMAWMAEMA
4510443.8454443.8
5480458.8468.5458.3
6530477.5497486.9
7495503.8504490.2
8560516.3526.5518.1
9610548.8564554.9
10575560574.5562.9
11640596.3606.5593.8
12620611.3616604.3

Common Moving Average Mistakes

  • Forgetting the lag. A trailing average describes the past k periods; it turns later than the data does.
  • Choosing a window that clashes with the season. A 5-day average of a weekly pattern leaves a ripple; use 7 days to cancel a weekly cycle.
  • Treating it as a forecast. A moving average summarises recent history; projecting it forwards assumes no trend.
  • Entering data out of order. The calculation assumes oldest first; reversed data gives the averages backwards.

Moving Average FAQs

Which type should I use?

Simple for a clear, easy-to-explain trend; exponential when recent changes matter more, as in finance; weighted as a middle ground.

Why are the first few rows blank?

A k-point average needs k values, so the first k − 1 points have no average yet.

How do I choose the window?

Match a natural cycle if there is one (7 days, 12 months); otherwise try a few and pick the shortest that shows the trend clearly.

What is α in the EMA?

The smoothing factor, 2 ÷ (k + 1). A 4-period EMA uses α = 0.4, giving the newest value 40% of the weight.

What is a centred moving average?

One where the window sits around each point rather than behind it. It doesn’t lag, but can’t be calculated for the latest points.

Does the EMA ever forget old data?

Never completely, but the weight falls geometrically: with α = 0.4, a value 10 periods old carries under 0.3% of the weight.

Why do traders use 50- and 200-day averages?

Convention: they show medium- and long-term trends, and their crossings are watched as signals.

Can I use it for missing data?

Fill or remove gaps first. This page treats the values as evenly spaced.

Sources

Related Tools