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

about line coupling with out ()



  • Hi. In my test case, I have the following code

    self.isover = self.move_average > self.move_average2( )
    

    where move_average's timeframe is day, move_average2's timeframe is week.

    if I use the following code and run my strategy, I get the same result as above. So I wonder if we can ommit ( ) after move_average2?

    self.isover = self.move_average > self.move_average2
    


  • I am asking this becasue the document says in Lines coupling, we should use ( ) notation after the larger timeframe indicator, sma1(), see below. But my test shows that if I omit ( ),that is using sma1, I get same result. Is there something wrong with my result?

    class MyStrategy(bt.Strategy):
    params = dict(period=20)

    def __init__(self):
    
        # data0 is a daily data
        sma0 = btind.SMA(self.data0, period=15)  # 15 days sma
        # data1 is a weekly data
        sma1 = btind.SMA(self.data1, period=5)  # 5 weeks sma
    
        self.buysig = sma0 > sma1()
    
    def next(self):
        if self.buysig[0]:
            print('daily sma is greater than weekly sma1')


  • I would follow docs. Do you have a strong reason to omit ()?


Log in to reply
 

});