Hi,
Is there an example of a multi timeframe strategy anywhere? Or a description of how to do this in MC .Net?
I’ve found a lot of examples of how to do it in std MC, but none for .Net.
Any assistance greatly appreciated.
Thanks and regards,
drolles
multi timeframe strategy?
Re: multi timeframe strategy?
Hi drolles,
Can you maybe elaborate what part you don't understand? It is just a matter of adding in multiple data streams and then using BarsOfData() to access your various timeframes within the code.
All my best,
MK
Can you maybe elaborate what part you don't understand? It is just a matter of adding in multiple data streams and then using BarsOfData() to access your various timeframes within the code.
All my best,
MK
Re: multi timeframe strategy?
MidKnight,
Thanks very much for your reply. I appreciate you stepping in – I love these forums when the users collaborate.
My post a suggestion and a question.
Firstly, the suggestion; was that there should be an introductory example of this.
Secondly, the question; (which you have in part answered – thank you) was how it is recommended to be done by the MC team?
Thanks for the suggestion of BarsOfData(). That’s good news as it is the conclusion that I’ve come to.
The scenario is: If I want to use timebased bars; I want to signal at a higher timeframe (e.g. 1 hour) and trade (including backtest) at a lower timeframe (1 min). If I want to signal to do this I’m assuming I need to filter for the appropriate timeframe? Therefore, I’m wondering what value I filter on the Object tree via the IInstrument interface? In OpenQuant you would filter via the following: if (Bar.Size == 60) as Size is defined as the seconds of the Bar.
I’ve found Resolution which doesn’t seem right as I inspected it via VS and it returns 1 with Resolution.Size … 1 what?
Thanks and regards,
drolles
Thanks very much for your reply. I appreciate you stepping in – I love these forums when the users collaborate.
My post a suggestion and a question.
Firstly, the suggestion; was that there should be an introductory example of this.
Secondly, the question; (which you have in part answered – thank you) was how it is recommended to be done by the MC team?
Thanks for the suggestion of BarsOfData(). That’s good news as it is the conclusion that I’ve come to.
The scenario is: If I want to use timebased bars; I want to signal at a higher timeframe (e.g. 1 hour) and trade (including backtest) at a lower timeframe (1 min). If I want to signal to do this I’m assuming I need to filter for the appropriate timeframe? Therefore, I’m wondering what value I filter on the Object tree via the IInstrument interface? In OpenQuant you would filter via the following: if (Bar.Size == 60) as Size is defined as the seconds of the Bar.
I’ve found Resolution which doesn’t seem right as I inspected it via VS and it returns 1 with Resolution.Size … 1 what?
Thanks and regards,
drolles
Re: multi timeframe strategy?
Hi there drolles,
I'm not really sure I understand your query correctly yet. Following on from your example where you have two timeframes that you want to reference in your code. If you create the chart with the 1 minute data and then add another instrument, which will be the same instrument but as 60 minute data. In the format instruments window I'd set the 60 minute data to hidden just to keep the chart clean, but this isn't required and you may want to leave it on for a while to make sure your code is doing what you expect it to.
Then in the code, anytime you reference Bars.Close[0], it would be referring to the 1 minute series. Anytime you reference BarsOfData(2).Close[0] it would be referring to the 60 minute series. The order that you have added the data onto the chart matters. The format instruments window shows each data series on the chart and its respective data stream ID number.
Does that help? I'm sorry if I'm not understanding your query properly...
With kind regards,
MK
I'm not really sure I understand your query correctly yet. Following on from your example where you have two timeframes that you want to reference in your code. If you create the chart with the 1 minute data and then add another instrument, which will be the same instrument but as 60 minute data. In the format instruments window I'd set the 60 minute data to hidden just to keep the chart clean, but this isn't required and you may want to leave it on for a while to make sure your code is doing what you expect it to.
Then in the code, anytime you reference Bars.Close[0], it would be referring to the 1 minute series. Anytime you reference BarsOfData(2).Close[0] it would be referring to the 60 minute series. The order that you have added the data onto the chart matters. The format instruments window shows each data series on the chart and its respective data stream ID number.
Does that help? I'm sorry if I'm not understanding your query properly...
With kind regards,
MK
Re: multi timeframe strategy?
Hi MidKnight,
Thanks very much for the reply.
My starting assumption is that you don't know timeframe is in the data order, which is the usual assumption you make in OpenQuant as you don't know (when you have multiple instruments) when the events are going to fire to fire the OnBar event.
You explanation has possibly helped. How is the data referenced when in the Portfolio Backtester? For instance, if I have the instruments configured as I have in this screen shot, will both instruments 1 min data always be Data1?
Thanks,
drolles
Thanks very much for the reply.
My starting assumption is that you don't know timeframe is in the data order, which is the usual assumption you make in OpenQuant as you don't know (when you have multiple instruments) when the events are going to fire to fire the OnBar event.
You explanation has possibly helped. How is the data referenced when in the Portfolio Backtester? For instance, if I have the instruments configured as I have in this screen shot, will both instruments 1 min data always be Data1?
Thanks,
drolles
- Attachments
-
- Portfolio Backtester shot.JPG
- (94.11 KiB) Downloaded 2754 times
Re: multi timeframe strategy?
MC.net isn't like that. AFAIK (and I may be wrong because I'm pretty new to MC), CalcBar() will fire on each new bar for your data1 series only. That is why you put your lowest timeframe into the data1 slot.My starting assumption is that you don't know timeframe is in the data order, which is the usual assumption you make in OpenQuant as you don't know (when you have multiple instruments) when the events are going to fire to fire the OnBar event.
You explanation has possibly helped. How is the data referenced when in the Portfolio Backtester? For instance, if I have the instruments configured as I have in this screen shot, will both instruments 1 min data always be Data1?
With regards to portfolio backtester, I've tried it a couple of times and it crashed on me so have not yet revisited it and cannot offer any advice on that subject - sorry.
With kind regards,
MK
- Henry MultiСharts
- Posts: 9165
- Joined: 25 Aug 2011
- Has thanked: 1264 times
- Been thanked: 2957 times
Re: multi timeframe strategy?
Hello drolles,
MidKnight's explanations are correct.
Your trading resolution should be the main data series (Data1 in Format Instruments window).
Then you need to add second data series (subchart, dataN) with XXX resolution.
In the script the calculation can be based on the subchartN (data seriesN) with the help of BarsOfData.
In MultiCharts the second data series is added using Format tab->Instrument->Add.
In Poftfolio Backtester the second data series is added using the vertical Data columns.
On your screenshot the setup is correct. 1min data series is the main(trading) dataseries, 1hour is data2 and can be used for reference in the code.
MidKnight's explanations are correct.
Your trading resolution should be the main data series (Data1 in Format Instruments window).
Then you need to add second data series (subchart, dataN) with XXX resolution.
In the script the calculation can be based on the subchartN (data seriesN) with the help of BarsOfData.
In MultiCharts the second data series is added using Format tab->Instrument->Add.
In Poftfolio Backtester the second data series is added using the vertical Data columns.
On your screenshot the setup is correct. 1min data series is the main(trading) dataseries, 1hour is data2 and can be used for reference in the code.
- Henry MultiСharts
- Posts: 9165
- Joined: 25 Aug 2011
- Has thanked: 1264 times
- Been thanked: 2957 times
Re: multi timeframe strategy?
MidKnight, please update to MC .Net 8.1 beta 1 and let me know if you still have the issue.With regards to portfolio backtester, I've tried it a couple of times and it crashed on me so have not yet revisited it and cannot offer any advice on that subject - sorry.
Re: multi timeframe strategy?
Hi
I agree with MidKnight,
Do you know if the indicator of Data2, will be updated every minute in CalcBar() of Data1
even if Data2 are 1 hour resolution ?
I am not sure about that
I agree with MidKnight,
We have to use data1 series only, I agree,CalcBar() will fire on each new bar for your data1 series only. That is why you put your lowest timeframe into the data1 slot.
Do you know if the indicator of Data2, will be updated every minute in CalcBar() of Data1
even if Data2 are 1 hour resolution ?
I am not sure about that
- Henry MultiСharts
- Posts: 9165
- Joined: 25 Aug 2011
- Has thanked: 1264 times
- Been thanked: 2957 times
Re: multi timeframe strategy?
Hello Emmanuel,Do you know if the indicator of Data2, will be updated every minute in CalcBar() of Data1 even if Data2 are 1 hour resolution ?
Please provide more detailed description of this inquiry.
Also attach a workspace and sample script so that we can check it in our environment.
Re: multi timeframe strategy?
Hi,
Thanks again all for the responses.
If CalcBar() only fires for how do you signal from a higher timeframe to a lower one? E.g. if I have a Bollinger Band strategy that signals at a higher timeframe of 1 hour and I want to backtest on 1 min data to get a better simulation of fills?
Thanks,
drolles
Thanks again all for the responses.
If CalcBar() only fires for how do you signal from a higher timeframe to a lower one? E.g. if I have a Bollinger Band strategy that signals at a higher timeframe of 1 hour and I want to backtest on 1 min data to get a better simulation of fills?
Thanks,
drolles
- Henry MultiСharts
- Posts: 9165
- Joined: 25 Aug 2011
- Has thanked: 1264 times
- Been thanked: 2957 times
Re: multi timeframe strategy?
Hello drolles,
You can create a 1 hour chart for signal calculation and turn on 1 min Bar Magnifier.
Here is how signals are calculated.
You can create a 1 hour chart for signal calculation and turn on 1 min Bar Magnifier.
Here is how signals are calculated.