How to plot two indicators on the same subplot?
-
Hi,
In backtrader indicators can be plot in separate subplots if set
subplot=True
like this:sma10 = bt.indicators.MovingAverageSimple(self.datas[0].close, period=10, subplot=True) sma20 = bt.indicators.MovingAverageSimple(self.datas[0].close, period=20, subplot=True)
They are shown on two separated subplots. If I want to place both SMAs on the same sub-plot (not with the data), so that I can see sma10 cross sma20, how can I code it? I read through the manual but did not find a way to specify which subplot an indicator to go. Can you please help? Thank you!
-
Docs - Plotting - Option:
plotmaster
-
@backtrader said in How to plot two indicators on the same subplot?:
Docs - Plotting - Option:
plotmaster
Cool. This works!
Just a suggestion. Backtrader plots are based on matplotlib, while it may be better to be interactive plots for analyzing, such as plot.ly or bokeh. There is a 3rd-party add-on based on bokeh https://github.com/verybadsoldier/backtrader_plotting , but it's kind of buggy (at least for plotmaster). In the long term, maybe backtrader can consider migrate to bokeh or other interactive plotting library?