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