Calculate the Trix (Triple Exponential Moving Average) for a given price series.

Trix is a momentum oscillator that calculates the percentage rate of change of a triple exponentially smoothed moving average. It helps identify overbought and oversold conditions in a market.

The formula is as follows:

\[\text{EMA1} = \operatorname{EMA}(\text{Close},\; \text{Window})\] \[\text{EMA2} = \operatorname{EMA}(\text{EMA1},\; \text{Window})\] \[\text{EMA3} = \operatorname{EMA}(\text{EMA2},\; \text{Window})\] \[\text{TRIX} = 100 \cdot ((\text{EMA3} - \text{EMA3} \left[- 1\right]) / \text{EMA3} \left[- 1\right])\]

Also known as: triple smoothed EMA, rate of change oscillator.

Triple Exponential Moving Average (TRIX) in Python

Install the Finance Toolkit with:

pip install financetoolkit -U

Then call get_trix as shown below.

from financetoolkit import Toolkit

toolkit = Toolkit(tickers=["AAPL", "MSFT"])

toolkit.technicals.get_trix()

Which returns:

Date AAPL MSFT Benchmark
2026-06-18 0.1364 -0.1466 0.0936
2026-06-22 0.1102 -0.1998 0.0849
2026-06-23 0.0852 -0.2492 0.0734
2026-06-24 0.061 -0.2982 0.0603
2026-06-25 0.0242 -0.3513 0.0471
2026-06-26 -0.0123 -0.3924 0.0325
2026-06-29 -0.0485 -0.4254 0.0216
2026-06-30 -0.0765 -0.4481 0.0154
2026-07-01 -0.0937 -0.4554 0.0122
2026-07-02 -0.0914 -0.4477 0.0107

Parameters

The function accepts the following parameters:

  • period (str, optional): The time period to consider for historical data. Can be “daily”, “weekly”, “quarterly”, or “yearly”. Defaults to “daily”.
  • close_column (str, optional): The column name for closing prices in the historical data. Defaults to “Adj Close”.
  • window (int, optional): Number of periods for moving average calculation. The number of periods (time intervals) over which to calculate the moving average.
  • rounding (int | None, optional): The number of decimals to round the results to. Defaults to 4.
  • growth (bool, optional): Whether to calculate the growth of the Trix. Defaults to False.
  • lag (int | list[int], optional): The lag to use for the growth calculation.
  • standardize (bool, optional): Whether to standardize (Z-Score) the result. When combined with growth=True, standardizes the growth values instead of the raw values. Defaults to False. Defaults to 1.
Share