NxEMA - exponentially-weighted moving (rolling/running) average

Returns the exponentially-weighted moving (rolling/running) average using the previous N data points.

Syntax

NxEMA(X, Order, N, Variant, Return)
X
is the univariate time series data (a one-dimensional array of cells (e.g. rows or columns)).
Order
is the time order in the data series (i.e. the first data point's corresponding date (earliest date=1 (default), latest date=0))
Order Description
1 ascending (the first data point corresponds to the earliest date) (default)
0 descending (the first data point corresponds to the latest date)
N
is the smoothing period expressed in number of data points (e.g. days).
Variant
is the variant/type of the exponentially-weighted moving average (i.e. 0= Simple (default), 1= Double, 2=Triple, 3=Zero-lagged). If missing or omitted, a simple exponentially-weighted moving average (i.e. Variant = 0) is assumed.
Value Description
0 Plain/simple exponentially-weighted moving average (EMA)
1 Double exponentially-weighted moving average (D-EMA)
2 Triple exponentially-weighted moving average (T-EMA)
3 Zero-lagged exponential-weighted moving average (ZLEMA)
Return
is return type of the function: 0 = last/most recent value (default), 1 = filtered time series (array.
Value Description
0 Return smoothed value of the Last/most-recent observation
1 Return the whole smoothed time series (array)

Remarks

  1. The time series is homogeneous or equally spaced.
  2. The time series may include missing values (e.g. #N/A) at either end.
  3. The formula of exponential moving average definition is expressed in technical analysis terms as follow: $$ \textrm{EMA}_t = \textrm{EMA}_{t-1} + \alpha \times ( x_t - \textrm{EMA}_{t-1}) $$ Where:
    • $\textrm{EMA}_t$ is the exponential moving average at time t.
    • $x_t$ is the value of the time series at time t.
    • $\alpha$ is the smoothing factor (between 0 and 1) represents the degree of weighting decrease. For EMA, the $\alpha$ is exp[ressed as follow: $$ \alpha = \frac{2}{N+2} $$ Where:
      • $N$ is the smoothing period expressed in number of data points (e.g. days)
    • The exponential moving average with a smooth period of N data points is expressed by N-period EMA.
  4. The double exponential moving average (aka. DEMA or D-EMA) is expressed as follow: $$\textrm{D-EMA}_t = 2 \times \textrm{EMA}_t -\textrm{EMA}(\textrm{EMA})_t$$ Where:
    • $\textrm{EMA}(\textrm{EMA})$ is the exponential moving average of the exponential moving average.
  5. The triple exponential moving average (aka. TEMA or T-EMA) is expressed as follow: $$\textrm{T-EMA} = 3\times \textrm{EMA}_t -3\times\textrm{EMA}(\textrm{EMA})_t + \textrm{EMA}(\textrm{EMA}(\textrm{EMA}))_t$$
  6. For zero-lag exponential moving average (ZLEMA),  $$ k = (N-1)/2 $$ $$ Y_t = x_t + (x_t - x_{t-k})$$ $$ \textrm{ZLEMA}_t = \textrm{EMA}_t^N (Y_t) $$ Where:
    • $k$ is the number of periods used to remove cumulative effect of moving average.
    • $Y_t$ is the de-lagged data. Data is de-lagged by removing the data from k-periods ago, thus removing the cumulative effect of the moving average.
  7. In the case the smoothing period ($N$) is an even number, then $k$ and $Y_t$ are calculated as follow: $$ k = \frac{N}{2}$$ $$ Y_t = 2x_t - \left(\frac{x_{t-k}+x_{t-k-1}}{2}\right)$$
  8. The ZLEMA technical indicator was created by John Ehlers and Ric Way.
  9. The NxEMA function is available starting with version 1.66 PARSON.

 

Files Examples

References

Comments

Please sign in to leave a comment.

Was this article helpful?
0 out of 0 found this helpful