Quant Analytics: from scratch to pro · Indicators, honestly measured · Intermediate
ATR, Bollinger Bands and volatility envelopes
The Average True Range and Bollinger Bands are two ways to draw a price's recent variability on a chart. Both are measures of past spread, useful as a ruler for distances and position size, and neither tells you where the price goes next.
In this lesson
- Compute the true range for a bar, including a gap, and update an ATR
- Build Bollinger Bands from a moving average and a standard deviation
- Use ATR as a ruler to convert a risk amount into a position size
- Explain what the bands do and do not say about probability
Read first: Moving averages and their lag, Volatility explained
Volatility changes over time: quiet weeks, then sharp ones. Two tools put that on a chart. The Average True Range (ATR) measures the typical size of a bar in price units. Bollinger Bands draw a channel around a moving average whose width follows the recent standard deviation. Both describe the past spread; they are rulers, not forecasts.
True range and ATR
A bar's high minus low misses what happened between bars. If a price closes at 100 and opens the next day at 104, the gap is movement that a high-low range ignores. Wilder (1978) defined the true range to include it:
TR = max(high - low, |high - previous close|, |low - previous close|)
The ATR averages the true range over n periods, with n = 14 as the usual choice. The first value is the mean of the first 14 true ranges. After that Wilder's smoothing applies: ATR_new = (ATR_old x 13 + TR) / 14. This is the same recursion used in the RSI (see oscillators).
ATR is in price units. To compare assets, divide by the price and express it as a percentage.
Worked example: true range and a distance
Yesterday's close was 100. Today's bar has a high of 104 and a low of 101. High minus low is 3. The distance from the previous close to the high is 4, and to the low it is 1. The true range is 4.
If the ATR(14) was 2.5, the update is (2.5 x 13 + 4) / 14 = 2.607.
ATR is often used as a ruler for distance. Suppose a risk amount of 1% on a 50,000 account, which is 500, and a stop placed 2.5 ATR from entry. The stop distance is 2.5 x 2.607 = 6.52 per share. The position that loses 500 if the stop is hit is 500 / 6.52 = 76.7 shares, so 76 after rounding down. A wider market gives a bigger ATR and a smaller position, which keeps the loss near the intended size, if the stop fills at its price. The size of the stop is a choice about risk. It carries no information about direction. For the sizing side see position sizing basics.
Bollinger Bands
John Bollinger's bands have three lines for a window of n closes (20 is the usual choice):
- Middle: the simple moving average.
- Upper: middle +
kx standard deviation of the closes, withk = 2the usual choice. - Lower: middle -
kx standard deviation.
Software differs on whether it divides by n or n - 1 in the standard deviation, which moves the bands slightly.
Two derived numbers are common. Bandwidth is (upper - lower) / middle, a measure of how wide the channel is relative to price. %b is (price - lower) / (upper - lower), the position of the price inside the channel: 0 at the lower band, 1 at the upper.
Worked example: bands
Five closes: 98, 100, 101, 103, 98. The mean is 100. The deviations are -2, 0, 1, 3, -2, with squares 4, 0, 1, 9, 4. The population variance is 3.6 and the standard deviation is 1.90. With k = 2 the bands are 96.21 and 103.79.
For a 20-period example with a middle of 100 and a standard deviation of 2.5, the bands are 95 and 105, the bandwidth is 10 / 100 = 10%, and a price of 103 has %b = (103 - 95) / 10 = 0.80.
What the bands say, and what they do not
If returns were normal and independent, about 95.45% of closes would fall within two standard deviations. Price data is not like that. Tails are usually fatter than the normal curve and volatility clusters, so the true share outside the bands depends on the market and period, and has to be measured. A close outside the band is a statement that the move is large relative to recent variation. It does not carry a direction for what follows. In a trend, price can stay near one band for a long time.
Volatility envelopes use the same idea with other widths: a fixed percentage around an average, or an average plus and minus a multiple of ATR. They suit different purposes, but each draws a channel from a centre and a spread.
Bands narrowing (low bandwidth) says volatility has recently been low. Volatility is persistent but also mean-reverting, so quiet spells are not a signal on their own.
Common mistakes
- Reading a band touch as a reason to expect a reversal, or as a reason to expect a breakout. Either needs evidence.
- Using high-low range as a volatility measure and missing overnight gaps.
- Setting stops by a fixed number of points when volatility has changed.
- Comparing ATR values of assets at different price levels without converting to percent.
- Treating a standard deviation of closing prices as a standard deviation of returns.
In practice
Use ATR or a band width as a scale: to set distances that adapt to current conditions and to size positions. Keep the questions "how big are the moves?" and "which way?" separate. The first has a good answer from these tools. Analytics on FinUties applies measures like these to the markets it covers, so they are at hand when you read a chart.
Worked numbers
Each result is recomputed from the formula shown.
| What | Formula | Result |
|---|---|---|
| true range of the bar with a gap | max(104 - 101, abs(104 - 100), abs(101 - 100)) | 4 |
| ATR(14) after a true range of 4 | (2.5 * 13 + tr_gap) / 14 | 2.607 |
| stop distance of 2.5 ATR | 2.5 * atr_new | 6.52 |
| risk of 1% on 50,000 | 0.01 * 50000 | 500 |
| position size, unrounded | risk_amt / stop_dist | 76.7 |
| mean of five closes | (98 + 100 + 101 + 103 + 98) / 5 | 100 |
| population variance of the five closes | ((98 - mean5)**2 + (100 - mean5)**2 + (101 - mean5)**2 + (103 - mean5)**2 + (98 - mean5)**2) / 5 | 3.6 |
| population standard deviation | sqrt(var5) | 1.90 |
| upper band, 2 standard deviations | mean5 + 2 * sd5 | 103.79 |
| lower band | mean5 - 2 * sd5 | 96.21 |
| bandwidth of the 20-period example | (105 - 95) / 100 | 10% |
| percent b for a price of 103 | (103 - 95) / (105 - 95) | 0.80 |
| normal share inside two standard deviations | 2 * phi(2) - 1 | 95.45% |
Check yourself
Yesterday's close was 100. Today the bar has a high of 104 and a low of 101. What is the true range?
The largest of high - low = 3, |high - previous close| = 4 and |low - previous close| = 1. So 4. The high-low range alone misses the gap.
The ATR(14) is 2.5 and today's true range is 4. What is the new ATR?
(2.5 x 13 + 4) / 14 = 2.607.
A 20-period average is 100 and the standard deviation of the closes is 2.5. Where are the bands, and what is the bandwidth?
Upper 105, lower 95. Bandwidth = (105 - 95) / 100 = 10%.
A price of 103 sits inside those bands. What is %b?
(103 - 95) / (105 - 95) = 0.80, which is four-fifths of the way from the lower to the upper band.
If returns were normal, what share of closes would fall inside a two-standard-deviation band?
About 95.45%. Real returns have fatter tails, and the bands move with the data, so the real share is not a fixed number.
Key terms
Sources
- New Concepts in Technical Trading Systems. Trend Research (J. Welles Wilder Jr.), 1978. Accessed 9 Nov 2026
- Bollinger on Bollinger Bands. McGraw-Hill (John Bollinger), 2001. Accessed 9 Nov 2026
- The Econometrics of Financial Markets. Princeton University Press (John Y. Campbell, Andrew W. Lo, A. Craig MacKinlay), 1997. Accessed 9 Nov 2026