TRIX Wikipedia.
A triple-smoothed EMA rate of change: the percent change of an EMA applied three times over. Values are close to zero in flat trends; the signal is usually its own EMA (not provided here).
See TAlib for the input conventions: prices are always given in
chronological order, oldest first, and the series is returned aligned
with the input. nil is returned when there is not enough data.
Summary
Functions
@spec trix([number()], pos_integer()) :: float() | nil
Calculate the latest TRIX value, in percent.
Parameters
- prices: list of prices, oldest first.
- period: EMA period, a positive integer (default 14).
At least 3 * (period - 1) + 2 prices are required for the triple EMA
to have two defined values to compare; otherwise nil is returned.
Examples
iex> TAlib.Indicators.TRIX.trix([1, 2, 3, 4, 5, 6, 7, 8], 2) |> Float.round(4)
18.1818
@spec trix_list([number()], pos_integer()) :: [float() | nil]
Calculate the full TRIX series.
Returns a list aligned with prices: the first 3 * (period - 1) + 1
entries are nil, and every later entry is the one-bar percent change
of the triple EMA.
Parameters
- prices: list of prices, oldest first.
- period: EMA period, a positive integer (default 14).
Examples
iex> TAlib.Indicators.TRIX.trix_list([1, 2, 3, 4, 5, 6, 7, 8], 2) |> Enum.map(fn
...> nil -> nil
...> x -> Float.round(x, 4)
...> end)
[nil, nil, nil, nil, 40.0, 28.5714, 22.2222, 18.1818]