TEMA on TradingView: formula and limits
The TEMA indicator combines three EMA stages to reduce smoothing delay: 3 × EMA1 − 3 × EMA2 + EMA3. It remains a line in price units. The subtraction matters: a triple-smoothed EMA alone is not TEMA, and the combined line can overshoot price.
E1 = EMA(source, N)
E2 = EMA(E1, N)
E3 = EMA(E2, N)
TEMA = 3 × E1 − 3 × E2 + E3
Formula: TradingView Triple EMA documentation. The worked example below checks what that formula does after a price step.
Copy the TEMA codeA price step exposes the overshoot
This is a synthetic calculation, not market data or a backtest. Set N = 3, so α = 2/(N + 1) = 0.5. Seed all three stages at 100 on bar 0. Price jumps to 108 on bar 1 and then stays there. Each stage uses its current input and its own previous value; retain full precision until display.
E1[t] = 0.5 × price[t] + 0.5 × E1[t−1]
E2[t] = 0.5 × E1[t] + 0.5 × E2[t−1]
E3[t] = 0.5 × E2[t] + 0.5 × E3[t−1]
| Bar | Price | E1 (EMA) | E2 | E3 | DEMA | TEMA |
|---|---|---|---|---|---|---|
| 0 (seed) | 100 | 100 | 100 | 100 | 100 | 100 |
| 1 (step) | 108 | 104 | 102 | 101 | 106 | 107 |
| 2 (flat) | 108 | 106 | 104 | 102.5 | 108 | 108.5 |
| 3 (flat) | 108 | 107 | 105.5 | 104 | 108.5 | 108.5 |
| 4 (flat) | 108 | 107.5 | 106.5 | 105.25 | 108.5 | 108.25 |
| 5 (flat) | 108 | 107.75 | 107.125 | 106.1875 | 108.375 | 108.0625 |
Check bar 2 by hand: E1 = 106, E2 = 104 and E3 = 102.5. Then TEMA = 318 − 312 + 102.5 = 108.5. The source has never exceeded 108. The negative coefficient on E2 means TEMA is not constrained to the source range as a positive-weight average would be.
At bar 1, price is above TEMA (108 versus 107). At bar 2, price is below TEMA (108 versus 108.5), even though price has not fallen. By bar 4, TEMA is declining while price remains flat. A crossing or slope change describes the filter output; it does not by itself establish a market reversal.
DEMA reaches the same 108.5 peak one bar later in this particular sequence. That is a property of this input and seed, not a universal one-bar advantage for TEMA.
TEMA Pine Script v6
The example keeps the three EMA stages separate so the calculation can be inspected. The expression 3 × (E1 − E2) + E3 is algebraically identical to the formula. Length 9 and close are editable defaults, not recommended settings.
//@version=6
indicator(title="Triple EMA", overlay=true, max_labels_count=500)
// Inputs
length = input.int(9, "Length", minval=1)
src = input.source(close, "Source")
// TEMA Calculation
e1 = ta.ema(src, length)
e2 = ta.ema(e1, length)
e3 = ta.ema(e2, length)
tema = 3 * (e1 - e2) + e3
// Plot
plot(tema, "TEMA", color.rgb(41, 98, 255, 0), 2)- Paste the complete code into the TradingView Pine Editor, save it and add it to the chart.
- Set the same source and length on any comparison indicator. A 9-bar setting means nine chart bars, not necessarily nine days.
- Inspect closed-bar values before interpreting crossings. The script plots one line and contains no alerts or orders.
For N = 1 and a defined source, α = 1: all three EMA stages equal the source and TEMA equals it too. This is a useful boundary check; it leaves no smoothing. Changing the source to hl2 changes the input series and does not guarantee fewer crossings.
Initialization and warm-up checks
An EMA is recursive. Its previous value carries older observations beyond the nominal N bars. The table explicitly seeds every stage at 100; that assumption is part of the example, not a claim that every chart or library starts that way.
For a single EMA with identical later inputs, an initial difference δ shrinks to δ × (1 − α)^k after k updates. In TEMA, differences also propagate from E1 into E2 and E3. A first nonmissing output is not proof of convergence, and exactly 3 × N bars is not a universal warm-up guarantee.
- Match symbol, chart timeframe, source, session and price adjustments before comparing values.
- Compare the intermediate stages. If E1 agrees but E2 does not, inspect the second-stage seed and history instead of changing the final coefficients.
- Repeat the calculation with an earlier history start. On the overlapping bars, record the maximum absolute TEMA difference and compare it with an explicit tolerance suitable for the intended use.
- Keep missing values visible during diagnosis. Replacing unavailable prices with zero creates a new input sequence and may create an artificial jump.
On a live bar, close and the plotted TEMA can update together. A temporary crossing may disappear by the close. If a later script adds signals, define whether it requires barstate.isconfirmed. Confirmation timing does not establish profitability or specify when a strategy order fills.
References: EMA recursion and Pine execution on realtime bars.
TEMA, DEMA and TRIX measure different things
| Output | Calculation | Meaning |
|---|---|---|
| EMA | E1 | One smoothing stage; source units |
| DEMA | 2 × E1 − E2 | Two-stage combination; source units |
| TEMA | 3 × E1 − 3 × E2 + E3 | Three-stage combination; source units |
| TRIX (percent) | 100 × (E3[t] / E3[t−1] − 1) | One-bar rate of change; percent |
DEMA uses stages through E2; TEMA adds E3 and changes the coefficients. Calling either one merely a double- or triple-smoothed average omits its subtraction. TradingView documents the DEMA formula.
For percentage TRIX on bar 2 of the example, 100 × (102.5 / 101 − 1) is about 1.48515%. That number describes the change in E3, while TEMA is 108.5 price units. A TRIX implementation using log-price changes has a different definition and scale. The percentage form requires a nonzero prior E3. TradingView describes TRIX as a one-period percentage change.
Turn the calculation into a checkable script
Use the Pine Script AI Coding Agent to describe the inputs and observation rules you need. Ask for inspectable intermediate values before adding trading logic.
Create a TEMA indicator with editable length and source. Use three EMA stages with the same length and combine them as 3 × E1 − 3 × E2 + E3. Expose all stages for inspection. Add optional close-confirmed price-cross markers. Document initialization and missing-value handling. Keep orders out of this indicator.
Compare the resulting values bar by bar, including a flat interval after a price step. If you later create a strategy, define exits, position sizing, commissions, slippage and execution timing separately. Syntax validation cannot verify those assumptions or trading results.
Open Pine Script AI Coding AgentEducational calculations, not investment advice. The examples provide no evidence of expected returns.
TEMA questions
Sources and related indicators
Documentation checked October 17, 2026. The numeric table is an original demonstration with stated assumptions.
- TradingView: Triple EMA
- TradingView: Double EMA
- TradingView: TRIX
- TradingView: moving average calculations
- Pine Script: execution model
Continue with EMA, DEMA or TRIX, or browse the TradingView indicators category.