Hi,

as certain CFDs can only be traded during specific market hours I am trying to set up AssetFrame accordingly.
I am aware that there are various posts on this forum as well as instructions in the manual, but so far I have not been able to figure out how this can be coded up in Zorro.

Using:

// trade two assets with different time zones
BarPeriod = 60;
FrameOffset = 9; // trade both assets at 9:00 of their local time
while(asset(loop("NAS100","UK100"))){
if(strstr(Asset,"NAS100"))
AssetZone = ET;
else if(strstr(Asset,"UK100"))
AssetZone = WET;
TimeFrame = AssetFrame; ...}

This did not work for UK100 - AssetFrame did not just skip the bars for the previous day but for a whole week (AssetFrame returned around -100).




Further I tried to create daily bars. This works fine with TimeFrame = frameSync(24) but not with

static int BarsPerDay = 0;


if(hour(0) < hour(1)) { // day change
TimeFrame = -BarsPerDay; // end the frame
BarsPerDay = 0;
} else {
TimeFrame = 0; // inside the frame
BarsPerDay++; // count number of bars per day
}

Looking into it I saw that hour(0) and hour(1) return the same figure after one day (in attached script 20170606 to 20170607 work fine BUT from 20170607 onwards hour(1) and hour(0) return the same number). Due to this no new Frame is created anymore.

The manual states that when multiple time frames are used, the offset is multiplied with TimeFrame. This would explain why after one day (offset*TimeFrame = 0) for both "hour" functions the same is returned. However, so far I could see this behaviour only on "NAS100" and "UK100".


Could anyone please shed some light on this ?

Thanks!

Attached Files
timeframe.c (4 downloads)