For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
How to change the index of indicator to the opposite ?
-
if we use code:
self.sma = bt.indicators.MovingAverageSimple(data, period)
self.sma[0] --> current bar
self.sma[-1] --> last one barBut, I want it:
self.sma[0] --> current bar
self.sma[1] --> last one bar
Is there any other way besides the function ? -
@MuSaCN said in How to change the index of indicator to the opposite ?:
Is there any other way besides the function ?
I don't know which "function" you may be referring to, because there is no such function.
But if you want to change the semantics of backtrader about what's the past and what's the future, you should consider using something else.
The semantics were chosen to stay as close as possible to the semantics of "last" in Python (i.e.:
-1
) and have a pivot point around0
(Python has no notion of a pivot for an array)