1. Функция GetTickCount не может быть использована для точного определения маленьких интервалов. Вы можете получить 0 мс, 16 мс, 1034 мс... Но от 1 до 14 мс Вы не получите никогда. Особенности архитектуры.
2. Функция Sleep работает не совсем так, как многие думают. На самом деле система гарантирует, что Sleep(1) займет НЕ МЕНЬШЕ 1ms, а верхний предел не лимитируется. (цитата из статьи "То, что вам никто не говорил о многозадачности в Windows")
3. Функция Sleep в клиентском терминале работает с грануляцией 100 мс, для того чтобы нельзя было завесить советника.
1. Function GetTickCount cannot be used for exact detection of small intervals. You may get 0 ms, 16 ms, 1034 ms, etc. However, you will never get 1-14 ms. This is due to architecture properties.
2. Function Sleep works in a bit different way than many people think. Indeed, the system guarantees that Sleep(1) will take AS MUCH AS 1ms, whereas the upper limit is not specified. (Quoted from the article "То, что вам никто не говорил о многозадачности в Windows" in Russian, translated into English by myself, sorry. This may sound like 'What You Have Never Been Told about Multitasking in Windows')
3. Function Sleep in the client terminal works with granulation of 100 ms in order one not to be able to hang the Expert Advisor.

- Бесплатные приложения для трейдинга
- 8 000+ сигналов для копирования
- Экономические новости для анализа финансовых рынков
Вы принимаете политику сайта и условия использования
I found the Sleep() function does not work exactly as expected.
See the table for test results. The test is to Sleep() from 0 to 99 milliseconds and use GetTickCount() to see how long the sleep lasted.
Results might vary with different PC hardware.
Conclusions:
This is probably OS and/or hardware limitation.
Sleep() occurs on a hit/miss fashion on 16millisecond boundaries
Don't rely on Sleep() to be exact, and don't rely on values less than 16 milliseconds.
Test code to collect data:
The script takes a few minutes to run, monitor progress (0-99) in the terminal