Trading only certain times of day

Posted By: bfleming

Trading only certain times of day - 12/03/13 15:21

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!
Posted By: jcl

Re: Trading only certain times of day - 12/03/13 16:24

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) ...
Posted By: bfleming

Re: Trading only certain times of day - 12/03/13 16:46

ah, ok. thanks!
Posted By: Mangal

Re: Trading only certain times of day - 03/07/15 09:32

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.
Posted By: yosoytrader

Re: Trading only certain times of day - 03/07/15 13:31

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;
Posted By: Mangal

Re: Trading only certain times of day - 03/09/15 12:37

Thank you Yosoy.
© 2024 lite-C Forums