backtrader.indicators.trix module

TRIX Indicator Module - Triple exponential moving average slope.

This module provides the TRIX indicator developed by Jack Hutson in the 1980s to show the rate of change of a triple smoothed moving average.

Classes:

Trix: TRIX indicator (alias: TRIX). TrixSignal: TRIX with signal line.

Example

class MyStrategy(bt.Strategy):
def __init__(self):

self.trix = bt.indicators.TRIX(self.data.close, period=15)

def next(self):
if self.trix[0] > 0:

self.buy()

class backtrader.indicators.trix.Trix[source]

Bases: Indicator

Defined by Jack Hutson in the 80s and shows the Rate of Change (%) or slope of a triple exponentially smoothed moving average

Formula:
  • ema1 = EMA(data, period)

  • ema2 = EMA(ema1, period)

  • ema3 = EMA(ema2, period)

  • trix = 100 * (ema3 - ema3(-1)) / ema3(-1)

The final formula can be simplified to: 100 * (ema3 / ema3(-1) - 1)

The moving average used is the one originally defined by Wilder, the SmoothedMovingAverage

See:
alias = ('TRIX',)
plotinfo = <backtrader.metabase.plotinfo_obj object>
__init__(*args, **kwargs)
next()[source]

Calculate TRIX for the current bar.

Formula: TRIX = 100 * (ema3 / ema3_rocperiod_ago - 1.0)

once(start, end)[source]

Calculate TRIX in runonce mode.

Computes triple EMA rate of change percentage across all bars.

frompackages = ()
packages = ()
class backtrader.indicators.trix.TrixSignal[source]

Bases: Trix

Extension of Trix with a signal line (ala MACD)

Formula:
  • trix = Trix(data, period)

  • signal = EMA(trix, sigperiod)

See:
__init__(*args, **kwargs)
nextstart()[source]

Seed TRIX Signal calculation on first valid bar.

Initializes signal line with TRIX value.

next()[source]

Calculate TRIX and signal line for current bar.

Signal line is EMA of TRIX values.

once(start, end)[source]

Calculate TRIX Signal in runonce mode.

Computes signal line as EMA of TRIX values across all bars.

frompackages = ()
packages = ()