Strategy won't calculate until open of next Data2 bar
Posted: Sep 02 2013
I've reported this problem 3 years ago and worked around it at the time. This is a very fundamental yet commonly encountered problem I cannot understand why after all these years it is still here.
What it is:
- The calculation of studies in MC happens at the open of "next bar" which is what it should be no problem here.
- However, if a strategy has any references to more than one data series, the whole strategy won't calculate until a new bar *of that series* is created. For example if a strategy has referenced Data2 the whole strategy won't calculate until there is a new Data2 bar created.
- That means if Data1 has a session end time of 15:15 and Data2 has a session end time of 15:00, the whole study won't calculate from 15:00-15:15 *everyday* in real-time trading until the next morning when there is a new Data2 bar created.
- Under back-testing this happens only on the last session end on chart because we have a new Data2 bar at every session end in *historical* back-testing except for the last session on chart. However in real time this is a daily problem and a very serious one! The strategy simply stops calculating until the next day!!!
- This creates a huge problem when we have multiple data series on a chart because many times we have different session end time among those data series.
- On TS the implementation is correct and we don't have this problem. Not so on MC. I've attached screenshots for both TS and MC.
I have provided with sample data and code and screen shot for TSS to reproduce this problem. Which is very straight forward to reproduce:
Data1: ES future 1 min intraday day session with session end time 15:00
Data2: S&P 500 index 1 min intraday session with session end time 15:15
Strategy Code:
if date data2 <> date[1] data2 then buy this bar close;
if time >= 1505 then sell this bar close;
What to expect:
- On the last session on chart the strategy won't sell at 1505 because no new Data2 bar has been created and the strategy stopped calculating since 1500
What it should be:
- The strategy should continue to calculate since there is still new data bars creating on Data1!!!
IMHO this is a very high priority bug as it affects *basic calculations* whenever the study uses more than 1 data series with different session end time!!! I'm totally surprised this bug is still here since I have reported it in full detail since MC 5.5 or 6.0.
What it is:
- The calculation of studies in MC happens at the open of "next bar" which is what it should be no problem here.
- However, if a strategy has any references to more than one data series, the whole strategy won't calculate until a new bar *of that series* is created. For example if a strategy has referenced Data2 the whole strategy won't calculate until there is a new Data2 bar created.
- That means if Data1 has a session end time of 15:15 and Data2 has a session end time of 15:00, the whole study won't calculate from 15:00-15:15 *everyday* in real-time trading until the next morning when there is a new Data2 bar created.
- Under back-testing this happens only on the last session end on chart because we have a new Data2 bar at every session end in *historical* back-testing except for the last session on chart. However in real time this is a daily problem and a very serious one! The strategy simply stops calculating until the next day!!!
- This creates a huge problem when we have multiple data series on a chart because many times we have different session end time among those data series.
- On TS the implementation is correct and we don't have this problem. Not so on MC. I've attached screenshots for both TS and MC.
I have provided with sample data and code and screen shot for TSS to reproduce this problem. Which is very straight forward to reproduce:
Data1: ES future 1 min intraday day session with session end time 15:00
Data2: S&P 500 index 1 min intraday session with session end time 15:15
Strategy Code:
if date data2 <> date[1] data2 then buy this bar close;
if time >= 1505 then sell this bar close;
What to expect:
- On the last session on chart the strategy won't sell at 1505 because no new Data2 bar has been created and the strategy stopped calculating since 1500
What it should be:
- The strategy should continue to calculate since there is still new data bars creating on Data1!!!
IMHO this is a very high priority bug as it affects *basic calculations* whenever the study uses more than 1 data series with different session end time!!! I'm totally surprised this bug is still here since I have reported it in full detail since MC 5.5 or 6.0.