ta.bb()
Bollinger Bands
Bollinger Bands. A Bollinger Band is a technical analysis tool defined by a set of lines plotted two standard deviations (positively and negatively) away from a simple moving average (SMA) of the security's price.
Syntax
ta.bb(series, length, mult) → [series float, series float, series float]Arguments
| Parameter | Type | Description |
|---|---|---|
| series | series int/float | Source series (typically price). |
| length | series int | Length of the moving average and standard deviation window. |
| mult | simple int/float | Standard deviation factor. |
Returns
Bollinger Bands.
Remarks
na values in the source series are ignored; the function calculates on the length quantity of non-na values.
Code Examples
//@version=6
indicator("ta.bb")
[middle, upper, lower] = ta.bb(close, 5, 4)
plot(middle, color=color.yellow)
plot(upper, color=color.yellow)
plot(lower, color=color.yellow)
// the same on pine
f_bb(src, length, mult) =>
float basis = ta.sma(src, length)
float dev = mult * ta.stdev(src, length)
[basis, basis + dev, basis - dev]
[pineMiddle, pineUpper, pineLower] = f_bb(close, 5, 4)
plot(pineMiddle)
plot(pineUpper)
plot(pineLower)Trading Applications
Identify overbought/oversold conditions when price touches bands
Detect volatility squeezes for breakout trading
Use band width for volatility measurement
Combine with RSI for confluence signals
Frequently Asked Questions
Generate ta.bb() Code with AI
Skip the manual coding. Use Pineify's AI Coding Agent to generate Pine Script code using ta.bb() and other built-in functions instantly.
Related Pine Script Functions
ta.bbw() - Bollinger Bands Width
Learn how to use ta.bbw() in Pine Script. Syntax, parameters, code examples for measuring Bollinger Band squeeze and width.
ta.kc() - Keltner Channels
Learn how to use ta.kc() in Pine Script. Syntax, parameters, code examples for Keltner Channel volatility bands.
ta.stdev() - Standard Deviation
Learn how to use ta.stdev() in Pine Script. Syntax, parameters, code examples for statistical standard deviation calculation.
ta.sma() - Simple Moving Average
Learn how to use ta.sma() in Pine Script. Syntax, parameters, code examples, and trading applications for the Simple Moving Average function.
ta.atr() - Average True Range
Learn how to use ta.atr() in Pine Script. Syntax, parameters, code examples for the Average True Range volatility indicator.