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
| Option | Type | Default | Description |
|---|---|---|---|
period | number | 15 | EMA period (applied three times) |
source | string | '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
- $EMA_1 = EMA(Price, period)$
- $EMA_2 = EMA(EMA_1, period)$
- $EMA_3 = EMA(EMA_2, period)$
- $TRIX = \frac{EMA_3[t] - EMA_3[t-1]}{EMA_3[t-1]} \times 100$
Related
Related
indicatortrixmomentumoscillatortrendqsl