Broker API HubMenu

Platform API

MetaTrader 4 API (MQL4)

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

Independent and unofficialNewest reading Official documentation

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: MQL4, WebRequest (HTTP from MQL4).

How you get access

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

Install terminal (MT4 help)checked

Who can use it

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

Opening of accounts (MT4 help)checked

Demo

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

Opening of accounts (MT4 help)checked

Authentication

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

MQL4 Referencechecked

Streaming

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

MQL4 Referencechecked

History depth

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

MQL4 docs: CopyRateschecked

Rate limits, as worded

Not published

MQL4 Referencechecked

MetaTrader 4 functions

28 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

MQL4

MetaTrader 4 API error codes

161 decoded error codes. All MetaTrader 4 (MQL4) errors

MetaTrader 4 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 4 API?

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

Install terminal (MT4 help)checked

Who can use the MetaTrader 4 API?

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

Opening of accounts (MT4 help)checked

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

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

Opening of accounts (MT4 help)checked

What are the MetaTrader 4 API rate limits?

Not published.

MQL4 Referencechecked

How does MetaTrader 4 API authentication work?

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

MQL4 Referencechecked

Does the MetaTrader 4 API support streaming?

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

MQL4 Referencechecked

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.

MQL4 docs: CopyRateschecked

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.

Trading platforms, Axi UKchecked Capital.com UK MT4checked CMC Markets UK MetaTrader 4checked FOREX.com UK trading platformschecked FXCM UK MetaTrader 4checked IG UK MetaTrader 4checked OANDA UK MetaTrader 4checked Pepperstone UK trading platformschecked Swissquote UK, forex and CFD platformschecked ThinkMarkets support: Spread betting accountchecked Tickmill UKchecked

MetaTrader 4 API questions, each answered in a sentence or two.

Everything this site records for MetaTrader 4 (MQL4), as one JSON file. Each section of the file states its own licence. About the files. This page as Markdown.

MetaTrader 4 API guides and reference

MetaTrader 4 API compared

The same fields from two records, side by side. No winner is picked.

What changed recently for the MetaTrader 4 API

The newest entries are shown. Every dated change, all brokers and platforms. Follow MetaTrader 4 changes by RSS

Open source repositories for MetaTrader 4

Read from GitHub's own records and ordered by stars as read. A listing is not a recommendation.

The full repository list

Brokers that offer MetaTrader 4 (MQL4)

BrokerEntityNoteSource
AxiAxi Financial Services (UK) LimitedListed on Axi's UK site and platforms page, with Expert Advisors presented for automated trading.Trading platforms, Axi UKchecked
Capital.comCapital Com (UK) LimitedMT4 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.Capital.com UK MT4checked
CMC MarketsCMC Markets UK plcOffered for spread betting and CFDs. The MT4 page says Expert Advisors can be used to automate trading.CMC Markets UK MetaTrader 4checked
FOREX.com / StoneX Trading (City Index)StoneX Financial Ltd (FOREX.com UK), FCA Register not read by usMT4 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.FOREX.com UK trading platformschecked
FOREX.com / StoneX Trading (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).StoneX Trading MetaTrader 4checked
FXCMStratos Markets LimitedMT4 on desktop, web and mobile. Expert Advisors allowed: 'Get MT4 EAs (Expert Advisors) and Virtual Private Server (VPS) with your MT4 account'.FXCM UK MetaTrader 4checked
FxProFxPro group (UK entity not confirmed on page)Listed on platform comparison with EA trading; page does not say which entity offers it.UnverifiedFxPro platform comparisonchecked
IGIG 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.IG UK MetaTrader 4checked
OANDAOANDA Europe LimitedMT4 offered. Expert Advisors allowed: 'The MetaTrader 4 platform supports Expert Advisors (EAs)'.OANDA UK MetaTrader 4checked
PepperstonePepperstone LimitedMetaTrader 4 is listed on the broker's UK platforms page for UK clients.Pepperstone UK trading platformschecked
SwissquoteSwissquote 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
ThinkMarketsTF Global Markets (UK) LimitedSupport article: spread betting is available on ThinkTrader, MT4 and MT5 for UK residents.ThinkMarkets support: Spread betting accountchecked
TickmillTickmill UK LtdMT4 on Windows, macOS, mobile and WebTrader.Tickmill UKchecked

How to cite this

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

Where you rely on a single figure, cite the source and the checked date printed beside it as well.

Sections