"Meta"-Trader 4/5 Bridge Plugin

"Meta"-Trader 4 and 5 (MTR4 and MTR5 in short) are cheap and popular trading platforms that are provided free by most brokers, sometimes under different names. The MT4/5 bridge controls a MTR4 or MTR5 platform - the "terminal" - as an Expert Advisor (EA). This way Zorro can trade with all brokers that provide one of these platforms for their clients.


                                Terminal with attached Zorro

The client terminal runs on the trader's PC and communicates with the broker's MTR4 or MTR5 server via Internet. The server generates prices and slippage as set up by the broker, and manages the trades. The MTR4/5 bridge DLL has also two sides. On the MTR4/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 the MTR4 or MTR5 terminal.

User Account number (as in the terminal's title bar)
Password Empty

Installation and startup

If you want to run Zorro on a VPS together with the MTR4/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 the terminal. First make sure to have installed Zorro and the broker's MTR4 or MTR5 platform (for MTR5 the 64 bit version is required). If you have the choice, use MTR4, which is supposedly more reliable than MTR5. Connect to your MTR4/5 account with the login data from your broker.

Symbols

Most MTR4/5 versions use special asset names with broker specific suffixes. For instance, the "EUR/USD" currency pair is called "EURUSD" in the MTR4 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 symbols used by Meta Trader must be entered directly in the Symbol column of the used asset list. Otherwise your selected assets are not found in the terminal's 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, you can find the reason in the Experts Log that the terminal generates. It normally tells you hat the problem is.

MTR4/MTR5 Installation issues:

MTR4/MTR5 trading issues:

Additional data and commands

The MTR4/5 bridge supports the following features:

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

You can add your own commands for sending or retrieving further information from the MTR4/MTR5 client. For this, edit the zorro.mq4 / zorro.mq5 EA. Any brokerCommand(Command,Parameter) call in a Zorro script triggers the CMD_BCOMMAND part of the Zorro EA run loop. Use a Command number between 2000 and 2999 for not getting into conflict with future official broker commands. The parameter is transferred in arr[1] and can be used for calling arbitrary MTR4 / MTR5 functions. Use arr[0] for transferring a numerical return value back to Zorro. Be aware that sent parameters are stored on the terminal side and thus affect all Zorro instances connected to that terminal - not only the instance that sent the parameter.

 

Zorro EA functions

Zorro can directly trade with MTR4/5 through the Zorro Expert Advisor. This EA is included in MQ4/MQ5 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 MTR4 init() function.

Returns:

0 when the initialization failed, otherwise nonzero.
 

ZorroExit ()

Release the Zorro plugin. Normally called in the MTR4 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 MTR4 start() function.

Parameters:

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

Returns:

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 MTR4 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.

Parameters:

cmd One of the following commands: CMD_ASSET, CMD_TICK, CMD_HISTORY, CMD_BALANCE, CMD_BUY, CMD_TRADE, CMD_SELL,CMD_STOP, CMD_BCOMMAND (see Zorro.mq4).
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