What it measures
A moving average measures where the price has been, on average, over a chosen number of bars. Nothing more. Because each new bar changes the average only a little, the line moves more slowly and more smoothly than the price it is made from.
The length is the one decision. A short average (10 bars) stays close to the price and turns quickly. A long one (200 bars) is far smoother and turns long after the price has. Neither is more correct: they answer different questions about the same past.
The two common kinds differ only in weighting. The simple moving average (SMA) treats the close from 20 bars ago exactly like the latest one, then drops it completely on the next bar. The exponential moving average (EMA) never drops anything: every past close keeps a share of the weight, and that share shrinks by the same proportion with each bar that passes.
How it is calculated, step by step
- 01
Choose a length, N.
The number of bars the average looks back over. On a daily chart, N = 20 is roughly a month of trading days.
- 02
Simple average: add the last N closes and divide by N.
SMA = (C₁ + C₂ + … + C_N) ÷ N. There is no value until N bars exist.
- 03
Move one bar on and do it again.
The oldest close leaves the window and the newest one enters. That is the only reason the line moves.
- 04
Exponential average: work out the multiplier.
k = 2 ÷ (N + 1). For N = 20, k = 2 ÷ 21, about 0.095: the newest close gets about 9.5% of the weight.
- 05
Give the EMA somewhere to start.
The usual choice, and the one on this page, is the simple average of the first N closes.
- 06
Then, for every bar after that:
EMA = close × k + previous EMA × (1 − k). The new value is the old value moved a fraction k of the way towards the latest close.
Charting programs do not all start an EMA the same way: some begin from the first close instead of a simple average. The difference fades as bars pass, but two programs can disagree on the early values.
A worked example, by hand
Five closes: 10, 12, 11, 13, 16. Length 3.
- SMA at bar 3 = (10 + 12 + 11) ÷ 3 = 11
- SMA at bar 4 = (12 + 11 + 13) ÷ 3 = 12
- SMA at bar 5 = (11 + 13 + 16) ÷ 3 = 13.33
- EMA: k = 2 ÷ (3 + 1) = 0.5, and it starts at bar 3 from the simple average, 11
- EMA at bar 4 = 13 × 0.5 + 11 × 0.5 = 12
- EMA at bar 5 = 16 × 0.5 + 12 × 0.5 = 14
The last close jumped to 16. The exponential average reached 14 while the simple one reached 13.33: the same data, weighted differently.
The numbers in this example were chosen to be easy to add up. They are not prices of anything.
How people read it
- Where the price is relative to the line. A close above a long average is described as an uptrend on that time frame, and below it as a downtrend. This is a description of the recent past, by definition.
- The slope. A rising average means recent closes have been higher than the ones leaving the window.
- Two averages together. When a shorter average crosses above a longer one, recent prices have risen faster than older ones. The crossing of the 50-bar and 200-bar averages is well known enough to have names: a golden cross upward, a death cross downward.
- As a moving reference. In a steady trend, pullbacks sometimes stop near a widely watched average. Sometimes they do not.
What it cannot tell you
- It cannot say what the next close will be. Every number in it is a close that has already happened.
- It cannot turn before the price does. An N-bar simple average is, in effect, (N − 1) ÷ 2 bars behind: a 200-bar average is describing the market of about 100 bars ago.
- It cannot tell a trend from a range in advance. In a sideways market the price crosses the average again and again, and each crossing looks, at the time, like the start of something.
- It cannot tell you which length is right. Any length that looks ideal was chosen by looking at prices that are already known.
Common mistakes
- Treating a crossover as a signal with a known outcome. A crossover reports that the average of recent prices has passed the average of older ones. It has already happened when it appears.
- Tuning the length until the past looks perfect. A length fitted to one stretch of prices has learned that stretch, not the market.
- Comparing a 20-bar average on a five-minute chart with one on a daily chart as if they measured the same thing. One covers under two hours, the other about a month.
- Forgetting the cost. A rule that trades every crossing in a sideways market pays the spread on every one of them.
Questions people ask
- What is the difference between an SMA and an EMA?
- Both average past closing prices. A simple moving average gives each of the last N closes the same weight. An exponential moving average gives the newest close a weight of 2 ÷ (N + 1) and lets the weight of older closes shrink steadily, so it reacts sooner to a change. Neither looks ahead.
- Which moving average length is best?
- None is best. The lengths in common use (20, 50, 100, 200) are conventions, and they are watched partly because they are conventions. A shorter average reacts quickly and crosses the price often; a longer one is smoother and later. A length that fitted past prices well says nothing certain about future ones.
- Does a golden cross mean the price will rise?
- No. A golden cross is the 50-bar average moving above the 200-bar average. It reports that prices over the last 50 bars have, on average, been higher than over the last 200, which means a rise has already happened. What follows can be a further rise, a fall or nothing much.
The words on this page
An indicator is arithmetic on prices that have already happened. It describes what a price did; it does not predict what a price will do. The chart on this page is invented: a seeded random walk, not a market. This page is an explanation for study. It is not advice, a recommendation or a forecast, and nothing an indicator shows says anything certain about what a price will do next.
