VariablePeriodTrix
Background
TRIX, developed by Jack Hutson, is a momentum oscillator built on a triple-smoothed exponential moving average of price. By smoothing three times it filters out short-lived price moves and minor cycles, leaving a clean view of the underlying trend; TRIX itself is the one-bar rate of change of that triple-smoothed average. It oscillates around a zero line: crossings above zero suggest building upward momentum, crossings below suggest the reverse, and divergences with price are watched as early warnings.
A standard TRIX uses a fixed smoothing length. VariablePeriodTrix takes a
period for each bar, so the triple smoothing adapts to market
conditions. Internally it builds on a variable-period triple EMA (TEMA) and then takes
its rate of change. The per-bar periods often come from an adaptor such as the
DominantCycle.
Included formula
The toolbox ships a ready-made Adaptive Smoothed TRIX indicator built on this function, so you can use it without writing any code. In AmiBroker open the Charts window, expand the WiseTraderToolbox group and drag Adaptive Smoothed TRIX onto a chart.
It plots TRIX in its own pane below price. The Adaptor you pick is what produces the per-bar period this function needs — so the triple smoothing adapts to the market — and an optional Smoother cleans up the input first. The adaptor's bounds, the smoothing and the colours are all set from the indicator's parameters.
The exported function
If you would rather build your own formula, the toolbox exports the calculation as a single AFL function you can call directly — it is the engine inside that indicator.
VariablePeriodTrix(Price, Periods)
| Parameter | Description |
|---|---|
| Price | The price array the indicator is calculated on. |
| Periods | An array (or value) giving the smoothing period to use at each bar. Most often
this is fed from an adaptor such as the DominantCycle. |
Usage
periods = DominantCycle( Close );
trix = VariablePeriodTrix( Close, periods );
Plot( trix, "Adaptive TRIX", colorRed );
Plot( 0, "", colorGrey40, styleDashed | styleNoLabel );
TRIX oscillates around zero. A move above zero signals building upward momentum and a move below zero the opposite; many traders also add a signal line (a moving average of TRIX) and trade the crossovers.