If you don't do Sleep, you often get a situation where the history has not had time to update after OrderClose and OrderCommission returns a value as if OrderClose has not been done.
Note that this is a script and there can't be any Event-overs. The only way out is a dumb Sleep.
If you rewrite this script with SB, nothing will change.
// 13.11.2016: // Add: Полная синхронизация OrderSend, OrderModify, OrderClose, OrderDelete с торговым окружением (реал-тайм и история) - как в MT4. // Максимальное время синхронизации можно задать через MT4ORDERS::OrderSend_MaxPause в мкс. Среднее время синхронизации в MT5 ~1 мс.
Practice shows that Sleep(1) is enough in the vast majority of cases.
In general, it is quite strange to receive a response from OrderSend about a changed trading environment, when this changed environment itself cannot be read yet.
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.
I guess an example like this is illustrative.
If you don't do Sleep, you often get a situation where the history has not had time to update after OrderClose and OrderCommission returns a value as if OrderClose has not been done.
Note that this is a script and there can't be any Event-overs. The only way out is a dumb Sleep.
If you rewrite this script with SB, nothing will change.
Don't confuse MT4 with MT5
This and MT5
That and MT5
There is no such thing in MT5.
They work completely differently.
There is no such thing in MT5.
They work completely differently.
Forum on trading, automated trading systems and strategy testing
Libraries: MT4Orders
fxsaber, 2016.11.14 13:33
// Add: Полная синхронизация OrderSend, OrderModify, OrderClose, OrderDelete с торговым окружением (реал-тайм и история) - как в MT4.
// Максимальное время синхронизации можно задать через MT4ORDERS::OrderSend_MaxPause в мкс. Среднее время синхронизации в MT5 ~1 мс.
Based on the above, should Sleep(1) be set after each trade?
No, the synchronization time is floating. See
Practice shows that Sleep(1) is enough in the vast majority of cases.
In general, it is quite strange to receive a response from OrderSend about a changed trading environment, when this changed environment itself cannot be read yet.
Practice shows that Sleep(1) is sufficient in the vast majority of cases.
Sometimes Sleep(0) is enough too. But there must be a working solution for all cases and for minimal waiting time.
Why should the developers have to fix the bug from "Mr. Balloon"?
and besides, there's OrderSendAsync().