How to count 30sec after bool flag=true
Hi, I just want to ask for your useful idea.
If flag becomes true, I just want to count 30sec,
After 30sec, then I want to delete object.
I tried to use Sleep(30000), but this sleep time stop other program in EA, so I don't want to use it.
Do you have any good idea ?
Hi,
you can use the OnTimer() function
https://docs.mql4.com/eventfunctions/eventsettimer
- docs.mql4.com
After 30sec, then I want to delete object.
When you set the flag, remember the time. On a new tick, compute the duration.
Hi,
you can use the OnTimer() function
https://docs.mql4.com/eventfunctions/eventsettimer
Thank you!
I will study OnTimer function.
If you are not using the timer for other things then you can do this:
bool flag; if (some event occure && !flag) { flag=true; EventSetTimer(30); } void OnTimer() { ObjectDelete( 0, "OBJECTA" ); EventKillTimer(); }
Hi, I just want to ask for your useful idea.
If flag becomes true, I just want to count 30sec,
After 30sec, then I want to delete object.
I tried to use Sleep(30000), but this sleep time stop other program in EA, so I don't want to use it.
Do you have any good idea ?