Skip to content

๐Ÿ“ SMA โ€” Simple Moving Average

The SMA is the most literal way to define a "trend": the unweighted average of the last \(N\) closing prices. Every EMA, Bollinger Band and Donchian midline in this catalogue builds on the same rectangular-window idea.


๐Ÿ’ก Financial Meaning

Because every observation in the window counts equally, the SMA reacts to new data more slowly than an EMA of the same length, but it also has zero phase distortion relative to its window โ€” it is not "biased" toward recent or old prices. Traders use SMA crossovers (e.g. the 50/200-day "golden cross", where a "day" is a trading session) as the textbook long-horizon trend signal.


๐Ÿ”ข Mathematical Formula

\[ SMA_{t}(N) = \frac{1}{N} \sum_{i=0}^{N-1} C_{t-i} \]

where \(C_t\) is the closing price at time \(t\). Equivalently, as a running update:

\[ SMA_t = SMA_{t-1} + \frac{C_t - C_{t-N}}{N} \]

which shows the SMA is a finite-memory filter: the oldest sample is dropped exactly as the newest one enters.


โš™๏ธ Parameters

Parameter Key Default Description
Period (\(N\)) period 20 Lookback window in sessions. Higher โ†’ smoother, slower.

๐ŸŽ›๏ธ Signal Processing Equivalent โ€” Rectangular FIR Filter

The SMA is a Finite Impulse Response (FIR) low-pass filter with a rectangular (boxcar) window of length \(N\). Its frequency response is a \(\operatorname{sinc}\) function, with the first null at \(\omega = 2\pi/N\) โ€” frequencies above that are attenuated, but with significant sidelobes (ripple) that let some high-frequency noise leak through, unlike a well-tuned IIR design.

flowchart LR
    subgraph Window["Sliding window of N=20 closes"]
        C1["C(t-19)"] --> C2["..."] --> C3["C(t)"]
    end
    Window -->|"unweighted average"| SMA["๐Ÿ“ SMA(t)"]

Group delay

A rectangular FIR filter of length \(N\) has a constant group delay of \((N-1)/2\) samples โ€” exactly the "lag" traders complain about. This is the price paid for the SMA's perfectly flat, unbiased weighting.

Moving average on Wikipedia