Metatrader4/5 Bridge Plugin

Metatrader4™ (MT4) and Metatrader5™ (MT5) by MetaQuotes™ are popular trading platforms, and at least one of them is supported by most brokers. With the MT4/5 bridge, Zorro can control MT4 or MT5 as an Expert Advisor (EA) and this way trade with all brokers that provide any of the Metatrader platforms for their clients.

                                MT4 client with attached Zorro

The MetaTrader software is split in two parts: The client terminal runs on the trader's PC and communicates with the MetaTrader server via Internet. The server generates prices and slippage as set up by the broker, and manages the trades. The MT4/5 bridge DLL has also two sides. On the MT4/5 side it appears as a 32 bit or 64 bit library DLL that can be called from any EA. On the Zorro side it appears as a Broker Plugin DLL. This way the bridge can theoretically be used not only by Zorro, but also by any other software for reading prices and sending orders to MT4 or MT5.

Installation and startup

If you want to run Zorro on a VPS together with the MT4/5 bridge and have limited PC experience, you can subscribe a VPS installation service on the download page. Otherwise, here are the 4 steps for connecting Zorro to Metatrader. First make sure to have installed Zorro and the broker's MT4 or MT5 platform (for MT5 the 64 bit version is required). Connect to your MT4/5 account with the login data from your broker.


Most Metatrader versions use special asset names with broker specific suffixes. For instance, the "EUR/USD" currency pair is called "EURUSD" in the MT4 version by FXCM™, "EURUSDm" in the IBFX™ version, "EURUSDi" in the version by Traders Way™, and "EURUSD.G" in the Global Prime™ version. The Zorro EA automatically adapts the names by removing the slash and adding the broker specific suffix from EURUSD symbol name of the EA chart window. So no adaption is required on your side.

For non-currency assets with names longer than 6 characters, or for names that can not be automatically adapted this way - for instance, "GOLD" instead of "XAU/USD" - the Metatrader symbols must be entered directly in the Symbol column of the used asset list. Otherwise your selected assets are not found in the Metatrader symbol list, and you'll get "asset unavailable" error messages when starting your script.

All assets you want to trade must be visible in the Market Watch window. If you still get error messages about unavailable assets, read the Metatrader Experts log. It normally tells you hat the problem is.

Known MT4/MT5 Issues:


Extra data

The MT4/5 bridge supports the following data streams:

Supported broker commands

The MT4 bridge supports the brokerCommand function with the following commands:

More commands can be implemented by the user by editing the Zorro EA. Any brokerCommand(Command,Parameter) call in a Zorro script triggers the CMD_BCOMMAND part of the Zorro EA run loop. The parameter is transferred in arr[1] and can be used for calling arbitrary functions. Use arr[0] for transferring the return value back to Zorro. Be aware that sent parameters are stored on the Metatrader side and thus affect all Zorro instances connected - not only the instance that sent the parameter.


Zorro EA functions

Zorro can directly trade with Metatrader through the Zorro Expert Advisor. This EA is included in MQL4/MQL5 source code, so it can be used as a template for writing own EAs that evaluate trade signals from Zorro. For this the following four functions are available in the ZorroMT4.ex4 or ZorroMT5.ex5 libraries:

ZorroInit () : int

Open the Zorro plugin. Normally called in the MT4 init() function.


0 when the initialization failed, otherwise nonzero.

ZorroExit ()

Release the Zorro plugin. Normally called in the MT4 deinit() function.

ZorroRequest (double& array[]): int

Receive a request from the DLL, f.i. for opening a trade. Normally called in a loop in the MT4 start() function.


array Array of up to 10 double variables that are filled with the request parameters.


0 if no request is pending, otherwise one of the following commands: CMD_COMMENT, CMD_PRINT, CMD_ASSET, CMD_HISTORY, CMD_BALANCE, CMD_BUY, CMD_TRADE, CMD_SELL, CMD_STOP, CMD_BCOMMAND (see Zorro.mq4). The zstring() function returns a string containing the requested asset name or a text message. Asset names need possibly be converted to the specific symbol names of the MT4 version (see remarks).

ZorroRespond (int cmd, double& array[])

Respond to a request from the DLL. Normally called to transfer the result after receiving a request.


array Array of up to 10 double variables containing the response parameters.


Example: see Zorro.mq4 or Zorro.mq5

See also:

Brokers, brokerCommand, order, broker plugin

► latest version online