Module 02 · Reading price and volume
MACD and Bollinger bands
Lesson 09 / 104 min read5 sections
MACD and Bollinger bands are both built from averages of closing prices. MACD measures the distance between a fast average and a slow one. Bollinger bands measure how widely recent closes have been spread around a single average. This chapter builds both from one illustrative price series and shows where each of them lags.
MACD is the gap between two averages
The moving-average chapter worked through a simple average. MACD uses exponential averages, or EMAs, which give more weight to recent closes. Each day the EMA moves a fixed fraction of the way from yesterday’s value towards today’s close. The fraction is 2 ÷ (N + 1): 2/13 for a 12-day EMA and 2/27 for a 26-day EMA. The first value is usually started from a simple average.
The MACD line is the 12-day EMA minus the 26-day EMA. It is positive when recent closes have been running above older ones, and it grows while that gap widens. The signal line is a 9-day EMA of the MACD line itself. The histogram is the MACD line minus the signal line, so it shows whether the gap between the averages is still widening or has started to narrow. Gerald Appel developed MACD in the late 1970s, and 12, 26 and 9 remain the usual defaults.
Bollinger bands measure spread, not direction
The middle band is a 20-day simple average. The upper and lower bands sit two standard deviations above and below it. Standard deviation measures how far the last 20 closes typically sat from their own average. Calm trading gives narrow bands. Violent trading gives wide ones. John Bollinger introduced the bands in the 1980s, and 20 sessions with two standard deviations is the common setting.
A close outside a band is a description, not an instruction. In the example below, a quiet stretch narrowed the bands to just ₹3.85 apart on session 34. The stock then broke out and closed above its upper band on seven sessions in a row, from session 36 to session 42. Selling each of those closes as ‘stretched’ would have meant selling a stock that kept rising. The narrow squeeze before it said that trading was calm. It did not say which way the calm would end.
One session, worked through
The table takes session 42 of an illustrative stock, the last of those closes above the upper band, and computes every line from the previous session’s values. All prices are in rupees.
| Step | Working | Result |
|---|---|---|
| Close | Session 42 | ₹638 |
| 12-day EMA | 616.43 + 2/13 × (638 − 616.43) | 619.75 |
| 26-day EMA | 610.22 + 2/27 × (638 − 610.22) | 612.28 |
| MACD line | 619.75 − 612.28 | 7.47 |
| Signal line | 3.03 + 2/10 × (7.47 − 3.03) | 3.92 |
| Histogram | 7.47 − 3.92 | 3.55 |
| Middle band | Average of the last 20 closes | 610.30 |
| Standard deviation | Of the same 20 closes | 11.73 |
| Upper band | 610.30 + 2 × 11.73 | 633.76 |
| Lower band | 610.30 − 2 × 11.73 | 586.84 |
Where the lag shows
The stock peaked at ₹650 on session 46. After a brief dip on session 43, the histogram began shrinking steadily on session 47. That was the earliest hint, and it still came after the top. The MACD line crossed below its signal line on session 52, with the stock at ₹631, ₹19 below the peak. The bands were at their widest on session 49, three sessions after the top, because the standard deviation was still digesting the climb.
None of this is a fault. MACD is an average of the difference between two averages, so it reacts after price does by construction. Bollinger bands describe the last 20 sessions, not the next one. Charting packages also differ in small details, such as how the first EMA is started and how the standard deviation is computed, so your screen may show slightly different numbers. One more caution: RSI, MACD, the bands and moving averages are all rearrangements of the same closing prices. Agreement between them is less independent evidence than it looks.
What to remember
- MACD line = 12-day EMA − 26-day EMA. The signal line is a 9-day EMA of it, and the histogram is the gap between the two.
- Bollinger bands are a 20-day average plus and minus two standard deviations. They measure spread, not direction.
- A close above the upper band can repeat for many sessions in a strong move. It is not a sell signal by itself.
- A squeeze says trading has been calm. It does not say which way the next move will go.
- Both tools lag the price, and indicators built from the same closes do not confirm each other independently.
End of lesson 9
Ready for the next lesson?
Next · Lesson 10 · 4 minTimeframes and the chart you choose← Previous: Momentum and the relative strength index