EMA - Exponential Moving Average

Description

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

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

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

Return value

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

inSeries Input data series for the indicator

period Number of bars included in the calculations

Visualization

Calculation

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

Example

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

Last updated