Bollinger Bands Complete Guide
Beyond "Sell at the Upper, Buy at the Lower"
Bollinger Bands is a volatility indicator invented by John Bollinger in the 1980s, and nearly every trader on the planet has seen it. But 90% of users only know the beginner playbook: "sell when price touches the upper band, buy when it touches the lower band" — and that approach gets repeatedly slapped down in strong trends.
This guide covers the math (why ±2 standard deviations), four real-world applications, the "Squeeze" breakout strategy, the Walk the Bands phenomenon Bollinger himself defined, and complete Pine Script code.
1. The Math Behind Bollinger Bands
Three lines:
Middle Band = SMA(close, 20) // 20-period simple moving average
Std Dev = stdev(close, 20) // standard deviation of the last 20 closes
Upper Band = Middle + 2 × Std Dev
Lower Band = Middle - 2 × Std DevKey concept: standard deviation.
Why ±2 standard deviations?
Statistical principle: if price follows a normal distribution,95.4% of the time it will sit inside ±2σ. In plain English: out of 100 candles, roughly 95 will stay inside the bands and 5 will touch or pierce through.
But real financial assets aren't normally distributed — they have "fat tails": extreme events happen more often than a normal distribution predicts. So in practice, price touches the bands more frequently than 5% of the time. That deviation is the trap Bollinger Bands set for you, and the root cause of the "Walk the Bands" phenomenon we'll get to later.
2. Beginner Application: Mean Reversion (Most Common, Most Likely to Blow Up)
The intuition:
- Price hits the upper band → overextended, short the bounce
- Price hits the lower band → overextended, buy the bounce
Bollinger himself called this phenomenon "Walking the Bands" — a signature of trending markets, not a reversal signal.
//@version=5
strategy("BB Mean Reversion (Teaching Version)", overlay=true)
length = input.int(20, "Period")
mult = input.float(2.0, "Std Dev Multiplier")
basis = ta.sma(close, length)
dev = mult * ta.stdev(close, length)
upper = basis + dev
lower = basis - dev
// Price touches lower band → buy
if (ta.crossunder(low, lower))
strategy.entry("Long", strategy.long)
// Price touches upper band → sell
if (ta.crossover(high, upper))
strategy.entry("Short", strategy.short)
plot(basis, "Middle", color=color.orange)
plot(upper, "Upper", color=color.red)
plot(lower, "Lower", color=color.green)3. Intermediate Application: Squeeze Breakout Strategy
This is where Bollinger Bands really shine. When the bands contract (upper and lower draw close together), volatility is dropping, the market is storing energy → the breakout direction often unleashes a big move.
How do you define a Squeeze?
Two common definitions:
A. Bollinger Bands Width (BBW)
BBW = (Upper - Lower) / MiddleBBW drops to its lowest value over the past X periods = Squeeze. Bollinger himself uses a 6-month low as the threshold.
B. Bollinger Squeeze (vs Keltner Channel)
When the Bollinger Bands sit entirely inside the Keltner Channel, that's a Squeeze. This is John Carter's version (from his book Mastering the Trade).
//@version=5
strategy("BB Squeeze Breakout", overlay=true)
length = input.int(20, "Period")
mult = input.float(2.0, "BB Multiplier")
keltnerMult = input.float(1.5, "Keltner Multiplier")
basis = ta.sma(close, length)
dev = mult * ta.stdev(close, length)
bbUpper = basis + dev
bbLower = basis - dev
atr = ta.atr(length)
keltnerUpper = basis + keltnerMult * atr
keltnerLower = basis - keltnerMult * atr
// Squeeze condition: BB inside Keltner
squeeze = bbUpper < keltnerUpper and bbLower > keltnerLower
// Squeeze ends + price breaks above upper band → go long
if (not squeeze and squeeze[1] and close > bbUpper)
strategy.entry("Long", strategy.long)
// Squeeze ends + price breaks below lower band → go short
if (not squeeze and squeeze[1] and close < bbLower)
strategy.entry("Short", strategy.short)
plot(basis, "Middle", color=color.orange)
plot(bbUpper, "BB Upper", color=color.red)
plot(bbLower, "BB Lower", color=color.green)
bgcolor(squeeze ? color.new(color.purple, 90) : na, title="Squeeze")4. Advanced Application: The %B Indicator
Bollinger later added a companion indicator called %Bthat quantifies where price sits inside the bands:
%B = (close - Lower) / (Upper - Lower)
%B = 0 → price just touched the lower band
%B = 0.5 → price is at the middle band
%B = 1 → price just touched the upper band
%B > 1 → price broke above the upper band (strong trend)
%B < 0 → price broke below the lower band (strong trend)With %B you can run:
- %B divergence: price makes a new high but %B doesn't → trend momentum is fading
- %B + RSI: %B > 0.95 and RSI > 70 → double-confirmed overbought
- %B crossing above 0.5: price moves from the lower half to the upper half — often a trend-starting signal
5. Pro Application: BB + RSI + Trend Filter
The combination Bollinger himself recommended most. Full workflow:
- Use the SMA 200 to gauge larger trend direction (above SMA 200 = bullish structure)
- Price pulls back to the BB middle band (not the lower band) → trend pullback entry
- RSI is simultaneously > 50 (bullish momentum still intact)
- Enter long
//@version=5
strategy("BB Middle Pullback + Trend Filter", overlay=true)
basis = ta.sma(close, 20)
dev = 2.0 * ta.stdev(close, 20)
upper = basis + dev
lower = basis - dev
sma200 = ta.sma(close, 200)
rsi = ta.rsi(close, 14)
// Bullish structure: price > SMA 200 + RSI > 50
bullishStructure = close > sma200 and rsi > 50
// Pullback to middle: low touches middle band but close reclaims above it
pullback = low <= basis and close > basis
if (bullishStructure and pullback)
strategy.entry("Long", strategy.long)
// Close below middle + RSI < 50 → exit
if (close < basis and rsi < 50)
strategy.close("Long")
plot(basis, "Middle", color=color.orange)
plot(upper, "Upper", color=color.red)
plot(lower, "Lower", color=color.green)
plot(sma200, "SMA 200", color=color.purple)6. Reading BB Across Different Timeframes
| Timeframe | BB Application | Primary Use |
|---|---|---|
| 1m / 5m | Too noisy, not recommended | Scalping, but low win rate |
| 15m / 1h | Squeeze breakouts most effective | Intraday swings |
| 4h | Middle-band pullback + trend filter | 2-7 day swings |
| D / W | Trend direction assessment | Monthly-scale allocation |
7. Common Mistakes
❌ Treating BB as "absolute boundaries"
Price touching the upper band ≠ automatic sell. In a bull market, price can "Walk the Bands" — touching them on a dozen consecutive candles. You need to read the larger trend structure to decide whether fading the move is even appropriate.
❌ Cranking the parameters too short
Some people set length to 5 and mult to 1.0 because they "want it more sensitive" — the result is bands that are too narrow, signals flooding in, and a win rate collapsing to 30%. Stick with the 20 / 2.0 defaults.
❌ Entering during a Squeeze
A Squeeze is the dormant phase — the market isn't moving. Enter during this period and you'll get chopped up until you stop out. Wait for the Squeeze to end and a clear breakout to develop before you pull the trigger.
❌ Looking at BB without checking volume
If price breaks the upper band but volume doesn't expand, the odds of a fakeout are high. Real breakouts are almost always accompanied by a volume surge.
Get started
Wire your strategy to a TradingView webhook and auto-execute on Binance / OKX / Bybit and 4 more.
Start free trial8. Highlights from Bollinger's Own "19 Rules"
John Bollinger wrote Bollinger on Bollinger Bands, which lists 19 rules. Here are the most critical ones:
- Rule 4: Price touching the bands is not, by itself, a signal — it requires confirmation from other indicators
- Rule 6: During a Squeeze the market stores energy; the breakout direction marks the start of a major move
- Rule 11: Walking the Bands is normal trending behavior — don't fight it
- Rule 14: BB is a "relative" tool, not an "absolute" one — the upper band is just "relatively high" and the lower band is just "relatively low"