Direct answer
SMA (Simple Moving Average) is calculated by taking the arithmetic mean of the most recent N data points, typically closing prices on a chosen timeframe. Each new point drops the oldest value and adds the newest value, producing a rolling average.
Mechanism and definition
An SMA is defined by three choices:
- What data you average: Common choices are a time series such as prices (for example, closes) or indicator values derived from prices. The calculation itself is the same: you average a sequence of numbers.
- The window length (N): N is the number of data points included in each average.
- The time alignment: You compute one SMA value for each position in the sequence, centered at the end of the window in the most common practical definition.
The formula
Let the data series be (x_t). For a window length (N), the SMA at time (t) is:
[ \text{SMA}t = \frac{1}{N}\sum{i=0}^{N-1} x_{t-i} ]
In plain language: for (\text{SMA}_t), add up the current value (x_t) and the (N-1) preceding values, then divide by (N).
Parameters and data requirements
To calculate SMA accurately, you need:
- A complete ordered sequence of (x_t) values (no missing points inside the part of the series you average).
- A consistent sampling frequency (for example, daily data or 1-hour bars). If you mix frequencies, the “last N points” no longer represent the same time span.
- A chosen N for each series you compare.
- A convention for the first available SMA values: With (N) points, SMA values only start once you have at least N observations.
Evidence or worked example
Assume you want a 3-point SMA of a series of numbers that represent a price-like metric on consecutive time steps.
Let the sequence be:
- (x_1 = 10)
- (x_2 = 12)
- (x_3 = 14)
- (x_4 = 13)
With (N=3):
- (\text{SMA}_3 = (x_3 + x_2 + x_1)/3 = (14 + 12 + 10)/3 = 12)
- (\text{SMA}_4 = (x_4 + x_3 + x_2)/3 = (13 + 14 + 12)/3 = 13)
This shows the rolling behavior: (\text{SMA}_4) reuses two values from (\text{SMA}_3) ((x_3) and (x_2)) and swaps out the oldest one ((x_1)) for the new point ((x_4)).
How SMA “works” in practice
Because SMA is an average, it reduces short-term noise relative to single data points. However, it also tends to respond more slowly than the original series because it reflects multiple past observations.
Limitations and risks
SMA is simple, but there are material ways it can fail to represent what you expect.
-
Lag (delay) behind the latest change Since the SMA includes past values equally, it may still be influenced by earlier levels even after the series moves. In fast-moving conditions, SMA can appear to “follow” rather than “anticipate.”
-
Choice of N changes the behavior A larger N smooths more but reacts more slowly. A smaller N reacts faster but can move more erratically. If someone compares SMA lines with different N values, the comparison can be misleading because the time horizons differ.
-
Data selection problems SMA depends entirely on the input series (x_t). If you average the wrong field (for example, using a derived value instead of the intended one) or use inconsistent sampling (different timeframes mixed), the result will not match the intended calculation.
-
Missing or irregular data If there are gaps or missing points, “last N values” may not correspond to a consistent time window. Some systems handle missing data by filling or skipping; either approach changes the computed SMA.
-
Historical relationships do not ensure future behavior Even when SMA has matched past patterns, the average of past values is not a guarantee of future average behavior. Market conditions can change, and the same parameter choice may behave differently over time.
Verification and next question
You can independently verify an SMA calculation by doing three checks:
- Confirm the window length N used.
- Recompute the SMA for a small section manually using (\text{SMA}t = (x_t + x{t-1} + \dots + x_{t-N+1})/N).
- Ensure the input series and timeframe match the definition (same frequency, same ordering).
If you want to go further, a useful next question is how SMA compares to other moving averages that use different weighting, because the formula changes even though the goal is similar.