What is a Moving Average? Definition, Formula, and Example
A moving average smooths price data by averaging closes over a rolling window of N bars, producing a lagging trend line that filters noise and defines the prevailing direction.
What is a moving average?
A moving average (MA) is a statistical line plotted on a price chart that averages the last N bars' closes (or another chosen input) and re-computes every bar. As the window slides forward in time, the oldest bar drops off and the newest bar enters, producing a smooth curve that follows — but lags — the raw price. It is the single most-used indicator in technical analysis because it answers one question precisely: over the last N sessions, is the prevailing price above or below where it has been on average?
How a moving average is calculated
The two canonical forms:
Simple Moving Average (SMA):
SMA(N) = (P₁ + P₂ + … + Pₙ) / N
Every bar contributes equally.
Exponential Moving Average (EMA):
EMA_t = α × P_t + (1 − α) × EMA_{t−1}
where α = 2 / (N + 1)
Recent bars carry exponentially more weight. A 20-period EMA has α ≈ 0.0952, so today's close contributes 9.5% of the new value and the remaining 90.5% comes from yesterday's EMA.
Other variants: Weighted (WMA) uses linearly decaying weights; Volume-Weighted (VWMA) weights each close by its bar's share volume; Hull (HMA) is a reduced-lag construction popular among short-term traders.
Worked example
On 2026-04-17, SPY closed at $547.12. The 50 prior daily closes summed to $26,750, so the 50-day SMA = $535.00. Price sits 2.26% above its 50-day — a measurable bullish tilt. The 200-day SMA on the same date was $518.40; price is 5.5% above it, and the 50-day itself is 3.2% above the 200-day — both filters align long.
An EMA(20) on the same series reacts faster than its SMA counterpart. A single gap-up day of +1.5% shifts the 20-SMA by 0.075% but the 20-EMA by 0.143%, roughly twice as sensitive — the trade-off traders accept when they want earlier turns at the cost of more whipsaws.
When traders use moving averages
- Trend definition: price above a rising 200-day = structural uptrend (Stan Weinstein, Mark Minervini frameworks). The 50-day crossing above the 200-day is a golden cross.
- Dynamic support/resistance: crowd-watched MAs (20, 50, 200 day) become self-fulfilling pivots where dip-buyers cluster.
- Crossover systems: price/MA or fast/slow MA crosses trigger entries — the backbone of trend-following CTAs.
- Regime filters: mechanical systems often require SPY above its 200-day before taking any long signal, cutting drawdown in bear markets substantially.
Limitations and common misconceptions
Moving averages lag by construction. A 50-day SMA lags price by roughly N/2 bars — about 25 sessions — so in a sharp reversal the MA confirms the new trend only after much of the move has passed. In ranging or choppy markets, MA systems whipsaw: every breakout reverses, the system buys high and sells low. The "right" period (50? 89? 200?) is usually curve-fit to the backtest window and degrades out of sample. Finally, an MA is only a function of closes — it ignores intrabar volatility, volume, and gaps. Traders treating a 200-day touch as a hard bounce line rather than a probability tilt are confusing a descriptive statistic with a support level.
Related terms
- What is a Golden Cross? — the 50/200 MA crossover signal
- What is MACD? — an oscillator built on two EMAs
- What is VWAP? — intraday volume-weighted average
- What is Bollinger Bands? — standard deviations around a moving average
- What is RSI? — complementary momentum oscillator