Returns the Bollinger Bands as three series: the moving-average basis and the bands mult standard deviations above and below it.
ta.bb returns [basis, upper, lower]. The basis is ta.sma(series, length), and each band sits mult times the window's standard deviation away. The deviation is the population form, dividing by length.
The first values appear on bar number length. Capture the tuple with three names: [mid, upper, lower] = ta.bb(close, 20, 2).
Syntax
ta.bb(series: series int/float, length: series int, mult: simple int/float) -> [series float, series float, series float]Arguments
| Name | Type | Default | Description |
|---|---|---|---|
| series | series int/ | required | Series the bands are built on, usually close. |
| length | series int | required | Window length for the average and the deviation. A whole number of 1 or more. |
| mult | simple int/ | required | Number of standard deviations between the basis and each band. |
Returns
[series float, series float, series float]: the basis, the upper band and the lower band.
Remarks
- The bands widen in volatile stretches and narrow in quiet ones;
ta.bbwtracks that width.
Example
//@version=6
indicator("Bollinger Bands", overlay = true)
[mid, upper, lower] = ta.bb(close, 20, 2)
plot(mid, "Basis", color = color.orange)
p1 = plot(upper, "Upper", color = color.blue)
p2 = plot(lower, "Lower", color = color.blue)
fill(p1, p2, color = color.new(color.blue, 90), title = "Band area")See also
Runs on Sidechair