Gamestudio Links
Zorro Links
Newest Posts
Purchase A8 full licence version
by ukgamer. 04/29/26 18:09
Z9 getting Error 058
by k_ivan. 04/25/26 19:13
ZorroGPT
by TipmyPip. 04/25/26 16:09
Stooq now requires an API key
by jcl. 04/13/26 09:42
Strange "Alien" Skull created with >Knubber<
by NeoDumont. 04/10/26 18:58
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
1 registered members (Quad), 5,707 guests, and 72 spiders.
Key: Admin, Global Mod, Mod
Newest Members
ukgamer, valino, juergenwue, VladMak, Geir
19210 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Help with hour() function #447533
12/19/14 02:15
12/19/14 02:15
Joined: Apr 2014
Posts: 482
Sydney, Australia
B
boatman Offline OP
Senior Member
boatman  Offline OP
Senior Member
B

Joined: Apr 2014
Posts: 482
Sydney, Australia
I'm trying to test a simple price action strategy that I read about on another forum. I seem to be having trouble with the hour() function. Specifically, I want to close all open trades on Friday afternoon, and I used the scrip from the Tips and Hacks section of the manual.

Oddly, Zorro never evaluates to true the comparison if(dow()==5 and hour()>=17). It does however evaluate the comparison if(dow()==5) as I would expect.

Any suggestions as to what I could be doing wrong? Full script below:

Code:
function run()
{
	BarPeriod = 1440;
	LookBack = 100;
	
	TimeFrame = 5; //weekly bars
	bool W1;
	if (priceOpen(1) < priceClose(1)) //previous bar was an up bar
		W1 = true;
	else W1 = false;
	
	TimeFrame = 20; //monthly bars
	bool M1;
	if (priceOpen(1) < priceClose(1)) //previous bar was an up bar
		M1 = true;
	else M1 = false;
	
	TimeFrame = 1;
	
	Lots = 1;
			
	if (W1 == true and M1 == true and priceOpen(1) > priceClose(1) and NumOpenLong < 1) { //monthly and weekly bars are up, daily bar is down
		Stop = 2*ATR(20);
		Trail = 2*ATR(20);
		TakeProfit = 5*ATR(20);
		TrailLock = 25;
		Entry = priceHigh(1);
		enterLong();
	}	
	
	if (W1 == false and M1 == false and priceOpen(1) < priceClose(1) and NumOpenShort < 1) { //monthly and weekly bars are down, daily bar is up
		Stop = 2*ATR(20);
		Trail = 2*ATR(20);
		TakeProfit = 5*ATR(20);
		TrailLock = 25;
		Entry = priceLow(1);
		enterShort();
	}
	
	if(dow() == 5 and hour() >= 17) 
	{   
		exitLong("*"); 
		exitShort("*"); 
	}
	
}


Last edited by boatman; 12/19/14 02:17.
Re: Help with hour() function [Re: boatman] #447534
12/19/14 03:54
12/19/14 03:54
Joined: Sep 2013
Posts: 504
California
G
GPEngine Offline
User
GPEngine  Offline
User
G

Joined: Sep 2013
Posts: 504
California
BarPeriod = 1440;
BarOffset = 0; (default)

Therefore with every iteration of run(), hour() == 0.

See for yourself by
function run() {
printf("\n%d", hour());

To get that kind of fidelity, you have to use a finer BarPeriod.

Re: Help with hour() function [Re: GPEngine] #447535
12/19/14 05:14
12/19/14 05:14
Joined: Apr 2014
Posts: 482
Sydney, Australia
B
boatman Offline OP
Senior Member
boatman  Offline OP
Senior Member
B

Joined: Apr 2014
Posts: 482
Sydney, Australia
Thanks GPEgnine, that makes perfect sense. Much appreciated.


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