backtrader.indicators.oscillator module¶
Oscillator Indicator Module - Oscillating indicators.
This module provides oscillator indicators that show the deviation of one data series from another, typically price from a moving average.
- Classes:
OscillatorMixIn: MixIn class to create oscillating indicators. Oscillator: Oscillation of data around another data.
Example
- class MyStrategy(bt.Strategy):
- def __init__(self):
# Oscillate price around SMA self.osc = bt.indicators.Oscillator(self.data, bt.indicators.SMA(self.data, period=20))
- def next(self):
# When oscillator is positive, price is above SMA if self.osc[0] > 0:
self.buy()
- elif self.osc[0] < 0:
self.sell()
- class backtrader.indicators.oscillator.OscillatorMixIn[source]¶
Bases:
IndicatorMixIn class to create a subclass with another indicator. The main line of that indicator will be substracted from the other base class main line creating an oscillator
The usage is:
Class XXXOscillator(XXX, OscillatorMixIn)
- Formula:
XXX calculates lines[0]
osc = self.data - XXX.lines[0]
- plotlines = <backtrader.metabase.plotlines_obj object>¶
- __init__(*args, **kwargs)¶
- frompackages = ()¶
- packages = ()¶
- class backtrader.indicators.oscillator.Oscillator[source]¶
Bases:
IndicatorOscillation of given data around another data
- Datas:
This indicator can accept one or two data for the calculation.
If one data is provided, it must be a complex “Lines” object (indicator) which also has “data”.Example: A moving average
The calculated oscillation will be that of the Moving Average (in the example) around the data that was used for the average calculation
If two data are provided, the calculated oscillation will be that of the second data around the first data
- Formula:
1 data -> osc = data.data - data
2 datas -> osc = data0 - data1
- plotlines = <backtrader.metabase.plotlines_obj object>¶
- __init__(*args, **kwargs)¶
- frompackages = ()¶
- packages = ()¶
- class backtrader.indicators.oscillator.AdaptiveMovingAverageOscillator¶
Bases:
AdaptiveMovingAverage,OscillatorMixInOscillation of a AdaptiveMovingAverage around its data
- alias = ['AdaptiveMovingAverageOsc', 'KAMAOscillator', 'KAMAOsc', 'MovingAverageAdaptiveOscillator', 'MovingAverageAdaptiveOsc']¶
- frompackages = ()¶
- packages = ()¶
- class backtrader.indicators.oscillator.DicksonMovingAverageOscillator¶
Bases:
DicksonMovingAverage,OscillatorMixInOscillation of a DicksonMovingAverage around its data
- alias = ['DicksonMovingAverageOsc', 'DMAOscillator', 'DMAOsc', 'DicksonMAOscillator', 'DicksonMAOsc']¶
- frompackages = ()¶
- packages = ()¶
- class backtrader.indicators.oscillator.DoubleExponentialMovingAverageOscillator¶
Bases:
DoubleExponentialMovingAverage,OscillatorMixInOscillation of a DoubleExponentialMovingAverage around its data
- alias = ['DoubleExponentialMovingAverageOsc', 'DEMAOscillator', 'DEMAOsc', 'MovingAverageDoubleExponentialOscillator', 'MovingAverageDoubleExponentialOsc']¶
- frompackages = ()¶
- packages = ()¶
- class backtrader.indicators.oscillator.ExponentialMovingAverageOscillator¶
Bases:
ExponentialMovingAverage,OscillatorMixInOscillation of a ExponentialMovingAverage around its data
- alias = ['ExponentialMovingAverageOsc', 'EMAOscillator', 'EMAOsc', 'MovingAverageExponentialOscillator', 'MovingAverageExponentialOsc']¶
- frompackages = ()¶
- packages = ()¶
- class backtrader.indicators.oscillator.HullMovingAverageOscillator¶
Bases:
HullMovingAverage,OscillatorMixInOscillation of a HullMovingAverage around its data
- alias = ['HullMovingAverageOsc', 'HMAOscillator', 'HMAOsc', 'HullMAOscillator', 'HullMAOsc']¶
- frompackages = ()¶
- packages = ()¶
- class backtrader.indicators.oscillator.MovingAverageSimpleOscillator¶
Bases:
MovingAverageSimple,OscillatorMixInOscillation of a MovingAverageSimple around its data
- alias = ['MovingAverageSimpleOsc', 'SMAOscillator', 'SMAOsc', 'SimpleMovingAverageOscillator', 'SimpleMovingAverageOsc']¶
- frompackages = ()¶
- packages = ()¶
- class backtrader.indicators.oscillator.SmoothedMovingAverageOscillator¶
Bases:
SmoothedMovingAverage,OscillatorMixInOscillation of a SmoothedMovingAverage around its data
- alias = ['SmoothedMovingAverageOsc', 'SMMAOscillator', 'SMMAOsc', 'WilderMAOscillator', 'WilderMAOsc', 'MovingAverageSmoothedOscillator', 'MovingAverageSmoothedOsc', 'MovingAverageWilderOscillator', 'MovingAverageWilderOsc', 'ModifiedMovingAverageOscillator', 'ModifiedMovingAverageOsc']¶
- frompackages = ()¶
- packages = ()¶
- class backtrader.indicators.oscillator.TripleExponentialMovingAverageOscillator¶
Bases:
TripleExponentialMovingAverage,OscillatorMixInOscillation of a TripleExponentialMovingAverage around its data
- alias = ['TripleExponentialMovingAverageOsc', 'TEMAOscillator', 'TEMAOsc', 'MovingAverageTripleExponentialOscillator', 'MovingAverageTripleExponentialOsc']¶
- frompackages = ()¶
- packages = ()¶
- class backtrader.indicators.oscillator.WeightedMovingAverageOscillator¶
Bases:
WeightedMovingAverage,OscillatorMixInOscillation of a WeightedMovingAverage around its data
- alias = ['WeightedMovingAverageOsc', 'WMAOscillator', 'WMAOsc', 'MovingAverageWeightedOscillator', 'MovingAverageWeightedOsc']¶
- frompackages = ()¶
- packages = ()¶
- class backtrader.indicators.oscillator.ZeroLagExponentialMovingAverageOscillator¶
Bases:
ZeroLagExponentialMovingAverage,OscillatorMixInOscillation of a ZeroLagExponentialMovingAverage around its data
- alias = ['ZeroLagExponentialMovingAverageOsc', 'ZLEMAOscillator', 'ZLEMAOsc', 'ZeroLagEmaOscillator', 'ZeroLagEmaOsc']¶
- frompackages = ()¶
- packages = ()¶
- class backtrader.indicators.oscillator.ZeroLagIndicatorOscillator¶
Bases:
ZeroLagIndicator,OscillatorMixInOscillation of a ZeroLagIndicator around its data
- alias = ['ZeroLagIndicatorOsc', 'ZLIndicatorOscillator', 'ZLIndicatorOsc', 'ZLIndOscillator', 'ZLIndOsc', 'ECOscillator', 'ECOsc', 'ErrorCorrectingOscillator', 'ErrorCorrectingOsc']¶
- frompackages = ()¶
- packages = ()¶
- backtrader.indicators.oscillator.newcls¶
alias of
DicksonMovingAverageOscillator