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 / 53-Period SMA (last 3)
sma3 = (v3 + v4 + v5) / 3Range
range_val = v5 - v1Variables
| Variable | Description | Default |
|---|---|---|
v1 | Value 1 (oldest) | 10 |
v2 | Value 2 | 12 |
v3 | Value 3 | 15 |
v4 | Value 4 | 14 |
v5 | Value 5 (newest) | 18 |
total | Derived value= v1 + v2 + v3 + v4 + v5 | calculated |
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
- 01Sum = 10 + 12 + 15 + 14 + 18 = 69
- 025-period SMA = 69 / 5 = 13.8
- 033-period SMA (last 3) = (15 + 14 + 18) / 3 = 15.6667
Ready to run the numbers?
Open Moving Average Calculator