Download MetaTrader 5

Runtime Errors

GetLastError() is the function that returns the last error code that is stored in the predefined variable _LastError. This value can be reset to zero by the ResetLastError() function.

Constant

Code

Description

ERR_SUCCESS

0

The operation completed successfully

ERR_INTERNAL_ERROR

4001

Unexpected internal error

ERR_WRONG_INTERNAL_PARAMETER

4002

Wrong parameter in the inner call of the client terminal function

ERR_INVALID_PARAMETER

4003

Wrong parameter when calling the system function

ERR_NOT_ENOUGH_MEMORY

4004

Not enough memory to perform the system function

ERR_STRUCT_WITHOBJECTS_ORCLASS

4005

The structure contains objects of strings and/or dynamic arrays and/or structure of such objects and/or classes

ERR_INVALID_ARRAY

4006

Array of a wrong type, wrong size, or a damaged object of a dynamic array

ERR_ARRAY_RESIZE_ERROR

4007

Not enough memory for the relocation of an array, or an attempt to change the size of a static array

ERR_STRING_RESIZE_ERROR

4008

Not enough memory for the relocation of string

ERR_NOTINITIALIZED_STRING

4009

Not initialized string

ERR_INVALID_DATETIME

4010

Invalid date and/or time

ERR_ARRAY_BAD_SIZE

4011

Requested array size exceeds 2 GB

ERR_INVALID_POINTER

4012

Wrong pointer

ERR_INVALID_POINTER_TYPE

4013

Wrong type of pointer

ERR_FUNCTION_NOT_ALLOWED

4014

Function is not allowed for call

ERR_RESOURCE_NAME_DUPLICATED

4015

The names of the dynamic and the static resource match

ERR_RESOURCE_NOT_FOUND

4016

Resource with this name has not been found in EX5

ERR_RESOURCE_UNSUPPOTED_TYPE

4017

Unsupported resource type or its size exceeds 16 Mb

ERR_RESOURCE_NAME_IS_TOO_LONG

4018

The resource name exceeds 63 characters

Charts

 

 

ERR_CHART_WRONG_ID

4101

Wrong chart ID

ERR_CHART_NO_REPLY

4102

Chart does not respond

ERR_CHART_NOT_FOUND

4103

Chart not found

ERR_CHART_NO_EXPERT

4104

No Expert Advisor in the chart that could handle the event

ERR_CHART_CANNOT_OPEN

4105

Chart opening error

ERR_CHART_CANNOT_CHANGE

4106

Failed to change chart symbol and period

ERR_CHART_WRONG_PARAMETER

4107

Error value of the parameter for the function of working with charts

ERR_CHART_CANNOT_CREATE_TIMER

4108

Failed to create timer

ERR_CHART_WRONG_PROPERTY

4109

Wrong chart property ID

ERR_CHART_SCREENSHOT_FAILED

4110

Error creating screenshots

ERR_CHART_NAVIGATE_FAILED

4111

Error navigating through chart

ERR_CHART_TEMPLATE_FAILED

4112

Error applying template

ERR_CHART_WINDOW_NOT_FOUND

4113

Subwindow containing the indicator was not found

ERR_CHART_INDICATOR_CANNOT_ADD

4114

Error adding an indicator to chart

ERR_CHART_INDICATOR_CANNOT_DEL

4115

Error deleting an indicator from the chart

ERR_CHART_INDICATOR_NOT_FOUND

4116

Indicator not found on the specified chart

Graphical Objects

 

 

ERR_OBJECT_ERROR

4201

Error working with a graphical object

ERR_OBJECT_NOT_FOUND

4202

Graphical object was not found

ERR_OBJECT_WRONG_PROPERTY

4203

Wrong ID of a graphical object property

ERR_OBJECT_GETDATE_FAILED

4204

Unable to get date corresponding to the value

ERR_OBJECT_GETVALUE_FAILED

4205

