Bollinger Bands
Dynamic volatility envelope that expands in high-volatility regimes and contracts during consolidation.
What is it?
Created by John Bollinger in the 1980s, Bollinger Bands consist of a middle band (typically a 20-period SMA) and two outer bands plotted at ±2 standard deviations from the middle band. Because standard deviation is a measure of volatility, the bands widen when price is volatile and contract when it is quiet. Approximately 95% of price action falls within the bands under normal distribution assumptions — though crypto markets frequently violate this. The 'Bollinger Squeeze' (bands narrowing to a multi-month low) often precedes a large directional move.
When to use it
- Identifying volatility contractions (squeezes) that precede breakouts — when the bands are at their narrowest in months, a large move is likely imminent.
- Mean-reversion trades in ranging markets: price touching the upper band in a range is a potential short; touching the lower band is a potential long.
- Riding the bands in trending markets: in a strong uptrend, price 'walks the upper band' — closes repeatedly near or above the upper band signal trend continuation, not reversal.
- Combining with RSI: a touch of the lower band with RSI below 30 is a higher-probability mean-reversion long than either signal alone.
- Detecting false breakouts: a close outside the band followed by a close back inside is a classic reversal signal (Bollinger Band 'W' bottom or 'M' top).
Common pitfalls
- Touching the band is not a signal by itself. In a trending market, price can walk the upper band for dozens of candles. Always check trend context first.
- The 2-standard-deviation setting means roughly 5% of closes will be outside the bands by definition — these are not rare events.
- Bollinger Bands use a simple moving average as the middle band. In fast-moving crypto markets, an EMA-based middle band (Keltner Channel) often performs better.
- The squeeze identifies that a move is coming — it does not tell you the direction. Always use a directional filter (trend, volume, or order flow) before trading a squeeze breakout.
- Bands calculated on closing prices miss intraday wicks. A wick that pierces the band but closes inside it is not a confirmed band touch.
Indicator Rider — Bollinger Ball
The Bollinger Ball bounces between the upper and lower bands — cyan at the top, orange at the bottom — with squash-and-stretch physics on impact.
Free code template
Paste directly into TradingView Pine Editor → Add to chart.
/indicator("Bollinger Bands — DAI Template", overlay=true)
// ── Inputs ──────────────────────────────────────────────────────────────────
bbLen = input.int(20, "BB Length", minval=1)
bbMult = input.float(2.0, "Multiplier", minval=0.1, step=0.1)
src = input.source(close, "Source")
// ── Calculation ─────────────────────────────────────────────────────────────
[mid, upper, lower] = ta.bb(src, bbLen, bbMult)
bandwidth = (upper - lower) / mid * 100
// ── Plots ───────────────────────────────────────────────────────────────────
pUpper = plot(upper, "Upper Band", color=color.new(#8b5cf6, 20), linewidth=1)
pLower = plot(lower, "Lower Band", color=color.new(#8b5cf6, 20), linewidth=1)
pMid = plot(mid, "Middle SMA", color=color.new(#94a3b8, 40), linewidth=1)
fill(pUpper, pLower, color.new(#8b5cf6, 92))
// ── Squeeze Detection ────────────────────────────────────────────────────────
bwLow = ta.lowest(bandwidth, 125) // 125-bar low of bandwidth
squeeze = bandwidth <= bwLow * 1.05 // within 5% of 125-bar low
bgcolor(squeeze ? color.new(#fbbf24, 90) : na, title="Squeeze Alert")
// ── Band Touch Signals ───────────────────────────────────────────────────────
touchUpper = close >= upper
touchLower = close <= lower
plotshape(touchUpper, "Upper Touch", shape.circle, location.abovebar, #ef4444, size=size.tiny)
plotshape(touchLower, "Lower Touch", shape.circle, location.belowbar, #22c55e, size=size.tiny)
alertcondition(squeeze, "BB Squeeze", "Bollinger Bands in squeeze — breakout imminent")
alertcondition(touchUpper, "Upper Band Touch","Price closed at or above upper Bollinger Band")
alertcondition(touchLower, "Lower Band Touch","Price closed at or below lower Bollinger Band")