The exponential moving average of the price data source over a period of time.


The exponential moving average is similar to the simple moving average, but applies more weight to more recent data. The weighting for each older price data decreases exponentially. Therefore the exponential moving average reacts faster to latest price changes than the simple moving average.


public interface ExponentialMovingAverage : MovingAverage, IIndicator



Example 1

public class EmaExample : Indicator
    private ExponentialMovingAverage _emaFast;
    private ExponentialMovingAverage _emaSlow;
    [Parameter("Data Source")]
    public DataSeries Price { get; set; }
    [Parameter("Slow Periods", DefaultValue = 10)]
    public int SlowPeriods { get; set; }
    [Parameter("Fast Periods", DefaultValue = 5)]
    public int FastPeriods { get; set; }
    protected override void Initialize()
        // initialize new instances of ExponentialMovingAverage Indicator class 
        _emaFast = Indicators.ExponentialMovingAverage(Price, FastPeriods);
        // _emaSlow is the exponential moving average of the emaFast 
        _emaSlow = Indicators.ExponentialMovingAverage(_emaFast.Result, SlowPeriods);
    public override void Calculate(int index)
        // If the index is less than SlowPeriods don't calculate
        if(index <= SlowPeriods)
            // Print the index at which the fast ema crossed the slow ema
            Print("Fast EMA Has Crossed Above at index = {0}", index);