For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See:
2019-10-02: The community is currently in read-only mode

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')

Log in to reply