# Triple Exponential Moving Average (TEMA)

Not to be confused with the Triple Exponential Moving Average (TRIX) indicator which has the same name but is a completely different indicator.

The triple exponential moving average (TEMA) 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 definition of TEMA1 is not a 'simple' triple EMA, but rather a composite of a single, double and triple EMAs, which eliminates the lag when there is a trend."

Of Price |
`3 * XAVGCx.z - 3 * XAVG(XAVGCx.z, x) + XAVG(XAVG(XAVGCx.z, x), x)` |
`x` =Period, `z` =Offset |

Generalized |
`3 * XAVG(w, x) - 3 * XAVG(XAVG(w, x), x) + XAVG(XAVG(XAVG(w, x), x), x)` |
`w` =Numeric, `x` =Period |

Where `x`

is the period which must be an integer.

Where `z`

is the offset. An offset of 1 returns the value for the previous bar instead of the current value.

Where `w`

is any formula returning a numeric result. Any offset must be part of this numeric formula.

### Examples

The current 20 period triple exponential moving average of price can be written as follows.

`3 * XAVGC20.0 - 3 * XAVG(XAVGC20.0, 20) + XAVG(XAVG(XAVGC20.0, 20), 20)`

But you can leave off the offsets because it is for the current bar.

`3 * XAVGC20 - 3 * XAVG(XAVGC20, 20) + XAVG(XAVG(XAVGC20, 20), 20)`

You would need to add the offsets back if you wanted the value for the previous bar instead of the current bar.

`3 * XAVGC20.1 - 3 * XAVG(XAVGC20.1, 20) + XAVG(XAVG(XAVGC20.1, 20), 20)`

A 20 period triple exponential moving average of the Kaufman Efficiency Ratio can be written as follows.

`3 * XAVG(2 * RSI20 - 100, 20) - 3 * XAVG(XAVG(2 * RSI20 - 100, 20), 20) + XAVG(XAVG(XAVG(2 * RSI20 - 100, 20), 20), 20)`

This could be shortened to the following by moving the `2 *`

and the `- 100`

outside the moving averages.

`2 * (3 * XAVG(RSI20, 20) - 3 * XAVG(XAVG(RSI20, 20), 20) + XAVG(XAVG(XAVG(RSI20, 20), 20), 20)) - 100`

If you wanted to get the value from 4 bars ago, you would need to include that as part of the formula for the Kaufman Efficiency Ratio in each place where it is used in the formula.

`2 * (3 * XAVG(RSI20.1.4, 20) - 3 * XAVG(XAVG(RSI20.1.4, 20), 20) + XAVG(XAVG(XAVG(RSI20.1.4, 20), 20), 20)) - 100`