Hey pre-made I have a expert advisor that automatically takes trades for me but i wanted it to only take trades between a certain time frame. Can someone tell me the line of code to add so i can have the EA start running at Time A and stop at Time B?. Also is there is a code to exclude some days of the week I'd also need help with that.
- need help EA adjustment
- Code to Average all the Previous Pending Orders and add with certain TakeProfit??
- MQL4 Code to Average all the Previous Pending Orders and add with certain TakeProfit??
extern int StartTime = 10; extern int EndTime = 22; extern int DaysNotToTrade = 1; //(0-Sunday,1,2,3,4,5,6) if (Hour() < StartTime) return(0); if (Hour() >= EndTime) return(0); if (DayOfWeek() == DaysNotToTrade) return(0);
Thanks Qjol!
if (Hour() < StartTime) return(0); if (Hour() >= EndTime) return(0);That only allows startTime<EndTime. If you wanted to start at 2200 and end at 0700 (just the Sydney market,) the code won't work. This does:
extern int TradeHr.UTC.Start = 7; // Tokyo open+2 extern int TradeHr.UTC.End = 14; // NY+8 #define DAYS_MAX 0x3F // 1<<6-1=63. (S-F) extern int Days.Mask = 22; // Mo/Tu/Th int Hr = TimeHour(now), DOW = TimeDayOfWeek(now), /* https://www.mql5.com/en/forum/127483 // reports DayOfWeek() always returns 5 in the tester. No refresh?*/ DayMask = 1 << DOW; if (Days.Mask & DayMask == 0){ rsn="|Day="+DOW; return;} int hrBeg = (Hr-TradeHr.UTC.Start +24)%24, hrEnd = (Hr-TradeHr.UTC.End +24)%24; if (hrBeg > hrEnd){ rsn="|HR"+(hrBeg-24); return;}
WHRoeder:
That only allows startTime<EndTime. If you wanted to start at 2200 and end at 0700 (just the Sydney market,) the code won't work. This does:
That only allows startTime<EndTime. If you wanted to start at 2200 and end at 0700 (just the Sydney market,) the code won't work. This does:
but he want between the hours of 2 a.m. - 11 a.m.
qjol:
but he want between the hours of 2 a.m. - 11 a.m.
The OP said but he want between the hours of 2 a.m. - 11 a.m.
EA start running at Time A and stop at Time B?.
No hours were given.
What i meant was i want the EA to be active during the hours of 0200 through 1100.

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