Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (dr_panther, TedMar, AndrewAMD), 1,353 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Trading only certain times of day #433620
12/03/13 15:21
12/03/13 15:21
Joined: Jul 2013
Posts: 110
B
bfleming Offline OP
Member
bfleming  Offline OP
Member
B

Joined: Jul 2013
Posts: 110
I want a strategy to only trade certain times of day. I've read through the relevant part of the manual, but I'm pretty sure I don't have the code right for only trading between say 17h and 8h, but this is what I have:

Code:
if(hour() >= 17 && hour() <=8){
   	if(crossUnder(Signal,-Threshold)) 
		reverseLong(1); 
	   else if(crossOver(Signal,Threshold)) 
		reverseShort(1);



Could someone help me get this correct?

Many thanks!

Re: Trading only certain times of day [Re: bfleming] #433631
12/03/13 16:24
12/03/13 16:24
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
If you want to trade in the evening after 17h or in the morning before 8h, you need an "or" condition:

if(hour() >= 17 or hour() <=8) ...

Re: Trading only certain times of day [Re: jcl] #433633
12/03/13 16:46
12/03/13 16:46
Joined: Jul 2013
Posts: 110
B
bfleming Offline OP
Member
bfleming  Offline OP
Member
B

Joined: Jul 2013
Posts: 110
ah, ok. thanks!

Re: Trading only certain times of day [Re: bfleming] #449189
03/07/15 09:32
03/07/15 09:32
Joined: Sep 2013
Posts: 73
M
Mangal Offline
Junior Member
Mangal  Offline
Junior Member
M

Joined: Sep 2013
Posts: 73
Can anyone tell me why it gives a syntax error the following:

if(hour()>=10EST and hour()<=17EST and....)

Even the following expresion gives a syntax error:

if(hour()>=10 and hour(0)<=17);

Just trying to trade at certain New York time window.

Re: Trading only certain times of day [Re: Mangal] #449193
03/07/15 13:31
03/07/15 13:31
Joined: Sep 2013
Posts: 64
Spain
yosoytrader Offline
Junior Member
yosoytrader  Offline
Junior Member

Joined: Sep 2013
Posts: 64
Spain
hour() returns an int, so EST has no sense here.
moreover in the second if statement, the instruction is missing: (f.i. x = 10)

if(hour()>=10 and hour(0)<=17)
X = 10;


Happy trading laugh
Re: Trading only certain times of day [Re: yosoytrader] #449230
03/09/15 12:37
03/09/15 12:37
Joined: Sep 2013
Posts: 73
M
Mangal Offline
Junior Member
Mangal  Offline
Junior Member
M

Joined: Sep 2013
Posts: 73
Thank you Yosoy.


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