Indicators/probuilder · probacktest · proorder · proscreener

BollingerBandWidth

BollingerBandWidth in ProBuilder returns the distance between the upper and lower Bollinger Bands, a direct volatility gauge. Syntax, formula, examples.

Syntax

probuilder
BollingerBandWidth[N](price)

Parameters

NameTypeDefaultDescription
Ninteger20Period used for the moving average and standard deviation underlying the bands. 20 is the standard Bollinger setting.
priceprice sourceclosePrice series the bands are computed on, typically close.

Formula

code
Upper = Average[N](price) + 2 * STD[N](price)
Lower = Average[N](price) - 2 * STD[N](price)
BollingerBandWidth = Upper - Lower = 4 * STD[N](price)

Because the upper and lower bands sit symmetrically two standard deviations from the moving average, the width reduces to four times the N-period standard deviation of price.

How it works

Bollinger Bands expand when price disperses and contract when price clusters around its mean. BollingerBandWidth extracts that expansion and contraction into a single line, removing the need to eyeball the distance between two plotted bands.

The value is expressed in price units. It rises during volatile phases, whether trending or crashing, and falls during consolidations. Prolonged contraction, often called a squeeze, indicates a market coiling into a tight range. Squeezes have no directional content, but they identify conditions under which the next directional move tends to travel further, which is why breakout systems often gate their entries on band width.

Since standard deviation scales with price level, raw width readings are only comparable to the same instrument's own history. Dividing by the middle band or by price converts the reading into a relative figure suitable for screening across markets.

Examples

Example 1, Fast and slow band width (Indicator)

probuilder
// 20-period width against a slower 30-period width for context
BBwidth = BollingerBandWidth[20](close)
BBwidthSlow = BollingerBandWidth[30](close)
RETURN BBwidth coloured(0,100,100), BBwidthSlow AS "more laggy BandWidth"

Plots two widths side by side. The 30-period version reacts more slowly, so the gap between the two lines highlights fresh volatility shifts.

Example 2, Squeeze screener (ProScreener)

probuilder
// Instruments whose band width sits at a 100-bar low
bw = BollingerBandWidth[20](close)
squeeze = bw <= Lowest[100](bw)
SCREENER[squeeze]((bw / close) * 100 AS "Width % of price")

Returns instruments in maximum compression relative to their own recent history, expressed as a percentage of price so results are comparable across markets.

Example 3, Breakout entry gated by expanding width (ProOrder)

probuilder
// Buy a channel breakout only when volatility is expanding from a squeeze
bw = BollingerBandWidth[20](close)
expanding = bw > bw[3]
wasTight = bw[3] < Average[50](bw)[3]

IF NOT LongOnMarket AND close CROSSES OVER BollingerUp[20](close) THEN
  IF expanding AND wasTight THEN
    BUY 1 CONTRACT AT MARKET
  ENDIF
ENDIF

IF LongOnMarket AND close CROSSES UNDER Average[20](close) THEN
  SELL AT MARKET
ENDIF

The band-width conditions require that the breakout emerges from compression and that volatility is actively expanding, filtering out band touches that happen inside established high-volatility phases.

Interpretation

ObservationReading
Width at multi-week lowsSqueeze. The market is compressed, expansion often follows. No directional bias.
Width rising sharplyVolatility expansion, usually accompanying a breakout or news move.
Width at extreme highsLate-stage volatility. Moves this stretched frequently pause or mean-revert.
Width declining after a spikeThe impulse is being digested, trend continuation becomes less explosive.

Band width identifies the volatility regime, not direction. It answers when a market is likely to move meaningfully, and other tools must answer which way.

Common errors and gotchas

  • Raw width is not comparable across instruments. The value is in price units and scales with price level. Screen or compare using width / close or width / Average[N](close) instead.
  • Treating a squeeze as a directional signal. Compression predicts expansion, not direction. Entering long purely because width is low buys a coin flip; a separate breakout or trend condition supplies the direction.
  • Confusing width with %B or band position. BollingerBandWidth measures the distance between bands. It says nothing about where price sits inside them. Position within the bands requires comparing price against BollingerUp and BollingerDown directly.
  • Short periods make the squeeze concept meaningless. With small N, width oscillates so quickly that squeezes appear constantly. The pattern's value comes from sustained compression on standard settings such as 20 periods.