Only Trade Asian Session

 

Hello fellow traders and coders:

I was wondering if there was a way to program my EA so it only trades during the asian session (so Meta trader hours equal to 1:00 - 10:00). I'm trying to think how to use the TimeCurrent() function without much success as the TimeCurrent will constantly add up and it won't work to just say If (TimeCurrent()<1:00 && TimeCurrent()> 10:00). Could I just use the regular time function?

Help please, long time trader, new to programming

Thanks,

Pat

Chicago

 
FXpipclash wrote >>

Hello fellow traders and coders:

I was wondering if there was a way to program my EA so it only trades during the asian session (so Meta trader hours equal to 1:00 - 10:00). I'm trying to think how to use the TimeCurrent() function without much success as the TimeCurrent will constantly add up and it won't work to just say If (TimeCurrent()<1:00 && TimeCurrent()> 10:00). Could I just use the regular time function?

Help please, long time trader, new to programming

Thanks,

Pat

Chicago

I think this will work, you will need to set your time

if( Hour()>8 && Hour()<21){return(0);} this will return you to start outside of these hours, might want to limit iterations to new bar save a lot of cpu

HTW

Keith

 
Thanks Keith, i'll give it a shot
 
FXpipclash:
Thanks Keith, i'll give it a shot

I'll give this one up, this is my old EA month reset code, you can set hours based on TimeNow quite easily if you think about it:


TimeNow = (Day * 1440) + (Hour * 60) + Minute;


These days I don't just use a fixed day, for those trades that cross months but it will work for your purpose and most time functions thereafter.

 
kminler:

I think this will work, you will need to set your time

if( Hour()>8 && Hour()<21){return(0);} this will return you to start outside of these hours, might want to limit iterations to new bar save a lot of cpu

HTW

Keith

You need to make sure that you program the asian time trading based on your broker timeclock.