pub struct Trix { /* private fields */ }Expand description
TRIX: the rate of change of a triple-smoothed price series.
Three exponential averages of len are chained over the close — e1 over the price, e2
over e1, e3 over e2 — and the published line is the relative change of that third
average against its own previous value:
TRIX_t = 100 * (e3_t / e3_{t-1} - 1)
The previous value is the denominator, so the result is the percentage change of the level it came from. Other implementations divide by the current value or publish the absolute difference instead; those are different numbers under the same name, and this type does not offer them.
This is not TEMA: TEMA combines the three averages linearly to reduce lag and stays in price units, while TRIX differentiates the third average and is a rate.
Every stage uses the shared Ema with its first-sample seed, so each stage always receives
a defined input — no stage is ever fed a substituted zero.
Units: percentage points per bar for the line, the signal and the histogram alike.
Per-bar outputs:
value: the TRIX line.extra["signal"]:Ema(signal_len)over the published TRIX values, seeded with the first of them and published only from thesignal_len-th on. Before that the key is absent — an unfinished signal line is left out, not zeroed.extra["hist"]:value - signal, present exactly when the signal is.
First output: with the len + 1-th bar, so both e3 values of the ratio are built from at
least len inputs each. A bar whose previous e3 is zero or non-finite produces no output
rather than a division result that means nothing. Indicator::reset clears all four
averages and the counters, so the next series starts deterministically.
Implementations§
Trait Implementations§
Source§impl Indicator for Trix
impl Indicator for Trix
fn name(&self) -> &str
fn warmup_period(&self) -> usize
fn on_bar(&mut self, bar: &Bar) -> Option<IndicatorOutput>
fn reset(&mut self)
Source§fn on_checked_bar(
&mut self,
bar: &Bar,
) -> Result<Option<IndicatorOutput>, BarValidationError>
fn on_checked_bar( &mut self, bar: &Bar, ) -> Result<Option<IndicatorOutput>, BarValidationError>
Indicator::on_bar.