2222 unicode_literals )
2323
2424import backtrader as bt
25- from . import SMA
26- from . import AO
25+ from . import MovAv , AwesomeOscillator
26+
27+
28+ __all__ = ['AccelerationDecelerationOscillator' , 'AccDeOsc' ]
2729
2830
2931class AccelerationDecelerationOscillator (bt .Indicator ):
3032 '''
31- Acceleration/Deceleration Technical Indicator (AC) measures acceleration and
32- deceleration of the current driving force. This indicator will change
33+ Acceleration/Deceleration Technical Indicator (AC) measures acceleration
34+ and deceleration of the current driving force. This indicator will change
3335 direction before any changes in the driving force, which, it its turn, will
3436 change its direction before the price.
3537
3638 Formula:
37- - MEDIAN PRICE = (HIGH + LOW) / 2
38- - AO = SMA (MEDIAN PRICE, 5) - SMA (MEDIAN PRICE, 34)
39- - AC = AO - SMA (AO, 5)
39+ - AcdDecOsc = AwesomeOscillator - SMA(AwesomeOscillator, period)
4040
4141 See:
4242 - https://www.metatrader5.com/en/terminal/help/indicators/bw_indicators/ao
4343 - https://www.ifcmarkets.com/en/ntx-indicators/ntx-indicators-accelerator-decelerator-oscillator
4444
4545 '''
46- alias = ('AC' , )
47- lines = ('ac ' , )
46+ alias = ('AccDeOsc' , )
47+ lines = ('accde ' , )
4848
49- plotlines = dict (ac = dict (_method = 'bar' ))
49+ params = (
50+ ('period' , 5 ),
51+ ('movav' , MovAv .SMA ),
52+ )
5053
51- def __init__ ( self ):
54+ plotlines = dict ( accde = dict ( _method = 'bar' , alpha = 0.50 , width = 1.0 ))
5255
53- ao = AO ()
54- #self.l.ac = ao - SMA(ao, 5)
55- self .l .ac = ao - SMA (ao , period = 5 )
56+ def __init__ (self ):
57+ ao = AwesomeOscillator ()
58+ self .l .accde = ao - self .p .movav (ao , period = self .p .period )
59+ super (AccelerationDecelerationOscillator , self ).__init__ ()
0 commit comments