Bollinger Bands: Squeeze, Band Walks and Mean Reversion Rules
How Bollinger Bands are calculated, what band width and %B show, and how trading bots use them for mean reversion, volatility squeezes and breakouts - plus the classic mistakes.
Bollinger Bands, created by John Bollinger, place a band above and below a moving average at a distance based on standard deviation. Because the distance grows and shrinks with volatility, the bands describe both where price is relative to recent behaviour and how volatile the market is. Bots use them in two opposite ways - fading extremes and trading breakouts - which is why the market regime matters so much.
How they are calculated
With the default settings (20, 2):
- Middle band = SMA(20) of the close.
- Upper band = middle + 2 × standard deviation of the last 20 closes.
- Lower band = middle − 2 × standard deviation.
Two derived indicators are useful in code:
- %B = (close − lower) / (upper − lower). 1.0 at the upper band, 0 at the lower band.
- Band width = (upper − lower) / middle. Low values mark a squeeze.
How to read the bands
- Price at a band - an extreme relative to the last 20 bars, not necessarily a reversal.
- Band walk - repeated closes along one band in a trend.
- Squeeze - narrowest band width in months; volatility contraction.
- Expansion - bands widening fast, usually after a breakout.
Bot strategy 1: mean reversion in ranges
- Regime filter: ADX(14) below 20, or price oscillating around a flat 50-100 period average.
- Entry: close below the lower band (%B < 0), then a close back inside → buy.
- Exit: middle band, or %B above 0.8.
- Stop: beyond the recent extreme or 1.5 × ATR.
Works in quiet markets; dangerous in trends. The regime filter is not optional.
Bot strategy 2: squeeze breakout
- Setup: band width at its lowest level in the last 120 bars.
- Entry: close above the upper band → buy; close below the lower band → sell.
- Stop: middle band or opposite band.
- Exit: trailing stop, or band width starting to contract again.
Many breakouts from squeezes fail at first. Requiring a close beyond the band, plus volume or a higher-timeframe trend filter, reduces false starts. Compare with Donchian channels for a breakout definition based on highs and lows.
Bollinger vs Keltner
Keltner Channels use ATR instead of standard deviation for the distance. Some traders define a squeeze as “Bollinger Bands inside Keltner Channels” - volatility measured by standard deviation has fallen below its ATR-based range.
A worked example
USDJPY M15 mean-reversion bot active only in the Asian session:
- Filter: session 00:00-06:00 server time, ADX(14) < 20.
- Entry: close below lower band (20, 2.2), next close back inside.
- Exit: middle band or 12 bars.
- Stop: 1.2 × ATR(14).
The session filter selects quieter hours where reversion is more common; the bot stays flat when London volatility arrives.
Pitfalls
- Fading band touches in trends.
- Treating squeezes as directional - they only predict movement, not direction.
- Optimising period and multiplier finely; results often hinge on a lucky combination.
- Using the open bar’s band values, which shift until the bar closes.
Key takeaways
- Bollinger Bands combine a moving average with volatility-based bands.
- In ranges they support mean reversion; after squeezes they frame breakouts.
- %B and band width make the bands easy to use in code.
- Decide the regime first - the same touch means opposite things in ranges and trends.
Related: mean reversion strategy and range trading.
FAQ
Is touching the upper band a sell signal?
No. In strong trends price can 'walk the band' for many bars. A touch is a sign of strength unless other conditions point to a range.
What is a Bollinger squeeze?
A period when the bands are unusually narrow, meaning volatility is low. Low volatility tends to be followed by higher volatility, so squeezes often precede breakouts - but they do not tell you the direction.
What are the standard settings?
A 20-period simple moving average with bands two standard deviations above and below it.
Sources and further reading
- StockCharts ChartSchool: Bollinger Bands - chartschool.stockcharts.com
- StockCharts ChartSchool: Keltner Channels - chartschool.stockcharts.com