Developing an Indicator
-
Use the link below to go the original post
Click here to see the full blog post
-
We have new MyTrix indicator. How can we call self.lines.trix in "def next" now?
If I try " print(self.lines.trix[0])" then:
AttributeError: 'Lines_LineSeries_LineIterator_DataAccessor_Strateg' object has no attribute 'trix' -
That error message shows that your defined line is not named
trix
, hence the error.Or else you mean the strategy's
next
in which you obviously have to go over the variable in which you have stored the reference to the indicator.But with so few details not much can be said
-
@backtrader said in Developing an Indicator:
That error message shows that your defined line is not named trix, hence the error.
Or else you mean the strategy's next in which you obviously have to go over the variable in which you have stored the reference to the indicator.I have MyTric.py and stretegy with imported MyTrix. Now I want to use self.lines.trix in this strategy. How can i do it? This line plot's on figure, but I don't understend how to get it's values.
-
Suggestion: read the Docs - Quickstart Access an comparison is done several times with a Simple Moving Average
- You store the created indicator in a variable:
self.myvar = bt.ind.Trix(...)
- You access the values:
self.myvar[0]
which automates the process of doingself.myvar.lines.trix[0]
- You store the created indicator in a variable: