• Overview
  • Reviews
  • Comments
  • What's new

Multi Period EMA

Multi Period EMA

A trend indicator based on the exponential moving average.

Keeping track of multiple EMA is a more effective way of detecting possible trend development.

This indicator allows for the setting of as many as 6 different EMA periods.  Unused period parameters

can be set to zero to exclude the particular EMA from being displayed on the chart.


Features

  • Up to 6 EMA displayed on chart.
  • Option to select high EMA and Low EMA in order to detect crossovers
  • Alert in event that change in slope of the high EMA in the direction of the low EMA is detected.


Description

The moving average periods are set through the MA_PERIOD inputs.  The periods are to be set in ascending order,

for example MA_PERIOD_1 = 10, MA_PERIOD_2 = 25, MA_PERIOD_3 = 40 and so on.


The parameter "input int price_to_ema" is used to indicate which price scheme to use in calculating the EMA.  The 

prescription for the values of "input int price_to_ema" are itemized below:

  • 0  ---> Apply EMA to close prices.
  • 1 ----> Apply EMA to open prices.
  • 2  ---> Apply EMA to the maximum price for the period.
  • 3  ---> Apply EMA to the minimum price for the period.
  • 4  ---> Apply EMA to the median price(high+low)/2 for the period.
  • 5  ---> Apply EMA to the typical price(high+low+close)/3 for the period.
  • 6  ---> Apply EMA to the weighted close price(high+low +close+close)/4 for the period.

This indicator also features the capability of specifying EMA of different periods such that when the lower period

EMA crosses the higher period EMA, an alert is given along with the direction of the cross.  The parameters that control this 

feature are "crossover_periodindex_low" and "crossover_periodindex_high".


The slope as well as the change in slope is computed. The time interval

crossover_periodindex_low is used to compute the best fitting line over the EMA of crossover_periodindex_high and the

change in the slope of this line over the history is computed.  This will give an indication of when the higher period EMA

start to turn towards the lower period EMA.  Additionally an alert is given

whenever this condition is met.


Parameters

          MA_PERIOD_1 = Period for the first moving average.

          MA_PERIOD_2 = Period for the Second moving average.

          MA_PERIOD_3 = Period for the Third moving average.

          MA_PERIOD_4 = Period for the Fourth moving average.

          MA_PERIOD_5 = Period for the Fifth moving average.

          MA_PERIOD_6 = Period for the Sixth moving average.

          input int price_to_ema = Between 1 and 6.  Used to determine which price scheme to use in computing EMA.

          crossover_periodindex_low = The index of the EMA to use for the lower EMA, for example, if MA_PERIOD_2  is to

                                                       be used for the lower EMA, then this parameter should be set to 2. 

          crossover_periodindex_high = The index of the EMA to use for the higher EMA, for example, if MA_PERIOD_5  is to

                                                       be used for the higher EMA, then this parameter should be set to 5. 






































































































No reviews
Version 3.0 2018.10.11
Debug the code a bit more.
Version 2.0 2018.10.10
Fixed minor error in the alerting method.