TEMA
TEMA in ProBuilder returns the Triple Exponential Moving Average, a low-lag trend line built from three layered EMAs. Syntax, formula, examples, gotchas.
Syntax
TEMA[N](price)Parameters
| Name | Type | Default | Description |
|---|---|---|---|
N | integer | 20 | Period of each of the three exponential averages in the construction. |
price | price source | close | The series being smoothed. Accepts close, open, high, low, or a custom variable. |
Formula
MA1 = ExponentialAverage[N](price)
MA2 = ExponentialAverage[N](MA1)
MA3 = ExponentialAverage[N](MA2)
TEMA = 3 * (MA1 - MA2) + MA3Despite the name, TEMA is not simply an EMA applied three times. The weighted recombination of the three layers is what removes lag: the 3 * (MA1 - MA2) term measures how far smoothing has pulled the line away from price and adds that displacement back.
How it works
Every moving average trades noise for lag. Smoothing a smoothed series (MA2, then MA3) compounds the lag, but it also isolates it: the difference between MA1 and MA2 is a good estimate of how far behind price the smoothing process is running. TEMA exploits this by adding three times that difference back before including the deepest layer, producing a line that turns with price far sooner than an EMA of the same period.
The practical effect is a trend line responsive enough for fast markets while still filtering bar-to-bar noise. The cost is a mild tendency to overshoot: because lag compensation is an extrapolation, TEMA can poke beyond price at sharp turns before settling.
TEMA is used anywhere a conventional moving average would be: crossovers with price or with a slower line, slope-based trend detection, and as a smoother for other indicators.
Examples
Example 1, TEMA slope as a trend gauge (Indicator)
// 20-period TEMA of the close
mm = TEMA[20](close)
// Momentum of the bar-to-bar change in the TEMA
slope = momentum[10](mm - mm[1])
RETURN slopeComputes the 20-period TEMA, then measures the 10-period momentum of its bar-to-bar change, a second-order reading of whether the trend line is accelerating or decelerating.
Example 2, Fast and slow TEMA crossover (ProOrder)
// Two TEMA lines of different speed
fast = TEMA[10](close)
slow = TEMA[40](close)
IF NOT OnMarket THEN
IF fast CROSSES OVER slow THEN
BUY 1 CONTRACT AT MARKET
ENDIF
ELSIF fast CROSSES UNDER slow THEN
SELL AT MARKET
ENDIFA classic dual moving average system using TEMA on both legs. The low lag of TEMA shifts crossings earlier than the same system built on simple averages.
Example 3, Price above a rising TEMA (ProScreener)
t = TEMA[20](close)
// Line must be rising and price above it
rising = t > t[1]
SCREENER[close > t AND rising]((close / t - 1) * 100 AS "% above TEMA")Returns instruments trading above a rising 20-period TEMA, ranked by their percentage distance from the line.
Interpretation
- Price versus TEMA. Price above a rising TEMA describes an uptrend; price below a falling TEMA a downtrend. Because the line follows price closely, whipsaws around it are more frequent than around slower averages.
- Slope. The direction of the TEMA itself is a cleaner trend statement than price crossings. Some systems require both price position and slope to agree.
- Crossovers. Fast and slow TEMA pairs give earlier signals than SMA or EMA pairs of the same periods, with correspondingly more false starts in ranges.
Comparable low-lag alternatives include DEMA (two layers instead of three), ZLEMA, and HullAverage, each with a different lag-versus-overshoot trade-off.
Common errors and gotchas
- Assuming a triple-smoothed EMA. An EMA applied three times in a row is much slower than price. TEMA is the opposite, a lag-compensated construction. Reimplementing it as
ExponentialAverageofExponentialAverageofExponentialAveragegives the MA3 layer only, not TEMA. - Overshoot at sharp turns. The lag compensation extrapolates recent movement, so TEMA can spike beyond price after violent reversals. Stops or filters keyed to the raw TEMA value can be hit by the overshoot rather than by price.
- Warm-up period. Three layers of exponential smoothing need roughly three times the usual history to stabilise. Values in the first bars of a chart or backtest drift as the layers converge.
- Ranging markets. The responsiveness that helps in trends produces frequent flips in sideways conditions. A volatility or regime filter is generally needed before trading TEMA crossovers systematically.
Related instructions
DEMA, double exponential moving average, the two-layer sibling.ExponentialAverage, the building block used three times inside TEMA.ZLEMA, zero-lag exponential moving average, an alternative lag-reduction scheme.HullAverage, weighted-average based low-lag smoother.Average, simple moving average baseline.TRIX, oscillator built on a triple-smoothed exponential average.WeightedAverage, linearly weighted moving average.TimeSeriesAverage, regression-based moving average.
