WBC
Use a function that has two sessions, eg this OTTOMH...
extern int StartHour.1 = 6; extern int EndHour.1 = 12; extern int StartHour.2 = 12; extern int EndHour.2 = 20; start() { //---- // Do stuff every tick //---- //---- if (TradingHours() == false) return (0); // Quit here if outside hours // Do stuff in your trading periods //---- } bool TradingHours() { //---- Check trading days/hours GMT if ((Hour()>= StartHour.1) && (Hour()<= EndHour.1) ) return (true); if ((Hour()>= StartHour.2) && (Hour() <= EndHour.2) ) return (true); return (false); }
extern int TradeHour.Start = 2; extern int TradeHour.Last = 11; ... int hrNow = Hour()+Server.Time.To.UTC +24)%24, hrBeg = (hrNow-TradeHour.Start+24)%24, hrEnd = (hrNow-TradeHour.Last +24)%24; if (hrBeg > hrEnd){ no.open = StringConcatenate(no.open, "|HR", hrBeg-24); openNow=false; }
Thanks for the replies guys. Will have a play and see if I can get it to do what I want!
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Been trying this all day but now just getting myself more and more confused. Say that I want my EA to stop trading from 8:00pm until 6:00am the following day, how would I go about this? I have code for finding the relative GMT offsets for the broker, local time, London, NY etc all working correctly so in what time zone the inputs are isn't a concern. I then wanted to use the function below from TimeSuite.mqh posted on this site (comments added are mine to help aid understanding). Let's assume I the times input are in GMT.
So I have the lines
In situations as above (8:00pm - 6:00am) how do I take into account that 6:00am would convert to be 'less than' 8:00pm once server time passed 00:00 and a new day started? Any and all help would be appreciated, going mad trying to do this.