Unable to get value corresponding to the date

MarketInfo

 

 

ERR_MARKET_UNKNOWN_SYMBOL

4301

Unknown symbol

ERR_MARKET_NOT_SELECTED

4302

Symbol is not selected in MarketWatch

ERR_MARKET_WRONG_PROPERTY

4303

Wrong identifier of a symbol property

ERR_MARKET_LASTTIME_UNKNOWN

4304

Time of the last tick is not known (no ticks)

ERR_MARKET_SELECT_ERROR

4305

Error adding or deleting a symbol in MarketWatch

History Access

 

 

ERR_HISTORY_NOT_FOUND

4401

Requested history not found

ERR_HISTORY_WRONG_PROPERTY

4402

Wrong ID of the history property

Global_Variables

 

 

ERR_GLOBALVARIABLE_NOT_FOUND

4501

Global variable of the client terminal is not found

ERR_GLOBALVARIABLE_EXISTS

4502

Global variable of the client terminal with the same name already exists

ERR_MAIL_SEND_FAILED

4510

Email sending failed

ERR_PLAY_SOUND_FAILED

4511

Sound playing failed

ERR_MQL5_WRONG_PROPERTY

4512

Wrong identifier of the program property

ERR_TERMINAL_WRONG_PROPERTY

4513

Wrong identifier of the terminal property

ERR_FTP_SEND_FAILED

4514

File sending via ftp failed

ERR_NOTIFICATION_SEND_FAILED

4515

Failed to send a notification

ERR_NOTIFICATION_WRONG_PARAMETER

4516

Invalid parameter for sending a notification — an empty string or NULL has been passed to the SendNotification() function

ERR_NOTIFICATION_WRONG_SETTINGS

4517

Wrong settings of notifications in the terminal (ID is not specified or permission is not set)

ERR_NOTIFICATION_TOO_FREQUENT

4518

Too frequent sending of notifications

ERR_FTP_NOSERVER

4519

FTP server is not specified

ERR_FTP_NOLOGIN

4520

FTP login is not specified

ERR_FTP_FILE_ERROR

4521

File not found in the MQL5\Files directory to send on FTP server

ERR_FTP_CONNECT_FAILED

4522

FTP connection failed

ERR_FTP_CHANGEDIR

4523

FTP path not found on server

ERR_FTP_CLOSED

4524

FTP connection closed

Custom Indicator Buffers

 

 

ERR_BUFFERS_NO_MEMORY

4601

Not enough memory for the distribution of indicator buffers

ERR_BUFFERS_WRONG_INDEX

4602

Wrong indicator buffer index

Custom Indicator Properties

 

 

ERR_CUSTOM_WRONG_PROPERTY

4603

Wrong ID of the custom indicator property

Account

 

 

ERR_ACCOUNT_WRONG_PROPERTY

4701

Wrong account property ID

ERR_TRADE_WRONG_PROPERTY

4751

Wrong trade property ID

ERR_TRADE_DISABLED

4752

Trading by Expert Advisors prohibited

ERR_TRADE_POSITION_NOT_FOUND

4753

Position not found

ERR_TRADE_ORDER_NOT_FOUND

4754

Order not found

ERR_TRADE_DEAL_NOT_FOUND

4755

Deal not found

ERR_TRADE_SEND_FAILED

4756

Trade request sending failed

Indicators

 

 

ERR_INDICATOR_UNKNOWN_SYMBOL

4801

Unknown symbol

ERR_INDICATOR_CANNOT_CREATE

4802

Indicator cannot be created

ERR_INDICATOR_NO_MEMORY

4803

Not enough memory to add the indicator

ERR_INDICATOR_CANNOT_APPLY

4804

The indicator cannot be applied to another indicator

ERR_INDICATOR_CANNOT_ADD

4805

Error applying an indicator to chart

ERR_INDICATOR_DATA_NOT_FOUND

4806

Requested data not found

