For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
Has anyone got LinePlotterIndicator to work?
-
I have read through the docs and tried every permutation I can think of but so far have not been able to get the LinePlotterIndicator to display on the Plot.
In the example below, data1, self.r5 and self.s5 all display on the plot but there is nothing from the AboveBelow indicator
Indicator Definition
# Indicator that displays whether the data source is above or below certain thresholds class AboveBelow(bt.Indicator): lines = ('above', 'below') params = (('above', 80), ('below', 20)) plotinfo = dict( # Simplify the y scale to 1 and 0 (for true, false) plotyticks=[1, 0]) plotlines = dict(above=dict(color='g'), below=dict(color='b') def __init__(self): above = self.data > self.p.above below = self.data < self.p.below # incorrect per the docs self.l.above = above # first attempt - Doesn't work bt.LinePlotterIndicator(above, name='Above') # second attempt - Doesn't work self.l.above = bt.LinePlotterIndicator(above, name='Above')
Strategy Definition
class St(bt.Strategy): def __init__(self): self.r5 = btind.RSI(self.data1, plotname='rsi_5M') self.s5 = StochasticRSI(self.r5, plotname='sto_5M') self.abovebelow = AboveBelow(self.s5.K, above=80, below=20) self.r5.plotinfo.plot = True self.s5.plotinfo.plot = True self.data1.plotinfo.plot = True
Run Strategy
cerebro = bt.Cerebro() cerebro.addstrategy(St, printlog=True) cerebro.adddata(data) cerebro.resampledata(data, timeframe=bt.TimeFrame.Minutes, compression=5, boundoff=1) cerebro.run(runonce=False) cerebro.plot(iplot=False, style='bar')
-
See the answer and corresponding question in your other thread: Community - Unable to get LinePlotterIndicator to display