Backtrader Community

    • 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/

    How to draw a line between two points

    Indicators/Strategies/Analyzers
    1
    2
    421
    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.
    • C
      cicidad last edited by

      how to draw a line between two points, I set other points as NAN, then the lines cannot show,
      for these code:

      class DummyInd(bt.Indicator):
          lines = ('dummyline',)
          plotinfo = dict(subplot=False,_skipnan=True, plotforce=True, plotname='1stInd',plotymargin=0.1)
          params = (('period', 1),)
          count =0
          def __init__(self):
              self.lines.dummyline = bt.Max(float('NaN'), float('NaN'))
              super(DummyInd, self).__init__()
      
          def next(self):
              DummyInd.count +=1
              if DummyInd.count % 30==0:
                  self.lines.dummyline[0] = self.data.close[0]+1.5
                  print(self.lines.dummyline[0])
              else:
              #    self.lines.dummyline[0] = max(float('NaN'), float('NaN'))
                  self.lines.dummyline[0] = 10
      

      I get the picture as following:
      截屏2021-02-10 下午11.07.38.png
      I want get line as the green line.
      but when I use the following code , set other points as NAN, then will get nothing.

          def next(self):
              DummyInd.count +=1
              if DummyInd.count % 30==0:
                  self.lines.dummyline[0] = self.data.close[0]+1.5
                  print(self.lines.dummyline[0])
              else:
                  self.lines.dummyline[0] = max(float('NaN'), float('NaN'))
                  #self.lines.dummyline[0] = 10
      

      how to get the lines between 2 points.

      1 Reply Last reply Reply Quote 0
      • C
        cicidad last edited by

        from the document, We can see

        _skipnan (bool, default: False): to skip NaN values when plotting and allowing for example to draw a line between 2 distant points generated by an indicator, which has all intermediate values as NaN (default value for new created data points)

        I also set the value, but not take effect.
        How to draw a line between 2 distant points ????

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