ERR_INDICATOR_WRONG_HANDLE

4807

Wrong indicator handle

ERR_INDICATOR_WRONG_PARAMETERS

4808

Wrong number of parameters when creating an indicator

ERR_INDICATOR_PARAMETERS_MISSING

4809

No parameters when creating an indicator

ERR_INDICATOR_CUSTOM_NAME

4810

The first parameter in the array must be the name of the custom indicator

ERR_INDICATOR_PARAMETER_TYPE

4811

Invalid parameter type in the array when creating an indicator

ERR_INDICATOR_WRONG_INDEX

4812

Wrong index of the requested indicator buffer

Depth of Market

 

 

ERR_BOOKS_CANNOT_ADD

4901

Depth Of Market can not be added

ERR_BOOKS_CANNOT_DELETE

4902

Depth Of Market can not be removed

ERR_BOOKS_CANNOT_GET

4903

The data from Depth Of Market can not be obtained

ERR_BOOKS_CANNOT_SUBSCRIBE

4904

Error in subscribing to receive new data from Depth Of Market

File Operations

 

 

ERR_TOO_MANY_FILES

5001

More than 64 files cannot be opened at the same time

ERR_WRONG_FILENAME

5002

Invalid file name

ERR_TOO_LONG_FILENAME

5003

Too long file name

ERR_CANNOT_OPEN_FILE

5004

File opening error

ERR_FILE_CACHEBUFFER_ERROR

5005

Not enough memory for cache to read

ERR_CANNOT_DELETE_FILE

5006

File deleting error

ERR_INVALID_FILEHANDLE

5007

A file with this handle was closed, or was not opening at all

ERR_WRONG_FILEHANDLE

5008

Wrong file handle

ERR_FILE_NOTTOWRITE

5009

The file must be opened for writing

ERR_FILE_NOTTOREAD

5010

The file must be opened for reading

ERR_FILE_NOTBIN

5011

The file must be opened as a binary one

ERR_FILE_NOTTXT

5012

The file must be opened as a text

ERR_FILE_NOTTXTORCSV

5013

The file must be opened as a text or CSV

ERR_FILE_NOTCSV

5014

The file must be opened as CSV

ERR_FILE_READERROR

5015

File reading error

ERR_FILE_BINSTRINGSIZE

5016

String size must be specified, because the file is opened as binary

ERR_INCOMPATIBLE_FILE

5017

A text file must be for string arrays, for other arrays - binary

ERR_FILE_IS_DIRECTORY

5018

This is not a file, this is a directory

ERR_FILE_NOT_EXIST

5019

File does not exist

ERR_FILE_CANNOT_REWRITE

5020

File can not be rewritten

ERR_WRONG_DIRECTORYNAME

5021

Wrong directory name

ERR_DIRECTORY_NOT_EXIST

5022

Directory does not exist

ERR_FILE_ISNOT_DIRECTORY

5023

This is a file, not a directory

ERR_CANNOT_DELETE_DIRECTORY

5024

The directory cannot be removed

ERR_CANNOT_CLEAN_DIRECTORY

5025

Failed to clear the directory (probably one or more files are blocked and removal operation failed)

ERR_FILE_WRITEERROR

5026

Failed to write a resource to a file

ERR_FILE_ENDOFFILE

5027

Unable to read the next piece of data from a CSV file (FileReadString, FileReadNumber, FileReadDatetime, FileReadBool), since the end of file is reached

String Casting

 

 

ERR_NO_STRING_DATE

5030

No date in the string

ERR_WRONG_STRING_DATE

5031

Wrong date in the string

ERR_WRONG_STRING_TIME

5032

Wrong time in the string

ERR_STRING_TIME_ERROR

5033

Error converting string to date

ERR_STRING_OUT_OF_MEMORY

5034

Not enough memory for the string

ERR_STRING_SMALL_LEN

5035

The string length is less than expected

ERR_STRING_TOO_BIGNUMBER

