Trend TrendReduced LagMT5 Built-in Available in Builder

TEMA

TEMA is DEMA's lag correction taken one stage further, and the extra stage is measurable in both directions: it reaches a new level in four bars where a plain EMA needs twenty, and it sits outside the recent high-low range more than three times as often as DEMA does. MetaTrader 5 ships it as iTEMA, and the length you set is a third of the history it needs.

Period set
14
Bars needed
39
Buffers plotted
1 of 4
TEMA (14) with DEMA and the plain EMA of the same periodZero — the correction has nothing to add and the line is just its EMABoth corrections on one scale — TEMA's is the larger (derived — iTEMA plots only the line)

Illustrative — synthetic data, not a live quote.

What TEMA tells you

DEMA takes an EMA, measures how far behind it is running by taking an EMA of that EMA, and adds the difference back. TEMA does the same thing with a third stage, and the coefficients — three, minus three, plus one — are what falls out of cancelling the lag twice rather than once. The result is the fastest line in this family and the one furthest from being an average: on a step change it arrives in a third of the time a plain EMA takes, and it regularly prints values that price never traded. Whether that is useful depends entirely on which side of a trade you put it on, which is the one thing most write-ups of it leave out.

  • It reaches a new level in 4 bars where DEMA needs 6 and a plain EMA needs 20
  • It leaves the last 14 bars' range on 7.5% of bars — DEMA 2.1%, a plain EMA 0.0%
  • The extra stage buys speed and pays in overshoot; nothing about it is smoother
  1. 1 An EMA of price, an EMA of that, and an EMA of that again
  2. 2 Three chained lags, cancelled twice rather than once
  3. 3 TEMA = 3 × EMA − 3 × EMA(EMA) + EMA(EMA(EMA))
Show the formula & calculation detail

TEMA is one line of arithmetic, and every coefficient in it is forced:

TEMA = 3 × EMA(price) − 3 × EMA(EMA(price)) + EMA(EMA(EMA(price)))

DEMA cancels a single EMA’s lag once. Cancel it twice and this is what falls out — three terms with alternating signs whose coefficients sum to one, so the line still lives on the price scale rather than drifting off it. Subtract DEMA from TEMA of the same period and what remains is EMA − 2 × EMA(EMA) + EMA(EMA(EMA)): a second difference of the same chain, checked to within 5.7e-14 over 3,958 bars. The extra stage is not more smoothing. It is curvature.

The speed is real and so is the bill. On a step from 100 to 110 with period 14:

95% of the new levelPeak
Plain EMA20 bars110.00
DEMA6 bars111.17
TEMA4 bars111.66

The peak matters as much as the timing: 111.66 is a price that never traded anywhere in the series. A real moving average cannot do that, because it is a weighted sum of its window with weights that add to one. On a random walk the line sits outside the last fourteen bars’ high-low range on 7.5% of bars — against 2.1% for DEMA and 0.0% for the plain EMA the same test was run on.

Which is why the template does not trade it. The obvious construction — a fast TEMA crossing a slow one — is the loudest thing in this family. Measured on the same random walk, TEMA 14/28 crosses 291 times, DEMA 14/28 crosses 227, and a plain EMA 14/28 crosses 114. Each of those crossings is a spread paid to find out whether the lead meant anything.

So the entries are left to the plain EMA pair and TEMA is put on the exit, where being early costs a re-entry instead of a trade. Against the same entries held until the opposite cross:

  • Average hold: 32.5 bars → 20.5
  • Share of the peak open profit realised: 16.6% → 22.0%
  • Trades closed within two bars of opening: 8.1% → 1.2%

Measured across five random-walk series — 512 trades under the TEMA exit against 593 under the opposite-cross exit. A random walk says nothing about whether the strategy makes money; what it can compare is how much of a move is still there when the position closes.

The period is a third of the history. Each EMA in the chain waits for the one before it, so MT5 sets PLOT_DRAW_BEGIN to 3 × period − 3 and calculates nothing before then. A TEMA(14) needs 39 bars; a TEMA(50) needs 147. Nothing errors — the left of the chart is simply empty.

Signals

The distinct, backtestable signals TEMA gives — and the regime each one suits.

TEMA Breaks the Fast EMA

Builder ready
Condition
TEMA crosses the plain EMA of the same period against the position
Best regime
Either regime
Typical use
The template's rule, and it is an exit rather than an entry — the lead is most valuable where a false signal only costs a re-entry

Price Against the Line

