Free reference
MQL5 error codes and trade retcodes
What a MetaTrader 5 trade server return code or runtime error means, the situations that cause it, and MQL5 code that handles it. Search by number, by the MQL4 number it replaces, or by words.
Trade server return codes
Trade server return codes arrive in MqlTradeResult.retcode after OrderSend() or OrderCheck(). 20 codes.
- 10004RequoteTRADE_RETCODE_REQUOTERequote: the price moved before the order was filled
- 10006Request RejectedTRADE_RETCODE_REJECTRequest rejected by the trade server
- 10013Invalid RequestTRADE_RETCODE_INVALIDInvalid request: a field of the trade request is wrong or missing
- 10014Invalid VolumeTRADE_RETCODE_INVALID_VOLUMEInvalid volume: the lot breaks the symbol's minimum, maximum or step
- 10015Invalid PriceTRADE_RETCODE_INVALID_PRICEInvalid price: the order price is not valid for the symbol
- 10016Invalid StopsTRADE_RETCODE_INVALID_STOPSInvalid stops: SL or TP too close to the price or on the wrong side
- 10017Trade DisabledTRADE_RETCODE_TRADE_DISABLEDTrade is disabled for the symbol or the account
- 10018Market ClosedTRADE_RETCODE_MARKET_CLOSEDMarket is closed: the request was sent outside a trading session
- 10019Not Enough MoneyTRADE_RETCODE_NO_MONEYNot enough money: the free margin does not cover the order
- 10020Prices ChangedTRADE_RETCODE_PRICE_CHANGEDPrices changed while the request was processed
- 10021Off QuotesTRADE_RETCODE_PRICE_OFFOff quotes: no current price for the symbol
- 10024Too Frequent RequestsTRADE_RETCODE_TOO_MANY_REQUESTSToo frequent requests: the EA sends faster than the server allows
- 10025No ChangesTRADE_RETCODE_NO_CHANGESNo changes: a modification that changes nothing
- 10027Algo Trading DisabledTRADE_RETCODE_CLIENT_DISABLES_ATAlgo trading is switched off in the terminal
- 10029Order or Position FrozenTRADE_RETCODE_FROZENOrder or position frozen: too close to its trigger to change
- 10030Invalid Filling TypeTRADE_RETCODE_INVALID_FILLInvalid filling type: FOK, IOC or Return not allowed for the symbol
- 10031No ConnectionTRADE_RETCODE_CONNECTIONNo connection with the trade server
- 10040Position LimitTRADE_RETCODE_LIMIT_POSITIONSPosition limit reached: the account holds as many positions as the server allows
- 10045FIFO Close RuleTRADE_RETCODE_FIFO_CLOSEFIFO rule: positions must be closed oldest first
- 10046Hedge ProhibitedTRADE_RETCODE_HEDGE_PROHIBITEDHedge prohibited: no opposite positions on one symbol
Runtime errors
Runtime errors arrive from GetLastError() after a function fails. 10 codes.
- 4014Function Not AllowedERR_FUNCTION_NOT_ALLOWEDFunction not allowed: called where MQL5 does not permit it
- 4108Timer or Invalid TicketERR_CHART_CANNOT_CREATE_TIMERA timer that could not be created (MQL5), an invalid ticket (MQL4)
- 4109Chart Property or Trade Not AllowedERR_CHART_WRONG_PROPERTYA wrong chart property (MQL5), trade not allowed (MQL4)
- 4301Unknown SymbolERR_MARKET_UNKNOWN_SYMBOLUnknown symbol: the broker has no symbol with that name
- 4302Symbol Not SelectedERR_MARKET_NOT_SELECTEDSymbol not selected in Market Watch
- 4752Trading by EAs ProhibitedERR_TRADE_DISABLEDTrading by Expert Advisors prohibited
- 4753Position Not FoundERR_TRADE_POSITION_NOT_FOUNDPosition not found: the ticket points at a position that is gone
- 4756Trade Request Sending FailedERR_TRADE_SEND_FAILEDTrade request sending failed: read the retcode, not 4756
- 4806Indicator Data Not FoundERR_INDICATOR_DATA_NOT_FOUNDIndicator data not found: CopyBuffer() before the data is ready
- 4807Wrong Indicator HandleERR_INDICATOR_WRONG_HANDLEWrong indicator handle: the handle is invalid or released
Reading a failed trade
OrderSend()returning false, orGetLastError()= 4756, only says the request failed. The reason is the server's return code inresult.retcode, withresult.comment.- Log both, with the symbol, volume, price and stops of the request, before anything else.
- Run
OrderCheck()before sending: it reports many of these codes without touching the server, but not all of them (a closed market passes the check).
MQL4 numbers
MQL4 reported trade problems as small numbers (130 invalid stops, 131 invalid volume, 134 not enough money). MQL5 uses the 10004–10046 return codes instead; each entry names the MQL4 number it replaces, and the search finds it. Some numbers mean different things in the two languages (4108, 4109): their pages explain both.
Every entry is written from the official MQL5 and MQL4 reference, which each page links. To check a whole EA for these mistakes, paste it into the EA Doctor.
Get your EA fixed
An EA that keeps failing with one of these codes? We find the cause in the code and fix it.