Gamestudio Links
Zorro Links
Newest Posts
Alternative to Stooq for Zorro S
by Petra. 10/14/26 07:04
ZorroGPT
by TipmyPip. 10/13/26 17:08
Stooq now requires an API key
by cwford. 10/08/26 23:27
Purchase A8 full licence version
by jcl. 10/05/26 12:12
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
0 registered members (), 25,118 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
JimSimons, julienp, julienper, KelleyAbbey, Yopachi
19246 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: 938
Spirit Offline

Moderator
Spirit  Offline

Moderator

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


Moderated by  Petra 

Gamestudio download | 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