@fino said in Multi timeframe indicator plotted twice and in the timeframe:
The current implementation of this indicator does not works: it has these two problems:
Sorry, but it does work.
@fino said in Multi timeframe indicator plotted twice and in the timeframe:
- both the H1 and the D1 charts are shown. I only want the H1 chart.
You have not told the system that you only want the H1
chart. It cannot be a problem. You have not configured things to work the way you want.
See - Docs - Plotting and use plotinfo.plot=False
for whatever you don't want plotted.
@fino said in Multi timeframe indicator plotted twice and in the timeframe:
- the indicator shows the right values in the D1 chart, but it is not plotted in the H1 chart
@fino said in Multi timeframe indicator plotted twice and in the timeframe:
data_h1 = bt.feeds.GenericCSVData(**{**csv_opts, **h1_opts})
data_d1 = bt.feeds.GenericCSVData(**{**csv_opts, **d1_opts})
@fino said in Multi timeframe indicator plotted twice and in the timeframe:
self.levels = Levels(self.data1, period=self.p.period)
Well, you load d1
as the second feed in the system (hence self.data1
) and you apply the indicator to self.data1
. It should be no surprise that the indicator plots on d1
and not on h1
. It would be a surprise if it did otherwise.
Again. See - Docs - Plotting and use plotinfo.plotmaster=YOUR_DESIRED_DATA
to plot on your chosen target.
@fino said in Multi timeframe indicator plotted twice and in the timeframe:
See? No indicator in the H1 chart and a superfluous D1 chart.
See above. There is nothing superfluous. You have to configure what you want and what you don't want and where you want it and where you don't want it.
@fino said in Multi timeframe indicator plotted twice and in the timeframe:
As you can see in the following code, at the top level I first load the H1 data and then the D1 data. . This should make H1 the default data source, right?
No idea what you mean with "default data source". There is no such thing in backtrader. The only thing you have achieved is that h1
can be referred as self.data0
or self.datas[0]
or self.data
. This is described here: Docs - Strategy in the section Member Attributes
@fino said in Multi timeframe indicator plotted twice and in the timeframe:
Then, in the strategy, I set up the indicator to use self.data1. This should link its calculations to the D1 timeframe, shouldn't it?
Yes. And that's why the indicator obviously plots on d1