backtrader.indicators.dema module¶
DEMA/TEMA Indicator Module - Double/Triple Exponential Moving Average.
This module provides DEMA and TEMA indicators introduced by Patrick G. Mulloy in 1994 to reduce the lag associated with traditional moving averages.
- Classes:
DoubleExponentialMovingAverage: DEMA indicator (alias: DEMA). TripleExponentialMovingAverage: TEMA indicator (alias: TEMA).
示例
- class MyStrategy(bt.Strategy):
- def __init__(self):
self.dema = bt.indicators.DEMA(self.data.close, period=20)
- def next(self):
- if self.data.close[0] > self.dema[0]:
self.buy()
- elif self.data.close[0] < self.dema[0]:
self.sell()
- class backtrader.indicators.dema.DoubleExponentialMovingAverage[源代码]¶
-
DEMA was first time introduced in 1994, in the article "Smoothing Data with Faster-Moving Averages" by Patrick G. Mulloy in "Technical Analysis of Stocks & Commodities" magazine.
It attempts to reduce the inherent lag associated with Moving Averages
- Formula:
dema = (2.0 - ema(data, period) - ema(ema(data, period), period)
- See:
(None)
- alias = ('DEMA', 'MovingAverageDoubleExponential')¶
- __init__(*args, **kwargs)¶
- frompackages = ()¶
- packages = ()¶
- class backtrader.indicators.dema.TripleExponentialMovingAverage[源代码]¶
-
TEMA was first time introduced in 1994, in the article "Smoothing Data with Faster-Moving Averages" by Patrick G. Mulloy in "Technical Analysis of Stocks & Commodities" magazine.
It attempts to reduce the inherent lag associated with Moving Averages
- Formula:
ema1 = ema(data, period)
ema2 = ema(ema1, period)
ema3 = ema(ema2, period)
tema = 3 * ema1 - 3 * ema2 + ema3
- See:
(None)
- alias = ('TEMA', 'MovingAverageTripleExponential')¶
- __init__(*args, **kwargs)¶
- frompackages = ()¶
- packages = ()¶