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

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

# IIndicatorsAccessor.MovingAverage

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

## MovingAverage(DataSeries source, int periods, MovingAverageType maType)

Moving Average indicators are used to smooth data producing trend indicators.

Environments: Desktop supported · CLI supported · Cloud supported.

C#:

```csharp
MovingAverage MovingAverage(DataSeries source, int periods, MovingAverageType maType)
```

Python:

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

### Parameters

- `source` (`DataSeries`, Python `DataSeries`): The source data used for the MA calculation.
- `periods` (`int`, Python `int`): The periods used in the calculation.
- `maType` (`MovingAverageType`, Python `MovingAverageType`): Method of calculation of MA.

### Returns

`MovingAverage` — Moving Average indicator instance

### Examples

C#:

```csharp
var ma = Indicators.MovingAverage(Bars.ClosePrices, 50, MovingAverageType.Exponential);
Print("EMA(50) last value: {0}", ma.Result.LastValue);
```

Python:

```python
ma = api.Indicators.MovingAverage(api.Bars.ClosePrices, 50, MovingAverageType.Exponential)
api.Print(f"EMA(50) last value: {ma.Result.LastValue}")
```

