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

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

# IIndicatorsAccessor.ExponentialMovingAverage

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

## ExponentialMovingAverage(DataSeries source, int periods)

The Exponential Moving Average smoothes the price data producing a trend indicator.

Environments: Desktop supported · CLI supported · Cloud supported.

C#:

```csharp
ExponentialMovingAverage ExponentialMovingAverage(DataSeries source, int periods)
```

Python:

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

### Parameters

- `source` (`DataSeries`, Python `DataSeries`): The source data used for the EMA calculation.
- `periods` (`int`, Python `int`): The periods used in the calculation.

### Returns

`ExponentialMovingAverage` — Exponential Moving Average indicator instance

### Examples

C#:

```csharp
var ema = Indicators.ExponentialMovingAverage(Bars.ClosePrices, 20);
if (Bars.ClosePrices.Last(1) > ema.Result.Last(1))
    Print("Last bar closed above EMA(20): {0}", ema.Result.Last(1));
```

Python:

```python
ema = api.Indicators.ExponentialMovingAverage(api.Bars.ClosePrices, 20)
if api.Bars.ClosePrices.Last(1) > ema.Result.Last(1):
    api.Print(f"Last bar closed above EMA(20): {ema.Result.Last(1)}")
```

