How can I limit my ea for certain hours of the day?

 

Hi

I want my ea to only open positions between 05:00 GMT to 17:00 GMT but to close them, if they are open and need to be closed, all the time. The idea is to avoid flat market, and assian session. Can this be done???

 
tznef:

Hi

I want my ea to only open positions between 05:00 GMT to 17:00 GMT but to close them, if they are open and need to be closed, all the time. The idea is to avoid flat market, and assian session. Can this be done???

It's an easy thing to do using TimeLocal() and OrdersTotal() functions. Read the documentation and book on this site they will teach you how to do it. It's not hard to do.

 
// bla bla bla

if(TimeHour(TimeCurrent())>5 && TimeHour(TimeCurrent())<17) 
   {
    ticket=OrderSend(Symbol(),OP_BUY.....);
   }
Also read the documentation :)
Reason: