Bollinger Bands
Bollinger Bands are a moving average with two bands a set number of standard deviations away, showing the market's volatility right on the chart.
What it is
John Bollinger built the tool in the 1980s. The middle band is a simple moving average, and the upper and lower bands sit a multiple of the price's standard deviation away from it. As the market gets more volatile the bands widen; as it calms down they narrow.
How it's calculated
- Middle band = 20-period simple moving average
- Upper band = middle + 2 × 20-period standard deviation
- Lower band = middle − 2 × 20-period standard deviation
How traders read it
- A squeeze, when the bands narrow, means volatility has dropped and often comes before a large move.
- Walking the band: in a strong trend price can ride the upper or lower band for a long time; a touch alone is not a reversal signal.
- In a range, moves back from the bands toward the middle are more common.
- The middle band often acts as dynamic support or resistance.
Settings
The standard settings are 20 periods and a multiplier of 2. A multiplier of 2.5 or 3 gives wider bands that are touched less often.
Where it misleads
- Selling every touch of the upper band in an uptrend keeps you against the trend.
- The bands don't tell you which way price will break out of a squeeze, only that a move is likely.
Its Pine Script on Vlevel
This is the script the chart runs. In the chart's indicators window you can open it, change it and save your own copy.
Bollinger Bands · Pine Script v6
//@version=6
indicator("Bollinger Bands", shorttitle = "BB", overlay = true)
length = input.int(20, "Length", minval = 1)
kind = input.string("SMA", "Basis MA Type", options = ["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"])
src = input.source(close, "Source")
mult = input.float(2.0, "StdDev", minval = 0.001, maxval = 50)
offset = input.int(0, "Offset", minval = -500, maxval = 500)
ma(float src, int len, string kind) =>
switch kind
"SMA" => ta.sma(src, len)
"EMA" => ta.ema(src, len)
"SMMA (RMA)" => ta.rma(src, len)
"WMA" => ta.wma(src, len)
"VWMA" => ta.vwma(src, len)
=> ta.sma(src, len)
basis = ma(src, length, kind)
dev = mult * ta.stdev(src, length)
plot(basis, "Basis", color = color.new(#2ee6a6, 65), offset = offset)
p1 = plot(basis + dev, "Upper", color = color.new(#2ee6a6, 40), offset = offset)
p2 = plot(basis - dev, "Lower", color = color.new(#2ee6a6, 40), offset = offset)
fill(p1, p2, color = color.new(#2ee6a6, 95))Indicators describe past prices; none predicts the future. For education, not investment advice.