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.
示例
- 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[源代码]¶
基类:
IndicatorDefined 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()[源代码]¶
Calculate TRIX for the current bar.
Formula: TRIX = 100 * (ema3 / ema3_rocperiod_ago - 1.0)
- once(start, end)[源代码]¶
Calculate TRIX in runonce mode.
Computes triple EMA rate of change percentage across all bars.
- frompackages = ()¶
- packages = ()¶
- class backtrader.indicators.trix.TrixSignal[源代码]¶
基类:
TrixExtension of Trix with a signal line (ala MACD)
- Formula:
trix = Trix(data, period)
signal = EMA(trix, sigperiod)
- See:
- __init__(*args, **kwargs)¶
- nextstart()[源代码]¶
Seed TRIX Signal calculation on first valid bar.
Initializes signal line with TRIX value.
- once(start, end)[源代码]¶
Calculate TRIX Signal in runonce mode.
Computes signal line as EMA of TRIX values across all bars.
- frompackages = ()¶
- packages = ()¶