Skip to content

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));
  }
CodeIDDescription
0ERR_NO_ERRORNo error returned
1ERR_NO_RESULTNo error returned, but the result is unknown
2ERR_COMMON_ERRORCommon error
3ERR_INVALID_TRADE_PARAMETERSInvalid trade parameters
4ERR_SERVER_BUSYTrade server is busy
5ERR_OLD_VERSIONOld version of the client terminal
6ERR_NO_CONNECTIONNo connection with trade server
7ERR_NOT_ENOUGH_RIGHTSNot enough rights
8ERR_TOO_FREQUENT_REQUESTSToo frequent requests
9ERR_MALFUNCTIONAL_TRADEMalfunctional trade operation
64ERR_ACCOUNT_DISABLEDAccount disabled
65ERR_INVALID_ACCOUNTInvalid account
128ERR_TRADE_TIMEOUTTrade timeout
129ERR_INVALID_PRICEInvalid price
130ERR_INVALID_STOPSInvalid stops
131ERR_INVALID_TRADE_VOLUMEInvalid trade volume
132ERR_MARKET_CLOSEDMarket is closed
133ERR_TRADE_DISABLEDTrade is disabled
134ERR_NOT_ENOUGH_MONEYNot enough money
135ERR_PRICE_CHANGEDPrice changed
136ERR_OFF_QUOTESOff quotes
137ERR_BROKER_BUSYBroker is busy
138ERR_REQUOTERequote
139ERR_ORDER_LOCKEDOrder is locked
140ERR_LONG_POSITIONS_ONLY_ALLOWEDBuy orders only allowed
141ERR_TOO_MANY_REQUESTSToo many requests
145ERR_TRADE_MODIFY_DENIEDModification denied because order is too close to market
146ERR_TRADE_CONTEXT_BUSYTrade context is busy
147ERR_TRADE_EXPIRATION_DENIEDExpirations are denied by broker
148ERR_TRADE_TOO_MANY_ORDERSThe amount of open and pending orders has reached the limit set by the broker
149ERR_TRADE_HEDGE_PROHIBITEDAn attempt to open an order opposite to the existing one when hedging is disabled
150ERR_TRADE_PROHIBITED_BY_FIFOAn attempt to close an order contravening the FIFO rule
Last updated on