Quant Analytics: from scratch to pro · Indicators, honestly measured · Beginner
Moving averages and their lag
A moving average smooths prices by averaging the recent past. The smoothing always comes at a price: the average is late. This lesson shows how simple and exponential averages are built, how large the delay is, and why a longer window means a later signal.
In this lesson
- Compute a simple moving average and an exponential moving average by hand
- Convert a window length n into the smoothing factor alpha = 2 / (n + 1)
- Estimate the lag of an average as (n - 1) / 2 periods
- Explain why smoother means later, and why averages cannot be judged by how they look on a chart
Read first: Reading a price chart
Prices bounce around. A moving average replaces them with a calmer line made from their recent past. It is the building block of many other indicators, so it is worth knowing exactly what it computes, and what it cannot do.
Simple moving average
The simple moving average over n periods (SMA) is the mean of the last n closes: SMA = (P_1 + P_2 + ... + P_n) / n. Each new period adds the latest close and drops the oldest. Every price in the window has the same weight, 1 / n, and anything older has none.
Exponential moving average
The exponential moving average (EMA) gives the most weight to the latest price and lets older ones fade:
EMA_today = alpha x P_today + (1 - alpha) x EMA_yesterday
The smoothing factor is alpha = 2 / (n + 1), so that an EMA is comparable to an SMA of length n. For n = 10, alpha = 0.1818: the latest price carries 18.18% of the weight, nearly twice the 10% of an SMA. The weights never reach zero, they only shrink; the chart shows the two shapes. Even after ten prices, 13.4% of the EMA(10) weight is still on older ones.
The first EMA value needs a starting point. A common choice is the SMA of the first n closes.
Worked example
Ten closes: 100, 102, 101, 104, 106, 105, 103, 107, 109, 108. Use n = 5, so alpha = 2 / 6 = 0.333.
SMA(5): the first value uses days 1-5, (100 + 102 + 101 + 104 + 106) / 5 = 102.6. The last uses days 6-10, (105 + 103 + 107 + 109 + 108) / 5 = 106.4.
EMA(5), seeded with 102.6:
| Day | Close | EMA(5) |
|---|---|---|
| 6 | 105 | 103.4 |
| 7 | 103 | 103.27 |
| 8 | 107 | 104.51 |
| 9 | 109 | 106.01 |
| 10 | 108 | 106.67 |
Each row is 0.333 x close + 0.667 x previous EMA. On day 10 the EMA (106.67) is above the SMA (106.4). After a run of rising closes, the one that weights the recent days more sits closer to the price.
Lag
Every average is late, because it contains old prices. For a price moving in a straight line, an n-period average trails the latest price by (n - 1) / 2 periods. A 20-period average lags by 9.5 periods and a 200-period by 99.5. The EMA with alpha = 2 / (n + 1) has the same lag on a steady trend.
Lag is the price of smoothness. Lengthening the window removes noise and delays the news by the same amount. No setting gives a line that is both smooth and early. The EMA reacts faster to a sudden jump than an SMA does, but it leaves older data in the line for longer.
The delay is the reason why a price crossing its average is a late event: by the time it happens, the move has already occurred. Whether that is still useful is an empirical question, treated in measuring an indicator honestly.
What a moving average does not do
- It does not predict. It describes the recent past in a smoothed form.
- It does not adapt to the noise level. In a sideways market, price crosses the line repeatedly and gives many reversals that lead nowhere.
- Its look on a chart says nothing about its use. Any smooth line fits the past nicely.
Brock, Lakonishok and LeBaron (1992) tested moving-average rules on Dow Jones data from 1897 to 1986. The method, comparing signals against what chance would give, is the part to learn; see the later lesson.
Common mistakes
- Reading the line as a forecast.
- Optimising
non a chart until the crossings look right. - Comparing an EMA of length 20 with an SMA of length 20 and concluding one is "faster" without checking what each does to the same move.
- Forgetting that the first EMA values depend on the seed.
- Using different closing times or timeframes for the price and the average.
In practice
When someone shows a moving-average line, ask the window, the type, the price used and the timeframe. A longer window gives fewer signals and later ones; a shorter window gives more and noisier ones. Analytics on FinUties applies measures like these to the markets it covers, so they are at hand when you read a chart.
Weight on each past price: SMA(10) against EMA(10)
- SMA(10)
- EMA(10)
Worked numbers
Each result is recomputed from the formula shown.
| What | Formula | Result |
|---|---|---|
| SMA(5) on the first five closes | (100 + 102 + 101 + 104 + 106) / 5 | 102.6 |
| SMA(5) on the last five closes | (105 + 103 + 107 + 109 + 108) / 5 | 106.4 |
| smoothing factor for n = 5 | 2 / (5 + 1) | 0.333 |
| EMA on day 6, seeded with the first SMA | alpha * 105 + (1 - alpha) * sma_a | 103.4 |
| EMA on day 7 | alpha * 103 + (1 - alpha) * ema6 | 103.27 |
| EMA on day 8 | alpha * 107 + (1 - alpha) * ema7 | 104.51 |
| EMA on day 9 | alpha * 109 + (1 - alpha) * ema8 | 106.01 |
| EMA on day 10 | alpha * 108 + (1 - alpha) * ema9 | 106.67 |
| smoothing factor for n = 10 | 2 / (10 + 1) | 0.1818 |
| lag of a 20-period average | (20 - 1) / 2 | 9.5 |
| lag of a 200-period average | (200 - 1) / 2 | 99.5 |
| weight of each price in SMA(10) | 1 / 10 | 10% |
| share of EMA(10) weight beyond the latest 10 prices | (1 - alpha10)**10 | 13.4% |
Check yourself
Closes of 105, 103, 107, 109, 108. What is the 5-period simple moving average?
(105 + 103 + 107 + 109 + 108) / 5 = 106.4.
What smoothing factor does a 10-period EMA use?
alpha = 2 / (10 + 1) = 0.1818, so the latest price gets about 18.2% of the weight.
A price rises by exactly 1 each day. How far behind is a 20-day simple average?
(20 - 1) / 2 = 9.5 days, which is 9.5 points below the latest price.
A 200-day average is smoother than a 20-day average. What do you give up?
Timeliness. The lag is 99.5 periods instead of 9.5. A smoother line reacts later.
Does an EMA have less lag than an SMA of the same n?
Not on a steady trend: with alpha = 2 / (n + 1) both lag by (n - 1) / 2. The EMA puts more weight on recent prices, so it reacts faster to a sudden move, but it also keeps a long tail of older prices.
Key terms
Moving averageExponential moving averageTimeframeCandlestick
Sources
- The Econometrics of Financial Markets. Princeton University Press (John Y. Campbell, Andrew W. Lo, A. Craig MacKinlay), 1997. Accessed 9 Nov 2026
- Simple Technical Trading Rules and the Stochastic Properties of Stock Returns. The Journal of Finance 47(5), 1731-1764 (William Brock, Josef Lakonishok, Blake LeBaron), 1992. Accessed 9 Nov 2026