I have a fully functioning EA, however I want to add a time of day trading filter so that the EA only trades within certain times of the day. I would also like to optimise this time function for best results.
Can some one on this forum please direct me to the section of code base that provides such code and or supply me with such so I can add it to my EA.
extern int StartTrade=X;
extern int StopTrade=Y;
if(Hour()>=StartTrade && Hour()<=StopTrade)
It is very basic but I still use it and it works fine. But you cannot use the code for over mid night. ie 11pm to 3am or 5pm to 2am. If you plan on keeping the times for the same trading day then it will work fine. You can also add in minutes and seconds for accuracy. :)
string StartTrade = "10:00"; // minutes
string StopTrade = "17:00:00"; // second
datetime now = TimeCurrent();
if(now >= StringToTime(StartTrade) && now < StringToTime(StopTrade)
To add comments, please log in or register