# Moving averages

> Smooth the noise with an average of the last few closes, and see why every average arrives late in a trend and whips back and forth in a range.

- Course: [Trading Basics: How It Works, How Not to Lose Everything](https://productovi.com/courses/trading.md)
- Module: Which tools are worth my time?
- Lesson 21/32, ~29 min
- Source: https://productovi.com/courses/trading/moving-averages

## A line through the noise

**Alex Tutor:** Back on your Pebble practice account, today we start on tools: the lines and gauges apps draw over a chart. First, the simplest one. Marc uses it, and Nora has just discovered it.

![On a board a smooth blue average line trails a jagged grey price line. Nora points at it in excitement, Alex checks his phone and Marc waits calmly by a stone.](https://productovi.com/courses/trading/diagrams/m6-l1-scene.png)

**Nora:** There's a smooth line on my Bluefin Energy chart. When the price crosses above it, you buy, right? It looks like magic.

**Alex Tutor:** No magic, just arithmetic. A **moving average** is the average of the last N closes. For a 5-day average, add the last five closes and divide by 5. Tomorrow, drop the oldest close, add the new one, and divide again.

![The 5-day average on 2024-10-31 is the mean of the last five closes: 235.07 ÷ 5 = 47.01. The next day the oldest close, 47.83, drops out and the new close comes in.](https://productovi.com/courses/trading/diagrams/m6-l1-sliding-average.png)

$$
\text{5-day average} = \frac{C_1 + C_2 + C_3 + C_4 + C_5}{5}
$$

*The last five closes, divided by five*

**Nora:** Why not just look at the price?

**Alex Tutor:** Daily closes jump around. The average irons out the jumps, so the direction of the last few weeks is easier to see. That's all it does: it summarises.

> **Exercise:** What does a moving average tell you?

**Sofia:** So it's a running average that moves along with the dates.

**Alex Tutor:** Exactly. Here are 110 days of Bluefin Energy with the close and the 20-day average. The average is blank for the first 19 days: there aren't 20 closes yet.

**Dataset (CSV):** [Bluefin Energy, 110 daily closes with a 20-day average](https://productovi.com/datasets/trading/moving-averages/m6_bfe_ma.csv)

Practice market data on Pebble, 2024-06-03 to 2024-11-01. Prices in dollars.

- `date`: Trading day
- `close`: Closing price
- `ma20`: Average of the last 20 closes, rounded to a cent

> **Exercise:** Compute the 5-day average on the last day, 2024-11-01, from the last five closes in the file. Round to cents.

**Alex Tutor:** Notice that 46.85 is below 47.87. That only means the last week was lower, on average, than the last month. It's a description, not a warning sign.

## Always late

**Bluefin Energy, close and 20-day average**

| date | Close | 20-day average |
| --- | --- | --- |
| 2024-06-03 | 42.86 |  |
| 2024-06-04 | 42.33 |  |
| 2024-06-05 | 42.5 |  |
| 2024-06-06 | 42.16 |  |
| 2024-06-07 | 41.6 |  |
| 2024-06-10 | 41.38 |  |
| 2024-06-11 | 41.07 |  |
| 2024-06-12 | 40.73 |  |
| 2024-06-13 | 40.12 |  |
| 2024-06-14 | 39.81 |  |
| 2024-06-17 | 39.36 |  |
| 2024-06-18 | 39.07 |  |
| 2024-06-19 | 38.67 |  |
| 2024-06-20 | 38.61 |  |
| 2024-06-21 | 38.58 |  |
| 2024-06-24 | 38.74 |  |
| 2024-06-25 | 38.82 |  |
| 2024-06-26 | 39.09 |  |
| 2024-06-27 | 39.04 |  |
| 2024-06-28 | 38.42 | 40.15 |
| 2024-07-01 | 38.59 | 39.93 |
| 2024-07-02 | 38.61 | 39.75 |
| 2024-07-03 | 38.91 | 39.57 |
| 2024-07-04 | 39.38 | 39.43 |
| 2024-07-05 | 40.05 | 39.35 |
| 2024-07-08 | 40.45 | 39.31 |
| 2024-07-09 | 41.25 | 39.32 |
| 2024-07-10 | 41.34 | 39.35 |
| 2024-07-11 | 41.4 | 39.41 |
| 2024-07-12 | 41.7 | 39.5 |
| 2024-07-15 | 41.69 | 39.62 |
| 2024-07-16 | 41.85 | 39.76 |
| 2024-07-17 | 42.63 | 39.96 |
| 2024-07-18 | 43.47 | 40.2 |
| 2024-07-19 | 43.27 | 40.44 |
| 2024-07-22 | 43.08 | 40.65 |
| 2024-07-23 | 42.98 | 40.86 |
| 2024-07-24 | 42.5 | 41.03 |
| 2024-07-25 | 42.62 | 41.21 |
| 2024-07-26 | 42.84 | 41.43 |
| 2024-07-29 | 43.33 | 41.67 |
| 2024-07-30 | 43.11 | 41.89 |
| 2024-07-31 | 42.91 | 42.09 |
| 2024-08-01 | 43.65 | 42.31 |
| 2024-08-02 | 44.07 | 42.51 |
| 2024-08-05 | 44.34 | 42.7 |
| 2024-08-06 | 44.98 | 42.89 |
| 2024-08-07 | 44.83 | 43.06 |
| 2024-08-08 | 45.09 | 43.25 |
| 2024-08-09 | 45.61 | 43.44 |
| 2024-08-12 | 46.34 | 43.68 |
| 2024-08-13 | 46.34 | 43.9 |
| 2024-08-14 | 46.33 | 44.08 |
| 2024-08-15 | 47.02 | 44.26 |
| 2024-08-16 | 46.92 | 44.44 |
| 2024-08-19 | 46.77 | 44.63 |
| 2024-08-20 | 46.58 | 44.81 |
| 2024-08-21 | 46.81 | 45.02 |
| 2024-08-22 | 47.1 | 45.25 |
| 2024-08-23 | 47.04 | 45.46 |
| 2024-08-26 | 47.27 | 45.66 |
| 2024-08-27 | 47.57 | 45.88 |
| 2024-08-28 | 48.42 | 46.15 |
| 2024-08-29 | 48.77 | 46.41 |
| 2024-08-30 | 48.85 | 46.65 |
| 2024-09-02 | 48.22 | 46.84 |
| 2024-09-03 | 47.39 | 46.96 |
| 2024-09-04 | 46.94 | 47.07 |
| 2024-09-05 | 45.97 | 47.11 |
| 2024-09-06 | 46.79 | 47.17 |
| 2024-09-09 | 46.47 | 47.18 |
| 2024-09-10 | 47.03 | 47.21 |
| 2024-09-11 | 47.16 | 47.25 |
| 2024-09-12 | 47.51 | 47.28 |
| 2024-09-13 | 47.83 | 47.32 |
| 2024-09-16 | 47.44 | 47.36 |
| 2024-09-17 | 48.09 | 47.43 |
| 2024-09-18 | 48.33 | 47.51 |
| 2024-09-19 | 47.28 | 47.52 |
| 2024-09-20 | 48 | 47.57 |
| 2024-09-23 | 48.03 | 47.6 |
| 2024-09-24 | 48.17 | 47.63 |
| 2024-09-25 | 47.99 | 47.61 |
| 2024-09-26 | 48.31 | 47.59 |
| 2024-09-27 | 49.13 | 47.6 |
| 2024-09-30 | 48.26 | 47.61 |
| 2024-10-01 | 48.51 | 47.66 |
| 2024-10-02 | 47.2 | 47.68 |
| 2024-10-03 | 47.7 | 47.76 |
| 2024-10-04 | 47.47 | 47.8 |
| 2024-10-07 | 48.24 | 47.88 |
| 2024-10-08 | 48.63 | 47.96 |
| 2024-10-09 | 48.85 | 48.05 |
| 2024-10-10 | 47.76 | 48.06 |
| 2024-10-11 | 48.2 | 48.08 |
| 2024-10-14 | 48.62 | 48.14 |
| 2024-10-15 | 47.51 | 48.11 |
| 2024-10-16 | 47.7 | 48.08 |
| 2024-10-17 | 47.31 | 48.08 |
| 2024-10-18 | 47.17 | 48.04 |
| 2024-10-21 | 48.36 | 48.05 |
| 2024-10-22 | 48.86 | 48.09 |
| 2024-10-23 | 48.96 | 48.14 |
| 2024-10-24 | 49.07 | 48.18 |
| 2024-10-25 | 47.83 | 48.11 |
| 2024-10-28 | 47.12 | 48.05 |
| 2024-10-29 | 46.28 | 47.94 |
| 2024-10-30 | 47.46 | 47.96 |
| 2024-10-31 | 46.38 | 47.89 |
| 2024-11-01 | 47.01 | 47.87 |

**Alex Tutor:** Look at the turn in summer. The lowest close was 38.42 on 2024-06-28. The price first closed above its 20-day average on 2024-07-05, at 40.05. An average is built from the past, so it can only react after the price has moved.

**Marc:** Same at the top. The climb's highest close was 48.85 on 2024-08-30. The price closed back below the average only on 2024-09-04, at 46.94.

**Sofia:** So the line gets you in late and out late.

**Alex Tutor:** Yes. That delay is called **lag**. A longer average is smoother and lags more; a shorter one reacts faster and gets fooled more often. There's no length without that trade-off.

![The low close 38.42 came on 2024-06-28, but the close first crossed above the 20-day average on 2024-07-05 at 40.05; after the 48.85 top it crossed back below only at 46.94.](https://productovi.com/courses/trading/diagrams/m6-l1-lag.png)

*In late, out late: that delay is lag.*

**Nora:** Then I'll use a 3-day average. Faster!

**Marc:** I tried that. It crossed almost every other day, and every crossing cost me the spread and the commission. Faster isn't free.

> **Exercise:** The crossing rule bought at 40.05 on 2024-07-05. How many dollars a share above the lowest close, 38.42, was that?

**Alex Tutor:** So which length should you pick? Match each kind of line with what it does.

> **Exercise:** Match each line or picture with what it really tells you.

**Alex Tutor:** Nora wants a faster line. What does that really cost her?

> **Exercise:** Nora switches from a 20-day to a 3-day average to get into trends earlier. What is the main cost?

## Back and forth in a range

**Nora:** Still, +6.89 a share! With 100 shares and 4 dollars of costs, that's +685. I'm sold on crossings.

**Alex Tutor:** Now look at September and October. The price went sideways between about 46 and 49, and the average went flat in the middle of it. The price kept crossing it both ways.

> **The crossing rule in the range, after costs**
>
> - 2024-09-12 → 2024-09-19: −27
> - 2024-09-20 → 2024-10-02: −84
> - 2024-10-07 → 2024-10-10: −52
> - 2024-10-11 → 2024-10-15: −73
> - 2024-10-21 → 2024-10-25: −57

**Marc:** Five trades, five losses, −293 together. Each one bought a cross up near the top of the range and sold a cross down near the bottom. Traders call this a whipsaw.

![In the September–October range the 20-day average went flat and the close crossed it both ways: five trades, five losses (−27, −84, −52, −73, −57), −293 after costs.](https://productovi.com/courses/trading/diagrams/m6-l1-whipsaw.png)

**Sofia:** Could anyone see it was a range while it was happening?

**Alex Tutor:** Not on 2024-09-12. That day it looked as if the climb might go on. You see the box only after it has been drawn.

> **Exercise:** In the September–October range, the crossing rule won most of its trades.

**Sofia:** So over all 110 days the rule made 685 minus 293?

**Alex Tutor:** Work it out before I say it. What did the whole test come to?

> **Exercise:** Over 110 days of Bluefin Energy, the 20-day crossing rule made one trend trade of +685 and five range trades of −27, −84, −52, −73 and −57, all after costs. What is the total, in dollars?

**Alex Tutor:** +392 on 6 trades. One big trend trade paid for five small losses, this time. Six trades are far too few to judge: another stretch with a longer range and no trend could turn the total negative.

**Nora:** Still, +392 is +392.

**Nora:** So averages are useless?

**Alex Tutor:** Not useless. An average is a calm way to see the backdrop: rising, flat or falling. It just isn't a machine that tells you when to buy.

**Sofia:** A backdrop, not a trigger.

> **Exercise:** Which statements about moving averages are true? Choose all that apply.

**Marc:** I keep one average, the 20-day, and use it only to describe that backdrop. I never trade a crossing on its own, and I log every trade with its costs.

**Nora:** Fine. Explain it to me as if I'm stubborn.

**Alex Tutor:** Last one: explain it to Nora with the numbers.

> **Exercise:** Nora says: "When the price crosses above the average, it's going to rise. That's my new system." In 2–3 sentences, explain with the Bluefin Energy numbers what a crossing can and can't do.

> **Key ideas**
>
> - A **moving average** is the average of the last N closes: drop the oldest, add the newest, divide again.
> - It is built from the past, so it **lags**: the crossing rule bought 1.63 above the low and sold 1.91 below the top.
> - In a sideways range the average goes flat and crossings **whipsaw**: 5 trades, 5 losses, −293.
> - Total: +392 on 6 trades, far too few to judge. An average smooths the picture; it doesn't forecast.

> **Educational, not advice**
>
> This course explains how trading works; it never tells you what to buy or sell. Most people who trade lose money, and you can lose all of it. For taxes and rules, ask a licensed professional where you live.

- Previous lesson: [Case: mark up a chart and write the plan](https://productovi.com/courses/trading/mark-up-a-chart.md)
- Next lesson: [A momentum gauge and the overbought myth](https://productovi.com/courses/trading/momentum-gauge.md)

---
Productovi Learning. Free, no sign-up needed to read.
