---
id: "M:cAlgo.API.Internals.IIndicatorsAccessor.BollingerBands(cAlgo.API.DataSeries,System.Int32,System.Double,cAlgo.API.MovingAverageType)"
kind: "method"
type: "T:cAlgo.API.Internals.IIndicatorsAccessor"
url: "https://help.ctrader.com/ctrader-algo/references/Indicators/IIndicatorsAccessor/BollingerBands/"
---

> Documentation index for agents: https://help.ctrader.com/ctrader-algo/llms.txt · machine index: https://help.ctrader.com/ctrader-algo/api.json

# IIndicatorsAccessor.BollingerBands

Member of [IIndicatorsAccessor](https://help.ctrader.com/ctrader-algo/references/Indicators/IIndicatorsAccessor/index.md).

## BollingerBands(DataSeries source, int periods, double standardDeviations, MovingAverageType maType)

The Bollinger Bands indicator shows volatility.

Environments: Desktop supported · CLI supported · Cloud supported.

C#:

```csharp
BollingerBands BollingerBands(DataSeries source, int periods, double standardDeviations, MovingAverageType maType)
```

Python:

```python
api.Indicators.BollingerBands(source: DataSeries, periods: int, standardDeviations: float, maType: MovingAverageType) -> BollingerBands
```

### Parameters

- `source` (`DataSeries`, Python `DataSeries`): The source data used for calculation.
- `periods` (`int`, Python `int`): The value of the periods used for calculation.
- `standardDeviations` (`double`, Python `float`): The value of the standard deviations used for calculation.
- `maType` (`MovingAverageType`, Python `MovingAverageType`): Type of the Moving Average.

### Returns

`BollingerBands` — Bollinger Bands indicator instance

### Examples

C#:

```csharp
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);
```

Python:

```python
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}")
```

