next() method indicator help
In the docs when talking about the next method and indicator use. It has two examples.
1.) close_over_sma = self.data.close > self.sma
2.) close_over_sma = self.data.close > self.sma
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 6443.9 >>> len(self.sma) 10 >>> self.sma 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?
@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
100in any case. That's the future and it only works because you are working with preloaded data (which speeds up things). The
datadoes only tell you how many actual points have been processed by the system for the backtesting so far.
It's not about
py-fooabilities, 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