For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
Disable plotting backtrader.indicator.PivotPoint
-
Hi,
I'm having issue with disabling the plot for the PivotPoint. Despite parsing "plot=False", the end result still plotting.
class MyStrat(bt.Strategy): params = dict( pivot_algo=bt.indicators.PivotPoint, ) def __init__(self): self.pivot = collections.defaultdict(dict) self.inds = collections.defaultdict(dict) # Decouple datas # First half is the daily, second half is monthly total_data = len(self.datas) self.daily = self.datas[:total_data//2] self.monthly = self.datas[total_data//2:] for d in self.monthly: self.pivot[d] = self.p.pivot_algo(d, plot=False, plotvaluetags=False, plotlinevalues=False)
my main:
cerebro = bt.Cerebro() # cerebro engine data = bt.feeds.GenericCSVData( dataname="stk_database/AIRASIA_5099_historical.csv", fromdate=begin_date, openinterest=-1, ) cerebro.adddata(data) cerebro.resampledata(data, timeframe=bt.TimeFrame.Months).plotinfo.plot = False #cerebro.broker.set_cash(1000) cerebro.addstrategy(MyStrat) # Add the trading strategy #cerebro.addsizer(TestStake) #cerebro.broker.addcommissioninfo(CommInfoStock()) print(f"Starting value is {cerebro.broker.getvalue()} with cash of {cerebro.broker.getcash()}") results = cerebro.run() # run it all print(f"Final value is {cerebro.broker.getvalue()} with cash of {cerebro.broker.getcash()}") cerebro.plot(style="candlestick")
Result:
I also tried with plotinfo.plot=False on the indicator, seems to give same result.
Thank you in advance.
-
Did you try this?
The indicator will try to automatically plo to the non-resampled data. To disable this behavior use the following during construction:
_autoplot=False