Navigation

    Backtrader Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

    Possible bug when using LinePlotterIndicator

    Indicators/Strategies/Analyzers
    3
    3
    162
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Rubén Briones
      Rubén Briones last edited by Rubén Briones

      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(self.data, bt.indicators.SMA(period=self.p.period))
              self.signal_add(bt.SIGNAL_LONG, signal)
      
              signal_to_plot = self.data - bt.indicators.SMA(period=self.p.period)
              bt.LinePlotterIndicator(signal_to_plot, name='SMAsignal')
      
      1 Reply Last reply Reply Quote 0
      • S
        sksuram last edited by

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

        1 Reply Last reply Reply Quote 0
        • R
          ratulb last edited by

          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 linebuffer.py

          Thanks

          1 Reply Last reply Reply Quote 0
          • 1 / 1
          • First post
            Last post
          Copyright © 2016, 2017, 2018, 2019, 2020, 2021 NodeBB Forums | Contributors