Backtrader Community

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    1. Home
    2. cicidad
    For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
    C
    • Profile
    • Following 0
    • Followers 0
    • Topics 2
    • Posts 5
    • Best 1
    • Controversial 0
    • Groups 0

    cicidad

    @cicidad

    1
    Reputation
    1
    Profile views
    5
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    cicidad Unfollow Follow

    Best posts made by cicidad

    • RE: how to set the indicator data point value as nan

      I use this code implement it.

      self.lines.dummyline[0] = max(float('NaN'), float('NaN'))
      

      thanks.

      posted in Indicators/Strategies/Analyzers
      C
      cicidad

    Latest posts made by cicidad

    • RE: how to set the indicator data point value as nan

      I use this code implement it.

      self.lines.dummyline[0] = max(float('NaN'), float('NaN'))
      

      thanks.

      posted in Indicators/Strategies/Analyzers
      C
      cicidad
    • RE: How to draw a line between two points

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

      posted in Indicators/Strategies/Analyzers
      C
      cicidad
    • How to draw a line between two points

      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.

      posted in Indicators/Strategies/Analyzers
      C
      cicidad
    • RE: how to set the indicator data point value as nan

      how to initial a line object as NaN, only set some points had value

      posted in Indicators/Strategies/Analyzers
      C
      cicidad
    • how to set the indicator data point value as nan

      I want set the data point per 10 days, and connect the points, need set other data point value as NAN, hot to set it

      class DummyInd(bt.Indicator):
         lines = ('dummyline',)
         plotinfo = dict(subplot=False,_skipnan=False)
         params = (('value', 0),('period', 1),)
         count =0
         def __init__(self):
                 self.lines.dummyline = numpy.nan #error here, do not know how to set.
         def next(self):
             DummyInd.count +=1
             if DummyInd.count % 10==0:
                 self.lines.dummyline[0] = self.data.close[0]
      
      posted in Indicators/Strategies/Analyzers
      C
      cicidad