# MetaTrader 4 API (MQL4)

Independent and unofficial. Not affiliated with or endorsed by any broker or platform named here. Educational only: nothing here is advice, and nothing here recommends a broker or a trade.

This is the markdown version of https://openbrokerapi.com/platforms/metatrader-4, written from the same records as that page.

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.

MetaQuotes' FX terminal; automation is MQL4 code running inside the terminal.

- Kind: Platform API
- Newest reading: 2026-10-12
- Official documentation: [docs.mql4.com](https://docs.mql4.com/)
- Everything recorded for MetaTrader 4 (MQL4), as one JSON file: https://openbrokerapi.com/data/platforms/metatrader-4.json

## Access, authentication and streaming

- How you get access: Install the MT4 terminal from a broker and write Expert Advisors or scripts in MQL4.
  - Status: verified. Source: [Install terminal (MT4 help)](https://www.metatrader4.com/en/trading-platform/help/userguide/installation), checked 2026-09-21.
- Who can use it: Real accounts can only be opened by brokerage companies that offer MT4.
  - Status: verified. Source: [Opening of accounts (MT4 help)](https://www.metatrader4.com/en/trading-platform/help/userguide/open_an_account), checked 2026-09-21.
- Demo: Yes: demo accounts can be opened from within the terminal.
  - Status: verified. Source: [Opening of accounts (MT4 help)](https://www.metatrader4.com/en/trading-platform/help/userguide/open_an_account), checked 2026-09-21.
- Authentication: No API keys: code runs inside a terminal already logged in to a trading account.
  - Status: verified. Source: [MQL4 Reference](https://docs.mql4.com/), checked 2026-09-20.
- Streaming: In-terminal events only (new tick, timer, depth changes); no external streaming API.
  - Status: verified. Source: [MQL4 Reference](https://docs.mql4.com/), checked 2026-09-20.
- History depth: Bars limited to the terminal's max bars in chart. Closed orders limited to what the Account History tab has loaded.
  - Status: verified. Source: [MQL4 docs: CopyRates](https://docs.mql4.com/series/copyrates), checked 2026-09-22.
- Rate limits, as worded: Not published
  - Status: verified. Source: [MQL4 Reference](https://docs.mql4.com/), checked 2026-09-20.

## MetaTrader 4 functions

28 documented functions. They are not HTTP endpoints: none has a method or a path. [Grouped by what they do](https://openbrokerapi.com/platforms/metatrader-4/functions).

- [AccountBalance()](https://openbrokerapi.com/platforms/metatrader-4/functions/mql4-accountbalance) (MQL4): Returns the balance of the account the terminal is logged in to.
- [AccountEquity()](https://openbrokerapi.com/platforms/metatrader-4/functions/mql4-accountequity) (MQL4): Returns the equity of the account the terminal is logged in to.
- [AccountFreeMargin()](https://openbrokerapi.com/platforms/metatrader-4/functions/mql4-accountfreemargin) (MQL4): Returns the free margin of the account the terminal is logged in to.
- [AccountFreeMarginCheck()](https://openbrokerapi.com/platforms/metatrader-4/functions/mql4-accountfreemargincheck) (MQL4): Returns the free margin that would be left after opening an order of a given symbol, direction and size at the current price.
- [AccountInfoDouble()](https://openbrokerapi.com/platforms/metatrader-4/functions/mql4-accountinfodouble) (MQL4): Returns one floating point property of the account, chosen by an identifier.
- [CopyRates()](https://openbrokerapi.com/platforms/metatrader-4/functions/mql4-copyrates) (MQL4): Copies historical bars of a symbol and timeframe into an array of MqlRates structures, by start position and count, by start time and count, or between two times.
- [iClose()](https://openbrokerapi.com/platforms/metatrader-4/functions/mql4-iclose) (MQL4): Returns the close price of one bar of a symbol and timeframe, counted back from the current bar.
- [MarketInfo()](https://openbrokerapi.com/platforms/metatrader-4/functions/mql4-marketinfo) (MQL4): Returns one item of data about a symbol in the Market Watch window, chosen by a request identifier: a price, or a dealing property such as the stop level.
- [OrderClose()](https://openbrokerapi.com/platforms/metatrader-4/functions/mql4-orderclose) (MQL4): Closes an open order, in full or for a given number of lots, at a price you pass.
- [OrderCloseBy()](https://openbrokerapi.com/platforms/metatrader-4/functions/mql4-ordercloseby) (MQL4): Closes an open order against another open order in the opposite direction.
- [OrderDelete()](https://openbrokerapi.com/platforms/metatrader-4/functions/mql4-orderdelete) (MQL4): Deletes a pending order that was placed earlier.
- [OrderLots()](https://openbrokerapi.com/platforms/metatrader-4/functions/mql4-orderlots) (MQL4): Returns the size, in lots, of the order now selected.
- [OrderMagicNumber()](https://openbrokerapi.com/platforms/metatrader-4/functions/mql4-ordermagicnumber) (MQL4): Returns the magic number of the order now selected, the identifier a program gave it when it was sent.
- [OrderModify()](https://openbrokerapi.com/platforms/metatrader-4/functions/mql4-ordermodify) (MQL4): Changes an open or pending order: its stop loss and take profit, and for a pending order its price and expiry too.
- [OrderOpenPrice()](https://openbrokerapi.com/platforms/metatrader-4/functions/mql4-orderopenprice) (MQL4): Returns the open price of the order now selected.
- [OrderProfit()](https://openbrokerapi.com/platforms/metatrader-4/functions/mql4-orderprofit) (MQL4): Returns the profit of the order now selected, before swaps and commission.
- [OrderSelect()](https://openbrokerapi.com/platforms/metatrader-4/functions/mql4-orderselect) (MQL4): Selects one order, by its place in a list or by its ticket, so that the functions which read an order's properties read that one.
- [OrderSend()](https://openbrokerapi.com/platforms/metatrader-4/functions/mql4-ordersend) (MQL4): Opens a market order or places a pending order. The page calls it the main function for doing either.
- [OrdersHistoryTotal()](https://openbrokerapi.com/platforms/metatrader-4/functions/mql4-ordershistorytotal) (MQL4): Returns how many closed orders are in the account history the terminal has loaded.
- [OrderStopLoss()](https://openbrokerapi.com/platforms/metatrader-4/functions/mql4-orderstoploss) (MQL4): Returns the stop loss level of the order now selected.
- [OrdersTotal()](https://openbrokerapi.com/platforms/metatrader-4/functions/mql4-orderstotal) (MQL4): Returns how many market and pending orders the account has.
- [OrderSymbol()](https://openbrokerapi.com/platforms/metatrader-4/functions/mql4-ordersymbol) (MQL4): Returns the symbol of the order now selected.
- [OrderTakeProfit()](https://openbrokerapi.com/platforms/metatrader-4/functions/mql4-ordertakeprofit) (MQL4): Returns the take profit level of the order now selected.
- [OrderTicket()](https://openbrokerapi.com/platforms/metatrader-4/functions/mql4-orderticket) (MQL4): Returns the ticket number of the order now selected.
- [OrderType()](https://openbrokerapi.com/platforms/metatrader-4/functions/mql4-ordertype) (MQL4): Returns the operation type of the order now selected, which says whether it is a buy or a sell and whether it is open or pending.
- [RefreshRates()](https://openbrokerapi.com/platforms/metatrader-4/functions/mql4-refreshrates) (MQL4): Refreshes the predefined price variables and series arrays that a running program holds its own copy of.
- [SymbolInfoDouble()](https://openbrokerapi.com/platforms/metatrader-4/functions/mql4-symbolinfodouble) (MQL4): Returns one floating point property of a symbol, chosen by an identifier.
- [SymbolInfoTick()](https://openbrokerapi.com/platforms/metatrader-4/functions/mql4-symbolinfotick) (MQL4): Writes the current prices of a symbol, with the time they were last updated, into an MqlTick structure.

## MetaTrader 4 API error codes

161 decoded error codes. [All MetaTrader 4 (MQL4) errors](https://openbrokerapi.com/errors/mt4).

- [0](https://openbrokerapi.com/errors/mt4/0-err-no-error): No error was returned.
- [1](https://openbrokerapi.com/errors/mt4/1-err-no-result): No error was returned, but the result is unknown.
- [2](https://openbrokerapi.com/errors/mt4/2-err-common-error): "Common error" is MetaQuotes' whole description of this code.
- [3](https://openbrokerapi.com/errors/mt4/3-err-invalid-trade-parameters): "Invalid trade parameters" is MetaQuotes' whole description of this code.
- [4](https://openbrokerapi.com/errors/mt4/4-err-server-busy): "Trade server is busy" is MetaQuotes' whole description of this code.
- [5](https://openbrokerapi.com/errors/mt4/5-err-old-version): "Old version of the client terminal" is MetaQuotes' whole description of this code.
- [6](https://openbrokerapi.com/errors/mt4/6-err-no-connection): "No connection with trade server" is MetaQuotes' whole description of this code.
- [7](https://openbrokerapi.com/errors/mt4/7-err-not-enough-rights): "Not enough rights" is MetaQuotes' whole description of this code.
- [8](https://openbrokerapi.com/errors/mt4/8-err-too-frequent-requests): "Too frequent requests" is MetaQuotes' whole description of this code.
- [9](https://openbrokerapi.com/errors/mt4/9-err-malfunctional-trade): "Malfunctional trade operation" is MetaQuotes' whole description of this code.
- [64](https://openbrokerapi.com/errors/mt4/64-err-account-disabled): "Account disabled" is MetaQuotes' whole description of this code.
- [65](https://openbrokerapi.com/errors/mt4/65-err-invalid-account): "Invalid account" is MetaQuotes' whole description of this code.
- [128](https://openbrokerapi.com/errors/mt4/128-err-trade-timeout): "Trade timeout" is MetaQuotes' whole description of this code.
- [129](https://openbrokerapi.com/errors/mt4/129-err-invalid-price): "Invalid price" is MetaQuotes' whole description of this code.
- [130](https://openbrokerapi.com/errors/mt4/130-err-invalid-stops): "Invalid stops" is MetaQuotes' whole description of this code.
- [131](https://openbrokerapi.com/errors/mt4/131-err-invalid-trade-volume): "Invalid trade volume" is MetaQuotes' whole description of this code.
- [132](https://openbrokerapi.com/errors/mt4/132-err-market-closed): "Market is closed" is MetaQuotes' whole description of this code.
- [133](https://openbrokerapi.com/errors/mt4/133-err-trade-disabled): "Trade is disabled" is MetaQuotes' whole description of this code.
- [134](https://openbrokerapi.com/errors/mt4/134-err-not-enough-money): "Not enough money" is MetaQuotes' whole description of this code.
- [135](https://openbrokerapi.com/errors/mt4/135-err-price-changed): "Price changed" is MetaQuotes' whole description of this code.
- [136](https://openbrokerapi.com/errors/mt4/136-err-off-quotes): "Off quotes" is MetaQuotes' whole description of this code.
- [137](https://openbrokerapi.com/errors/mt4/137-err-broker-busy): "Broker is busy" is MetaQuotes' whole description of this code.
- [138](https://openbrokerapi.com/errors/mt4/138-err-requote): "Requote" is MetaQuotes' whole description of this code.
- [139](https://openbrokerapi.com/errors/mt4/139-err-order-locked): "Order is locked" is MetaQuotes' whole description of this code.
- [140 ERR_LONG_POSITIONS_ONLY_ALLOWED](https://openbrokerapi.com/errors/mt4/140): Only buy orders are allowed.
- [141](https://openbrokerapi.com/errors/mt4/141-err-too-many-requests): "Too many requests" is MetaQuotes' whole description of this code.
- [145](https://openbrokerapi.com/errors/mt4/145-err-trade-modify-denied): The modification was denied because the order is too close to the market.
- [146](https://openbrokerapi.com/errors/mt4/146-err-trade-context-busy): "Trade context is busy" is MetaQuotes' whole description of this code.
- [147](https://openbrokerapi.com/errors/mt4/147-err-trade-expiration-denied): Expirations are denied by the broker.
- [148](https://openbrokerapi.com/errors/mt4/148-err-trade-too-many-orders): The number of open and pending orders has reached the limit set by the broker.
- [149](https://openbrokerapi.com/errors/mt4/149-err-trade-hedge-prohibited): The code tried to open an order opposite to an existing one while hedging is disabled.
- [150](https://openbrokerapi.com/errors/mt4/150-err-trade-prohibited-by-fifo): The code tried to close an order in a way that breaks the FIFO rule.
- [4000](https://openbrokerapi.com/errors/mt4/4000-err-no-mqlerror): No error was returned.
- [4001](https://openbrokerapi.com/errors/mt4/4001-err-wrong-function-pointer): "Wrong function pointer" is MetaQuotes' whole description of this code.
- [4002](https://openbrokerapi.com/errors/mt4/4002-err-array-index-out-of-range): "Array index is out of range" is MetaQuotes' whole description of this code.
- [4003](https://openbrokerapi.com/errors/mt4/4003-err-no-memory-for-call-stack): "No memory for function call stack" is MetaQuotes' whole description of this code.
- [4004](https://openbrokerapi.com/errors/mt4/4004-err-recursive-stack-overflow): "Recursive stack overflow" is MetaQuotes' whole description of this code.
- [4005 ERR_NOT_ENOUGH_STACK_FOR_PARAM](https://openbrokerapi.com/errors/mt4/4005): "Not enough stack for parameter" is MetaQuotes' whole description of this code.
- [4006 ERR_NO_MEMORY_FOR_PARAM_STRING](https://openbrokerapi.com/errors/mt4/4006): "No memory for parameter string" is MetaQuotes' whole description of this code.
- [4007 ERR_NO_MEMORY_FOR_TEMP_STRING](https://openbrokerapi.com/errors/mt4/4007): "No memory for temp string" is MetaQuotes' whole description of this code.
- [4008](https://openbrokerapi.com/errors/mt4/4008-err-not-initialized-string): "Not initialized string" is MetaQuotes' whole description of this code.
- [4009 ERR_NOT_INITIALIZED_ARRAYSTRING](https://openbrokerapi.com/errors/mt4/4009): "Not initialized string in array" is MetaQuotes' whole description of this code.
- [4010 ERR_NO_MEMORY_FOR_ARRAYSTRING](https://openbrokerapi.com/errors/mt4/4010): "No memory for array string" is MetaQuotes' whole description of this code.
- [4011](https://openbrokerapi.com/errors/mt4/4011-err-too-long-string): "Too long string" is MetaQuotes' whole description of this code.
- [4012 ERR_REMAINDER_FROM_ZERO_DIVIDE](https://openbrokerapi.com/errors/mt4/4012): "Remainder from zero divide" is MetaQuotes' whole description of this code.
- [4013](https://openbrokerapi.com/errors/mt4/4013-err-zero-divide): "Zero divide" is MetaQuotes' whole description of this code.
- [4014](https://openbrokerapi.com/errors/mt4/4014-err-unknown-command): "Unknown command" is MetaQuotes' whole description of this code.
- [4015](https://openbrokerapi.com/errors/mt4/4015-err-wrong-jump): "Wrong jump" is MetaQuotes' description, and it marks this as an error that is never generated.
- [4016](https://openbrokerapi.com/errors/mt4/4016-err-not-initialized-array): "Not initialized array" is MetaQuotes' whole description of this code.
- [4017](https://openbrokerapi.com/errors/mt4/4017-err-dll-calls-not-allowed): "DLL calls are not allowed" is MetaQuotes' whole description of this code.
- [4018](https://openbrokerapi.com/errors/mt4/4018-err-cannot-load-library): "Cannot load library" is MetaQuotes' whole description of this code.
- [4019](https://openbrokerapi.com/errors/mt4/4019-err-cannot-call-function): "Cannot call function" is MetaQuotes' whole description of this code.
- [4020 ERR_EXTERNAL_CALLS_NOT_ALLOWED](https://openbrokerapi.com/errors/mt4/4020): "Expert function calls are not allowed" is MetaQuotes' whole description of this code.
- [4021 ERR_NO_MEMORY_FOR_RETURNED_STR](https://openbrokerapi.com/errors/mt4/4021): There is not enough memory for the temporary string returned from a function.
- [4022](https://openbrokerapi.com/errors/mt4/4022-err-system-busy): "System is busy" is MetaQuotes' description, and it marks this as an error that is never generated.
- [4023](https://openbrokerapi.com/errors/mt4/4023-err-dllfunc-criticalerror): "DLL-function call critical error" is MetaQuotes' whole description of this code.
- [4024](https://openbrokerapi.com/errors/mt4/4024-err-internal-error): "Internal error" is MetaQuotes' whole description of this code.
- [4025](https://openbrokerapi.com/errors/mt4/4025-err-out-of-memory): "Out of memory" is MetaQuotes' whole description of this code.
- [4026](https://openbrokerapi.com/errors/mt4/4026-err-invalid-pointer): "Invalid pointer" is MetaQuotes' whole description of this code.
- [4027 ERR_FORMAT_TOO_MANY_FORMATTERS](https://openbrokerapi.com/errors/mt4/4027): "Too many formatters in the format function" is MetaQuotes' whole description of this code.
- [4028 ERR_FORMAT_TOO_MANY_PARAMETERS](https://openbrokerapi.com/errors/mt4/4028): "Parameters count exceeds formatters count" is MetaQuotes' whole description of this code.
- [4029](https://openbrokerapi.com/errors/mt4/4029-err-array-invalid): "Invalid array" is MetaQuotes' whole description of this code.
- [4030](https://openbrokerapi.com/errors/mt4/4030-err-chart-noreply): "No reply from chart" is MetaQuotes' whole description of this code.
- [4050 ERR_INVALID_FUNCTION_PARAMSCNT](https://openbrokerapi.com/errors/mt4/4050): "Invalid function parameters count" is MetaQuotes' whole description of this code.
- [4051 ERR_INVALID_FUNCTION_PARAMVALUE](https://openbrokerapi.com/errors/mt4/4051): "Invalid function parameter value" is MetaQuotes' whole description of this code.
- [4052](https://openbrokerapi.com/errors/mt4/4052-err-string-function-internal): "String function internal error" is MetaQuotes' whole description of this code.
- [4053](https://openbrokerapi.com/errors/mt4/4053-err-some-array-error): "Some array error" is MetaQuotes' whole description of this code.
- [4054 ERR_INCORRECT_SERIESARRAY_USING](https://openbrokerapi.com/errors/mt4/4054): "Incorrect series array using" is MetaQuotes' whole description of this code.
- [4055](https://openbrokerapi.com/errors/mt4/4055-err-custom-indicator-error): "Custom indicator error" is MetaQuotes' whole description of this code.
- [4056](https://openbrokerapi.com/errors/mt4/4056-err-incompatible-arrays): "Arrays are incompatible" is MetaQuotes' whole description of this code.
- [4057 ERR_GLOBAL_VARIABLES_PROCESSING](https://openbrokerapi.com/errors/mt4/4057): "Global variables processing error" is MetaQuotes' whole description of this code.
- [4058 ERR_GLOBAL_VARIABLE_NOT_FOUND](https://openbrokerapi.com/errors/mt4/4058): "Global variable not found" is MetaQuotes' whole description of this code.
- [4059 ERR_FUNC_NOT_ALLOWED_IN_TESTING](https://openbrokerapi.com/errors/mt4/4059): "Function is not allowed in testing mode" is MetaQuotes' whole description of this code.
- [4060](https://openbrokerapi.com/errors/mt4/4060-err-function-not-confirmed): "Function is not allowed for call" is MetaQuotes' whole description of this code.
- [4061](https://openbrokerapi.com/errors/mt4/4061-err-send-mail-error): "Send mail error" is MetaQuotes' whole description of this code.
- [4062 ERR_STRING_PARAMETER_EXPECTED](https://openbrokerapi.com/errors/mt4/4062): "String parameter expected" is MetaQuotes' whole description of this code.
- [4063 ERR_INTEGER_PARAMETER_EXPECTED](https://openbrokerapi.com/errors/mt4/4063): "Integer parameter expected" is MetaQuotes' whole description of this code.
- [4064 ERR_DOUBLE_PARAMETER_EXPECTED](https://openbrokerapi.com/errors/mt4/4064): "Double parameter expected" is MetaQuotes' whole description of this code.
- [4065 ERR_ARRAY_AS_PARAMETER_EXPECTED](https://openbrokerapi.com/errors/mt4/4065): "Array as parameter expected" is MetaQuotes' whole description of this code.
- [4066](https://openbrokerapi.com/errors/mt4/4066-err-history-will-updated): "Requested history data is in updating state" is MetaQuotes' whole description of this code.
- [4067](https://openbrokerapi.com/errors/mt4/4067-err-trade-error): "Internal trade error" is MetaQuotes' whole description of this code.
- [4068](https://openbrokerapi.com/errors/mt4/4068-err-resource-not-found): "Resource not found" is MetaQuotes' whole description of this code.
- [4069](https://openbrokerapi.com/errors/mt4/4069-err-resource-not-supported): "Resource not supported" is MetaQuotes' whole description of this code.
- [4070](https://openbrokerapi.com/errors/mt4/4070-err-resource-duplicated): "Duplicate resource" is MetaQuotes' whole description of this code.
- [4071](https://openbrokerapi.com/errors/mt4/4071-err-indicator-cannot-init): "Custom indicator cannot initialize" is MetaQuotes' whole description of this code.
- [4072](https://openbrokerapi.com/errors/mt4/4072-err-indicator-cannot-load): "Cannot load custom indicator" is MetaQuotes' whole description of this code.
- [4073](https://openbrokerapi.com/errors/mt4/4073-err-no-history-data): "No history data" is MetaQuotes' whole description of this code.
- [4074](https://openbrokerapi.com/errors/mt4/4074-err-no-memory-for-history): "No memory for history data" is MetaQuotes' whole description of this code.
- [4075](https://openbrokerapi.com/errors/mt4/4075-err-no-memory-for-indicator): "Not enough memory for indicator calculation" is MetaQuotes' whole description of this code.
- [4099](https://openbrokerapi.com/errors/mt4/4099-err-end-of-file): "End of file" is MetaQuotes' whole description of this code.
- [4100](https://openbrokerapi.com/errors/mt4/4100-err-some-file-error): "Some file error" is MetaQuotes' whole description of this code.
- [4101](https://openbrokerapi.com/errors/mt4/4101-err-wrong-file-name): "Wrong file name" is MetaQuotes' whole description of this code.
- [4102](https://openbrokerapi.com/errors/mt4/4102-err-too-many-opened-files): "Too many opened files" is MetaQuotes' whole description of this code.
- [4103](https://openbrokerapi.com/errors/mt4/4103-err-cannot-open-file): "Cannot open file" is MetaQuotes' whole description of this code.
- [4104](https://openbrokerapi.com/errors/mt4/4104-err-incompatible-fileaccess): "Incompatible access to a file" is MetaQuotes' whole description of this code.
- [4105](https://openbrokerapi.com/errors/mt4/4105-err-no-order-selected): "No order selected" is MetaQuotes' whole description of this code.
- [4106](https://openbrokerapi.com/errors/mt4/4106-err-unknown-symbol): "Unknown symbol" is MetaQuotes' whole description of this code.
- [4107](https://openbrokerapi.com/errors/mt4/4107-err-invalid-price-param): "Invalid price" is MetaQuotes' whole description of this code.
- [4108](https://openbrokerapi.com/errors/mt4/4108-err-invalid-ticket): "Invalid ticket" is MetaQuotes' whole description of this code.
- [4109](https://openbrokerapi.com/errors/mt4/4109-err-trade-not-allowed): Trade is not allowed.
- [4110](https://openbrokerapi.com/errors/mt4/4110-err-longs-not-allowed): Long positions are not allowed.
- [4111](https://openbrokerapi.com/errors/mt4/4111-err-shorts-not-allowed): Short positions are not allowed.
- [4112 ERR_TRADE_EXPERT_DISABLED_BY_SERVER](https://openbrokerapi.com/errors/mt4/4112): "Automated trading by Expert Advisors/Scripts disabled by trade server" is MetaQuotes' whole description of this code.
- [4200](https://openbrokerapi.com/errors/mt4/4200-err-object-already-exists): "Object already exists" is MetaQuotes' whole description of this code.
- [4201](https://openbrokerapi.com/errors/mt4/4201-err-unknown-object-property): "Unknown object property" is MetaQuotes' whole description of this code.
- [4202](https://openbrokerapi.com/errors/mt4/4202-err-object-does-not-exist): "Object does not exist" is MetaQuotes' whole description of this code.
- [4203](https://openbrokerapi.com/errors/mt4/4203-err-unknown-object-type): "Unknown object type" is MetaQuotes' whole description of this code.
- [4204](https://openbrokerapi.com/errors/mt4/4204-err-no-object-name): "No object name" is MetaQuotes' whole description of this code.
- [4205](https://openbrokerapi.com/errors/mt4/4205-err-object-coordinates-error): "Object coordinates error" is MetaQuotes' whole description of this code.
- [4206](https://openbrokerapi.com/errors/mt4/4206-err-no-specified-subwindow): "No specified subwindow" is MetaQuotes' whole description of this code.
- [4207](https://openbrokerapi.com/errors/mt4/4207-err-some-object-error): "Graphical object error" is MetaQuotes' whole description of this code.
- [4210](https://openbrokerapi.com/errors/mt4/4210-err-chart-prop-invalid): "Unknown chart property" is MetaQuotes' whole description of this code.
- [4211](https://openbrokerapi.com/errors/mt4/4211-err-chart-not-found): "Chart not found" is MetaQuotes' whole description of this code.
- [4212](https://openbrokerapi.com/errors/mt4/4212-err-chartwindow-not-found): "Chart subwindow not found" is MetaQuotes' whole description of this code.
- [4213](https://openbrokerapi.com/errors/mt4/4213-err-chartindicator-not-found): "Chart indicator not found" is MetaQuotes' whole description of this code.
- [4220](https://openbrokerapi.com/errors/mt4/4220-err-symbol-select): "Symbol select error" is MetaQuotes' whole description of this code.
- [4250](https://openbrokerapi.com/errors/mt4/4250-err-notification-error): "Notification error" is MetaQuotes' whole description of this code.
- [4251](https://openbrokerapi.com/errors/mt4/4251-err-notification-parameter): "Notification parameter error" is MetaQuotes' whole description of this code.
- [4252](https://openbrokerapi.com/errors/mt4/4252-err-notification-settings): "Notifications disabled" is MetaQuotes' whole description of this code.
- [4253 ERR_NOTIFICATION_TOO_FREQUENT](https://openbrokerapi.com/errors/mt4/4253): "Notification send too frequent" is MetaQuotes' whole description of this code.
- [4260](https://openbrokerapi.com/errors/mt4/4260-err-ftp-noserver): "FTP server is not specified" is MetaQuotes' whole description of this code.
- [4261](https://openbrokerapi.com/errors/mt4/4261-err-ftp-nologin): "FTP login is not specified" is MetaQuotes' whole description of this code.
- [4262](https://openbrokerapi.com/errors/mt4/4262-err-ftp-connect-failed): "FTP connection failed" is MetaQuotes' whole description of this code.
- [4263](https://openbrokerapi.com/errors/mt4/4263-err-ftp-closed): "FTP connection closed" is MetaQuotes' whole description of this code.
- [4264](https://openbrokerapi.com/errors/mt4/4264-err-ftp-changedir): "FTP path not found on server" is MetaQuotes' whole description of this code.
- [4265](https://openbrokerapi.com/errors/mt4/4265-err-ftp-file-error): The file to send to the FTP server was not found in the Files directory under MQL4.
- [4266](https://openbrokerapi.com/errors/mt4/4266-err-ftp-error): "Common error during FTP data transmission" is MetaQuotes' whole description of this code.
- [5001](https://openbrokerapi.com/errors/mt4/5001-err-file-too-many-opened): "Too many opened files" is MetaQuotes' whole description of this code.
- [5002](https://openbrokerapi.com/errors/mt4/5002-err-file-wrong-filename): "Wrong file name" is MetaQuotes' whole description of this code.
- [5003](https://openbrokerapi.com/errors/mt4/5003-err-file-too-long-filename): "Too long file name" is MetaQuotes' whole description of this code.
- [5004](https://openbrokerapi.com/errors/mt4/5004-err-file-cannot-open): "Cannot open file" is MetaQuotes' whole description of this code.
- [5005 ERR_FILE_BUFFER_ALLOCATION_ERROR](https://openbrokerapi.com/errors/mt4/5005): "Text file buffer allocation error" is MetaQuotes' whole description of this code.
- [5006](https://openbrokerapi.com/errors/mt4/5006-err-file-cannot-delete): "Cannot delete file" is MetaQuotes' whole description of this code.
- [5007](https://openbrokerapi.com/errors/mt4/5007-err-file-invalid-handle): "Invalid file handle (file closed or was not opened)" is MetaQuotes' whole description of this code.
- [5008](https://openbrokerapi.com/errors/mt4/5008-err-file-wrong-handle): "Wrong file handle (handle index is out of handle table)" is MetaQuotes' whole description of this code.
- [5009](https://openbrokerapi.com/errors/mt4/5009-err-file-not-towrite): "File must be opened with FILE_WRITE flag" is MetaQuotes' whole description of this code.
- [5010](https://openbrokerapi.com/errors/mt4/5010-err-file-not-toread): "File must be opened with FILE_READ flag" is MetaQuotes' whole description of this code.
- [5011](https://openbrokerapi.com/errors/mt4/5011-err-file-not-bin): "File must be opened with FILE_BIN flag" is MetaQuotes' whole description of this code.
- [5012](https://openbrokerapi.com/errors/mt4/5012-err-file-not-txt): "File must be opened with FILE_TXT flag" is MetaQuotes' whole description of this code.
- [5013](https://openbrokerapi.com/errors/mt4/5013-err-file-not-txtorcsv): "File must be opened with FILE_TXT or FILE_CSV flag" is MetaQuotes' whole description of this code.
- [5014](https://openbrokerapi.com/errors/mt4/5014-err-file-not-csv): "File must be opened with FILE_CSV flag" is MetaQuotes' whole description of this code.
- [5015](https://openbrokerapi.com/errors/mt4/5015-err-file-read-error): "File read error" is MetaQuotes' whole description of this code.
- [5016](https://openbrokerapi.com/errors/mt4/5016-err-file-write-error): "File write error" is MetaQuotes' whole description of this code.
- [5017](https://openbrokerapi.com/errors/mt4/5017-err-file-bin-stringsize): "String size must be specified for binary file" is MetaQuotes' whole description of this code.
- [5018](https://openbrokerapi.com/errors/mt4/5018-err-file-incompatible): "Incompatible file (for string arrays-TXT, for others-BIN)" is MetaQuotes' whole description of this code.
- [5019](https://openbrokerapi.com/errors/mt4/5019-err-file-is-directory): "File is directory not file" is MetaQuotes' whole description of this code.
- [5020](https://openbrokerapi.com/errors/mt4/5020-err-file-not-exist): "File does not exist" is MetaQuotes' whole description of this code.
- [5021](https://openbrokerapi.com/errors/mt4/5021-err-file-cannot-rewrite): "File cannot be rewritten" is MetaQuotes' whole description of this code.
- [5022](https://openbrokerapi.com/errors/mt4/5022-err-file-wrong-directoryname): "Wrong directory name" is MetaQuotes' whole description of this code.
- [5023](https://openbrokerapi.com/errors/mt4/5023-err-file-directory-not-exist): "Directory does not exist" is MetaQuotes' whole description of this code.
- [5024](https://openbrokerapi.com/errors/mt4/5024-err-file-not-directory): "Specified file is not directory" is MetaQuotes' whole description of this code.
- [5025 ERR_FILE_CANNOT_DELETE_DIRECTORY](https://openbrokerapi.com/errors/mt4/5025): "Cannot delete directory" is MetaQuotes' whole description of this code.
- [5026 ERR_FILE_CANNOT_CLEAN_DIRECTORY](https://openbrokerapi.com/errors/mt4/5026): "Cannot clean directory" is MetaQuotes' whole description of this code.
- [5027](https://openbrokerapi.com/errors/mt4/5027-err-file-arrayresize-error): "Array resize error" is MetaQuotes' whole description of this code.
- [5028](https://openbrokerapi.com/errors/mt4/5028-err-file-stringresize-error): "String resize error" is MetaQuotes' whole description of this code.
- [5029](https://openbrokerapi.com/errors/mt4/5029-err-file-struct-with-objects): "Structure contains strings or dynamic arrays" is MetaQuotes' whole description of this code.
- [5200 ERR_WEBREQUEST_INVALID_ADDRESS](https://openbrokerapi.com/errors/mt4/5200): "Invalid URL" is MetaQuotes' whole description of this code.
- [5201 ERR_WEBREQUEST_CONNECT_FAILED](https://openbrokerapi.com/errors/mt4/5201): "Failed to connect to specified URL" is MetaQuotes' whole description of this code.
- [5202](https://openbrokerapi.com/errors/mt4/5202-err-webrequest-timeout): "Timeout exceeded" is MetaQuotes' whole description of this code.
- [5203 ERR_WEBREQUEST_REQUEST_FAILED](https://openbrokerapi.com/errors/mt4/5203): "HTTP request failed" is MetaQuotes' whole description of this code.
- [65536](https://openbrokerapi.com/errors/mt4/65536-err-user-error-first): This is not an error in itself: it is the first code available for errors that a program defines for itself.

## MetaTrader 4 API: questions and answers

### How do I get access to the MetaTrader 4 API?

Install the MT4 terminal from a broker and write Expert Advisors or scripts in MQL4.

- Status: verified. Source: [Install terminal (MT4 help)](https://www.metatrader4.com/en/trading-platform/help/userguide/installation), checked 2026-09-21.

### Who can use the MetaTrader 4 API?

Real accounts can only be opened by brokerage companies that offer MT4.

- Status: verified. Source: [Opening of accounts (MT4 help)](https://www.metatrader4.com/en/trading-platform/help/userguide/open_an_account), checked 2026-09-21.

### MetaTrader 4 API demo: is there a demo or sandbox?

Yes: demo accounts can be opened from within the terminal.

- Status: verified. Source: [Opening of accounts (MT4 help)](https://www.metatrader4.com/en/trading-platform/help/userguide/open_an_account), checked 2026-09-21.

### What are the MetaTrader 4 API rate limits?

Not published.

- Status: verified. Source: [MQL4 Reference](https://docs.mql4.com/), checked 2026-09-20.

### How does MetaTrader 4 API authentication work?

No API keys: code runs inside a terminal already logged in to a trading account.

- Status: verified. Source: [MQL4 Reference](https://docs.mql4.com/), checked 2026-09-20.

### Does the MetaTrader 4 API support streaming?

In-terminal events only (new tick, timer, depth changes); no external streaming API.

- Status: verified. Source: [MQL4 Reference](https://docs.mql4.com/), checked 2026-09-20.

### How much history does the MetaTrader 4 API return?

Bars limited to the terminal's max bars in chart. Closed orders limited to what the Account History tab has loaded.

- Status: verified. Source: [MQL4 docs: CopyRates](https://docs.mql4.com/series/copyrates), checked 2026-09-22.

### Which brokers offer MetaTrader 4?

Brokers on this register recorded as offering MetaTrader 4, with a source: Axi, Capital.com, CMC Markets, FOREX.com, FXCM, IG, OANDA, Pepperstone, Swissquote, ThinkMarkets and Tickmill. Recorded as offering it but unverified: FxPro.

- Status: verified. Source: [Trading platforms, Axi UK](https://www.axi.com/uk/trading-platforms), checked 2026-10-12.
- Status: verified. Source: [Capital.com UK MT4](https://capital.com/en-gb/trading-platforms/mt4), checked 2026-09-18.
- Status: verified. Source: [CMC Markets UK MetaTrader 4](https://www.cmcmarkets.com/en-gb/trading-platforms/metatrader-4), checked 2026-10-12.
- Status: verified. Source: [FOREX.com UK trading platforms](https://www.forex.com/en-uk/trading-platforms/), checked 2026-09-18.
- Status: verified. Source: [FXCM UK MetaTrader 4](https://www.fxcm.com/uk/platforms/metatrader-4/), checked 2026-09-18.
- Status: verified. Source: [IG UK MetaTrader 4](https://www.ig.com/uk/trading-platforms/metatrader-4), checked 2026-09-18.
- Status: verified. Source: [OANDA UK MetaTrader 4](https://www.oanda.com/uk-en/trading/platforms/metatrader-4/), checked 2026-09-18.
- Status: verified. Source: [Pepperstone UK trading platforms](https://pepperstone.com/en-gb/trading-platforms/), checked 2026-09-18.
- Status: verified. Source: [Swissquote UK, forex and CFD platforms](https://www.swissquote.com/en-uk/private/trade/platforms/forex-cfds), checked 2026-10-12.
- Status: verified. Source: [ThinkMarkets support: Spread betting account](https://support.thinkmarkets.com/hc/en-gb/articles/11613215353745-Spread-betting-account), checked 2026-09-18.
- Status: verified. Source: [Tickmill UK](https://www.tickmill.com/uk), checked 2026-09-18.

[MetaTrader 4 API questions, each answered in a sentence or two](https://openbrokerapi.com/answers/metatrader-4).

## Brokers that offer MetaTrader 4 (MQL4)

- [Axi](https://openbrokerapi.com/brokers/axi) (Axi Financial Services (UK) Limited): Listed on Axi's UK site and platforms page, with Expert Advisors presented for automated trading.
  - Status: verified. Source: [Trading platforms, Axi UK](https://www.axi.com/uk/trading-platforms), checked 2026-10-12.
- [Capital.com](https://openbrokerapi.com/brokers/capital-com) (Capital Com (UK) Limited): MT4 offered; Expert Advisors allowed ('Expert advisors execute according to rules set in advance'), with a disclaimer that Capital.com is not responsible for EA performance.
  - Status: verified. Source: [Capital.com UK MT4](https://capital.com/en-gb/trading-platforms/mt4), checked 2026-09-18.
- [CMC Markets](https://openbrokerapi.com/brokers/cmc-markets) (CMC Markets UK plc): Offered for spread betting and CFDs. The MT4 page says Expert Advisors can be used to automate trading.
  - Status: verified. Source: [CMC Markets UK MetaTrader 4](https://www.cmcmarkets.com/en-gb/trading-platforms/metatrader-4), checked 2026-10-12.
- [FOREX.com / StoneX Trading (City Index)](https://openbrokerapi.com/brokers/forex-com-city-index) (StoneX Financial Ltd (FOREX.com UK), FCA Register not read by us): MT4 on desktop, web and mobile. Expert Advisors allowed ('Expert Advisors (EAs) are programs that can be used to automate trading'); only one EA per chart; EA hosting/VPS for qualifying clients.
  - Status: verified. Source: [FOREX.com UK trading platforms](https://www.forex.com/en-uk/trading-platforms/), checked 2026-09-18.
- [FOREX.com / StoneX Trading (City Index)](https://openbrokerapi.com/brokers/forex-com-city-index) (StoneX Financial Ltd trading as StoneX Trading (formerly City Index UK)): City Index UK pages now redirect to stonex.com/en-gb. MT4 offered with Expert Advisors from FX Blue (nine EAs).
  - Status: verified. Source: [StoneX Trading MetaTrader 4](https://www.stonex.com/en-gb/trading-platforms/metatrader-4/), checked 2026-09-18.
- [FXCM](https://openbrokerapi.com/brokers/fxcm) (Stratos Markets Limited): MT4 on desktop, web and mobile. Expert Advisors allowed: 'Get MT4 EAs (Expert Advisors) and Virtual Private Server (VPS) with your MT4 account'.
  - Status: verified. Source: [FXCM UK MetaTrader 4](https://www.fxcm.com/uk/platforms/metatrader-4/), checked 2026-09-18.
- [FxPro](https://openbrokerapi.com/brokers/fxpro) (FxPro group (UK entity not confirmed on page)): Listed on platform comparison with EA trading; page does not say which entity offers it.
  - Status: unverified. Source: [FxPro platform comparison](https://www.fxpro.com/trading-platforms/comparison), checked 2026-09-18.
- [IG](https://openbrokerapi.com/brokers/ig) (IG Markets Ltd (CFDs), IG Index Ltd (spread betting)): Offered for spread betting and CFD accounts. Expert Advisors allowed: page says you can build strategies to execute automatically using your algorithms or MT4's own, called Expert Advisors.
  - Status: verified. Source: [IG UK MetaTrader 4](https://www.ig.com/uk/trading-platforms/metatrader-4), checked 2026-09-18.
- [OANDA](https://openbrokerapi.com/brokers/oanda) (OANDA Europe Limited): MT4 offered. Expert Advisors allowed: 'The MetaTrader 4 platform supports Expert Advisors (EAs)'.
  - Status: verified. Source: [OANDA UK MetaTrader 4](https://www.oanda.com/uk-en/trading/platforms/metatrader-4/), checked 2026-09-18.
- [Pepperstone](https://openbrokerapi.com/brokers/pepperstone) (Pepperstone Limited): MetaTrader 4 is listed on the broker's UK platforms page for UK clients.
  - Status: verified. Source: [Pepperstone UK trading platforms](https://pepperstone.com/en-gb/trading-platforms/), checked 2026-09-18.
- [Swissquote](https://openbrokerapi.com/brokers/swissquote) (Swissquote Ltd (UK)): Listed on the UK private client forex and CFD platforms page, with Expert Advisors ticked in the comparison table.
  - Status: verified. Source: [Swissquote UK, forex and CFD platforms](https://www.swissquote.com/en-uk/private/trade/platforms/forex-cfds), checked 2026-10-12.
- [ThinkMarkets](https://openbrokerapi.com/brokers/thinkmarkets) (TF Global Markets (UK) Limited): Support article: spread betting is available on ThinkTrader, MT4 and MT5 for UK residents.
  - Status: verified. Source: [ThinkMarkets support: Spread betting account](https://support.thinkmarkets.com/hc/en-gb/articles/11613215353745-Spread-betting-account), checked 2026-09-18.
- [Tickmill](https://openbrokerapi.com/brokers/tickmill) (Tickmill UK Ltd): MT4 on Windows, macOS, mobile and WebTrader.
  - Status: verified. Source: [Tickmill UK](https://www.tickmill.com/uk), checked 2026-09-18.

## Licence and how to cite

The limit records on this page come from the limits register, which is CC BY 4.0 (https://openbrokerapi.com/data/limits.json). Everything else on it comes from records that are all rights reserved. This file is the page itself, at its own address, in another format, and it is not part of the CC BY 4.0 downloads listed at https://openbrokerapi.com/data.

Cite as: MetaTrader 4 API (MQL4). Broker API Hub, https://openbrokerapi.com/platforms/metatrader-4, newest check 2026-10-12.

Where you rely on a single figure, cite the source and the checked date printed beside it as well. Where this page and a broker's own documentation differ, the documentation wins.
