backtrader.indicators.aroon module¶
Aroon Indicator Module - Aroon trend indicator.
This module provides the Aroon indicator developed by Tushar Chande in 1995 to identify trend strength and direction.
- Classes:
_AroonBase: Base class for Aroon indicators. AroonUp: Aroon Up component. AroonDown: Aroon Down component. AroonUpDown: Combined Aroon Up and Down (alias: AroonIndicator). AroonOscillator: Aroon Oscillator (alias: AroonOsc). AroonUpDownOscillator: Combined AroonUpDown and Oscillator (alias: AroonUpDownOsc).
Example
- class MyStrategy(bt.Strategy):
- def __init__(self):
self.aroon = bt.indicators.AroonUpDown(self.data, period=14)
- def next(self):
- if self.aroon.aroonup[0] > self.aroon.aroondown[0]:
self.buy()
- elif self.aroon.aroonup[0] < self.aroon.aroondown[0]:
self.sell()
- class backtrader.indicators.aroon.AroonUp[source]¶
Bases:
_AroonBaseThis is the AroonUp from the indicator AroonUpDown developed by Tushar Chande in 1995.
- Formula:
up = 100 * (period - distance to the highest high) / period
Note
The lines oscillate between 0 and 100. That means that the “distance” to the last highest or lowest must go from 0 to period so that the formula can yield 0 and 100.
Hence, the lookback period is period + 1, because the current bar is also taken into account. And therefore, this indicator needs an effective lookback period of period + 1.
- __init__(*args, **kwargs)¶
- next()[source]¶
Calculate Aroon Up for the current bar.
Copies the up value from the parent calculation.
- frompackages = ()¶
- packages = ()¶
- class backtrader.indicators.aroon.AroonDown[source]¶
Bases:
_AroonBaseThis is the AroonDown from the indicator AroonUpDown developed by Tushar Chande in 1995.
- Formula:
down = 100 * (period - distance to the lowest low) / period
Note
The lines oscillate between 0 and 100. That means that the “distance” to the last highest or lowest must go from 0 to period so that the formula can yield 0 and 100.
Hence, the lookback period is period + 1, because the current bar is also taken into account. And therefore, this indicator needs an effective lookback period of period + 1.
- __init__(*args, **kwargs)¶
- next()[source]¶
Calculate Aroon Down for the current bar.
Copies the down value from the parent calculation.
- frompackages = ()¶
- packages = ()¶
- class backtrader.indicators.aroon.AroonUpDown[source]¶
-
Developed by Tushar Chande in 1995.
It tries to determine if a trend exists or not by calculating how far away within a given period the last highs/lows are (AroonUp/AroonDown)
- Formula:
up = 100 * (period - distance to the highest high) / period
down = 100 * (period - distance to the lowest low) / period
Note
The lines oscillate between 0 and 100. That means that the “distance” to the last highest or lowest must go from 0 to period so that the formula can yield 0 and 100.
Hence, the lookback period is period + 1, because the current bar is also taken into account. And therefore, this indicator needs an effective lookback period of period + 1.
- alias = ('AroonIndicator',)¶
- frompackages = ()¶
- packages = ()¶
- class backtrader.indicators.aroon.AroonOscillator[source]¶
Bases:
_AroonBaseIt is a variation of the AroonUpDown indicator which shows the current difference between the AroonUp and AroonDown value, trying to present a visualization which indicates which is stronger (greater than 0 -> AroonUp and less than 0 -> AroonDown)
- Formula:
aroonosc = aroonup - aroondown
- See:
- alias = ('AroonOsc',)¶
- __init__(*args, **kwargs)¶
- once(start, end)[source]¶
Calculate Aroon Oscillator in runonce mode.
Computes oscillator as difference of up and down values.
- frompackages = ()¶
- packages = ()¶
- class backtrader.indicators.aroon.AroonUpDownOscillator[source]¶
Bases:
AroonUpDown,AroonOscillatorPresents together the indicators AroonUpDown and AroonOsc
- Formula:
(None uses the aforementioned indicators)
- See:
- alias = ('AroonUpDownOsc',)¶
- frompackages = ()¶
- packages = ()¶