next() method indicator help
-
In the docs when talking about the next method and indicator use. It has two examples.
https://www.backtrader.com/docu/induse.html1.) close_over_sma = self.data.close > self.sma
2.) close_over_sma = self.data.close[0] > self.sma[0]in the second example is I set a breakpoint on the line and inspect it. self.sma has strange behavior.
>>> self.sma <backtrader.indicators.sma.SimpleMovingAverage object at 0x7f1c74ac2d30> >>> self.sma[0] 6443.9 >>> len(self.sma) 10 >>> self.sma[100] 6442.0 >>> self.sma[-1] 6444.1 >>> for i in range(0, len(self.sma)): print(self.sma[i]) 6443.9 6444.3 6444.8 6443.9 6446.9 6450.2 6453.5 6454.1 6454.8 6452.2
Can some explain to me what is going on? This doesn't make sense to me. Also I need to find when RSI goes overbought oversold and comes back. If anyone knows how?
-
@deedcoin said in next() method indicator help:
self.sma has strange behavior.
You may want to let us know what you find strange ... and how you run things and ...
-
@backtrader I'm not used to being able to get the 100th item in a list when the length is only 10. That's weird to me. Maybe you're py-foo is stronger than mine.
-
You shouldn't be addressing
100
in any case. That's the future and it only works because you are working with preloaded data (which speeds up things). Thelen
of thedata
does only tell you how many actual points have been processed by the system for the backtesting so far.It's not about
py-foo
abilities, it has to do with documentation:- Docs - Platform Concepts - Section: Indexing: 0 and -1*
- Docs - Cerebro and see the available execution options
A data feed in backtrader is not a
Dataframe
.