ATR and ADX indicators
Does backtrader have ADX & ATR indicators within? Or need to use TA-Lib?
ADX and ATR are in the
docs - indicators ref
Just as a side note: the
116in the version number is the total of built-in indicators.
TA-Libindicators are not included in that number, because it's an add-on which people may choose to use (or not)
Now, how would reference plusDI and Minus DI?
say I want a strategy ; when plusDI is > MinusDI and plusDI>20; Buy
how would i write this in backtrader, please?
minusDIare lines of the
DirectionalIndicator(probably the one meant instead of the
ADXwhich is the
There is a family of those indicators and which lines are provided by which is documented.
Just look for
How to access the lines of any object containing them is documented here:
Strategies that buy when going over a value and sell when going below another are usually documente with a moving average cross over or a moving average compared with the close price:
And with signals:
if self.mydi.lines.plusDi > self.mydi.lines.minusDI and ...: self.buy()
Thanks for the help,
I am also not clear about the difference between bt.indicators.ATR(self.data, period=14) and bt.indicators.ATR(self.data,period=14).
That's not a valid construct.
self.datagives you access to the current data point of
data(which is an alias to
data0) and at that point in time may break (will work with preloaded data, but will not work in many other circumstances)
That builds an
Another question, how is the latest bar/tick referenced; self.data.close or self.data[-1].close, is it not using python type indexing like first item of a series= series, last item=series[-1]?
basically i need latest bar>previous bar> previous bar
That's all in the link above: Docs - Platform Concepts
There is a section about indexing and how
0is the current point in time. Last is the last produced value before the current point in time and addressable with