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 ()?



  • Has anyone found a way to turn off the 5 lines associated with LineCoupler when charting?

    I have used Bollinger Bands at data1 = 1min coupled to data0 = 5secs. this works fine, but I want to be able to see the boll bands shown in red, but I do not want to see the 5 line couplers on the chart.

    Image

    Ideas on how to hide them?



  • TURNING OFF PLOTTING 'LINESCOUPLER'

    Once you have lines coupled, but you do not want to show the lines when plotting, turn them off using this:

    #data0 = lower timeframe
    #data1 = higher timeframe
    
    
    def __init__():
         #data1 Bollinger Bands
         self.boll = bb_lc = bt.indicators.BollingerBands(self.data1, period=self.p.bbperiod, devfactor=self.p.devfactor, plot=True)
    
         #Line Coupling used on Bollinger Bands
         bb_lc1 = bb_lc()
    
         #Turn off plotting of LinesCoupler
         bb_lc1.plotinfo.plot = False
    

    More options on plotting:
    https://www.backtrader.com/docu/plotting/plotting/


Log in to reply
 

});