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

Any guidance on when to use self. ?



  • Hi, I see some code in strategy as follows:

    def __init__(self):
        # To control operation entries
        self.orderid = None
    
        # Create SMA on 2nd data
        sma = btind.MovAv.SMA(self.data1, period=self.p.period)
        # Create a CrossOver Signal from close an moving average
        self.signal = btind.CrossOver(self.data1.close, sma)
    

    I wonder why the sma isn't prefixed by self. while signal is. Is there any guidance tell us when to use self or not?



  • When to use self is a general python coding issues and you can google or youtube it to learn it's application. If you get stuck after that let us know.



  • Got it. I misunderstood something stupidly.


Log in to reply
 

});