5036

Too large number, more than ULONG_MAX

ERR_WRONG_FORMATSTRING

5037

Invalid format string

ERR_TOO_MANY_FORMATTERS

5038

Amount of format specifiers more than the parameters

ERR_TOO_MANY_PARAMETERS

5039

Amount of parameters more than the format specifiers

ERR_WRONG_STRING_PARAMETER

5040

Damaged parameter of string type

ERR_STRINGPOS_OUTOFRANGE

5041

Position outside the string

ERR_STRING_ZEROADDED

5042

0 added to the string end, a useless operation

ERR_STRING_UNKNOWNTYPE

5043

Unknown data type when converting to a string

ERR_WRONG_STRING_OBJECT

5044

Damaged string object

Operations with Arrays

 

 

ERR_INCOMPATIBLE_ARRAYS

5050

Copying incompatible arrays. String array can be copied only to a string array, and a numeric array - in numeric array only

ERR_SMALL_ASSERIES_ARRAY

5051

The receiving array is declared as AS_SERIES, and it is of insufficient size

ERR_SMALL_ARRAY

5052

Too small array, the starting position is outside the array

ERR_ZEROSIZE_ARRAY

5053

An array of zero length

ERR_NUMBER_ARRAYS_ONLY

5054

Must be a numeric array

ERR_ONEDIM_ARRAYS_ONLY

5055

Must be a one-dimensional array

ERR_SERIES_ARRAY

5056

Timeseries cannot be used

ERR_DOUBLE_ARRAY_ONLY

5057

Must be an array of type double

ERR_FLOAT_ARRAY_ONLY

5058

Must be an array of type float

ERR_LONG_ARRAY_ONLY

5059

Must be an array of type long

ERR_INT_ARRAY_ONLY

5060

Must be an array of type int

ERR_SHORT_ARRAY_ONLY

5061

Must be an array of type short

ERR_CHAR_ARRAY_ONLY

5062

Must be an array of type char

Operations with OpenCL

 

 

ERR_OPENCL_NOT_SUPPORTED

5100

OpenCL functions are not supported on this computer

ERR_OPENCL_INTERNAL

5101

Internal error occurred when running OpenCL

ERR_OPENCL_INVALID_HANDLE

5102

Invalid OpenCL handle

ERR_OPENCL_CONTEXT_CREATE

5103

Error creating the OpenCL context

ERR_OPENCL_QUEUE_CREATE

5104

Failed to create a run queue in OpenCL

ERR_OPENCL_PROGRAM_CREATE

5105

Error occurred when compiling an OpenCL program

ERR_OPENCL_TOO_LONG_KERNEL_NAME

5106

Too long kernel name (OpenCL kernel)

ERR_OPENCL_KERNEL_CREATE

5107

Error creating an OpenCL kernel

ERR_OPENCL_SET_KERNEL_PARAMETER

5108

Error occurred when setting parameters for the OpenCL kernel

ERR_OPENCL_EXECUTE

5109

OpenCL program runtime error

ERR_OPENCL_WRONG_BUFFER_SIZE

5110

Invalid size of the OpenCL buffer

ERR_OPENCL_WRONG_BUFFER_OFFSET

5111

Invalid offset in the OpenCL buffer

ERR_OPENCL_BUFFER_CREATE

5112

Failed to create an OpenCL buffer

Operations with WebRequest

 

 

ERR_WEBREQUEST_INVALID_ADDRESS

5200

Invalid URL

ERR_WEBREQUEST_CONNECT_FAILED

5201

Failed to connect to specified URL

ERR_WEBREQUEST_TIMEOUT

5202

Timeout exceeded

ERR_WEBREQUEST_REQUEST_FAILED

5203

HTTP request failed

User-Defined Errors

 

 

ERR_USER_ERROR_FIRST

65536

User defined errors start with this code

See also

Trade Server Return Codes


Updated: 2016.02.18