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.

示例

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[源代码]

基类:Indicator

MixIn 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[源代码]

基类:Indicator

Oscillation 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

基类:AdaptiveMovingAverage, OscillatorMixIn

Oscillation of a AdaptiveMovingAverage around its data

alias = ['AdaptiveMovingAverageOsc', 'KAMAOscillator', 'KAMAOsc', 'MovingAverageAdaptiveOscillator', 'MovingAverageAdaptiveOsc']
frompackages = ()
packages = ()
class backtrader.indicators.oscillator.DicksonMovingAverageOscillator

基类:DicksonMovingAverage, OscillatorMixIn

Oscillation of a DicksonMovingAverage around its data

alias = ['DicksonMovingAverageOsc', 'DMAOscillator', 'DMAOsc', 'DicksonMAOscillator', 'DicksonMAOsc']
frompackages = ()
packages = ()
class backtrader.indicators.oscillator.DoubleExponentialMovingAverageOscillator

基类:DoubleExponentialMovingAverage, OscillatorMixIn

Oscillation of a DoubleExponentialMovingAverage around its data

alias = ['DoubleExponentialMovingAverageOsc', 'DEMAOscillator', 'DEMAOsc', 'MovingAverageDoubleExponentialOscillator', 'MovingAverageDoubleExponentialOsc']
frompackages = ()
packages = ()
class backtrader.indicators.oscillator.ExponentialMovingAverageOscillator

基类:ExponentialMovingAverage, OscillatorMixIn

Oscillation of a ExponentialMovingAverage around its data

alias = ['ExponentialMovingAverageOsc', 'EMAOscillator', 'EMAOsc', 'MovingAverageExponentialOscillator', 'MovingAverageExponentialOsc']
frompackages = ()
packages = ()
class backtrader.indicators.oscillator.HullMovingAverageOscillator

基类:HullMovingAverage, OscillatorMixIn

Oscillation of a HullMovingAverage around its data

alias = ['HullMovingAverageOsc', 'HMAOscillator', 'HMAOsc', 'HullMAOscillator', 'HullMAOsc']
frompackages = ()
packages = ()
class backtrader.indicators.oscillator.MovingAverageSimpleOscillator

基类:MovingAverageSimple, OscillatorMixIn

Oscillation of a MovingAverageSimple around its data

alias = ['MovingAverageSimpleOsc', 'SMAOscillator', 'SMAOsc', 'SimpleMovingAverageOscillator', 'SimpleMovingAverageOsc']
frompackages = ()
packages = ()
class backtrader.indicators.oscillator.SmoothedMovingAverageOscillator

基类:SmoothedMovingAverage, OscillatorMixIn

Oscillation 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

基类:TripleExponentialMovingAverage, OscillatorMixIn

Oscillation of a TripleExponentialMovingAverage around its data

alias = ['TripleExponentialMovingAverageOsc', 'TEMAOscillator', 'TEMAOsc', 'MovingAverageTripleExponentialOscillator', 'MovingAverageTripleExponentialOsc']
frompackages = ()
packages = ()
class backtrader.indicators.oscillator.WeightedMovingAverageOscillator

基类:WeightedMovingAverage, OscillatorMixIn

Oscillation of a WeightedMovingAverage around its data

alias = ['WeightedMovingAverageOsc', 'WMAOscillator', 'WMAOsc', 'MovingAverageWeightedOscillator', 'MovingAverageWeightedOsc']
frompackages = ()
packages = ()
class backtrader.indicators.oscillator.ZeroLagExponentialMovingAverageOscillator

基类:ZeroLagExponentialMovingAverage, OscillatorMixIn

Oscillation of a ZeroLagExponentialMovingAverage around its data

alias = ['ZeroLagExponentialMovingAverageOsc', 'ZLEMAOscillator', 'ZLEMAOsc', 'ZeroLagEmaOscillator', 'ZeroLagEmaOsc']
frompackages = ()
packages = ()
class backtrader.indicators.oscillator.ZeroLagIndicatorOscillator

基类:ZeroLagIndicator, OscillatorMixIn

Oscillation of a ZeroLagIndicator around its data

alias = ['ZeroLagIndicatorOsc', 'ZLIndicatorOscillator', 'ZLIndicatorOsc', 'ZLIndOscillator', 'ZLIndOsc', 'ECOscillator', 'ECOsc', 'ErrorCorrectingOscillator', 'ErrorCorrectingOsc']
frompackages = ()
packages = ()
backtrader.indicators.oscillator.newcls

DicksonMovingAverageOscillator 的别名