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

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

# IIndicatorsAccessor.AverageTrueRange

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

## AverageTrueRange(int periods, MovingAverageType maType)

Average true range. An indicator providing the degree of price volatility.

Environments: Desktop supported · CLI supported · Cloud supported.

C#:

```csharp
AverageTrueRange AverageTrueRange(int periods, MovingAverageType maType)
```

Python:

```python
api.Indicators.AverageTrueRange(periods: int, maType: MovingAverageType) -> AverageTrueRange
```

### Parameters

- `periods` (`int`, Python `int`): Period of moving average to use for Average True Range caluclation.
- `maType` (`MovingAverageType`, Python `MovingAverageType`): Type of moving average to use for Average True Range caluclation.

### Returns

`AverageTrueRange` — Average True Range indicator instance

### Examples

C#:

```csharp
var atr = Indicators.AverageTrueRange(14, MovingAverageType.Exponential);
var stopLossPips = 2 * atr.Result.LastValue / Symbol.PipSize;
Print("ATR(14): {0}, stop loss at 2 x ATR: {1} pips", atr.Result.LastValue, stopLossPips);
```

Python:

```python
atr = api.Indicators.AverageTrueRange(14, MovingAverageType.Exponential)
stopLossPips = 2 * atr.Result.LastValue / api.Symbol.PipSize
api.Print(f"ATR(14): {atr.Result.LastValue}, stop loss at 2 x ATR: {stopLossPips} pips")
```

## AverageTrueRange(Bars bars, int periods, MovingAverageType maType)

Average true range. An indicator providing the degree of price volatility.

Environments: Desktop supported · CLI supported · Cloud supported.

C#:

```csharp
AverageTrueRange AverageTrueRange(Bars bars, int periods, MovingAverageType maType)
```

Python:

```python
api.Indicators.AverageTrueRange(bars: Bars, periods: int, maType: MovingAverageType) -> AverageTrueRange
```

### Parameters

- `bars` (`Bars`, Python `Bars`): The Bars that will be used by indicator, you can pass another timeframe/symbol bars
- `periods` (`int`, Python `int`): Period of moving average to use for Average True Range caluclation.
- `maType` (`MovingAverageType`, Python `MovingAverageType`): Type of moving average to use for Average True Range caluclation.

### Returns

`AverageTrueRange` — Average True Range indicator instance

### Examples

C#:

```csharp
var dailyBars = MarketData.GetBars(TimeFrame.Daily);
var dailyAtr = Indicators.AverageTrueRange(dailyBars, 14, MovingAverageType.Exponential);
Print("Daily ATR(14): {0} pips", dailyAtr.Result.LastValue / Symbol.PipSize);
```

Python:

```python
dailyBars = api.MarketData.GetBars(TimeFrame.Daily)
dailyAtr = api.Indicators.AverageTrueRange(dailyBars, 14, MovingAverageType.Exponential)
api.Print(f"Daily ATR(14): {dailyAtr.Result.LastValue / api.Symbol.PipSize} pips")
```

