# EMA - Exponential Moving Average

#### Description <a href="#description_61" id="description_61"></a>

Exponential moving averages work to reduce lag by weighting recent prices more heavily. The weighting given to the most recent price depends on the number of periods in the moving average. Calculating an exponential moving average involves three steps. 1. Calculate the simple moving average. An exponential moving average (EMA) must start somewhere, therefore a simple moving average is used as the previous period's EMA in the beginning calculation. 2. Calculate the weighting multiplier. 3. Calculate the EMA.

#### Interpretation <a href="#interpretation_31" id="interpretation_31"></a>

The EMA is used by many traders in the most varying of timeframes. It is especially meaningful within the 15, 60 and 240-minute charts. The EMA 200 line is also especially popular with traders.

If the price rises sharply and moves away quickly from the respective EMA line, it is possible to enter countertrend positions in order to profit from the potential return to the moving average. General interpretations of the moving averages also apply to the EMA.

#### Usage <a href="#usage_63" id="usage_63"></a>

```csharp
EMA(int period)
EMA(IDataSeries inSeries, int period)
EMA(int period)[int barsAgo]
EMA(IDataSeries inSeries, int period)[int barsAgo]
```

#### Return value <a href="#return-value_60" id="return-value_60"></a>

**double**

When using this method with an index (e.g. **EMA**(20)\[**int** barsAgo] ), the value of the indicator will be issued for the referenced bar.

#### Parameters <a href="#parameters_53" id="parameters_53"></a>

inSeries Input data series for the indicator

period Number of bars included in the calculations

#### Visualization <a href="#visualization_56" id="visualization_56"></a>

![EMA - Exponential Moving Average](https://agenatrader.github.io/AgenaIndicator-documentation/media/EMA.jpg)

#### Calculation <a href="#calculation_3" id="calculation_3"></a>

```csharp
Value.Set(ProcessingBarIndex == 0 ? InSeries[0] : InSeries[0] * (2.0 / (1 + Period)) + (1 - (2.0 / (1 + Period))) * Value[1]);
```

#### Example <a href="#example_59" id="example_59"></a>

```csharp
//Output the value for the EMA
Print("The current EMA value is " + EMA(20)[0]);
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://indicators.agenatrader.com/standard-indicators/moving-averages/ema-exponential-moving-average.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
