talib.BBANDS
Calculates the Bollinger Bands and returns the upper band, middle band and lower band.
talib.BBANDS(inReal)
talib.BBANDS(inReal, optInTimePeriod)
talib.BBANDS(inReal, optInTimePeriod, optInNbDevUp)
talib.BBANDS(inReal, optInTimePeriod, optInNbDevUp, optInNbDevDn)
talib.BBANDS(inReal, optInTimePeriod, optInNbDevUp, optInNbDevDn, optInMAType)Examples
Compute the Bollinger Bands from the latest K-lines.
javascript
function main() {
var records = exchange.GetRecords()
if (!records) return
var ret = talib.BBANDS(records)
// Output: [upper band array, middle band array, lower band array]
Log(ret)
}
python
import talib
def main():
records = exchange.GetRecords()
if not records:
return
ret = talib.BBANDS(records.Close)
# Output: (upper band array, middle band array, lower band array)
Log(ret)Returns
| Type | Description |
array | Two-dimensional array: [upper band array, middle band array, lower band array] (a tuple in the same order in Python). |
Arguments
| Name | Type | Required | Description |
inReal |
| Yes | K-line array (close prices are used) or numeric array; in Python, pass a numeric array such as |
optInTimePeriod | number | No | Calculation period. Default |
optInNbDevUp | number | No | Standard deviation multiplier for the upper band. Default |
optInNbDevDn | number | No | Standard deviation multiplier for the lower band. Default |
optInMAType | number | No | Moving average type; see the MAType table on the |
See Also
Remarks
TA-Lib equivalent: BBANDS(Records[Close],Time Period = 5,Deviations up = 2,Deviations down = 2,MA Type = 0) = [Array(outRealUpperBand),Array(outRealMiddleBand),Array(outRealLowerBand)].