Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
5 registered members (AndrewAMD, Nymphodora, Quad, TipmyPip, Imhotep), 852 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Trading assets in different time zones #467106
07/16/17 01:05
07/16/17 01:05
Joined: Mar 2017
Posts: 65
G
Ger1 Offline OP
Junior Member
Ger1  Offline OP
Junior Member
G

Joined: Mar 2017
Posts: 65
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)
Re: Trading assets in different time zones [Re: Ger1] #467126
07/17/17 09:53
07/17/17 09:53
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
I can at least imagine why you got a problem with that:

if(hour(0) < hour(1)) ....

When you have a daily time frame, hour(0) is _always_ identical to hour(1) _unless_ your asset had by chance some gaps in the price data, so that the previous day ended at a different hour. With daily time frames, I would use dow() for checking a day change, or set TimeFrame=1 before the day change detection.

I'll check the other problem also. Theoretically, you can use even a daily bar period for trading assets from 2 different time zones when you use the EntryDelay in live trading for delaying the trade entry until the markets open.

Re: Trading assets in different time zones [Re: jcl] #467127
07/17/17 10:19
07/17/17 10:19
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
I can not confirm the UK100 problem here. Maybe somethign wrong with your UK100 data? You can test the AssetZone this way:

Code:
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;
	if(frame(0))
		printf("\n%s %s",Asset,strdate(YMDHMS));
}



Moderated by  Petra 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1