For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
Solution to Plotting Issue Regarding Indicator with Single Price Line Input
-
Re: LinesCoupler is plotted on different figure when passing line instead of data to SMA indicator
Although I did try to implement a custom plotter using
plotly
in order to solve the problem as I believed that it was caused by the default plottermatplotlib
, I finally realized that the problem is caused by providing a price line as an input to the indicator.The final
__init__
method shall look like the following.def __init__(self): self.sma = sma = btind.SMA(self.data1.open) # use open price liz sma.plotinfo.plot = True # show plotting if self.p.multi: self.sma1 = sma() # couple the entire indicators ''' By providing only a price line to the indicator, the clock of the `LinesCoupler` object `self.sma1` won't be updated, it shall be set manually. ''' self.sma1._clock = self.data0 self.sellsignal = self.data0.close < self.sma1.sma else: self.sellsignal = self.data0.close < sma.sma()