IIndicatorsAccessor.BollingerBands
method · IIndicatorsAccessor · cAlgo.API.Internals
DesktopCLICloud
The Bollinger Bands indicator shows volatility.
Definition
BollingerBands BollingerBands(DataSeries source, int periods, double standardDeviations, MovingAverageType maType)
api.Indicators.BollingerBands(source: DataSeries, periods: int, standardDeviations: float, maType: MovingAverageType) -> BollingerBands
Parameters
| Name | C# type | Python type | Description |
|---|---|---|---|
source | DataSeries | DataSeries | The source data used for calculation. |
periods | int | int | The value of the periods used for calculation. |
standardDeviations | double | float | The value of the standard deviations used for calculation. |
maType | MovingAverageType | MovingAverageType | Type of the Moving Average. |
Returns BollingerBands — Bollinger Bands indicator instance
Examples
var bollingerBands = Indicators.BollingerBands(Bars.ClosePrices, 20, 2, MovingAverageType.Simple);
if (Symbol.Bid > bollingerBands.Top.LastValue)
Print("Bid is above the top band {0}", bollingerBands.Top.LastValue);
else if (Symbol.Bid < bollingerBands.Bottom.LastValue)
Print("Bid is below the bottom band {0}", bollingerBands.Bottom.LastValue);
bollingerBands = api.Indicators.BollingerBands(api.Bars.ClosePrices, 20, 2, MovingAverageType.Simple)
if api.Symbol.Bid > bollingerBands.Top.LastValue:
api.Print(f"Bid is above the top band {bollingerBands.Top.LastValue}")
elif api.Symbol.Bid < bollingerBands.Bottom.LastValue:
api.Print(f"Bid is below the bottom band {bollingerBands.Bottom.LastValue}")