Builder ready
Condition
Price closes above or below TEMA
Best regime
Trending
Typical use
A direction filter that turns sooner than DEMA of the same length, and flips more often for the same reason

Fast / Slow TEMA Cross

Builder ready
Condition
A short-period TEMA crosses a longer one
Best regime
Trending
Typical use
The obvious construction, and the noisiest of the family — measured on a random walk it crosses 291 times against 227 for the same pair of DEMAs

Overshoot Past the Range

Advanced logic
Condition
The line sits outside the recent bars' high and low
Best regime
Trending
Typical use
A stretch reading in principle; comparing the line against a rolling range is not a single node

MT5 implementation

What MetaTrader 5 itself computes and draws — the reference every rule on this page is written against.

Buffers

Index Buffer Drawn in MT5 as What it holds
0 MAIN_LINE TEMA The line, and the only series MT5 plots. The indicator declares four buffers; the other three hold the EMA, the EMA of that EMA and the EMA of that, all marked INDICATOR_CALCULATIONS — working storage rather than output. The Builder reads index 0.

Platform notes

Works best / use carefully

No indicator is a universal edge. Here is where TEMA helps — and where it misleads.

Works best

  • On the exit side, where arriving early costs a re-entry rather than a losing trade
  • Trends steep enough that the overshoot is behind price rather than ahead of it
  • As a faster read of a higher timeframe, where its flips are rarer in chart-bar terms
  • Anywhere a DEMA has been shortened to get more lead — this is the principled version of that shortening

Use carefully

  • As an entry trigger: it pokes outside the recent range on 7.5% of bars, and most of those are not moves
  • Ranges, where two corrections keep supplying lead to a move that is not there
  • Short histories: nothing is drawn until three times the period minus three bars exist
  • Reading the line as a level — it sits at prices that never traded more often than DEMA does

Build a strategy with TEMA

Wire the signal into entry and exit rules, then export a compilable MT5 EA — no code.

  1. One TEMA node on Close at 14, and two plain EMA nodes at 14 and 28
  2. TEMA falls through the fast EMA → Close the long. Rises through it → Close the short
  3. EMA 14 crosses above EMA 28 → Open Buy · SL 70 / TP 210. Below → Open Sell
  4. All three read the last closed bar, so every cross is a settled fact
  5. The close nodes come before the entries, and that ordering is deliberate

Combine TEMA with other indicators

One indicator rarely stands alone. These pairings cover TEMA's blind spots.

TEMA + DEMA

  1. DEMA at 14
  2. TEMA at 14
  3. Compare
Why
The comparison that defines this indicator. Same period, same applied price, same smoothing constant — the only difference is that one cancels the lag once and the other twice, so every gap on screen is the third stage doing its work. It also settles the question of whether the extra stage is worth it on your instrument: on a step change TEMA arrives two bars sooner, and on a random walk it sits outside the recent range on 7.5% of bars against 2.1%. Those two numbers are the whole trade-off
Best regime
Either regime

No single-flow template pairs them. Start from EMA Cross Entry x TEMA Early Exit, add a DEMA node at 14 on Close, and put it into a Compare against the TEMA node.

Open Builder →

TEMA + ADX

  1. ADX above 25
  2. EMA 14 crosses above EMA 28
  3. Buy
Why
The failure mode is specific and the answer is not more smoothing. Two correction stages keep supplying lead in a range, so the line crosses things that are not moves. A trend-strength reading does not improve the line — it decides whether the lead is worth acting on, and it belongs on the entry rather than the exit, because an early exit in a range is the behaviour you wanted anyway
Best regime
Trending

No single-flow template combines them. Add an ADX node with a Compare at 25 to EMA Cross Entry x TEMA Early Exit and join it to the entry Cross with an And gate — leave the exit path untouched.

Open Builder →

TEMA + ATR

  1. ATR at 14
  2. Stop loss in ATR mode
  3. TEMA crosses the fast EMA
Why
The template exits on a line crossing and stops out at a fixed 70 pips, which are two different ideas about how much room to give a trade. Sizing the stop from measured volatility instead puts both on the same footing: the line handles the case where the move is over, the stop handles the case where it was never there. It also stops the fixed distance from being wrong in two directions at once across instruments
Best regime
Either regime

The Stop Loss node has an ATR mode, so this needs no extra condition — swap the fixed distance for the ATR setting and the exit path is unchanged.

Open Builder →

Parameters

Starting values to validate on your own pair and timeframe — not guaranteed settings.

