DocsStrategy APIindicators

TEMA (Triple Exponential Moving Average)

TEMA further reduces lag by applying EMA three times and combining the results. It is the most responsive of the standard moving average family.

Declaration

function init(ctx) { ctx.indicator('tema', 'TEMA', { period: 14, source: 'close' }); }

Options

OptionTypeDefaultDescription
periodnumber20Lookback period
sourcestring'close'Price source (open, high, low, close, hl2, hlc3, ohlc4)

Output

Returns a single number[] series.

Accessing Values

function onBar(ctx, i) { const temaValue = ctx.ind.tema[i]; }

Use Cases

Scalping Entries with Minimal Lag

function init(ctx) { ctx.indicator('tema', 'TEMA', { period: 8 }); ctx.indicator('sma', 'SMA', { period: 50 }); } function onBar(ctx, i) { // TEMA for fast entry, SMA for trend filter const trendUp = ctx.ind.sma[i] > ctx.ind.sma[i - 5]; if (trendUp && q.crossOver(ctx.series.close, ctx.ind.tema, i)) { ctx.order.market('ASSET', 1, { signal: 'buy', reason: 'tema_reclaim' }); } }

Calculation

$$TEMA = 3 \times EMA_1 - 3 \times EMA_2 + EMA_3$$

Where $EMA_1 = EMA(Price)$, $EMA_2 = EMA(EMA_1)$, $EMA_3 = EMA(EMA_2)$

Related

  • DEMA - Double EMA, slightly more lag
  • EMA - Standard exponential moving average
  • TRIX - Rate of change of TEMA
indicatortemamoving-averagetrendqsl