Skip to content

Runtime Errors

Runtime Errors

The GetLastError() function return last error code, stored in _LastError predefined variable. This value can be reset using the ResetLastError() function. Error code constants defined at stderror.mqh file. To print text messages use ErrorDescription() function defined at stdlib.mqh file.

For convenience, trade errors are additionally listed in the Trade Server Return Codes section.

Runtime errors of mql4-program:

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
4000ERR_NO_MQLERRORNo error returned
4001ERR_WRONG_FUNCTION_POINTERWrong function pointer
4002ERR_ARRAY_INDEX_OUT_OF_RANGEArray index is out of range
4003ERR_NO_MEMORY_FOR_CALL_STACKNo memory for function call stack
4004ERR_RECURSIVE_STACK_OVERFLOWRecursive stack overflow
4005ERR_NOT_ENOUGH_STACK_FOR_PARAMNot enough stack for parameter
4006ERR_NO_MEMORY_FOR_PARAM_STRINGNo memory for parameter string
4007ERR_NO_MEMORY_FOR_TEMP_STRINGNo memory for temp string
4008ERR_NOT_INITIALIZED_STRINGNot initialized string
4009ERR_NOT_INITIALIZED_ARRAYSTRINGNot initialized string in array
4010ERR_NO_MEMORY_FOR_ARRAYSTRINGNo memory for array string
4011ERR_TOO_LONG_STRINGToo long string
4012ERR_REMAINDER_FROM_ZERO_DIVIDERemainder from zero divide
4013ERR_ZERO_DIVIDEZero divide
4014ERR_UNKNOWN_COMMANDUnknown command
4015ERR_WRONG_JUMPWrong jump (never generated error)
4016ERR_NOT_INITIALIZED_ARRAYNot initialized array
4017ERR_DLL_CALLS_NOT_ALLOWEDDLL calls are not allowed
4018ERR_CANNOT_LOAD_LIBRARYCannot load library
4019ERR_CANNOT_CALL_FUNCTIONCannot call function
4020ERR_EXTERNAL_CALLS_NOT_ALLOWEDExpert function calls are not allowed
4021ERR_NO_MEMORY_FOR_RETURNED_STRNot enough memory for temp string returned from function
4022ERR_SYSTEM_BUSYSystem is busy (never generated error)
4023ERR_DLLFUNC_CRITICALERRORDLL-function call critical error
4024ERR_INTERNAL_ERRORInternal error
4025ERR_OUT_OF_MEMORYOut of memory
4026ERR_INVALID_POINTERInvalid pointer
4027ERR_FORMAT_TOO_MANY_FORMATTERSToo many formatters in the format function
4028ERR_FORMAT_TOO_MANY_PARAMETERSParameters count exceeds formatters count
4029ERR_ARRAY_INVALIDInvalid array
4030ERR_CHART_NOREPLYNo reply from chart
4050ERR_INVALID_FUNCTION_PARAMSCNTInvalid function parameters count
4051ERR_INVALID_FUNCTION_PARAMVALUEInvalid function parameter value
4052ERR_STRING_FUNCTION_INTERNALString function internal error
4053ERR_SOME_ARRAY_ERRORSome array error
4054ERR_INCORRECT_SERIESARRAY_USINGIncorrect series array using
4055ERR_CUSTOM_INDICATOR_ERRORCustom indicator error
4056ERR_INCOMPATIBLE_ARRAYSArrays are incompatible
4057ERR_GLOBAL_VARIABLES_PROCESSINGGlobal variables processing error
4058ERR_GLOBAL_VARIABLE_NOT_FOUNDGlobal variable not found
4059ERR_FUNC_NOT_ALLOWED_IN_TESTINGFunction is not allowed in testing mode
4060ERR_FUNCTION_NOT_CONFIRMEDFunction is not allowed for call
4061ERR_SEND_MAIL_ERRORSend mail error
4062ERR_STRING_PARAMETER_EXPECTEDString parameter expected
4063ERR_INTEGER_PARAMETER_EXPECTEDInteger parameter expected
4064ERR_DOUBLE_PARAMETER_EXPECTEDDouble parameter expected
4065ERR_ARRAY_AS_PARAMETER_EXPECTEDArray as parameter expected
4066ERR_HISTORY_WILL_UPDATEDRequested history data is in updating state
4067ERR_TRADE_ERRORInternal trade error
4068ERR_RESOURCE_NOT_FOUNDResource not found
4069ERR_RESOURCE_NOT_SUPPORTEDResource not supported
4070ERR_RESOURCE_DUPLICATEDDuplicate resource
4071ERR_INDICATOR_CANNOT_INITCustom indicator cannot initialize
4072ERR_INDICATOR_CANNOT_LOADCannot load custom indicator
4073ERR_NO_HISTORY_DATANo history data
4074ERR_NO_MEMORY_FOR_HISTORYNo memory for history data
4075ERR_NO_MEMORY_FOR_INDICATORNot enough memory for indicator calculation
4099ERR_END_OF_FILEEnd of file
4100ERR_SOME_FILE_ERRORSome file error
4101ERR_WRONG_FILE_NAMEWrong file name
4102ERR_TOO_MANY_OPENED_FILESToo many opened files
4103ERR_CANNOT_OPEN_FILECannot open file
4104ERR_INCOMPATIBLE_FILEACCESSIncompatible access to a file
4105ERR_NO_ORDER_SELECTEDNo order selected
4106ERR_UNKNOWN_SYMBOLUnknown symbol
4107ERR_INVALID_PRICE_PARAMInvalid price
4108ERR_INVALID_TICKETInvalid ticket
4109ERR_TRADE_NOT_ALLOWEDTrade is not allowed. Enable checkbox “Allow live trading” in the Expert Advisor properties
4110ERR_LONGS_NOT_ALLOWEDLongs are not allowed. Check the Expert Advisor properties
4111ERR_SHORTS_NOT_ALLOWEDShorts are not allowed. Check the Expert Advisor properties
4112ERR_TRADE_EXPERT_DISABLED_BY_SERVERAutomated trading by Expert Advisors/Scripts disabled by trade server
4200ERR_OBJECT_ALREADY_EXISTSObject already exists
4201ERR_UNKNOWN_OBJECT_PROPERTYUnknown object property
4202ERR_OBJECT_DOES_NOT_EXISTObject does not exist
4203ERR_UNKNOWN_OBJECT_TYPEUnknown object type
4204ERR_NO_OBJECT_NAMENo object name
4205ERR_OBJECT_COORDINATES_ERRORObject coordinates error
4206ERR_NO_SPECIFIED_SUBWINDOWNo specified subwindow
4207ERR_SOME_OBJECT_ERRORGraphical object error
4210ERR_CHART_PROP_INVALIDUnknown chart property
4211ERR_CHART_NOT_FOUNDChart not found
4212ERR_CHARTWINDOW_NOT_FOUNDChart subwindow not found
4213ERR_CHARTINDICATOR_NOT_FOUNDChart indicator not found
4220ERR_SYMBOL_SELECTSymbol select error
4250ERR_NOTIFICATION_ERRORNotification error
4251ERR_NOTIFICATION_PARAMETERNotification parameter error
4252ERR_NOTIFICATION_SETTINGSNotifications disabled
4253ERR_NOTIFICATION_TOO_FREQUENTNotification send too frequent
4260ERR_FTP_NOSERVERFTP server is not specified
4261ERR_FTP_NOLOGINFTP login is not specified
4262ERR_FTP_CONNECT_FAILEDFTP connection failed
4263ERR_FTP_CLOSEDFTP connection closed
4264ERR_FTP_CHANGEDIRFTP path not found on server
4265ERR_FTP_FILE_ERRORFile not found in the MQL4\Files directory to send on FTP server
4266ERR_FTP_ERRORCommon error during FTP data transmission
5001ERR_FILE_TOO_MANY_OPENEDToo many opened files
5002ERR_FILE_WRONG_FILENAMEWrong file name
5003ERR_FILE_TOO_LONG_FILENAMEToo long file name
5004ERR_FILE_CANNOT_OPENCannot open file
5005ERR_FILE_BUFFER_ALLOCATION_ERRORText file buffer allocation error
5006ERR_FILE_CANNOT_DELETECannot delete file
5007ERR_FILE_INVALID_HANDLEInvalid file handle (file closed or was not opened)
5008ERR_FILE_WRONG_HANDLEWrong file handle (handle index is out of handle table)
5009ERR_FILE_NOT_TOWRITEFile must be opened with FILE_WRITE flag
5010ERR_FILE_NOT_TOREADFile must be opened with FILE_READ flag
5011ERR_FILE_NOT_BINFile must be opened with FILE_BIN flag
5012ERR_FILE_NOT_TXTFile must be opened with FILE_TXT flag
5013ERR_FILE_NOT_TXTORCSVFile must be opened with FILE_TXT or FILE_CSV flag
5014ERR_FILE_NOT_CSVFile must be opened with FILE_CSV flag
5015ERR_FILE_READ_ERRORFile read error
5016ERR_FILE_WRITE_ERRORFile write error
5017ERR_FILE_BIN_STRINGSIZEString size must be specified for binary file
5018ERR_FILE_INCOMPATIBLEIncompatible file (for string arrays-TXT, for others-BIN)
5019ERR_FILE_IS_DIRECTORYFile is directory not file
5020ERR_FILE_NOT_EXISTFile does not exist
5021ERR_FILE_CANNOT_REWRITEFile cannot be rewritten
5022ERR_FILE_WRONG_DIRECTORYNAMEWrong directory name
5023ERR_FILE_DIRECTORY_NOT_EXISTDirectory does not exist
5024ERR_FILE_NOT_DIRECTORYSpecified file is not directory
5025ERR_FILE_CANNOT_DELETE_DIRECTORYCannot delete directory
5026ERR_FILE_CANNOT_CLEAN_DIRECTORYCannot clean directory
5027ERR_FILE_ARRAYRESIZE_ERRORArray resize error
5028ERR_FILE_STRINGRESIZE_ERRORString resize error
5029ERR_FILE_STRUCT_WITH_OBJECTSStructure contains strings or dynamic arrays
5200ERR_WEBREQUEST_INVALID_ADDRESSInvalid URL
5201ERR_WEBREQUEST_CONNECT_FAILEDFailed to connect to specified URL
5202ERR_WEBREQUEST_TIMEOUTTimeout exceeded
5203ERR_WEBREQUEST_REQUEST_FAILEDHTTP request failed
User errors
65536ERR_USER_ERROR_FIRSTUser defined errors start with this code

Last updated on