Technical analysisModule 3, lesson 12 of 32
Moving averages
How to calculate simple and exponential moving averages, why every moving average lags, how crossovers work, and why their signals whipsaw in sideways markets.
In this lesson
- Calculate a simple moving average and an exponential moving average.
- Explain why moving averages lag and how the period changes the lag.
- Describe price and moving-average crossovers and what they measure.
- Explain why moving-average signals whipsaw in trading ranges.
Builds on
- Trends and market structureMoving averages are used to describe trends, explained there.
- Averages, spread and volatilityA moving average is the ordinary average applied to a sliding window of prices.
On this page
In simple terms
A moving average smooths a price series by averaging the most recent prices. Each day, the oldest price drops out and the newest comes in, so the average "moves" along the chart. It turns a jagged price line into a smoother one that is easier to read as a trend.
Moving averages are the building block of many other indicators, including MACD and Bollinger Bands.
Simple moving average
SMA (N periods) = sum of the last N closing prices ÷ N
Worked example: A five-day SMA
A made-up share's closing prices over ten days: ₹100, 102, 101, 104, 106, 105, 108, 110, 109, 112.
| Day 5: (100 + 102 + 101 + 104 + 106) ÷ 5 | ₹102.6 |
|---|---|
| Day 6: (102 + 101 + 104 + 106 + 105) ÷ 5 | ₹103.6 |
| Day 7: (101 + 104 + 106 + 105 + 108) ÷ 5 | ₹104.8 |
| Day 8: (104 + 106 + 105 + 108 + 110) ÷ 5 | ₹106.6 |
| Day 9: (106 + 105 + 108 + 110 + 109) ÷ 5 | ₹107.6 |
| Day 10: (105 + 108 + 110 + 109 + 112) ÷ 5 | ₹108.8 |
On day 10 the price is ₹112, but the average is ₹108.8. The average sits below the price in a rising market, because it includes older, lower prices.
Exponential moving average
An exponential moving average (EMA) gives more weight to recent prices:
EMA today = price today × k + EMA yesterday × (1 − k) k = 2 ÷ (N + 1)
For a five-day EMA, k = 2 ÷ 6 = 0.33, so a third of the weight goes to today's price. Using the same prices and starting from the day-5 SMA of ₹102.6, the EMA reaches about ₹108.9 on day 10, slightly above the SMA's ₹108.8, because it responds faster to recent rises.
Lag
Every moving average lags the price, because it is built entirely from past prices. The longer the period, the smoother the line and the greater the lag:
- A 10-day average follows the price closely, with lots of wiggles.
- A 200-day average moves slowly and can stay far from the current price for months.
There is no free lunch: reducing lag means accepting more noise, and reducing noise means accepting more lag.
Crossovers
Traders watch for two kinds of crossover:
- Price crossing an average: the price closing above or below, say, its 50-day average.
- Two averages crossing: a shorter average crossing a longer one. A 50-day average crossing above a 200-day average is popularly called a "golden cross"; crossing below, a "death cross".
Because both averages lag, a crossover confirms that prices have already moved for some time. It describes a change in the recent trend; it does not predict that a new trend has begun or will last.
Whipsaws in sideways markets
In a trading range, prices move back and forth around the average, so crossovers flip repeatedly.
Worked example: Whipsaws in a range
A made-up share trades between ₹195 and ₹205 for three months. A trader buys whenever the price closes above its 20-day average and sells when it closes below. Over the three months:
| Number of buy and sell signals | 9 round trips |
|---|---|
| Average loss per round trip, including costs | about 1.5% |
| Total loss over three months | about 13% of the position |
These figures are made up, but the pattern is typical: in sideways markets, crossover rules buy after small rises and sell after small falls, paying costs each time.
Why it matters
Moving averages are the most widely used indicator, and the basis of many others. Understanding how they are built shows clearly what they can do, smooth noise and describe direction, and what they cannot: predict turning points. Recognising lag and whipsaws protects you from treating crossovers as forecasts.
Limitations
All moving averages lag. The choice of period is arbitrary, and results depend heavily on it, which makes it tempting to pick the period that worked best in the past, an example of the overfitting problem. Moving averages also say nothing about value.
Common mistakes
- Treating a crossover as a prediction.
- Using moving-average rules in sideways markets without expecting whipsaws.
- Choosing the period that looks best on a past chart.
- Using unadjusted prices, which put false jumps into the average, as the adjusted prices lesson explains.
Try it yourself
- Take ten closing prices for any share from the exchange website.
- Calculate the five-day SMA for the last six days by hand.
- Calculate a five-day EMA starting from the first SMA, using k = 0.33.
- Plot both with the prices on paper or a spreadsheet, and note which reacts faster.
Key takeaways
- A simple moving average (SMA) is the average closing price over the last N periods, recalculated each period.
- An exponential moving average (EMA) gives more weight to recent prices, so it reacts faster.
- Every moving average lags, because it is built from past prices. Longer periods lag more but smooth more.
- Crossovers, of price and an average or of two averages, describe a change that has already happened; they do not predict new trends.
- In sideways markets, crossover signals flip back and forth, producing repeated small losses known as whipsaws.
Check your understanding
Finished reading?
Your progress is saved only in this browser.
Terms used in this lesson
- Moving average
- The average closing price over the last N periods, recalculated each period, used to smooth price movements and describe trends.
- Trend
- The direction of prices over a period, defined by the sequence of swing highs and lows on a chosen timeframe.
- Trading range
- A period in which prices move sideways between roughly stable highs and lows, without a clear trend.
Spotted a mistake or something unclear? Report it by email. Here is how corrections work.
This lesson is general education, not investment advice. Examples use made-up or clearly dated figures to explain ideas; they are not recommendations. Read the disclaimer.