01 — Moving Averages

Simple Moving Average#

Debated1 min read
◆ The PatternAveraging cancels noise: the longer the window, the calmer the line and the later it reacts

The Simple Moving Average is the arithmetic mean of the last N closing prices.

SMA = (C₁ + C₂ + … + Cₙ) / N

Common periods: 20 (short-term), 50 (medium), 200 (long-term).

Golden Cross: 50-day SMA crosses above 200-day → bullish signal.
Death Cross: 50-day crosses below 200-day → bearish.

Limitations: equal weighting means SMA lags price — old data has the same influence as new data.

Worked example

Five-day SMA on day 15: the last five closes are 104, 102, 99, 101 and 104, so (104 + 102 + 99 + 101 + 104) / 5 = 102.0. The average peaked at 107.0 on day 9, two days after the highest close (109 on day 7) — the lag the averaging pays for its smoothness.

The example data: 15 days, used in every indicator here
DayHighLowCloseVolume
11019910050,000
210310010262,000
310310010148,000
410510110470,000
510810410785,000
610810510660,000
711010610990,000
811010710872,000
910810410580,000
1010510210366,000
1110510210455,000
1210410110275,000
13102989995,000
141029910164,000
1510510110471,000
Where it misleads
  • Lag: the average turns only after enough of the window has turned, so crossover signals arrive late and give back part of the move.
  • Whipsaw in sideways markets: price crosses the average back and forth, and each cross is a losing trade.
  • An old price leaving the window moves the average as much as a new one entering it, so the line can jump on a day when nothing happened.
In code
df['sma5'] = df['close'].rolling(5).mean()
Python, in your browser — edit the code and run it again

Assumes import numpy as np, import pandas as pd, and a DataFrame df with columns high, low, close and volume — the 15 days above.

Sources
  • W. Brock, J. Lakonishok & B. LeBaron, “Simple Technical Trading Rules and the Stochastic Properties of Stock Returns”, Journal of Finance 47(5), 1992 — moving-average rules on the Dow, 1897–1986
  • R. Sullivan, A. Timmermann & H. White, “Data-Snooping, Technical Trading Rule Performance, and the Bootstrap”, Journal of Finance 54(5), 1999 — the same rules after correcting for testing many of them; the edge does not hold out of sample

Last reviewed October 2026 · How this site checks its content · Report a mistake

Check yourself

1. Roughly how far does a 20-day simple moving average lag the price?

Show answer

C. The average sits at the centre of its window, which is (n − 1) / 2 days in the past.

2. What is a “golden cross”?

Show answer

A. The death cross is the opposite. Both are slow signals because both averages lag.

3. Why can an SMA move although today’s price did not change?

Show answer

B. This “drop-off effect” is one reason exponential averages, which never drop values abruptly, are used instead.

Pattern bridge: The simple moving average is the arithmetic mean on a rolling window. The same smoothing kernel powers CNN convolutions — a filter sliding across data.
Linked from 5
Open in the full reader, with the topic sidebar