There is no need to write if(bool) (do true) else (do false) if (Use_Friday_Close && DayOfWeek()==5 && currentTime>=fridayCloseTime) { return true; } else { return false; }
Just write (do bool) return Use_Friday_Close && DayOfWeek()==5 && currentTime>=fridayCloseTime;
You would never write if( (2+2 == 4) == true) would you? if(2+2 == 4) is sufficient. So Don't write if(bool == true), just use if(bool) or if(!bool). Code becomes self documenting when you use meaningful variable names, like bool isLongEnabled. Long_Entry sounds like a trigger price or a ticket number and "if long entry" is an incomplete sentence.
xbut it also does not trade from 0:00 - 03:00 friday morning. Then it is not suppoed to open any orders before after monday start trading (11:30) - But it does trade from 00:00 - 03:00, after that it waits to 11:30 Also we do not want it to trade in mornings from 9:00 to 11:30,Too complicated to understand, to complicated to code.if ((currentTime<pauseStartTime || currentTime>=pauseEndTime) && (DayOfWeek()!=0) && (DayOfWeek()!=5 || currentTime<fridayStopTime) && (DayOfWeek()!=1 || currentTime>=mondayStartTime)) { return true; } else { return false; }
Simplify if (DayOfWeek()==0) return false; // Not Sunday if (DayOfWeek()==5 && currentTime > fridayStopTime) return false; // Late Friday if (DayOfWeek()==1 && currentTime < mondayStartTime) return false; // Early Monday return currentTime <= pauseStartTime || currentTime >= pauseEndTime; // good except pauseTime. }
Thanks.
I will try that, but I had to make a small shange, just if any body else has same question.
if (DayOfWeek()==0) return false; // Not Sunday if (DayOfWeek()==5 && currentTime > fridayStopTime) return false; // Late Friday if (DayOfWeek()==1 && currentTime < mondayStartTime) return false; // Early Monday return currentTime <= pauseStartTime || currentTime >= pauseEndTime; // good except pauseTime. }
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
I have a good MT4 EA, but the timefilter does not work as supposed.
We want it to stop trade at friday evening, and close all orders late friday evening. - This does work correctly, - but it also does not trade from 0:00 - 03:00 friday morning.
Then it is not suppoed to open any orders before after monday start trading (11:30) - But it does trade from 00:00 - 03:00, after that it waits to 11:30
Also we do not want it to trade in mornings from 9:00 to 11:30, which works perfectly.
Broker is Tickmill
Can anyone please help to see my mistake in coding.
if(CloseDeals())CloseAllPositions("Close All Now");
int start() { if(GoodTime()== true) { //Trading code