Skip to main content

Trix

Struct Trix 

Source
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 the signal_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§

Source§

impl Trix

Source

pub fn new(len: usize, signal_len: usize) -> Self

Source

pub fn with_defaults() -> Self

Trait Implementations§

Source§

impl Clone for Trix

Source§

fn clone(&self) -> Trix

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Trix

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Indicator for Trix

Source§

fn name(&self) -> &str

Source§

fn warmup_period(&self) -> usize

Source§

fn on_bar(&mut self, bar: &Bar) -> Option<IndicatorOutput>

Source§

fn reset(&mut self)

Source§

fn on_checked_bar( &mut self, bar: &Bar, ) -> Result<Option<IndicatorOutput>, BarValidationError>

Validates a bar before forwarding it to Indicator::on_bar.
Source§

fn alerts(&self) -> Vec<IndicatorAlert>

Auto Trait Implementations§

§

impl Freeze for Trix

§

impl RefUnwindSafe for Trix

§

impl Send for Trix

§

impl Sync for Trix

§

impl Unpin for Trix

§

impl UnsafeUnpin for Trix

§

impl UnwindSafe for Trix

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.