Features of the mql5 language, subtleties and tricks - page 100
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
Such a slip can take tens of milliseconds.
Such a slip can run for tens of milliseconds.
What does it mean?
I remember a long time ago Sleep() was mentioned in paralleling processes
What does that mean?
Exactly what he said.
Such a slip can run for tens of milliseconds.
Not tens, but 15.625 milliseconds.
I have been using the construction for a long time:
Not tens, but 15.625 milliseconds.
I have been using the design for a long time:
Result
Result
Calculate the average time.
Accumulate SleepTime, and divide it by the number of iterations after the loop ends.
Otherwise, the presented result looks scary to immature minds. Show me the minimum time while you're at it.
PS. The Sleep() function in MQL5 is not a redirect to the win api function ::Sleep(). Well, if the value is less than 100 it's a redirect. But above 100 it is a loop with win api slip inside, so that it can be interrupted by IsStopped.
And there is one more nuance. At value of milliseconds <=0 we substitute 1. That is, we never call ::Sleep(0).
PPS import the Sleep function from kernel32.dll and do the same experiment with it
Calculate the average time.
Accumulate SleepTime, and divide it by the number of iterations after the cycle ends.
I was not talking about the average time, but about the possibility of spikes. I encountered them when waiting for the trading history to be synchronized with the OrderSend result. I was waiting for it through Sleep(0). It turned out that it cannot be done that way.
PS. The Sleep() function in MQL5 is not a redirect to the win api function ::Sleep(). Well, if the value is less than 100, this is a redirect. But above 100 it is a loop with win api slip inside, so that it can be interrupted by IsStopped.
And there is one more nuance. At value of milliseconds <=0 we substitute 1. That is, we never call ::Sleep(0).
Thank you for the details. I didn't know that Sleep(5000) can be terminated through IsStopped().
It was not about the average time, but about the possibility of spikes. I encountered them while waiting for the trading history to be synchronized with the OrderSend result. I was waiting via Sleep(0). It turned out that it cannot be done that way.
fxsaber:
Thanks for the details. I didn't know that Sleep(5000) can be broken via IsStopped().
https://www.mql5.com/ru/docs/common/sleep
The function has a built-in check for the status of the Expert Advisor stop flag every 0.1 second.
So the Windows operating system has never been a real-time system
To be honest, I don't even know what it means and where in MQL5 you can encounter it.