For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

Predefined signal which compares previous values



  • I have coded a signal, is there any way to compare previous values sticking to self.signal_enter in init?
    I get error IndexError: array index out of range

    def __init__(self, **kwargs):
         self.st = bt.ind.Stochastic(self.data, period=14, period_dfast=3, period_dslow=3)
         self.signal_enter = self.st.percK[-2] > self.st.percD[-3]
    
    def next(self):
        if self.signal_enter:
           self.buy()
    

Log in to reply
 

});