how to limit trading times

 

How do I get my ea to only trade during the New York Session? GMT 0800 to 1600

How do I display GMT on my chart?

 
mrchuckw :

How do I get my ea to only trade during the New York Session? GMT 0800 to 1600

How do I display GMT on my chart?

At the beginning of the start() function check the time, if it is not within the NY session return(0);

You chart shows the timezone the Broker chooses, want a different timezone ? use a different Broker.

 
Trading during certain times, what a can of worms that is. When seasonal clock changes (and arbitrary broker server time changes) in historic data are not obvious, it makes developing and back-testing of an EA that trades action around the open of an index (for example), no fun whatsoever. So much time is spent getting accurate data and then ensuring your testing accurately against it, it can be a nightmare!
 
mrchuckw : How do I get my ea to only trade during the New York Session? GMT 0800 to 1600
Server time to GMT. Filter. See Why is there NO Complete EA within the Code-Base? - MQL4 forum
 
RaptorUK :

At the beginning of the start() function check the time, if it is not within the NY session return(0);

You chart shows the timezone the Broker chooses, want a different timezone ? use a different Broker.


"At the beginning of the start() function check the time, if it is not within the NY session return(0);"

exactly what i want to do, but dont know how> here is code I have tried. (my broker is 3 hours ahead o gmt... broker time is 22 then gmt is 17)

this code showed always < 12 and did not trade.

int time.h = Hour();
   if((time.h-3) < 12) reprt = "Before trading time"; return;
   if((time.h-3) > 19) reprt =  "After trading time"; return;
   reprt = "Managing trades";
 
mrchuckw :


"At the beginning of the start() function check the time, if it is not within the NY session return(0);"

exactly what i want to do, but dont know how> here is code I have tried. (my broker is 3 hours ahead o gmt... broker time is 22 then gmt is 17)

this code showed always < 12 and did not trade.

Are you running this live or in the Strategy Tester ? I seem to recall other users having issues with functions like Hour() in the Strategy Tester, instead use TimeHour ( TimeCurrent() )
 
RaptorUK :
Are you running this live or in the Strategy Tester ? I seem to recall other users having issues with functions like Hour() in the Strategy Tester, instead use TimeHour ( TimeCurrent() )


live on a demo account