I want to ask, how I can implement a function for starting a timer after a certain condition like
If buyCondition is true, then wait excactly 60 or defined seconds and check the buycondition again after the seconds are over.
I used in my code function like TimeSeconds(TimeCurrent()) which provides me the exact seconds, but how can I compare it with the current time.
For instance, if the seconds, where the buyCondition is true is 15 seconds, and normally I have to add this to the current time and compare this with
TimeCurrent(). How can I do this in Mql4?
Thanks for your help.
When your buy condition is true:
From within OnTimer(), kill the timer and check again for the buy condition
// now check your buy logic again
static datetime timer;
static bool buyCondition;
bool wasCondition = buyCondition; buyCondition = ...;
if(buyCondition && !wasCondition) timer = TimeCurrent();
if(TimeCurrent() - timer >= 60) CheckAgain();
To add comments, please log in or register