@momentum said in indicator with dynamically changing data:
Do you mean instead of changing the data of the indicator, change the data feed itself?
No, I said that you create a data feed which dynamically changes the data it serves.
You fail to understand that the self.datas array in each object is a different one. This is obvious if you consider that you can do this
ma_on_ma = bt.ind.SMA(bt.ind.SMA(self.data, period=5), period=5)
The outer SMA has, obviously, only 1 data feed which happens to be another SMA (the inner one)
Futhermore, you expect things to use the array self.datas and you manipulate it with that expectation. As noted above, this is not supported, given that other notations and references are used in the internals.
Thank you for your answer.
I should have asked my question in a different way. I do know how to keep a reference in a class to a value but somehow it was not working in my code. Your answer opened my eyes: since I know how to program, the cause of error must have been somewhere else, not in the referencing method, so I could correct the code.