# Double Exponential Moving Average

The double exponential moving average (DEMA) was introduced by Patrick Mulloy in his "Smoothing Data with Faster Moving Averages" article in the February 1994, Technical Analysis of Stocks & Commodities magazine.

As Mulloy explains in his original article, "the DEMA is not just a double EMA with twice the lag time of a single EMA, but is a composite implementation of single and double EMAs producing another EMA with less lag than either of the original two."

It is designed to have reduced lag compared to more traditional moving averages.

Custom PCF Formula
 Of Price `2 * XAVGCx.z - XAVG(XAVGCx.z, x)` `x`=Period, `z`=Offset Generalized Version `2 * XAVG(w, x) - XAVG(XAVG(w, x), x)` `w`=Numeric, `x`=Period

Where `w` is any formula returning a numeric value.

Where `x` is the period and must be an integer.

Where `z` is the offset. An offset of 1 is 1 bar ago.

### Examples

A 20 period double exponential moving average of price for the current bar can be written as follows.

`2 * XAVGC20.0 - XAVG(XAVGC20.0, 20)`

But you can leave off the offset since it is zero for the current bar.

`2 * XAVGC20 - XAVG(XAVGC20, 20)`

You would need to add the offset back to get the value for the previous bar.

`2 * XAVGC20.1 - XAVG(XAVGC20.1, 20)`

A 20 period double exponential moving average of the current 14 period ADX can be written as follows.

`2 * XAVG(ADX14.14, 20) - XAVG(XAVG(ADX14.14, 20), 20)`

You would need to offset the formula for the ADX to get the value for the previous bar.

`2 * XAVG(ADX14.14.1, 20) - XAVG(XAVG(ADX14.14.1, 20), 20)`   