BB
Bollinger Bands
A volatility envelope built from a moving average and ±2 standard deviations, expanding and contracting as volatility changes.
Bollinger Bands plot a 20-period SMA with upper and lower bands at ±2 standard deviations of price. The bands widen during volatile moves and squeeze during calm periods. Roughly 95% of bars close inside the bands. Default settings: length 20, multiplier 2.
Bollinger Bands plot a 20-period simple moving average as the middle band, with upper and lower bands at ±2 standard deviations of price. The bands widen during volatile moves and squeeze during calm periods — their width itself becomes a volatility signal.
Prices spend roughly 95% of the time inside the bands (by the properties of a normal distribution), so band touches aren't trade signals on their own — they're context. The most reliable setups combine band behaviour with confirmation: squeeze breakouts, lower-band touches plus bullish candles, or middle-band reclaims.
How do I read BB?
- Price near the upper band = stretched upside. Statistically about 2.5% of bars close above; not a sell signal alone, but elevated mean-reversion risk.
- Price near the lower band = stretched downside. Same statistical framing applies in reverse.
- The middle band (20 SMA) acts as dynamic support in uptrends, resistance in downtrends — a useful regime gauge.
- Squeeze: when band-width contracts to a multi-bar low, volatility is coiled. Often precedes an expansion move in either direction.
- Walking the band: in strong trends, price can ride the upper or lower band for many bars without reverting. Treat sustained band-touching as a strength signal, not weakness.
- Band-width itself is a volatility regime indicator — useful even without trading the bands directly.
How is BB calculated?
Bollinger Bands wrap a moving average with statistical envelopes that scale to the asset's recent volatility.
- 1.Compute a 20-bar simple moving average (SMA) of close — the middle band.
- 2.Compute the 20-bar standard deviation of close.
- 3.Upper band = middle band + (2 × standard deviation).
- 4.Lower band = middle band − (2 × standard deviation).
- 5.Band width (upper − lower) reflects current volatility; widening = expansion, contracting = squeeze.
What are the default BB settings?
| Parameter | Default | When to adjust |
|---|---|---|
| Length | 20 | John Bollinger's original setting. Reduce to 10 for very short-term sensitivity; raise to 50 for weekly/macro context. |
| Multiplier (std dev) | 2 | Captures roughly 95% of price action under a normal distribution. Drop to 1.5 for tighter bands (more touches); raise to 2.5 for fewer, more meaningful touches. |
| Source | Close | Most common. Some traders use HLC3 to smooth wick noise on volatile instruments. |
| MA type | SMA | Bollinger's original used a simple moving average. Some modern variants use EMA for responsiveness — produces different bands. |
How do I plot BB in Pine Script?
//@version=5
indicator("Bollinger Bands Example", overlay=true)
length = input.int(20, title="Length", minval=2)
mult = input.float(2.0, title="Multiplier", minval=0.1, step=0.1)
src = input.source(close, title="Source")
[middle, upper, lower] = ta.bb(src, length, mult)
p_upper = plot(upper, title="Upper", color=color.blue)
p_lower = plot(lower, title="Lower", color=color.blue)
plot(middle, title="Middle (SMA 20)", color=color.orange)
fill(p_upper, p_lower, color=color.new(color.blue, 95))Pine's ta.bb() returns the middle band, upper, and lower in one call — saves you from computing the standard deviation manually. The fill between upper and lower bands gives you the visible envelope; many traders also like to display band-width separately as its own oscillator. Using overlay=true plots the bands directly on price.
Continue exploring
Related indicators
ATR
Average True Range
A non-directional measure of volatility: the average size of the bar-to-bar true range over a chosen lookback.
View ATRMomentumRSI
Relative Strength Index
A momentum oscillator that measures the speed and magnitude of recent price changes on a bounded 0–100 scale.
View RSITrendMACD
Moving Average Convergence Divergence
A trend-momentum indicator built from the difference between two EMAs, plus a signal line and histogram that visualise momentum shifts.
View MACDAbout this reference
This page is an educational reference explaining what BB is, how it is calculated, its default settings, and how to plot it in Pine Script. It is compiled from established trading literature and public technical documentation. Last review: .
Educational content. Not financial advice.