Error codes
MetaTrader 4 API error codes
161 decoded error codes for MetaTrader 4 (MQL4). Each page gives the exact error text and what it means. 24 of them carry a fix or a next step, and each of those rows is marked Fix recorded. Where the source gives no remedy, the page says so.
Risk warning: CFDs and spread bets are complex instruments and come with a high risk of losing money rapidly due to leverage. You can lose money on these products, and each provider publishes its own loss figure under FCA rules. You should consider whether you understand how they work and whether you can afford to take the high risk of losing your money. Automated and API trading can amplify losses through bugs, connectivity failures and runaway orders.
Trade server return codes
32 codes
Returned by the trade server to the platform.
ERR_Fix recorded No error was returned.NO_ ERROR (0) ERR_No error was returned, but the result is unknown.NO_ RESULT (1) ERR_"Common error" is MetaQuotes' whole description of this code.COMMON_ ERROR (2) ERR_"Invalid trade parameters" is MetaQuotes' whole description of this code.INVALID_ TRADE_ PARAMETERS (3) ERR_"Trade server is busy" is MetaQuotes' whole description of this code.SERVER_ BUSY (4) ERR_Fix recorded "Old version of the client terminal" is MetaQuotes' whole description of this code.OLD_ VERSION (5) ERR_Fix recorded "No connection with trade server" is MetaQuotes' whole description of this code.NO_ CONNECTION (6) ERR_"Not enough rights" is MetaQuotes' whole description of this code.NOT_ ENOUGH_ RIGHTS (7) ERR_Fix recorded "Too frequent requests" is MetaQuotes' whole description of this code.TOO_ FREQUENT_ REQUESTS (8) ERR_"Malfunctional trade operation" is MetaQuotes' whole description of this code.MALFUNCTIONAL_ TRADE (9) ERR_"Account disabled" is MetaQuotes' whole description of this code.ACCOUNT_ DISABLED (64) ERR_"Invalid account" is MetaQuotes' whole description of this code.INVALID_ ACCOUNT (65) ERR_"Trade timeout" is MetaQuotes' whole description of this code.TRADE_ TIMEOUT (128) ERR_Fix recorded "Invalid price" is MetaQuotes' whole description of this code.INVALID_ PRICE (129) ERR_Fix recorded "Invalid stops" is MetaQuotes' whole description of this code.INVALID_ STOPS (130) ERR_Fix recorded "Invalid trade volume" is MetaQuotes' whole description of this code.INVALID_ TRADE_ VOLUME (131) ERR_"Market is closed" is MetaQuotes' whole description of this code.MARKET_ CLOSED (132) ERR_"Trade is disabled" is MetaQuotes' whole description of this code.TRADE_ DISABLED (133) ERR_"Not enough money" is MetaQuotes' whole description of this code.NOT_ ENOUGH_ MONEY (134) ERR_Fix recorded "Price changed" is MetaQuotes' whole description of this code.PRICE_ CHANGED (135) ERR_"Off quotes" is MetaQuotes' whole description of this code.OFF_ QUOTES (136) ERR_"Broker is busy" is MetaQuotes' whole description of this code.BROKER_ BUSY (137) ERR_"Requote" is MetaQuotes' whole description of this code.REQUOTE (138) ERR_"Order is locked" is MetaQuotes' whole description of this code.ORDER_ LOCKED (139) 140 ERR_Only buy orders are allowed.LONG_ POSITIONS_ ONLY_ ALLOWED ERR_Fix recorded "Too many requests" is MetaQuotes' whole description of this code.TOO_ MANY_ REQUESTS (141) ERR_The modification was denied because the order is too close to the market.TRADE_ MODIFY_ DENIED (145) ERR_Fix recorded "Trade context is busy" is MetaQuotes' whole description of this code.TRADE_ CONTEXT_ BUSY (146) ERR_Expirations are denied by the broker.TRADE_ EXPIRATION_ DENIED (147) ERR_The number of open and pending orders has reached the limit set by the broker.TRADE_ TOO_ MANY_ ORDERS (148) ERR_The code tried to open an order opposite to an existing one while hedging is disabled.TRADE_ HEDGE_ PROHIBITED (149) ERR_The code tried to close an order in a way that breaks the FIFO rule.TRADE_ PROHIBITED_ BY_ FIFO (150)
Runtime error codes
129 codes
Raised inside the platform's own language.
ERR_Fix recorded No error was returned.NO_ MQLERROR (4000) ERR_"Wrong function pointer" is MetaQuotes' whole description of this code.WRONG_ FUNCTION_ POINTER (4001) ERR_"Array index is out of range" is MetaQuotes' whole description of this code.ARRAY_ INDEX_ OUT_ OF_ RANGE (4002) ERR_"No memory for function call stack" is MetaQuotes' whole description of this code.NO_ MEMORY_ FOR_ CALL_ STACK (4003) ERR_"Recursive stack overflow" is MetaQuotes' whole description of this code.RECURSIVE_ STACK_ OVERFLOW (4004) 4005 ERR_"Not enough stack for parameter" is MetaQuotes' whole description of this code.NOT_ ENOUGH_ STACK_ FOR_ PARAM 4006 ERR_"No memory for parameter string" is MetaQuotes' whole description of this code.NO_ MEMORY_ FOR_ PARAM_ STRING 4007 ERR_"No memory for temp string" is MetaQuotes' whole description of this code.NO_ MEMORY_ FOR_ TEMP_ STRING ERR_"Not initialized string" is MetaQuotes' whole description of this code.NOT_ INITIALIZED_ STRING (4008) 4009 ERR_"Not initialized string in array" is MetaQuotes' whole description of this code.NOT_ INITIALIZED_ ARRAYSTRING 4010 ERR_"No memory for array string" is MetaQuotes' whole description of this code.NO_ MEMORY_ FOR_ ARRAYSTRING ERR_"Too long string" is MetaQuotes' whole description of this code.TOO_ LONG_ STRING (4011) 4012 ERR_"Remainder from zero divide" is MetaQuotes' whole description of this code.REMAINDER_ FROM_ ZERO_ DIVIDE ERR_"Zero divide" is MetaQuotes' whole description of this code.ZERO_ DIVIDE (4013) ERR_"Unknown command" is MetaQuotes' whole description of this code.UNKNOWN_ COMMAND (4014) ERR_"Wrong jump" is MetaQuotes' description, and it marks this as an error that is never generated.WRONG_ JUMP (4015) ERR_"Not initialized array" is MetaQuotes' whole description of this code.NOT_ INITIALIZED_ ARRAY (4016) ERR_"DLL calls are not allowed" is MetaQuotes' whole description of this code.DLL_ CALLS_ NOT_ ALLOWED (4017) ERR_"Cannot load library" is MetaQuotes' whole description of this code.CANNOT_ LOAD_ LIBRARY (4018) ERR_"Cannot call function" is MetaQuotes' whole description of this code.CANNOT_ CALL_ FUNCTION (4019) 4020 ERR_"Expert function calls are not allowed" is MetaQuotes' whole description of this code.EXTERNAL_ CALLS_ NOT_ ALLOWED 4021 ERR_There is not enough memory for the temporary string returned from a function.NO_ MEMORY_ FOR_ RETURNED_ STR ERR_"System is busy" is MetaQuotes' description, and it marks this as an error that is never generated.SYSTEM_ BUSY (4022) ERR_"DLL-function call critical error" is MetaQuotes' whole description of this code.DLLFUNC_ CRITICALERROR (4023) ERR_"Internal error" is MetaQuotes' whole description of this code.INTERNAL_ ERROR (4024) ERR_"Out of memory" is MetaQuotes' whole description of this code.OUT_ OF_ MEMORY (4025) ERR_"Invalid pointer" is MetaQuotes' whole description of this code.INVALID_ POINTER (4026) 4027 ERR_"Too many formatters in the format function" is MetaQuotes' whole description of this code.FORMAT_ TOO_ MANY_ FORMATTERS 4028 ERR_"Parameters count exceeds formatters count" is MetaQuotes' whole description of this code.FORMAT_ TOO_ MANY_ PARAMETERS ERR_"Invalid array" is MetaQuotes' whole description of this code.ARRAY_ INVALID (4029) ERR_"No reply from chart" is MetaQuotes' whole description of this code.CHART_ NOREPLY (4030) 4050 ERR_"Invalid function parameters count" is MetaQuotes' whole description of this code.INVALID_ FUNCTION_ PARAMSCNT 4051 ERR_"Invalid function parameter value" is MetaQuotes' whole description of this code.INVALID_ FUNCTION_ PARAMVALUE ERR_"String function internal error" is MetaQuotes' whole description of this code.STRING_ FUNCTION_ INTERNAL (4052) ERR_"Some array error" is MetaQuotes' whole description of this code.SOME_ ARRAY_ ERROR (4053) 4054 ERR_"Incorrect series array using" is MetaQuotes' whole description of this code.INCORRECT_ SERIESARRAY_ USING ERR_"Custom indicator error" is MetaQuotes' whole description of this code.CUSTOM_ INDICATOR_ ERROR (4055) ERR_"Arrays are incompatible" is MetaQuotes' whole description of this code.INCOMPATIBLE_ ARRAYS (4056) 4057 ERR_"Global variables processing error" is MetaQuotes' whole description of this code.GLOBAL_ VARIABLES_ PROCESSING 4058 ERR_"Global variable not found" is MetaQuotes' whole description of this code.GLOBAL_ VARIABLE_ NOT_ FOUND 4059 ERR_"Function is not allowed in testing mode" is MetaQuotes' whole description of this code.FUNC_ NOT_ ALLOWED_ IN_ TESTING ERR_"Function is not allowed for call" is MetaQuotes' whole description of this code.FUNCTION_ NOT_ CONFIRMED (4060) ERR_"Send mail error" is MetaQuotes' whole description of this code.SEND_ MAIL_ ERROR (4061) 4062 ERR_"String parameter expected" is MetaQuotes' whole description of this code.STRING_ PARAMETER_ EXPECTED 4063 ERR_"Integer parameter expected" is MetaQuotes' whole description of this code.INTEGER_ PARAMETER_ EXPECTED 4064 ERR_"Double parameter expected" is MetaQuotes' whole description of this code.DOUBLE_ PARAMETER_ EXPECTED 4065 ERR_"Array as parameter expected" is MetaQuotes' whole description of this code.ARRAY_ AS_ PARAMETER_ EXPECTED ERR_"Requested history data is in updating state" is MetaQuotes' whole description of this code.HISTORY_ WILL_ UPDATED (4066) ERR_"Internal trade error" is MetaQuotes' whole description of this code.TRADE_ ERROR (4067) ERR_"Resource not found" is MetaQuotes' whole description of this code.RESOURCE_ NOT_ FOUND (4068) ERR_"Resource not supported" is MetaQuotes' whole description of this code.RESOURCE_ NOT_ SUPPORTED (4069) ERR_"Duplicate resource" is MetaQuotes' whole description of this code.RESOURCE_ DUPLICATED (4070) ERR_"Custom indicator cannot initialize" is MetaQuotes' whole description of this code.INDICATOR_ CANNOT_ INIT (4071) ERR_"Cannot load custom indicator" is MetaQuotes' whole description of this code.INDICATOR_ CANNOT_ LOAD (4072) ERR_"No history data" is MetaQuotes' whole description of this code.NO_ HISTORY_ DATA (4073) ERR_"No memory for history data" is MetaQuotes' whole description of this code.NO_ MEMORY_ FOR_ HISTORY (4074) ERR_"Not enough memory for indicator calculation" is MetaQuotes' whole description of this code.NO_ MEMORY_ FOR_ INDICATOR (4075) ERR_"End of file" is MetaQuotes' whole description of this code.END_ OF_ FILE (4099) ERR_"Some file error" is MetaQuotes' whole description of this code.SOME_ FILE_ ERROR (4100) ERR_"Wrong file name" is MetaQuotes' whole description of this code.WRONG_ FILE_ NAME (4101) ERR_"Too many opened files" is MetaQuotes' whole description of this code.TOO_ MANY_ OPENED_ FILES (4102) ERR_"Cannot open file" is MetaQuotes' whole description of this code.CANNOT_ OPEN_ FILE (4103) ERR_"Incompatible access to a file" is MetaQuotes' whole description of this code.INCOMPATIBLE_ FILEACCESS (4104) ERR_"No order selected" is MetaQuotes' whole description of this code.NO_ ORDER_ SELECTED (4105) ERR_Fix recorded "Unknown symbol" is MetaQuotes' whole description of this code.UNKNOWN_ SYMBOL (4106) ERR_"Invalid price" is MetaQuotes' whole description of this code.INVALID_ PRICE_ PARAM (4107) ERR_"Invalid ticket" is MetaQuotes' whole description of this code.INVALID_ TICKET (4108) ERR_Fix recorded Trade is not allowed.TRADE_ NOT_ ALLOWED (4109) ERR_Fix recorded Long positions are not allowed.LONGS_ NOT_ ALLOWED (4110) ERR_Fix recorded Short positions are not allowed.SHORTS_ NOT_ ALLOWED (4111) 4112 ERR_"Automated trading by Expert Advisors/Scripts disabled by trade server" is MetaQuotes' whole description of this code.TRADE_ EXPERT_ DISABLED_ BY_ SERVER ERR_"Object already exists" is MetaQuotes' whole description of this code.OBJECT_ ALREADY_ EXISTS (4200) ERR_"Unknown object property" is MetaQuotes' whole description of this code.UNKNOWN_ OBJECT_ PROPERTY (4201) ERR_"Object does not exist" is MetaQuotes' whole description of this code.OBJECT_ DOES_ NOT_ EXIST (4202) ERR_"Unknown object type" is MetaQuotes' whole description of this code.UNKNOWN_ OBJECT_ TYPE (4203) ERR_"No object name" is MetaQuotes' whole description of this code.NO_ OBJECT_ NAME (4204) ERR_"Object coordinates error" is MetaQuotes' whole description of this code.OBJECT_ COORDINATES_ ERROR (4205) ERR_"No specified subwindow" is MetaQuotes' whole description of this code.NO_ SPECIFIED_ SUBWINDOW (4206) ERR_"Graphical object error" is MetaQuotes' whole description of this code.SOME_ OBJECT_ ERROR (4207) ERR_"Unknown chart property" is MetaQuotes' whole description of this code.CHART_ PROP_ INVALID (4210) ERR_"Chart not found" is MetaQuotes' whole description of this code.CHART_ NOT_ FOUND (4211) ERR_"Chart subwindow not found" is MetaQuotes' whole description of this code.CHARTWINDOW_ NOT_ FOUND (4212) ERR_"Chart indicator not found" is MetaQuotes' whole description of this code.CHARTINDICATOR_ NOT_ FOUND (4213) ERR_"Symbol select error" is MetaQuotes' whole description of this code.SYMBOL_ SELECT (4220) ERR_"Notification error" is MetaQuotes' whole description of this code.NOTIFICATION_ ERROR (4250) ERR_"Notification parameter error" is MetaQuotes' whole description of this code.NOTIFICATION_ PARAMETER (4251) ERR_"Notifications disabled" is MetaQuotes' whole description of this code.NOTIFICATION_ SETTINGS (4252) 4253 ERR_"Notification send too frequent" is MetaQuotes' whole description of this code.NOTIFICATION_ TOO_ FREQUENT ERR_"FTP server is not specified" is MetaQuotes' whole description of this code.FTP_ NOSERVER (4260) ERR_"FTP login is not specified" is MetaQuotes' whole description of this code.FTP_ NOLOGIN (4261) ERR_"FTP connection failed" is MetaQuotes' whole description of this code.FTP_ CONNECT_ FAILED (4262) ERR_"FTP connection closed" is MetaQuotes' whole description of this code.FTP_ CLOSED (4263) ERR_"FTP path not found on server" is MetaQuotes' whole description of this code.FTP_ CHANGEDIR (4264) ERR_Fix recorded The file to send to the FTP server was not found in the Files directory under MQL4.FTP_ FILE_ ERROR (4265) ERR_"Common error during FTP data transmission" is MetaQuotes' whole description of this code.FTP_ ERROR (4266) ERR_"Too many opened files" is MetaQuotes' whole description of this code.FILE_ TOO_ MANY_ OPENED (5001) ERR_"Wrong file name" is MetaQuotes' whole description of this code.FILE_ WRONG_ FILENAME (5002) ERR_"Too long file name" is MetaQuotes' whole description of this code.FILE_ TOO_ LONG_ FILENAME (5003) ERR_"Cannot open file" is MetaQuotes' whole description of this code.FILE_ CANNOT_ OPEN (5004) 5005 ERR_"Text file buffer allocation error" is MetaQuotes' whole description of this code.FILE_ BUFFER_ ALLOCATION_ ERROR ERR_"Cannot delete file" is MetaQuotes' whole description of this code.FILE_ CANNOT_ DELETE (5006) ERR_"Invalid file handle (file closed or was not opened)" is MetaQuotes' whole description of this code.FILE_ INVALID_ HANDLE (5007) ERR_"Wrong file handle (handle index is out of handle table)" is MetaQuotes' whole description of this code.FILE_ WRONG_ HANDLE (5008) ERR_Fix recorded "File must be opened with FILE_WRITE flag" is MetaQuotes' whole description of this code.FILE_ NOT_ TOWRITE (5009) ERR_Fix recorded "File must be opened with FILE_READ flag" is MetaQuotes' whole description of this code.FILE_ NOT_ TOREAD (5010) ERR_Fix recorded "File must be opened with FILE_BIN flag" is MetaQuotes' whole description of this code.FILE_ NOT_ BIN (5011) ERR_Fix recorded "File must be opened with FILE_TXT flag" is MetaQuotes' whole description of this code.FILE_ NOT_ TXT (5012) ERR_Fix recorded "File must be opened with FILE_TXT or FILE_CSV flag" is MetaQuotes' whole description of this code.FILE_ NOT_ TXTORCSV (5013) ERR_Fix recorded "File must be opened with FILE_CSV flag" is MetaQuotes' whole description of this code.FILE_ NOT_ CSV (5014) ERR_"File read error" is MetaQuotes' whole description of this code.FILE_ READ_ ERROR (5015) ERR_"File write error" is MetaQuotes' whole description of this code.FILE_ WRITE_ ERROR (5016) ERR_Fix recorded "String size must be specified for binary file" is MetaQuotes' whole description of this code.FILE_ BIN_ STRINGSIZE (5017) ERR_"Incompatible file (for string arrays-TXT, for others-BIN)" is MetaQuotes' whole description of this code.FILE_ INCOMPATIBLE (5018) ERR_"File is directory not file" is MetaQuotes' whole description of this code.FILE_ IS_ DIRECTORY (5019) ERR_"File does not exist" is MetaQuotes' whole description of this code.FILE_ NOT_ EXIST (5020) ERR_"File cannot be rewritten" is MetaQuotes' whole description of this code.FILE_ CANNOT_ REWRITE (5021) ERR_"Wrong directory name" is MetaQuotes' whole description of this code.FILE_ WRONG_ DIRECTORYNAME (5022) ERR_"Directory does not exist" is MetaQuotes' whole description of this code.FILE_ DIRECTORY_ NOT_ EXIST (5023) ERR_"Specified file is not directory" is MetaQuotes' whole description of this code.FILE_ NOT_ DIRECTORY (5024) 5025 ERR_"Cannot delete directory" is MetaQuotes' whole description of this code.FILE_ CANNOT_ DELETE_ DIRECTORY 5026 ERR_"Cannot clean directory" is MetaQuotes' whole description of this code.FILE_ CANNOT_ CLEAN_ DIRECTORY ERR_"Array resize error" is MetaQuotes' whole description of this code.FILE_ ARRAYRESIZE_ ERROR (5027) ERR_"String resize error" is MetaQuotes' whole description of this code.FILE_ STRINGRESIZE_ ERROR (5028) ERR_"Structure contains strings or dynamic arrays" is MetaQuotes' whole description of this code.FILE_ STRUCT_ WITH_ OBJECTS (5029) 5200 ERR_"Invalid URL" is MetaQuotes' whole description of this code.WEBREQUEST_ INVALID_ ADDRESS 5201 ERR_"Failed to connect to specified URL" is MetaQuotes' whole description of this code.WEBREQUEST_ CONNECT_ FAILED ERR_"Timeout exceeded" is MetaQuotes' whole description of this code.WEBREQUEST_ TIMEOUT (5202) 5203 ERR_"HTTP request failed" is MetaQuotes' whole description of this code.WEBREQUEST_ REQUEST_ FAILED ERR_Fix recorded This is not an error in itself: it is the first code available for errors that a program defines for itself.USER_ ERROR_ FIRST (65536)
How to cite this
MetaTrader 4 API error codes. Broker API Hub, https://openbrokerapi.com/errors/mt4, newest check .
Where you rely on a single figure, cite the source and the checked date printed beside it as well.