Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/18/24 10:45
StartWeek not working as it should
by Zheka. 04/18/24 10:11
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (SBGuy), 712 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Using BarZone vs lhour with timezone #475829
01/09/19 09:00
01/09/19 09:00
Joined: Feb 2017
Posts: 369
D
Dalla Offline OP
Senior Member
Dalla  Offline OP
Senior Member
D

Joined: Feb 2017
Posts: 369
I'm a bit puzzled as to the behavior of lhour() I'm seeing with the below two snippets.
The manual says:
"Closing local hour of the given bar in the given time zone (see timeOffset below), considering daylight saving time (see dst below). F.i. lhour(EST) returns the current hour at the New York Stock Exchange. If BarZone is set to the local zone, lhour() is identical to hour()."

Here we pass JST as timezone to lhour()
Code:
void run() {
	set(LOGFILE);
	int timezone = JST;
	//BarZone = JST;
	BarPeriod = 15;
   StartDate = 2010;
   EndDate = 2019;
	asset("USD/JPY");
	
	if(lhour(timezone) == 10 && minute() == 00) {
		enterShort();
	}
	if(lhour(timezone) == 12 && minute() == 30) {
		exitShort();
	}
}



Here instead we use BarZone, which if I understand correctly would set the zone of all bars to JST, meaning hour should return identical values to the code above.
Code:
void run() {
	set(LOGFILE);
	//int timezone = JST;
	BarZone = JST;
	BarPeriod = 15;
   StartDate = 2010;
   EndDate = 2019;
	asset("USD/JPY");
	
	if(hour() == 10 && minute() == 00) {
		enterShort();
	}
	if(hour() == 12 && minute() == 30) {
		exitShort();
	}
}



However these two snippets result in totally different backtests.
Did I missunderstand for BarZone vs lhour() works?

Re: Using BarZone vs lhour with timezone [Re: Dalla] #475835
01/09/19 19:21
01/09/19 19:21
Joined: Sep 2003
Posts: 929
Spirit Offline

Moderator
Spirit  Offline

Moderator

Joined: Sep 2003
Posts: 929
I thought hour() is UTC. You could print the hour and lhour to the log for checking.


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