NAME

GT::Indicators::EMA - Exponential Moving Average


DESCRIPTION

An exponential moving average gives more importance to recent prices ...

Parameters

Period (default 20)

The first argument is the period used to calculate the average.

Other data input

The second argument is optional. It can be used to specify an other stream of input data for the average instead of the close prices. This is usually an indicator (detailed via {I:MyIndic <param>}).

Start data input

The third argument is optional. It can be used to specify the stream of input data to compute the starting point of the moving average. The default is computed by the SMA of the given period.

If a very long period is required, it may be advisable to set this to {I:PRICES CLOSE} (or whatever data stream is used as the input for the EMA) to avoid excessive history data being required just to compute the starting value. Using the first value of the input series does not result in a large error and requires no dependencies.

Calculation

alpha = 2 / ( N + 1 ) EMA[n] = EMA[n-1] + alpha * ( INPUT - EMA[n-1] )

In TA, the first value is often constructed as SMA(N).

Note: One criticism could be that the EMA is calculated starting from the designated period. But actually the EMA goes all the way back to the beginning of the available data. But in all tools I checked they start computation from the loaded data on.

Creation

 GT::Indicators::EMA->new()
 GT::Indicators::EMA->new([20])

If you need a 30 days EMA of the opening prices you can write one of those lines :

 GT::Indicators::EMA->new([30, "{I:Prices OPEN}"])

A 10 days EMA of the RSI could be created with :

 GT::Indicators::EMA->new([10, "{I:RSI}"])