1-day Rate-Of-Change (ROC) of a Triple Smooth EMA (TRIX)
Summary
1-day Rate-Of-Change of a triple-smoothed EMA of the input. Momentum oscillator that filters out price moves shorter than the chosen period. Oscillates around zero; sign, zero-crossings and slope signal momentum direction.
Chart
Chart metadata i
Outputs
outReal:line·zero·positive·negative
Formula
E1 = EMA(inReal, n); E2 = EMA(E1, n); E3 = EMA(E2, n); TRIX = ROC_1(E3) = 100 * (E3_today/E3_yesterday - 1)
Notes
- The input is assumed positive. The previous triple-smoothed value is the divisor. Near zero the divisor is small and the output very large; no error is returned. A series that reaches or crosses zero, such as an oscillator or a spread, has no meaningful result here.
- The final rate-of-change step yields 0 when the previous smoothed value is exactly zero, rather than being undefined.
Inputs
inReal— Source series to smooth
Outputs
outReal— 1-day percent ROC of the triple EMA
Parameters
| Parameter | Type | Default | Accepted values | Description |
|---|---|---|---|---|
optInTimePeriod | integer | 30 | 1–100000 | EMA period used at each of the three smoothing passes |
Properties
Numerical Stability: Initial Unstable Period — Inherited from EMA, which TRIX computes internally; tunable via EMA's unstable period.
| ☐ Overlap Input |
| ✅ Independent Y-Axis i |
| ☐ Candlestick |
| ☐ Display Shift |
| ☐ Can Output NaN or ±Inf |
| ☐ Identity at Period 1 |
| ☐ Uses Transcendental |
| ✅ Input Must Be Positive i |
Example
C
#include <stdio.h>
#include <ta_libc.h>
int n = 252;
double series[252]; /* your data, oldest first */
double out[252];
int outBegIdx, outNBElement;
TA_Initialize();
TA_TRIX( 0, n - 1, series, 30, &outBegIdx, &outNBElement, out );
printf( "%d values from bar %d; last out = %f\n", outNBElement, outBegIdx, out[outNBElement - 1] );Rust
use ta_lib::Core;
let series = vec![0.0; 252]; // your data, oldest first
let mut out = vec![0.0; 252];
let core = Core::new();
let range = core.trix(0, series.len() - 1, &series, 30, &mut out)?;
println!("{} values from bar {}; last out = {}", range.count, range.beg_idx, out[range.count - 1]);Java
import io.github.talib.Core;
import io.github.talib.OutRange;
double[] series = new double[252]; // your data, oldest first
double[] out = new double[252];
Core core = Core.DEFAULT;
OutRange r = core.trix(0, series.length - 1, series, 30, out);
System.out.println(r.count() + " values from bar " + r.begIdx() + "; last out = " + out[r.count() - 1]);C#
using System;
using TALib;
var series = new double[252]; // your data, oldest first
var outReal = new double[252];
var core = Core.Default;
OutRange r = core.Trix(0, series.Length - 1, series, 30, outReal);
Console.WriteLine($"{r.Count} values from bar {r.BegIdx}; last outReal = {outReal[r.Count - 1]}");TypeScript
import { trix } from 'ta-lib';
const series = new Float64Array(252); // your data, oldest first
const { begIdx, values } = trix(series, { timePeriod: 30 });
console.log(values.length + ' values from bar ' + begIdx + '; last values = ' + values[values.length - 1]);Implementation
Added in 0.4.0.
TA-Lib Definition: trix.c · trix.yaml
| Native | File |
|---|---|
| C | ta_TRIX.c |
| Rust | trix.rs |
| Java | Core_TRIX.java |
| C# | Core_TRIX.cs |
| TypeScript | trix.ts |
Python: talib.TRIX, see ta-lib-python.
TA-Lib is also available for R and more using a wrapper.
Aliases
Triple Exponential Average
See Also
References
- Jack K. Hutson, Technical Analysis of Stocks & Commodities (1980s)