Moving average (SMA)
The average closing price over the last N days, recalculated each day.
4 min readLesson 39 of 57Interactive
In short
It smooths out daily noise. A price above its 200-day average is often read as an uptrend; a short average crossing above a long one is a classic "golden cross" buy signal.
Why it matters
A stock's daily chart is noisy. It can rise three days in a row, drop sharply on a headline, then recover within a week. Looking at single days, it's hard to say whether the price is broadly heading up, down or sideways.
A moving average answers that question by averaging the noise away. It's the simplest and most widely used technical indicator: charting sites draw it by default, financial news quotes the 50-day and 200-day averages of big stocks, and many trading rules are built on it. Knowing exactly what it measures, and what it can't, helps you read all of those.
How it works
Pick a number of days, N. Add up the last N closing prices and divide by N. Tomorrow, add the new close, drop the oldest one, and divide again. Because the window slides forward one day at a time, the average "moves" with the price. Until a stock has N days of history, there's no average yet.
The length sets the trade-off. A 10-day average follows the price closely and turns quickly. A 200-day average is very smooth and turns slowly, so it's used for the long-term trend. Every close in the window counts equally, which is why it's called simple, as opposed to the exponential average, which weights recent days more.
Because it's built from past prices, a moving average always lags. After a sharp turn, the average keeps heading the old way for a while, because the window still holds many days from before the turn. The longer the average, the longer the lag.
Traders often compare two averages. When a short one, like the 50-day, rises above a long one, like the 200-day, it's called a golden cross; the opposite is a death cross. Trading on those signals is a strategy of its own, covered in the Moving-average crossover lesson.
SMA(N) = (sum of the last N closes) ÷ N
The plain average of the last N closing prices, worked out again every day.
A worked example
A stock closed at $100, $102, $101, $104 and $108 over five days. Work out its 5-day simple moving average, then update it after a sixth close of $110.
- Add the five closes: 100 + 102 + 101 + 104 + 108 = 515.
- Divide by 5: 515 ÷ 5 = $103. That's the 5-day average on day five.
- On day six, the window slides: drop the oldest close ($100) and add the new one ($110). The sum becomes 515 − 100 + 110 = 525.
- Divide by 5 again: 525 ÷ 5 = $105.
Result: The average rose from $103 to $105 while the price closed at $108 and then $110. It moves the same way as the price, but it trails behind it: that gap is the lag.
Try it
Averages and crossovers
Over two years the 20-day and 100-day averages crossed 3 times. The fast one is now above the slow one.
Crossovers
3
Labeled on the chart
Signal now
Uptrend: hold
Warm-up
100 days
Before the slow average exists
Generated prices for illustration, not market data.
How to read it
- Price above a rising average
- The stock has been in an uptrend over that window. Many investors read a price above its 200-day average as a sign of a long-term uptrend.
- Price below a falling average
- The stock has been in a downtrend. It says nothing certain about tomorrow, only that recent prices have been lower than earlier ones.
- Price crossing back and forth over a flat average
- No clear trend. This is where signals based on the average fail most often, because each cross is soon reversed.
- Short average crossing a long one
- A golden cross (short above long) or a death cross (short below long). Widely watched, but they arrive late, after the move has already started.
In the real world
- The 50-day and 200-day averages are the most widely watched. Market commentators often note when a big stock or an index like the S&P 500 crosses its 200-day average, and some fund managers use it as a simple test of whether the market is in an uptrend.
- Some long-term investors use a trend rule, such as holding stocks only while the price is above its 200-day average, mainly to try to sidestep long bear markets. Studies of such rules have found mixed results: they have sometimes cut drawdowns, but they also miss rebounds and trade more, and they often trail plain buy and hold after costs.
- Some traders treat the averages as support and resistance: places where a falling price might pause. Since so many people watch the same lines, prices sometimes do react there, but often they slice straight through.
Common mistakes
- Reading the average as a forecast. It's a summary of the past. A price above its average says the recent trend was up, not that it will stay up.
- Forgetting the lag. By the time a 200-day average turns down, the price may already have fallen a long way.
- Hunting for the perfect length. Try enough lengths on past data and one will look brilliant by luck, which is Overfitting. Round, widely used lengths like 20, 50 and 200 at least weren't picked to fit your data.
- Trading every cross in a choppy market. Each false signal costs a little in trading costs, and they add up.
See it in MarketLab
Backtest: price above 200-day average →
Test the classic trend rule on Apple: hold it while the price is above its 200-day average, and cash otherwise.
Custom rules →
Choose Custom rules to build your own conditions, like "price crosses above 50-day average", with up to 4 conditions for buying and for selling.
Test yourself
Optional: 4 quick questions on the words, using the idea, and how it plays out in real markets.
Loading your answers…