MQL4 Reference Constants, Enumerations and Structures Codes of Errors and Warnings Trade Server Return Codes
Trade Server Return Codes
GetLastError() - returns error codes. Error codes are defined in stderror.mqh. To print the error description you can use the ErrorDescription() function, defined in stdlib.mqh.
Example:
#include <stderror.mqh>
#include <stdlib.mqh>
void SendMyMessage(string text)
{
int check;
SendMail("Test", text);
check=GetLastError();
if(check!=ERR_NO_ERROR) Print("Message not sent. Error: ",ErrorDescription(check));
} |
|
|
|
0
|
ERR_NO_ERROR
|
No error returned
|
1
|
ERR_NO_RESULT
|
No error returned, but the result is unknown
|
2
|
ERR_COMMON_ERROR
|
Common error
|
3
|
ERR_INVALID_TRADE_PARAMETERS
|
Invalid trade parameters
|
4
|
ERR_SERVER_BUSY
|
Trade server is busy
|
5
|
ERR_OLD_VERSION
|
Old version of the client terminal
|
6
|
ERR_NO_CONNECTION
|
No connection with trade server
|
7
|
ERR_NOT_ENOUGH_RIGHTS
|
Not enough rights
|
8
|
ERR_TOO_FREQUENT_REQUESTS
|
Too frequent requests
|
9
|
ERR_MALFUNCTIONAL_TRADE
|
Malfunctional trade operation
|
64
|
ERR_ACCOUNT_DISABLED
|
Account disabled
|
65
|
ERR_INVALID_ACCOUNT
|
Invalid account
|
128
|
ERR_TRADE_TIMEOUT
|
Trade timeout
|
129
|
ERR_INVALID_PRICE
|
Invalid price
|
130
|
ERR_INVALID_STOPS
|
Invalid stops
|
131
|
ERR_INVALID_TRADE_VOLUME
|
Invalid trade volume
|
132
|
ERR_MARKET_CLOSED
|
Market is closed
|
133
|
ERR_TRADE_DISABLED
|
Trade is disabled
|
134
|
ERR_NOT_ENOUGH_MONEY
|
Not enough money
|
135
|
ERR_PRICE_CHANGED
|
Price changed
|
136
|
ERR_OFF_QUOTES
|
Off quotes
|
137
|
ERR_BROKER_BUSY
|
Broker is busy
|
138
|
ERR_REQUOTE
|
Requote
|
139
|
ERR_ORDER_LOCKED
|
Order is locked
|
140
|
ERR_LONG_POSITIONS_ONLY_ALLOWED
|
Buy orders only allowed
|
141
|
ERR_TOO_MANY_REQUESTS
|
Too many requests
|
145
|
ERR_TRADE_MODIFY_DENIED
|
Modification denied because order is too close to market
|
146
|
ERR_TRADE_CONTEXT_BUSY
|
Trade context is busy
|
147
|
ERR_TRADE_EXPIRATION_DENIED
|
Expirations are denied by broker
|
148
|
ERR_TRADE_TOO_MANY_ORDERS
|
The amount of open and pending orders has reached the limit set by the broker
|
149
|
ERR_TRADE_HEDGE_PROHIBITED
|
An attempt to open an order opposite to the existing one when hedging is disabled
|
150
|
ERR_TRADE_PROHIBITED_BY_FIFO
|
An attempt to close an order contravening the FIFO rule
|
|