Metatrader4™ Bridge Plugin - version 1.4

Metatrader4™ (MT4) is a popular trading platform, supported by most brokers. It consists of two parts: The MT4 client terminal runs on the trader's PC and communicates with MT4 server via Internet. The MT4 server program runs on the broker's server; it generates prices and slippage as set up by the broker, and manages the trades. With the MT4 bridge, Zorro can control the MT4 client terminal as an Expert Advisor (EA) and this way trade with all brokers that provide the MT4 platform for their clients.

Through its DLL functions, the MT4 bridge can also be used for controlling Metatrader4 with third party software.

                                MT4 client with attached Zorro

The MT4 bridge DLL has two sides. On the MT4 side it appears as a library DLL that can be called from any EA. On the Zorro side it appears as a Broker Plugin. This way the MT4 bridge can theoretically be used not only by Zorro, but also by any other software for reading prices and sending orders via MT4.

Installation and startup

If you want to run Zorro on a VPS together with the MT4 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 MT4 build 600 and above:

MT4 symbols

Most MT4 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.mq4 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 MT4 symbols must be entered directly in the Symbol column of the AssetsFix.csv spreadsheet. Otherwise your selected assets are not found in the MT4 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 MT4 Market Watch window. If you still get error messages about unavailable assets, read the MT4 Experts log. It normally tells what the problem is.

Known MT4 Issues:


Extra data

The MT4 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.mq4 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 MT4 side and thus affect all Zorro instances connected - not only the instance that sent the parameter.


Zorro EA functions

Zorro can directly trade with MT4 through the Zorro.mq4 Expert Advisor. This EA is included in MQL4 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 library:

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 source\Zorro.mq4

See also:

Brokers, brokerCommand, order, broker plugin

► latest version online