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

Possible bug when using LinePlotterIndicator

  • When I use the bt.LinePlotterIndicator the Strategy starts executing later than the period defined in params. I think that when we add the bt.LinePlotterIndicator, backtrader multiply by 2 the bars needed to start executing the strategy.

    My code is:

    class SMACloseSignal(bt.SignalStrategy):
        params = (('period', 30),)
        def __init__(self):
            signal = bt.indicators.CrossOver(, bt.indicators.SMA(period=self.p.period))
            self.signal_add(bt.SIGNAL_LONG, signal)
            signal_to_plot = - bt.indicators.SMA(period=self.p.period)
            bt.LinePlotterIndicator(signal_to_plot, name='SMAsignal')

  • @Rubén-Briones I am noticing a similar issue. Were you able to figure out a solution to this problem.

  • Hi @Rubén-Briones , @sksuram

    Did either of you haven any luck with this? I also think I'm having a similar issue whereby I get a 'IndexError: array assignment index out of range' exception raised from


Log in to reply