Price turns down.
But the moving average keeps going up.
Is the indicator wrong?
No.
In fact, this is one of the most important things to understand about a moving average.
A moving average is designed to smooth price. And smoothing has a cost: the line reacts later than price.
less noise
↕
more delay
That delay is called lag.
In this lesson, we will see exactly where the lag comes from. Once you understand the mechanism, the line stops looking mysterious.
1. Start with Price, Not the Indicator
Imagine this simple price sequence:
100
102
104
106
108
110
109
108
107
106
Price rises to 110.
Then it starts falling:
110
↓
109
↓
108
↓
107
The price has already turned.
Now put a 5-period Simple Moving Average on the same data.
2. Something Surprising Happens
Just before the price peak, the first five prices are:
102
104
106
108
110
Their average is:
(102 + 104 + 106 + 108 + 110) / 5
= 106
Now price falls from 110 to 109.
You might expect the moving average to fall too.
But the new 5-price window is:
104
106
108
110
109
Its average is:
(104 + 106 + 108 + 110 + 109) / 5
= 107.4
Look carefully:
Price
110 → 109
DOWN
SMA
106 → 107.4
UP
Price fell.
The moving average rose.
That is not an error. It is the direct result of how the average works.
3. Why Did the Average Still Rise?
Compare the two windows.
before
102 104 106 108 110
after
104 106 108 110 109
The newest price, 109, is lower than the previous price, 110.
But something else happened:
The old value 102 disappeared.
And 109 entered.
102 leaves
109 enters
Replacing 102 with 109 still pushes the average higher.
This is the heart of moving-average lag.
4. The Formula from the Last Lesson Explains Everything
In Phase 3-4, we learned:
SMA today - SMA yesterday
=
(new price - old price leaving the window)
/
N
For a 5-period SMA:
SMA change
=
(new price - price 5 bars ago)
/
5
This gives us a powerful rule.
new price
>
price leaving the window
→ SMA can keep rising
So price can already be falling from its recent high while the moving average continues upward.
The moving average is still absorbing earlier low prices and replacing them with newer, higher prices.
5. Price Can Turn Before the Average Turns
Think of the moving average as a slow summary of recent history.
Price
turns now
↓
Moving Average
old prices remain
inside the calculation
↓
line keeps moving
in the old direction
↓
eventually turns
Price reacts immediately because price is the new observation.
The moving average contains many observations.
One new price must share the calculation with all the older prices that are still inside the window.
6. This Is What “Lag” Means
Lag does not mean:
the calculation is late
because Python is slow
It means:
the indicator reacts later
because it is built
from past observations
Fidelity's SMA guide describes the same trade-off: longer-period SMAs are smoother, but they introduce more lag between the average and its source data.
7. Why Smooth Price at All?
If lag is a disadvantage, why not just look at the raw price?
Because raw price moves a lot.
up
down
up
up
down
down
up
...
Every small move does not necessarily represent a meaningful change in the broader direction.
Averaging reduces some of those short-term fluctuations.
raw price
↓
many small movements
moving average
↓
smoother summary
The moving average trades detail for stability.
8. The Real Trade-Off: Smoothness vs Speed
This is the main concept to remember:
shorter window
less smoothing
faster response
longer window
more smoothing
slower response
Or even more simply:
SMOOTHER
↔
SLOWER
Research comparing moving averages often treats smoothness and lag as two central characteristics of the filter.
9. Compare a 10-Day and 30-Day SMA
Now return to a real candlestick chart.
Add:
SMA 10
+
SMA 30
Both lines use the same Close data.
The difference is the amount of history inside each average.
SMA 10
→ 10 recent prices
SMA 30
→ 30 recent prices
The 10-day line normally bends sooner because each new price represents a larger part of its calculation.
The 30-day line normally looks smoother because each new price has less influence on the total average.
10. Read the Real Chart in This Order
When you run the Python file, look at the AAPL chart in this order:
1. Find a place where candles change direction.
2. Watch SMA 10.
3. Watch SMA 30.
4. Ask which line bends first.
5. Ask which line looks smoother.
You should not expect every market turn to produce a perfect textbook picture.
Real price is noisy.
That is exactly why this is an experiment rather than a drawing to memorize.
11. Lag Is Not Always Bad
Suppose an average responded instantly to every tiny price move.
It would be fast.
But it would also start looking more like the noisy price series we were trying to smooth.
very fast
→ more sensitive
→ more small changes
very smooth
→ less sensitive
→ more lag
So the question is not:
How do we remove all lag?
A better question is:
How much smoothing
and
how much responsiveness
do we want?
12. Why Crossovers Can Be Even Later
This also explains what we saw in Phase 3-3.
A crossover uses two moving averages.
price changes
↓
short MA reacts
↓
long MA reacts more slowly
↓
their relative positions change
↓
crossover
So by the time a crossover appears, price may already have moved noticeably.
That does not make the crossover useless.
It tells us what kind of information the crossover contains: it is a confirmation from smoothed historical data, not an instant detector of the exact turning point.
13. Full Runnable Python File
Save:
phase3_05_moving_average_lag.py
Run:
python phase3_05_moving_average_lag.py
The file performs two experiments.
Experiment A — Controlled Example
simple price sequence
↓
5-period SMA
↓
price peak
vs
SMA peak
It saves:
moving_average_lag_concept.png
Experiment B — Real Market Data
AAPL candlesticks
+
SMA 10
+
SMA 30
It saves:
moving_average_lag_aapl.png
14. Change One Thing Yourself
Start with:
short_sma_days = 10
long_sma_days = 30
Then try:
short_sma_days = 5
long_sma_days = 50
Ask:
Which line follows price more closely?
Which line looks smoother?
Which line turns later?
Does faster always look better?
Do not optimize the numbers yet.
The goal is to feel the trade-off by changing the windows yourself.
Check Your Understanding
- A moving average lags because it contains older prices.
- Price can fall while an SMA is still rising.
- The SMA direction depends on the new price entering and the old price leaving the window.
- A longer SMA usually looks smoother but reacts more slowly.
- A shorter SMA usually reacts faster but follows more short-term movement.
- Lag is a consequence of smoothing, not a calculation error.
- A crossover can occur after the underlying price move has already begun.
What You Just Learned
PRICE
changes first
↓
MOVING AVERAGE
contains past prices
↓
SMOOTHING
reduces short-term movement
↓
LAG
appears
↓
LONGER WINDOW
more smoothness
more delay
If one idea stays in your head, let it be this:
A moving average is slower than price for the same reason it is smoother than price: it remembers the past.
That leads naturally to the next question.
Can we keep the smoothing, but make the moving average react faster to recent prices?
One answer is the Exponential Moving Average, or EMA.
References
- Fidelity — Simple Moving Average (SMA)
- Fidelity — Exponential Moving Average (EMA)
- Zakamulin — Moving Averages for Market Timing