Platform API
MetaTrader 5 Python API
MetaQuotes' multi-asset trading terminal. MQL5 programs run inside it, and the MetaTrader5 Python package talks to it locally.
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.
Access, authentication and streaming
API types listed in the record: Python package (MetaTrader5), MQL5, WebRequest and sockets from MQL5.
- How you get access
Install the MT5 terminal from your broker, then pip install MetaTrader5 on Windows x86-64 or write MQL5 in MetaEditor. The terminal must be at build 4755 or later.
order_sendchecked
- Who can use it
Real accounts come from brokers offering MT5; the API runs through your own local terminal.
- Demo
Yes: demo accounts can be opened from within the terminal.
- Authentication
No API keys: initialize() connects to the local terminal, optionally with account login, password and server.
initializechecked
- Streaming
No push API in Python: poll ticks and bars; market_book_add subscribes the terminal to depth events. MQL5 EAs get tick events.
MetaTrader for Pythonchecked
- History depth
Bars limited to the terminal's Max bars in chart setting. Deal history by date range with no stated limit.
MQL5 docs: copy_rates_fromchecked
- Rate limits, as worded
Not published. The Python page states none, carries no version and no date, and gives no consolidated error list beyond last_error() (read 22 Sep 2026).
MetaTrader for Pythonchecked
MetaTrader 5 API SDKs and wrappers
| Library | Language | Official | Note | Source |
|---|---|---|---|---|
| MetaTrader5 | Python | Official | Official MetaQuotes package, version 5.0.6231 of 27 Sep 2026, MIT licence, CPython 3.6 to 3.14, classified Production/Stable. Wheels are published for Windows x86-64 only, so the Python route is Windows only. | pypi.orgchecked |
| Community Python MCP server (MQL5 article 21905) | Python | Community | A community route documented in MQL5's own article library on 30 Apr 2026, separate from the native MCP in build 6060. It exposes 14 tools including place, modify and cancel orders, is Windows only because of the MT5 Python API, is single-threaded, and executes on whatever account MT5 is logged into. It has no approval step. The author advises demo testing first. | mql5.comchecked |
MetaTrader 5 functions
78 documented functions. They are functions of a programming language, not HTTP endpoints: none has a method or a path, and the code runs against the terminal on your own computer. Grouped by what they do, each with its summary
MetaTrader5 Python package
- account_info()
- copy_rates_from()
- copy_rates_from_pos()
- copy_rates_range()
- copy_ticks_from()
- copy_ticks_range()
- history_deals_get()
- history_deals_total()
- history_orders_get()
- history_orders_total()
- initialize()
- last_error()
- login()
- market_book_add()
- market_book_get()
- market_book_release()
- order_calc_margin()
- order_calc_profit()
- order_check()
- order_send()
- orders_get()
- orders_total()
- positions_get()
- positions_total()
- shutdown()
- symbol_info()
- symbol_info_tick()
- symbol_select()
- symbols_get()
- symbols_total()
- terminal_info()
- version()
MQL5
- AccountInfoDouble()
- AccountInfoInteger()
- AccountInfoString()
- CopyRates()
- CopyTicks()
- CopyTicksRange()
- HistoryDealGetDouble()
- HistoryDealGetInteger()
- HistoryDealGetString()
- HistoryDealGetTicket()
- HistoryDealSelect()
- HistoryDealsTotal()
- HistoryOrderGetDouble()
- HistoryOrderGetInteger()
- HistoryOrderGetString()
- HistoryOrderGetTicket()
- HistoryOrderSelect()
- HistoryOrdersTotal()
- HistorySelect()
- HistorySelectByPosition()
- OrderCalcMargin()
- OrderCalcProfit()
- OrderCheck()
- OrderGetDouble()
- OrderGetInteger()
- OrderGetString()
- OrderGetTicket()
- OrderSelect()
- OrderSend()
- OrderSendAsync()
- OrdersTotal()
- PositionGetDouble()
- PositionGetInteger()
- PositionGetString()
- PositionGetSymbol()
- PositionGetTicket()
- PositionSelect()
- PositionSelectByTicket()
- PositionsTotal()
- SymbolInfoDouble()
- SymbolInfoInteger()
- SymbolInfoString()
- SymbolInfoTick()
- SymbolName()
- SymbolSelect()
- SymbolsTotal()
MetaTrader 5 API error codes
311 decoded error codes. All MetaTrader 5 (Python package and MQL5) errors
-A generic failure.1 -The function was called with invalid arguments.2 -The terminal ran out of memory.3 -No history was found for the request.4 -Version mismatch.5 -Login to the trade account failed.6 -The method is not supported.7 -Algo trading is disabled in the terminal.8 -General failure talking to the terminal.10000 -Sending to the terminal failed.10001 -Receiving from the terminal failed.10002 -IPC initialisation failed; the docs also list RES_E_INTERNAL_FAIL_CONNECT (internal IPC no ipc) under -10003.10003 -No interprocess link (IPC) between the Python package and the terminal.10003 -The terminal did not respond in time.10005 0The operation completed successfully.1Generic success: the last call to the MetaTrader5 Python package worked.4001"Unexpected internal error" is MetaQuotes' whole description of this code.4002"Wrong parameter in the inner call of the client terminal function" is MetaQuotes' whole description of this code.4003"Wrong parameter when calling the system function" is MetaQuotes' whole description of this code.4004"Not enough memory to perform the system function" is MetaQuotes' whole description of this code.4005 ERR_The structure contains strings, dynamic arrays, classes, or structures that hold any of these.STRUCT_ WITHOBJECTS_ ORCLASS 4006The array is of the wrong type or the wrong size, or the object of a dynamic array is damaged.4007There is not enough memory to relocate an array, or the code tried to change the size of a static array.4008"Not enough memory for the relocation of string" is MetaQuotes' whole description of this code.4009"Not initialized string" is MetaQuotes' whole description of this code.4010"Invalid date and/or time" is MetaQuotes' whole description of this code.4011"Total amount of elements in the array cannot exceed 2147483647" is MetaQuotes' whole description of this code.4012"Wrong pointer" is MetaQuotes' whole description of this code.4013"Wrong type of pointer" is MetaQuotes' whole description of this code.4014"Function is not allowed for call" is MetaQuotes' whole description of this code.4015"The names of the dynamic and the static resource match" is MetaQuotes' whole description of this code.4016"Resource with this name has not been found in EX5" is MetaQuotes' whole description of this code.4017 ERR_"Unsupported resource type or its size exceeds 16 Mb" is MetaQuotes' whole description of this code.RESOURCE_ UNSUPPORTED_ TYPE 4018 ERR_"The resource name exceeds 63 characters" is MetaQuotes' whole description of this code.RESOURCE_ NAME_ IS_ TOO_ LONG 4019"Overflow occurred when calculating math function" is MetaQuotes' whole description of this code.4020"Out of test end date after calling Sleep()" is MetaQuotes' whole description of this code.4022The test was forcibly stopped from outside.4023"Invalid type" is MetaQuotes' whole description of this code.4024"Invalid handle" is MetaQuotes' whole description of this code.4025"Object pool filled out" is MetaQuotes' whole description of this code.4101"Wrong chart ID" is MetaQuotes' whole description of this code.4102"Chart does not respond" is MetaQuotes' whole description of this code.4103"Chart not found" is MetaQuotes' whole description of this code.4104"No Expert Advisor in the chart that could handle the event" is MetaQuotes' whole description of this code.4105"Chart opening error" is MetaQuotes' whole description of this code.4106"Failed to change chart symbol and period" is MetaQuotes' whole description of this code.4107"Error value of the parameter for the function of working with charts" is MetaQuotes' whole description of this code.4108 ERR_"Failed to create timer" is MetaQuotes' whole description of this code.CHART_ CANNOT_ CREATE_ TIMER 4109"Wrong chart property ID" is MetaQuotes' whole description of this code.4110"Error creating screenshots" is MetaQuotes' whole description of this code.4111"Error navigating through chart" is MetaQuotes' whole description of this code.4112"Error applying template" is MetaQuotes' whole description of this code.4113"Subwindow containing the indicator was not found" is MetaQuotes' whole description of this code.4114 ERR_"Error adding an indicator to chart" is MetaQuotes' whole description of this code.CHART_ INDICATOR_ CANNOT_ ADD 4115 ERR_"Error deleting an indicator from the chart" is MetaQuotes' whole description of this code.CHART_ INDICATOR_ CANNOT_ DEL 4116 ERR_"Indicator not found on the specified chart" is MetaQuotes' whole description of this code.CHART_ INDICATOR_ NOT_ FOUND 4201"Error working with a graphical object" is MetaQuotes' whole description of this code.4202"Graphical object was not found" is MetaQuotes' whole description of this code.4203"Wrong ID of a graphical object property" is MetaQuotes' whole description of this code.4204"Unable to get date corresponding to the value" is MetaQuotes' whole description of this code.4205"Unable to get value corresponding to the date" is MetaQuotes' whole description of this code.4301"Unknown symbol" is MetaQuotes' whole description of this code.4302"Symbol is not selected in MarketWatch" is MetaQuotes' whole description of this code.4303"Wrong identifier of a symbol property" is MetaQuotes' whole description of this code.4304"Time of the last tick is not known (no ticks)" is MetaQuotes' whole description of this code.4305"Error adding or deleting a symbol in MarketWatch" is MetaQuotes' whole description of this code.4306"Exceeded the limit of selected symbols in MarketWatch" is MetaQuotes' whole description of this code.4307The session ID passed to SymbolInfoSessionQuote or SymbolInfoSessionTrade is wrong.4401"Requested history not found" is MetaQuotes' whole description of this code.4402"Wrong ID of the history property" is MetaQuotes' whole description of this code.4403"Exceeded history request timeout" is MetaQuotes' whole description of this code.4404"Number of requested bars limited by terminal settings" is MetaQuotes' whole description of this code.4405"Multiple errors when loading history" is MetaQuotes' whole description of this code.4407"Receiving array is too small to store all requested data" is MetaQuotes' whole description of this code.4501"Global variable of the client terminal is not found" is MetaQuotes' whole description of this code.4502"Global variable of the client terminal with the same name already exists" is MetaQuotes' whole description of this code.4503 ERR_"Global variables were not modified" is MetaQuotes' whole description of this code.GLOBALVARIABLE_ NOT_ MODIFIED 4504 ERR_"Cannot read file with global variable values" is MetaQuotes' whole description of this code.GLOBALVARIABLE_ CANNOTREAD 4505 ERR_"Cannot write file with global variable values" is MetaQuotes' whole description of this code.GLOBALVARIABLE_ CANNOTWRITE 4510"Email sending failed" is MetaQuotes' whole description of this code.4511"Sound playing failed" is MetaQuotes' whole description of this code.4512"Wrong identifier of the program property" is MetaQuotes' whole description of this code.4513"Wrong identifier of the terminal property" is MetaQuotes' whole description of this code.4514"File sending via ftp failed" is MetaQuotes' whole description of this code.4515"Failed to send a notification" is MetaQuotes' whole description of this code.4516 ERR_The parameter for sending a notification is invalid: an empty string or NULL was passed to SendNotification().NOTIFICATION_ WRONG_ PARAMETER 4517 ERR_The notification settings in the terminal are wrong: the ID is not specified or permission is not set.NOTIFICATION_ WRONG_ SETTINGS 4518 ERR_"Too frequent sending of notifications" is MetaQuotes' whole description of this code.NOTIFICATION_ TOO_ FREQUENT 4519"FTP server is not specified" is MetaQuotes' whole description of this code.4520"FTP login is not specified" is MetaQuotes' whole description of this code.4521The file to send to the FTP server was not found in the Files directory under MQL5.4522"FTP connection failed" is MetaQuotes' whole description of this code.4523"FTP path not found on server" is MetaQuotes' whole description of this code.4601"Not enough memory for the distribution of indicator buffers" is MetaQuotes' whole description of this code.4602"Wrong indicator buffer index" is MetaQuotes' whole description of this code.4603"Wrong ID of the custom indicator property" is MetaQuotes' whole description of this code.4701"Wrong account property ID" is MetaQuotes' whole description of this code.4751"Wrong trade property ID" is MetaQuotes' whole description of this code.4752Trading by Expert Advisors is prohibited.4753"Position not found" is MetaQuotes' whole description of this code.4754"Order not found" is MetaQuotes' whole description of this code.4755"Deal not found" is MetaQuotes' whole description of this code.4756"Trade request sending failed" is MetaQuotes' whole description of this code.4758"Failed to calculate profit or margin" is MetaQuotes' whole description of this code.4801"Unknown symbol" is MetaQuotes' whole description of this code.4802"Indicator cannot be created" is MetaQuotes' whole description of this code.4803"Not enough memory to add the indicator" is MetaQuotes' whole description of this code.4804"The indicator cannot be applied to another indicator" is MetaQuotes' whole description of this code.4805"Error applying an indicator to chart" is MetaQuotes' whole description of this code.4806"Requested data not found" is MetaQuotes' whole description of this code.4807"Wrong indicator handle" is MetaQuotes' whole description of this code.4808 ERR_"Wrong number of parameters when creating an indicator" is MetaQuotes' whole description of this code.INDICATOR_ WRONG_ PARAMETERS 4809 ERR_"No parameters when creating an indicator" is MetaQuotes' whole description of this code.INDICATOR_ PARAMETERS_ MISSING 4810"The first parameter in the array must be the name of the custom indicator" is MetaQuotes' whole description of this code.4811"Invalid parameter type in the array when creating an indicator" is MetaQuotes' whole description of this code.4812"Wrong index of the requested indicator buffer" is MetaQuotes' whole description of this code.4901"Depth Of Market can not be added" is MetaQuotes' whole description of this code.4902"Depth Of Market can not be removed" is MetaQuotes' whole description of this code.4903"The data from Depth Of Market can not be obtained" is MetaQuotes' whole description of this code.4904"Error in subscribing to receive new data from Depth Of Market" is MetaQuotes' whole description of this code.5001"More than 64 files cannot be opened at the same time" is MetaQuotes' whole description of this code.5002"Invalid file name" is MetaQuotes' whole description of this code.5003"Too long file name" is MetaQuotes' whole description of this code.5004"File opening error" is MetaQuotes' whole description of this code.5005"Not enough memory for cache to read" is MetaQuotes' whole description of this code.5006"File deleting error" is MetaQuotes' whole description of this code.5007The file with this handle was closed, or was never opened.5008"Wrong file handle" is MetaQuotes' whole description of this code.5009"The file must be opened for writing" is MetaQuotes' whole description of this code.5010"The file must be opened for reading" is MetaQuotes' whole description of this code.5011"The file must be opened as a binary one" is MetaQuotes' whole description of this code.5012"The file must be opened as a text" is MetaQuotes' whole description of this code.5013"The file must be opened as a text or CSV" is MetaQuotes' whole description of this code.5014"The file must be opened as CSV" is MetaQuotes' whole description of this code.5015"File reading error" is MetaQuotes' whole description of this code.5016"String size must be specified, because the file is opened as binary" is MetaQuotes' whole description of this code.5017"A text file must be for string arrays, for other arrays - binary" is MetaQuotes' whole description of this code.5018"This is not a file, this is a directory" is MetaQuotes' whole description of this code.5019"File does not exist" is MetaQuotes' whole description of this code.5020"File can not be rewritten" is MetaQuotes' whole description of this code.5021"Wrong directory name" is MetaQuotes' whole description of this code.5022"Directory does not exist" is MetaQuotes' whole description of this code.5023"This is a file, not a directory" is MetaQuotes' whole description of this code.5024"The directory cannot be removed" is MetaQuotes' whole description of this code.5025The directory could not be cleared.5026"Failed to write a resource to a file" is MetaQuotes' whole description of this code.5027The end of a CSV file was reached, so the next piece of data could not be read.5030"No date in the string" is MetaQuotes' whole description of this code.5031"Wrong date in the string" is MetaQuotes' whole description of this code.5032"Wrong time in the string" is MetaQuotes' whole description of this code.5033"Error converting string to date" is MetaQuotes' whole description of this code.5034"Not enough memory for the string" is MetaQuotes' whole description of this code.5035"The string length is less than expected" is MetaQuotes' whole description of this code.5036"Too large number, more than ULONG_MAX" is MetaQuotes' whole description of this code.5037"Invalid format string" is MetaQuotes' whole description of this code.5038"Amount of format specifiers more than the parameters" is MetaQuotes' whole description of this code.5039"Amount of parameters more than the format specifiers" is MetaQuotes' whole description of this code.5040"Damaged parameter of string type" is MetaQuotes' whole description of this code.5041"Position outside the string" is MetaQuotes' whole description of this code.5042"0 added to the string end, a useless operation" is MetaQuotes' whole description of this code.5043"Unknown data type when converting to a string" is MetaQuotes' whole description of this code.5044"Damaged string object" is MetaQuotes' whole description of this code.5050The arrays being copied are incompatible.5051"The receiving array is declared as AS_SERIES, and it is of insufficient size" is MetaQuotes' whole description of this code.5052"Too small array, the starting position is outside the array" is MetaQuotes' whole description of this code.5053"An array of zero length" is MetaQuotes' whole description of this code.5054"Must be a numeric array" is MetaQuotes' whole description of this code.5055"Must be a one-dimensional array" is MetaQuotes' whole description of this code.5056"Timeseries cannot be used" is MetaQuotes' whole description of this code.5057"Must be an array of type double" is MetaQuotes' whole description of this code.5058"Must be an array of type float" is MetaQuotes' whole description of this code.5059"Must be an array of type long" is MetaQuotes' whole description of this code.5060"Must be an array of type int" is MetaQuotes' whole description of this code.5061"Must be an array of type short" is MetaQuotes' whole description of this code.5062"Must be an array of type char" is MetaQuotes' whole description of this code.5063"String array only" is MetaQuotes' whole description of this code.5100"OpenCL functions are not supported on this computer" is MetaQuotes' whole description of this code.5101"Internal error occurred when running OpenCL" is MetaQuotes' whole description of this code.5102"Invalid OpenCL handle" is MetaQuotes' whole description of this code.5103"Error creating the OpenCL context" is MetaQuotes' whole description of this code.5104"Failed to create a run queue in OpenCL" is MetaQuotes' whole description of this code.5105"Error occurred when compiling an OpenCL program" is MetaQuotes' whole description of this code.5106 ERR_"Too long kernel name (OpenCL kernel)" is MetaQuotes' whole description of this code.OPENCL_ TOO_ LONG_ KERNEL_ NAME 5107"Error creating an OpenCL kernel" is MetaQuotes' whole description of this code.5108 ERR_"Error occurred when setting parameters for the OpenCL kernel" is MetaQuotes' whole description of this code.OPENCL_ SET_ KERNEL_ PARAMETER 5109"OpenCL program runtime error" is MetaQuotes' whole description of this code.5110"Invalid size of the OpenCL buffer" is MetaQuotes' whole description of this code.5111 ERR_"Invalid offset in the OpenCL buffer" is MetaQuotes' whole description of this code.OPENCL_ WRONG_ BUFFER_ OFFSET 5112"Failed to create an OpenCL buffer" is MetaQuotes' whole description of this code.5113"Too many OpenCL objects" is MetaQuotes' whole description of this code.5114"OpenCL device selection error" is MetaQuotes' whole description of this code.5120"Internal database error" is MetaQuotes' whole description of this code.5121"Invalid database handle" is MetaQuotes' whole description of this code.5122 ERR_"Exceeded the maximum acceptable number of Database objects" is MetaQuotes' whole description of this code.DATABASE_ TOO_ MANY_ OBJECTS 5123"Database connection error" is MetaQuotes' whole description of this code.5124"Request execution error" is MetaQuotes' whole description of this code.5125"Request generation error" is MetaQuotes' whole description of this code.5126"No more data to read" is MetaQuotes' whole description of this code.5127"Failed to move to the next request entry" is MetaQuotes' whole description of this code.5128"Data for reading request results are not ready yet" is MetaQuotes' whole description of this code.5129"Failed to auto substitute parameters to an SQL request" is MetaQuotes' whole description of this code.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 5202"Timeout exceeded" is MetaQuotes' whole description of this code.5203 ERR_"HTTP request failed" is MetaQuotes' whole description of this code.WEBREQUEST_ REQUEST_ FAILED 5270"Invalid socket handle passed to function" is MetaQuotes' whole description of this code.5271 ERR_"Too many open sockets (max 128)" is MetaQuotes' whole description of this code.NETSOCKET_ TOO_ MANY_ OPENED 5272"Failed to connect to remote host" is MetaQuotes' whole description of this code.5273"Failed to send/receive data from socket" is MetaQuotes' whole description of this code.5274 ERR_"Failed to establish secure connection (TLS Handshake)" is MetaQuotes' whole description of this code.NETSOCKET_ HANDSHAKE_ FAILED 5275"No data on certificate protecting the connection" is MetaQuotes' whole description of this code.5300"A custom symbol must be specified" is MetaQuotes' whole description of this code.5301The name of the custom symbol is invalid.5302The name of the custom symbol is too long.5303The path of the custom symbol is too long.5304"A custom symbol with the same name already exists" is MetaQuotes' whole description of this code.5305"Error occurred while creating, deleting or changing the custom symbol" is MetaQuotes' whole description of this code.5306"You are trying to delete a custom symbol selected in Market Watch" is MetaQuotes' whole description of this code.5307 ERR_"An invalid custom symbol property" is MetaQuotes' whole description of this code.CUSTOM_ SYMBOL_ PROPERTY_ WRONG 5308 ERR_"A wrong parameter while setting the property of a custom symbol" is MetaQuotes' whole description of this code.CUSTOM_ SYMBOL_ PARAMETER_ ERROR 5309 ERR_"A too long string parameter while setting the property of a custom symbol" is MetaQuotes' whole description of this code.CUSTOM_ SYMBOL_ PARAMETER_ LONG 5310"Ticks in the array are not arranged in the order of time" is MetaQuotes' whole description of this code.5400"Array size is insufficient for receiving descriptions of all values" is MetaQuotes' whole description of this code.5401"Request time limit exceeded" is MetaQuotes' whole description of this code.5402"Country is not found" is MetaQuotes' whole description of this code.5601"Generic error" is MetaQuotes' whole description of this code.5602"SQLite internal logic error" is MetaQuotes' whole description of this code.5603"Access denied" is MetaQuotes' whole description of this code.5604"Callback routine requested abort" is MetaQuotes' whole description of this code.5605"Database file locked" is MetaQuotes' whole description of this code.5606"Database table locked" is MetaQuotes' whole description of this code.5607"Insufficient memory for completing operation" is MetaQuotes' whole description of this code.5608"Attempt to write to readonly database" is MetaQuotes' whole description of this code.5609"Operation terminated by sqlite3_interrupt()" is MetaQuotes' whole description of this code.5610"Disk I/O error" is MetaQuotes' whole description of this code.5611"Database disk image corrupted" is MetaQuotes' whole description of this code.5612"Unknown operation code in sqlite3_file_control()" is MetaQuotes' whole description of this code.5613"Insertion failed because database is full" is MetaQuotes' whole description of this code.5614"Unable to open the database file" is MetaQuotes' whole description of this code.5615"Database lock protocol error" is MetaQuotes' whole description of this code.5616"Internal use only" is MetaQuotes' whole description of this code.5617"Database schema changed" is MetaQuotes' whole description of this code.5618"String or BLOB exceeds size limit" is MetaQuotes' whole description of this code.5619"Abort due to constraint violation" is MetaQuotes' whole description of this code.5620"Data type mismatch" is MetaQuotes' whole description of this code.5621"Library used incorrectly" is MetaQuotes' whole description of this code.5622"Uses OS features not supported on host" is MetaQuotes' whole description of this code.5623"Authorization denied" is MetaQuotes' whole description of this code.5624"Not used" is MetaQuotes' whole description of this code.5625"Bind parameter error, incorrect index" is MetaQuotes' whole description of this code.5626"File opened that is not database file" is MetaQuotes' whole description of this code.5700"Internal error of the matrix/vector executing subsystem" is MetaQuotes' whole description of this code.5701"Matrix/vector not initialized" is MetaQuotes' whole description of this code.5702"Inconsistent size of matrices/vectors in operation" is MetaQuotes' whole description of this code.5703"Invalid matrix/vector size" is MetaQuotes' whole description of this code.5704"Invalid matrix/vector type" is MetaQuotes' whole description of this code.5705"Function not available for this matrix/vector" is MetaQuotes' whole description of this code.5706"Matrix/vector contains non-numbers (Nan/Inf)" is MetaQuotes' whole description of this code.5707"Error during execution of an OpenBLAS function" is MetaQuotes' whole description of this code.5708 ERR_"Invalid parameter of an OpenBLAS function" is MetaQuotes' whole description of this code.MATRIX_ OPENBLAS_ PARAMETER 5800"ONNX internal error" is MetaQuotes' whole description of this code.5801"ONNX Runtime API initialization error" is MetaQuotes' whole description of this code.5802"Property or value not supported by MQL5" is MetaQuotes' whole description of this code.5803"ONNX runtime API run error" is MetaQuotes' whole description of this code.5804 ERR_"Invalid number of parameters passed to OnnxRun" is MetaQuotes' whole description of this code.ONNX_ INVALID_ PARAMETERS_ COUNT 5805"Invalid parameter value" is MetaQuotes' whole description of this code.5806 ERR_"Invalid parameter type" is MetaQuotes' whole description of this code.ONNX_ INVALID_ PARAMETER_ TYPE 5807 ERR_"Invalid parameter size" is MetaQuotes' whole description of this code.ONNX_ INVALID_ PARAMETER_ SIZE 5808"Tensor dimension not set or invalid" is MetaQuotes' whole description of this code.10004The price changed and the server offered a new one.10006The server rejected the request.10007The request was cancelled by the trader.10008The order was placed.10009The request was completed.10010Only part of the request was completed.10011The server reports an error in processing the request.10012The request was cancelled because it timed out.10013The trade request is malformed.10014Volume is outside min, max or step for the symbol.10015The price is not valid.10016Stop loss or take profit is invalid, often too close to price.10017 TRADE_Trading is disabled.RETCODE_ TRADE_ DISABLED 10018The market is closed.10019Insufficient margin.10020Prices changed while the request was being handled.10021There are no quotes to process the request.10022 TRADE_The order expiration date in the request is invalid.RETCODE_ INVALID_ EXPIRATION 10023The state of the order changed.10024 TRADE_Requests are being sent too often.RETCODE_ TOO_ MANY_ REQUESTS 10025The request contains no changes.10026 TRADE_Autotrading is disabled by the server.RETCODE_ SERVER_ DISABLES_ AT 10027Algo trading is switched off in the terminal.10028The request is locked for processing.10029The order or position is frozen.10030Invalid order filling type: order_send asked for a filling mode the symbol does not allow.10031There is no connection with the trade server.10032The operation is allowed only for live accounts.10033The number of pending orders has reached the limit.10034The volume of orders and positions for the symbol has reached the limit.10035The order type is incorrect or prohibited.10036 TRADE_The position with the specified POSITION_IDENTIFIER has already been closed.RETCODE_ POSITION_ CLOSED 10038 TRADE_The close volume is larger than the current volume of the position.RETCODE_ INVALID_ CLOSE_ VOLUME 10039 TRADE_A close order already exists for the position.RETCODE_ CLOSE_ ORDER_ EXIST 10040 TRADE_The number of open positions on the account has reached a limit set on the server.RETCODE_ LIMIT_ POSITIONS 10041The request to activate a pending order was rejected and the order was cancelled.10042The request was rejected because the symbol has the rule "Only long positions are allowed" (POSITION_TYPE_BUY).10043The request was rejected because the symbol has the rule "Only short positions are allowed" (POSITION_TYPE_SELL).10044The request was rejected because the symbol has the rule "Only position closing is allowed".10045The request was rejected because the trading account has the flag "Position closing is allowed only by FIFO rule" set (ACCOUNT_FIFO_CLOSE=true).10046 TRADE_The request was rejected because the trading account has the rule "Opposite positions on a single symbol are disabled".RETCODE_ HEDGE_ PROHIBITED 65536This is not an error in itself: it is the first code available for errors that a program defines for itself.
MetaTrader 5 API: questions and answers
Each answer is read from the record on this page, not written separately. Where the record is unverified, the answer says so.
How do I get access to the MetaTrader 5 API?
Install the MT5 terminal from your broker, then pip install MetaTrader5 on Windows x86-64 or write MQL5 in MetaEditor. The terminal must be at build 4755 or later.
order_sendchecked
Who can use the MetaTrader 5 API?
Real accounts come from brokers offering MT5; the API runs through your own local terminal.
MetaTrader 5 API demo: is there a demo or sandbox?
Yes: demo accounts can be opened from within the terminal.
What are the MetaTrader 5 API rate limits?
Not published. The Python page states none, carries no version and no date, and gives no consolidated error list beyond last_error() (read 22 Sep 2026).
MetaTrader for Pythonchecked
How does MetaTrader 5 API authentication work?
No API keys: initialize() connects to the local terminal, optionally with account login, password and server.
initializechecked
Does the MetaTrader 5 API support streaming?
No push API in Python: poll ticks and bars; market_book_add subscribes the terminal to depth events. MQL5 EAs get tick events.
MetaTrader for Pythonchecked
How much history does the MetaTrader 5 API return?
Bars limited to the terminal's Max bars in chart setting. Deal history by date range with no stated limit.
MQL5 docs: copy_rates_fromchecked
Is there a Python library for the MetaTrader 5 API?
This register lists these Python libraries for the MetaTrader 5 API. MetaTrader5 (official, Python): Official MetaQuotes package, version 5.0.6231 of 27 Sep 2026, MIT licence, CPython 3.6 to 3.14, classified Production/Stable. Wheels are published for Windows x86-64 only, so the Python route is Windows only. Community Python MCP server (MQL5 article 21905) (community, Python): A community route documented in MQL5's own article library on 30 Apr 2026, separate from the native MCP in build 6060. It exposes 14 tools including place, modify and cancel orders, is Windows only because of the MT5 Python API, is single-threaded, and executes on whatever account MT5 is logged into. It has no approval step. The author advises demo testing first.
MetaTrader5checked Community Python MCP server (MQL5 article 21905)checked
Which brokers offer MetaTrader 5?
Brokers on this register recorded as offering MetaTrader 5, with a source: Axi, IG, OANDA, Pepperstone, Swissquote, ThinkMarkets and Tickmill. Recorded as offering it but unverified: FxPro.
Axi UKchecked IG UK MetaTrader 5checked OANDA UK MetaTrader 5checked Pepperstone UK trading platformschecked Swissquote UK, forex and CFD platformschecked ThinkMarkets support: Spread betting accountchecked Tickmill UKchecked
MetaTrader 5 API questions, each answered in a sentence or two.
Everything this site records for MetaTrader 5 (Python package and MQL5), as one JSON file. Each section of the file states its own licence. About the files. This page as Markdown.
MetaTrader 5 API guides and reference
- MetaTrader 5 API quickstart: key to first call
- MetaTrader 5 API error codes
- Claude with MetaTrader 5: a safe, read-first setupThere are two routes: MetaTrader 5's own AI and MCP support, where Anthropic is a selectable provider, or Claude writing Python for the MetaTrader5 package. Either way, start on demo, read before you trade and confirm every order yourself.
- MetaTrader 5 for Python: which platforms does it run on?The commonest question about the MetaTrader 5 Python package is which operating systems it runs on. The vendor’s own page does not answer it.
- MT5 trade history to a spreadsheet with PythonAsked over and over on the MQL5 forum and answered in no single place. This is the whole job: the constraint that stops most people, the one call that does the work, and a script that writes a CSV.
- MetaTrader 5 Python internal error codes
- MetaTrader5 Python package on Linux and macOS: it needs Windows
- MT5 Python initialize() failed: error -10005, IPC timeout
- MT5 Python initialize() hangs: terminal build mismatch
MetaTrader 5 API compared
The same fields from two records, side by side. No winner is picked.
What changed recently for the MetaTrader 5 API
Addition
MetaTrader5 Python package 5.0.6180 on PyPI, Windows x86-64 builds for Python 3.6 to 3.14, so a Linux host still needs a bridge. It follows 5.0.6162 (3 Sep), 5.0.6147 (27 Aug), 5.0.6090 (1 Aug) and 5.0.6070 (28 Jul).
MetaTrader5 on PyPIchecked
Addition
Build 6180, 3 Sep 2026, is the current MetaTrader 5 build. It gave the AI Assistant Strategy Tester powers: retrieving tester reports, launching optimisations, and reading tester and expert advisor logs. The 6180 page does not itself use the word MCP, and the MQL5 language reference still carries no MCP section, so MCP remains a terminal feature rather than a language feature.
Addition
Build 6140 added LLM providers including Alibaba, Cerebras and z.ai, added an MCP tool to halt the Strategy Tester, and cut the built-in MQL5.community context window from 1,000,000 to 500,000 tokens.
The newest entries are shown. Every dated change, all brokers and platforms. Follow MetaTrader 5 changes by RSS
Sample apps that use the MetaTrader 5 API
- MT5 trade journal exportConnects to your running MetaTrader 5 terminal, reads closed deals and writes a trade journal CSV.
- PipDeckOur Stream Deck plugin for MetaTrader 5 and TradeLocker, built as a TypeScript monorepo of six packages. The repo is private for now and goes public soon.
Open source repositories for MetaTrader 5
Read from GitHub's own records and ordered by stars as read. A listing is not a recommendation. The first of the list is shown here.
Partner programme
Not verified. No programme page was opened, which is not evidence that no programme exists. The MetaQuotes partner programme record. The programme register holds every record. This site carries no affiliate links.
Brokers that offer MetaTrader 5 (Python package and MQL5)
| Broker | Entity | Note | Source |
|---|---|---|---|
| Axi | Axi Financial Services (UK) Limited | Listed on Axi's UK site, which says MT5 lets you develop algorithmic strategies with Expert Advisors. | Axi UKchecked |
| FxPro | FxPro group (UK entity not confirmed on page) | Listed on platform comparison; entity not stated. | UnverifiedFxPro platform comparisonchecked |
| IG | IG UK (IG Markets Ltd / IG Index Ltd) | MT5 offered to UK clients; page mentions running Expert Advisors, MQL5 and free VPS for qualifying accounts. Account type split (CFD vs spread bet) not stated on page. | IG UK MetaTrader 5checked |
| OANDA | OANDA Europe Limited | MT5 on web, desktop and mobile, live and demo. Expert Advisors allowed: 'Create expert advisors in MQL5 to automate your trading strategies'. | OANDA UK MetaTrader 5checked |
| Pepperstone | Pepperstone Limited | MetaTrader 5 is listed on the broker's UK platforms page for UK clients. | Pepperstone UK trading platformschecked |
| Swissquote | Swissquote Ltd (UK) | Listed on the UK private client forex and CFD platforms page, with Expert Advisors ticked in the comparison table. | Swissquote UK, forex and CFD platformschecked |
| ThinkMarkets | TF Global Markets (UK) Limited | Support article: spread betting is available on ThinkTrader, MT4 and MT5 for UK residents, so MT5 is offered to UK clients. | ThinkMarkets support: Spread betting accountchecked |
| Tickmill | Tickmill UK Ltd | MT5 on Windows, macOS, mobile and WebTrader. | Tickmill UKchecked |
How to cite this
MetaTrader 5 Python API. Broker API Hub, https://openbrokerapi.com/platforms/metatrader-5, newest check .
Where you rely on a single figure, cite the source and the checked date printed beside it as well.