Bollinger Band Width (bbw)
[[bbw]] measures the distance between the Bollinger Bands around their middle average. You can use it to identify volatility contraction or expansion phases, filter market conditions, or compare multiple parameter setups in grid search.
BBW does not tell you price direction. A high value means the bands are wider and recent volatility is stronger. A lower value means the bands are tighter and the market is quieter.
Block declaration
A strategy can contain multiple [[bbw]] blocks. Each block produces one numeric series representing the BBW value.
Examples
Minimal setup
This block computes BBW from close using the default settings: a 20-period window and a multiplier of 2.0.
[[bbw]]
id = "bbw"Custom fixed setup
This block uses custom length and multiplier values.
[[bbw]]
id = "bbw"
length = 24
multiplier = 2.4Search for the optimal period and multiplier
This block explores ranges of values for length and multiplier to identify the best-performing configuration.
[[bbw]]
id = "bbw"
length.start = 10
length.stop = 30
multiplier.start = 1.0
multiplier.stop = 3.0
multiplier.step = 0.2Dedicated timeframe
This BBW block uses a dedicated daily timeframe. The price series needed to compute the bands are taken from this timeframe (timeframe = "D"), rather than from the primary timeframe defined in [backtest]. See the Exchanges, Symbols and Timeframes page for alignment rules between this timeframe and the primary timeframe.
[[bbw]]
id = "bbw"
timeframe = "D"Specific symbol
This block reads its candles from the specific symbol BINANCE:ETHUSDT. See the Exchanges, Symbols and Timeframes page for alignment with the main symbol.
[[bbw]]
id = "bbw"
symbol = "BINANCE:ETHUSDT"Parameters
| Parameter | Description |
|---|---|
idString Required | Unique series name. |
sourceString or Array Optional | Input series used for the calculation. Accepted forms: source = "hl2" or source = ["close", "hl2"].Each value can be either a standard price source ( open, close, high, low, hl2, hlc3, ohlc4, hlcc4, volume) or the id of another indicator.Default value: "close" |
lengthInteger or Range Optional | SMA and standard deviation window; must be ≥ 1. Default value: 20.Usage: • Fixed: length = value• Grid search: – length.start = min_value– length.stop = max_value– length.step = value (optional, default 1) |
multiplierDecimal or Range Optional | Standard deviation factor. Default value: 2.0.Usage: • Fixed: multiplier = value• Grid search: – multiplier.start = min_value– multiplier.stop = max_value– multiplier.step = value (optional, default 1) |
symbolString or Array Optional | Market symbol(s) used when source contains standard prices (open, close, high, low, hl2, hlc3, ohlc4, hlcc4, volume).If source mixes standard prices and indicator ids, symbol is applied only to combinations based on standard prices.If source contains only indicator ids, symbol is ignored.For symbol format and alignment rules, see Exchanges, Symbols and Timeframes. |
timeframeString or Array Optional | Timeframe on which this indicator is computed. If timeframe is omitted, the computation uses the grid’s main timeframe defined in [backtest].For accepted formats and timeframe alignment rules, see Exchanges, Symbols and Timeframes. |
Available variables
The BBW block exposes one numeric series and its parameters, along with the input source, symbol, and timeframe.
Assume the block is configured as:
[[bbw]]
id = "bbw"Then:
| Variable | Description |
|---|---|
bbw or bbw[0]Decimal | Current BBW value. |
bbw[n]Decimal | BBW value from n candles ago. |
bbw.lengthDecimal | Length in use. |
bbw.multiplierDecimal | Multiplier in use. |
bbw.sourceString | Input series name. |
bbw.symbolString | Symbol used. |
bbw.timeframeString | Timeframe used. |