The Simple Moving Average is the unweighted mean of the last period
closes. It's the slowest of the moving averages because every bar
inside the window has equal weight.
Formula
SMA[t] = (close[t-N+1] + close[t-N+2] + ... + close[t]) / NParams
period- number of closed bars to average. Required.
Output
Single column named after your indicator (e.g. 200-bar SMA).
Common periods
| Period | Typical use |
|---|---|
| 20 | Short-term trend, often paired w/ price action |
| 50 | Medium swing trend |
| 100 | Daily-bias on higher timeframes |
| 200 | Long-term regime divider - above/below = bull/bear |
Usage
Most strategies use SMA as a regime filter: "only go long when close
SMA(200)". Crossovers between two SMAs are slower than EMA crossovers and produce fewer false signals at the cost of lag.
Pitfalls
- Lag scales with period. SMA(200) is unresponsive to recent moves. If you want a long-term reference that adapts faster, use EMA.
- Old data leaves the window discontinuously. The bar dropping out of the window can move the SMA more than the new bar entering. This is sometimes called the "drop-off effect."
