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/

    Wish to plot LineBuffer object in the main figure

    General Code/Help
    1
    1
    60
    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.
    • F
      fanpeix last edited by

      I need to plot self.U and self.D in the main figure, here is the code

              # 指标计算
              self.HH = bt.ind.Highest(self.high, period=self.p.period, subplot=False, plot=False)     # N日high的最高价
              self.LC = bt.ind.Lowest(self.close, period=self.p.period, subplot=False, plot=False)     # N日close的最低价
              self.HC = bt.ind.Highest(self.close, period=self.p.period, subplot=False, plot=False)    # N日close的最高价
              self.LL = bt.ind.Lowest(self.low, period=self.p.period, subplot=False, plot=False)       # N日low的最低价
              self.range = bt.ind.Highest((self.HH - self.LC), (self.HC - self.LL), subplot=False, plot=False)
              self.U = self.open + self.p.upper_factor * self.range             # 上轨
              self.D = self.open - self.p.lower_factor * self.range            # 下轨
      
      
              # WISH TO PLOT THESE TWO OBJECTS!!
              self.U.plotinfo.plot = True
              self.D.plotinfo.plot = True
      
      
              # 计算突破
              self.crossover_up = bt.ind.CrossOver(self.close, self.lines.U, subplot=False, plot=False)
              self.crossover_dn = bt.ind.CrossOver(self.close, self.lines.D, subplot=False, plot=False)
      
      

      and it returned:

        File "C:/Users/Administrator/PycharmProjects/backtrader_coin/strategies/dual_thrust.py", line 63, in __init__
          self.U.plotinfo.plot = True
      AttributeError: 'LinesOperation' object has no attribute 'plotinfo'
      

      how can I achieve that?

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