MovAvgExponential

Description

The Exponential Moving Average (EMA) is a type of moving average that assigns greater weight to the most recent price data. Unlike the simple moving average where all data points have the same weight, the EMA's weighting factors to price data decrease exponentially. 

The recursive representation of the EMA formula is the following:

EMA1 = price1;

EMA2 = α*price2 + (1 - α)*EMA1;

EMA3 = α*price3 + (1 - α)*EMA2;

EMAN = α*priceN + (1 - α)*EMAN-1;

where:

  • N is the bar number;
  • α is a smoothing coefficient equal to 2/(length + 1).

Calculation of an N-period EMA will normally include more than N bars worth of data; in fact, these bars will normally be assigned about 86% of weight.

The main plot of the exponential moving average can also be accompanied with breakout signals: crossovers of the price plot with the average. Bullish breakouts are indicated every time the price crosses above the average. When the price falls below the average, a bearish breakout is recognized. By default, breakout signals are disabled; to enable them, set the show breakout signals parameter value to yes.

Input Parameters

Parameter Description
price

The price with which the EMA is to be calculated.

length The number of bars which affect the EMA most significantly.
displace The displacement of the EMA study, in bars. Positive values signify backward displacement.
show breakout signals Controls visibility of breakout signals.

Plots

Plot Description
AvgExp The Exponential Moving Average (EMA) plot.
UpSignal If enabled, displays an up arrow every time the price crosses above the exponential moving average.
DownSignal If enabled, displays an up arrow every time the price crosses above the simple moving average.

Example*

*For illustrative purposes only. Not a recommendation of a specific security or investment strategy.