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

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

# IIndicatorsAccessor.HistoricalVolatility

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

## HistoricalVolatility(DataSeries source, int periods, int barHistory)

The Historical Volatility indicator is derived from time series of past market prices.

Environments: Desktop supported · CLI supported · Cloud supported.

C#:

```csharp
HistoricalVolatility HistoricalVolatility(DataSeries source, int periods, int barHistory)
```

Python:

```python
api.Indicators.HistoricalVolatility(source: DataSeries, periods: int, barHistory: int) -> HistoricalVolatility
```

### Parameters

- `source` (`DataSeries`, Python `DataSeries`): The source data used for calculation.
- `periods` (`int`, Python `int`): The value of the periods used for calculation.
- `barHistory` (`int`, Python `int`): The value of the bar history used for calculation.

### Returns

`HistoricalVolatility` — Historical Volatility indicator instance

### Examples

C#:

```csharp
var historicalVolatility = Indicators.HistoricalVolatility(Bars.ClosePrices, 20, 252);
Print("Historical volatility: {0}", historicalVolatility.Result.LastValue);
```

Python:

```python
historicalVolatility = api.Indicators.HistoricalVolatility(api.Bars.ClosePrices, 20, 252)
api.Print(f"Historical volatility: {historicalVolatility.Result.LastValue}")
```

