When the OrderSend() returns -1 and sets _LastError, OrderManager::send() uses GetLastError(), sends Alert() and returns -1. This leaves no clue about the error to the caller. For example, I may want to repeat send() in case of context lock, or maybe I should abort due to server problems. Since GetLastError() effectively resets _LastError, this deprives the calling function of knowing the error.
The reason is this. Say we have two experts on different charts. If they try to issue orders simultaneously one of them would receive ERR_TRADE_CONTEXT_BUSY error and would have to retry. But if the expert gets ERR_ACCOUNT_DISABLED error, it would have to stop trading at all. Using OrderManager as is doesn't allow to distinguish the trading behavour.
The proposed solutions:
1) Mql::getLastError() should memorize the last error, or;
2) return the error code with negative sign as the output of send(), modify() etc., or
3) introduce own error handling with similar to GetLastError() semantics.
When the
OrderSend()
returns -1 and sets_LastError
,OrderManager::send()
usesGetLastError()
, sendsAlert()
and returns -1. This leaves no clue about the error to the caller. For example, I may want to repeatsend()
in case of context lock, or maybe I should abort due to server problems. SinceGetLastError()
effectively resets_LastError
, this deprives the calling function of knowing the error.The reason is this. Say we have two experts on different charts. If they try to issue orders simultaneously one of them would receive ERR_TRADE_CONTEXT_BUSY error and would have to retry. But if the expert gets ERR_ACCOUNT_DISABLED error, it would have to stop trading at all. Using
OrderManager
as is doesn't allow to distinguish the trading behavour.The proposed solutions: 1)
Mql::getLastError()
should memorize the last error, or; 2) return the error code with negative sign as the output ofsend()
,modify()
etc., or 3) introduce own error handling with similar toGetLastError()
semantics.Any thoughts?