yarns90401:
What does this mean? How often will the code run?
depends on the second parameter of the mathmod function\ timecurrent returns
the total number of seconds since 1970 , so by finding the reminder of the division
of the current time by the number of seconds you want the code to be activated
at , your problem will be solved , try it , the 17 means that the code will be
executed every 17 seconds
yarns90401:
The idea should be to ignore the code in the start procedure if it just ran in
the past n seconds. Does calling the sleep function prevent a subsequent tick move
prevent the start procedure from executing?
No more than one call to start() at a time. If there is another tick coming in
while current start() is still in process, the newer tick is ignored. So Sleep()-ing
will ignore all those ticks.
if(MathMod(TimeCurrent() , 17) ==0))// better to use a prime number 17,23,31 etc{YOURCODE}
Nice but may not work all the time. Suppose last tick as at t=16, and because it's
a slow day, the next one instead of at t=17, it comes at t=18. You'll miss one
whole cycle, and may be more.
if(MathMod(TimeCurrent() , 17) ==0))// better to use a prime number 17,23,31 etc{YOURCODE}
Nice but may not work all the time. Suppose last tick as at t=16, and because it's
a slow day, the next one instead of at t=17, it comes at t=18. You'll miss one
whole cycle, and may be more.
you are right, i realized that after i had posted it. however tthe second
solution is better . note that it skip ticks not seconds
fireflies: Probably you're right. But why do you want to keep a script running forever? Doesn't
EA do the job?
The script doesn't have to run forever, just until stopped (just like an EA) ,
an the question was: "Is there a way to run an EA every n seconds?" My
code does exactly this. Why would one need this? I don't know, maybe I misunderstood
something.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
What does this mean? How often will the code run?
depends on the second parameter of the mathmod function\ timecurrent returns the total number of seconds since 1970 , so by finding the reminder of the division of the current time by the number of seconds you want the code to be activated at , your problem will be solved , try it , the 17 means that the code will be executed every 17 seconds
OR
hope this is easier :)The idea should be to ignore the code in the start procedure if it just ran in the past n seconds. Does calling the sleep function prevent a subsequent tick move prevent the start procedure from executing?
you are right, i realized that after i had posted it. however tthe second solution is better . note that it skip ticks not seconds
Probably you're right. But why do you want to keep a script running forever? Doesn't EA do the job?