Skip to content

Technical indicators

Triple Exponential Moving Average (TEMA)

The DEMA idea taken one step further.

The TEMA combines an EMA, the EMA of that EMA, and the EMA of that again, weighted so their lags cancel. Like the DEMA, it sits on the close when prices rise by the same amount every bar, and it holds closer to the price through a curve. Patrick Mulloy published both in 1994. It is not the same as TRIX, which is the rate of change of a triple-smoothed EMA.

As the DEMA: a quick moving average for crossings and trend direction, with more false turns when the market goes sideways.

EMA1 = EMA(CLOSE, periods)
EMA2 = EMA(EMA1, periods)
EMA3 = EMA(EMA2, periods)
TEMA = 3 × EMA1 − 3 × EMA2 + EMA3

Each EMA starts from the mean of its first periods values, as TA-Lib’s TEMA does.

Call: tema(periods)

Setting Chart default
periods: Periods 20

What you get: a number.

Warm-up: with tema(20), it asks for 0 bars of history and a run-up of 160, and its first value came on bar 58 of the example data.

Triple Exponential Moving Average drawn by its own code on example prices

The prices are made up, hourly, and the same on every page, so the chart shows how the indicator behaves, not how a market behaved.

function onIntervalClose() {
const fast = tema(20);
if (fast !== null && CLOSE < fast && OPEN_POSITIONS_COUNT === 0) {
openPosition("SELL", { quantity: 10000, stopLossPips: 30 });
}
}