Parameter Default Suggested test range What it does
Period 14 1–999 The EMA length used three times — on price, on the result, and on that result. Longer is slower as usual, but the history it consumes is three times what you set: MT5 draws nothing until 3 × period − 3 bars exist, because the third EMA cannot start until the second has. A TEMA(50) needs 147 bars.
Applied price Close Close / Open / High / Low / Median / Typical / Weighted Which series the whole calculation runs on. As with DEMA this is a real control rather than a formality — all three stages and therefore both corrections are computed from whatever you choose.
Shift 0 0–100 Which bar to read. The template sets 1 so an exit is decided on a closed bar. This is not iTEMA's own ma_shift, which slides the drawn line sideways — the Builder pins that to 0 and exposes only the bar offset.
Timeframe Current Current / M1–MN1 Which timeframe's bars the line is built from. Set above the chart and its flips become rarer in chart-bar terms, which is one of the few ways to keep the lead without paying the full overshoot bill.

Starting presets

Template 14 One TEMA on the exit, with a plain EMA 14/28 pair supplying the entries
Slower 21 Fewer exits and later ones; the lead survives, the flip count drops
Pair 14 / 28 Two TEMAs as a crossover — the loudest configuration, and worth measuring before trusting

Market examples

Where TEMA works, where it fails, and how a filter changes the outcome.

Works

Out near the top

A move stalls and the line breaks the fast average several bars before the entry pair would have crossed back. The position closes with most of the excursion still in it — the behaviour the 16.6% to 22.0% measurement is describing.

Fails

The exit that was early

A pullback inside a live trend breaks the line, the position closes, and the trend continues. This is the cost of the design, and it is deliberately the cheap side of the trade: the entry rule is still valid and can fire again.

Filtered

Same stretch, strength required

The identical range with a trend-strength condition on the entry. The exit path is untouched, because closing early in a range was never the problem.

FAQ

Is TEMA built into MetaTrader 5?
Yes. iTEMA is a standard MQL5 function taking a symbol, a timeframe, the period, an ma_shift and an applied price, and the terminal also ships a TEMA custom indicator under Indicators\Examples. The Builder calls the built-in, so a generated EA needs no extra files on the terminal that runs it.
Is TEMA just three EMAs averaged together?
No. It uses three chained EMAs but combines them as 3 × EMA − 3 × EMA(EMA) + EMA(EMA(EMA)) — two of the three terms are subtractions. Averaging them would be slower than any of them; the alternating signs cancel the lag twice over, which is what makes the line arrive early. The coefficients sum to one, so the result still lives on the price scale.
How is it different from DEMA?
One correction stage. Same period, same applied price, same smoothing constant; the difference between the two lines is EMA − 2 × EMA(EMA) + EMA(EMA(EMA)), a second difference of the same chain. In numbers: on a step from 100 to 110, TEMA reaches 95% of the new level in 4 bars against DEMA's 6, and on a random walk it sits outside the recent 14-bar range on 7.5% of bars against DEMA's 2.1%. Faster, and wrong about levels more often.
How many bars does it need before it draws?
3 × period − 3. Each EMA in the chain waits for the previous one, so a period of 14 needs 39 bars and a period of 50 needs 147. MT5 returns without calculating while the history is shorter, so the left of the chart is empty rather than wrong.
Why does the template use TEMA to close rather than to open?
Because the measured overshoot makes it an expensive trigger and a cheap exit. It sits outside the recent range on 7.5% of bars, so as an entry it mostly buys round trips — TEMA 14/28 crosses 291 times on a random walk where a plain EMA 14/28 crosses 114. On the exit the same eagerness shortens the average hold from 32.5 bars to 20.5 and raises the realised share of the peak open profit from 16.6% to 22.0% (512 trades against the opposite-cross exit's 593, over five random-walk series), and a wrong exit costs a re-entry rather than a trade.
Can I build a TEMA EA without coding?
Yes. The EMA Cross Entry x TEMA Early Exit template enters on a plain EMA 14/28 crossover and closes when TEMA breaks the fast EMA, with the close nodes ahead of the entries so a netting account reverses correctly. The three periods, the applied price, the shift, the stop distances, the lot and the spread limit are all EA inputs.
How should I validate settings before going live?
Backtest on quality tick data, then demo, and read the trade list rather than only the curve. Two checks are specific to this indicator. Make sure the test contains ranges as well as trends, because the overshoot only shows its bill in the former. And before lengthening the period to calm the line down, check whether the noise you are seeing is on the entry side — if it is, the entry rule is what needs the filter, and slowing TEMA down removes the one property you selected it for.