Moving Average Calculator Formula

Understand the math behind the moving average calculator. Each variable explained with a worked example.

Formulas Used

5-Period SMA

sma5 = total / 5

3-Period SMA (last 3)

sma3 = (v3 + v4 + v5) / 3

Range

range_val = v5 - v1

Variables

VariableDescriptionDefault
v1Value 1 (oldest)10
v2Value 212
v3Value 315
v4Value 414
v5Value 5 (newest)18
totalDerived value= v1 + v2 + v3 + v4 + v5calculated

How It Works

How to Calculate a Simple Moving Average

Formula

SMA(n) = (v1 + v2 + ... + vn) / n

The simple moving average smooths data by averaging the most recent n observations. As new data arrives, the oldest point drops off and the newest is added. SMA reduces noise and reveals underlying trends in time-series data.

Worked Example

Daily sales: 10, 12, 15, 14, 18. Calculate the 5-day moving average.

v1 = 10v2 = 12v3 = 15v4 = 14v5 = 18
  1. 01Sum = 10 + 12 + 15 + 14 + 18 = 69
  2. 025-period SMA = 69 / 5 = 13.8
  3. 033-period SMA (last 3) = (15 + 14 + 18) / 3 = 15.6667

Ready to run the numbers?

Open Moving Average Calculator