Trading hours

 

Hello everyone,

Could anybody help me to find info about how to set trading hours. For example no trade before 7AM and no trade after 8PM.

Thank you very much in advance!

Best regards

Patrick

 
Patrick00069:

Hello everyone,

Could anybody help me to find info about how to set trading hours. For example no trade before 7AM and no trade after 8PM.

Thank you very much in advance!

Best regards

Patrick

Try something like this (MQL5):

MqlDateTime dateTimeNowUtc;
TimeGMT(dateTimeNowUtc);
if (dateTimeNowUtc.hour>=7 && dateTimeNowUtc.hour<=20) {
    // do trade operations
}
else {
    // close any open positions but no other trade operations
}

 - Patrick

 
Pix:

Try something like this (MQL5):

 - Patrick

Thanks a lot man!
 
Pix:

Try something like this (MQL5):

 - Patrick

Thankyou for sharing maybe useful not for only ts but all people

I am still not use mt5 now whether this codebase also can used on mt4 platform and how to use it
Reason: