DocsStrategy APIindicators

TRIX (Triple EMA Oscillator)

TRIX shows the percentage rate of change of a triple-smoothed EMA. The triple smoothing filters out minor price movements, making TRIX useful for identifying significant trend changes.

Declaration

function init(ctx) { ctx.indicator('trix', 'TRIX', { period: 15, source: 'close' }); }

Options

OptionTypeDefaultDescription
periodnumber15EMA period (applied three times)
sourcestring'close'Price source

Output

Returns a single number[] series oscillating around zero.

Accessing Values

function onBar(ctx, i) { const trix = ctx.ind.trix[i]; // Percentage value }

Use Cases

Zero-Line Crossover

function onBar(ctx, i) { const trix = ctx.ind.trix[i]; const prevTrix = ctx.ind.trix[i - 1]; if (prevTrix <= 0 && trix > 0) { ctx.order.market('ASSET', 1, { signal: 'buy', reason: 'trix_bullish' }); } if (prevTrix >= 0 && trix < 0) { ctx.order.close('ASSET', { signal: 'sell', reason: 'trix_bearish' }); } }

Calculation

  1. $EMA_1 = EMA(Price, period)$
  2. $EMA_2 = EMA(EMA_1, period)$
  3. $EMA_3 = EMA(EMA_2, period)$
  4. $TRIX = \frac{EMA_3[t] - EMA_3[t-1]}{EMA_3[t-1]} \times 100$

Related

  • TEMA - Triple EMA value (not rate of change)
  • ROC - Rate of change of raw price
  • MACD - Dual EMA momentum indicator
indicatortrixmomentumoscillatortrendqsl