Guru's Verification engine ensures consistency, confidence, and trust in the knowledge your organization shares. Learn more.

MetaQuotes Management Bridge - Rolls & Swaps Tool

Introduction

The MahiMarkets MTx Management Bridge is a Windows service designed to manage the configuration of a fleet of MetaTrader servers - both MT4 and MT5.

Please contact support@mahimarkets.com for any questions related to this document.

Installation

Run the MTx Management Bridge installer or extract the zip archive on a Windows environment where the service is intended to be deployed. The service is consisted of the following files:

  • MTxManagementBridge.exe - the Windows service binary

  • MTxManagementBridge.ini - configuration file

  • MTxManagementBridge.lic - license file

  • mtmanapi.dll - MT4 Manager library

  • MT5APIManager.dll - MT5 Manager library

Edit the configuration file (MTxManagementBridge.ini) and make sure all parameters are set up correctly. Please refer to the Configuration section below for details about each parameter as well as the example configuration file.

To install the service, start a PowerShell terminal as administrator and simply run:

`./MTxManagementBridge.exe /install`

Now the bridge is installed and can be started from the Windows Services snap-in (Start menu -> Run -> Services). Alternatively restarting Windows will also start the service on boot up.

To uninstall the service, please first stop it through the Windows Services snap-in and then run the following command in PowerShell:

`./MTxManagementBridge.exe /remove`

Bulk swap update

Introduction

The bulk swap update feature allows for periodic updates of MT4/MT5 symbol swap values from a given CSV file.

The bridge associates every MetaTrader server with an input directory which is scanned periodically and any CSV file found during the scan is processed. Changes are applied to the respective MetaTrader server and finally the bridge generates a report and sends an update summary email.

Update period

The `SWAP UPDATE PERIOD` parameter is used to specify how often (and when) the bridge will scan a server’s input directory and apply updates.

The update period is specified as a cron expression, consisting of 6 mandatory fields (seconds, minutes, hours, days of month, months, days of week). A field can contain an integer, a range, or an asterisk (*) symbol to designate any value.

Here are a few examples:

  • “0 5 18 * * *” - this expression will cause the bridge to trigger an update everyday at 6:05pm (local time);

  • “30 0 15 * * *” - this will trigger everyday at 30 seconds after 3:00pm;

  • “0 0 */2 * * MON-FRI” - this will trigger every two hours between Monday and Friday.

For more details about cron expressions please refer here.

Dry run

The bridge supports updating swap values in “dry run” mode - which means the update operation will be “simulated” and a report will be generated without any actual change being applied to the remote MetaTrader server.

A common scenario is to have a dry run for a certain set of changes and review the reports before proceeding with actually applying the new swap values.

Dry run mode is enabled by setting `DRY RUN ENABLE` parameter to `Y` and `DRY RUN UPDATE PERIOD” to a cron expression specifying the desired schedule.

Rollback

Everytime the bridge applies new swap values to a MetaTrader server’s configuration database, the previous swap values will be saved to a separate CSV file located in the rollback directory (see Configuration section for more details). In case of any issue it is possible to roll the configuration back to the point prior to a certain swap update.

In order to perform a rollback please refer to the following steps:

  1. Open the rollback directory (by default it should be `.\data\{SERVER}\rollback`)

  2. Select a subdirectory corresponding to the date/time you would like to rollback to

  3. Copy the CSV files into the input directory (by default it should be `.\data\{SERVER}\input`)

  4. Stop the bridge (from the Windows Services manager window) and reconfigure it to run after a short amount of time (by editing the `SWAP UPDATE PERIOD` parameter) - e.g. after 5 minutes

  5. Start the bridge service and wait for the input directory to get scanned

  6. At this point the rollback should have taken place

  7. Please edit `SWAP UPDATE PERIOD` back to its previous value and restart the bridge again

Configuration

The configuration of the bridge is performed through an INI file. The “default” section of the INI file contains global parameters affecting the entire bridge. Also there are dedicated sections per each server which hold per-server parameters.

The name of a server configuration section should start either with “SERVER.MT4.” or “SERVERS.MT5.” depending on the version of the remote MetaTrader server being managed (see example below).

Parameters

Following is a list of all global configuration parameters:

Parameter

Description

Type

Default

Example

MT TRACING ENABLED

Logs additional events (useful for troubleshooting and debugging)

Boolean

Y

N

MT TRACING LOGS MAX DAYS TO KEEP

The bridge will keep the logs for this number of days

Integer

14

30

EMAIL ADDRESS

Email address to receive email summary reports and alerts

Text

to@email.com

EMAIL FROM ADDRESS

Sender address of email reports and alerts

Text

from@email.com

EMAIL SMTP SERVER

SMTP server address

Text

smtp.my-server.com

EMAIL SMTP SERVER PORT

SMTP server port

Integer

587

EMAIL SMTP USER

SMTP username

Text

apikey

EMAIL SMTP PASSWORD

SMTP password

Text

mystrongpassword

The following parameters are supported in server sections:

Parameter

Description

Type

Derivable

Default

Example

MT SERVER ADDRESS

Address (and port) of the remote MT4/MT5 server

Text

No

127.0.0.1:443

MT USER ID

MT4/MT5 manager user ID (needs administrative privilege)

Integer

No

1000

MT USER PASSWORD

MT4/MT5 user password

Text

No

mystrongpassword

SWAP UPDATE PERIOD

Schedule for performing regular swap updates

Text

Yes

00 00 18 * * *

00 00 18 * * *

DRY RUN ENABLE

Enables the dry run feature

Boolean

Yes

N

Y

DRY RUN SWAP UPDATE PERIOD

Schedule for performing updates in dry run mode (requires `DRY RUN ENABLE`=`Y`)

Text

Yes

00 00 15 * * *

00 00 15 * * *

INPUT DIR

The bridge will scan this directory for CSV files with new swap values

Text

No

.\data\{SECTION}\input

C:\tmp\different-input-dir

ARCHIVE DIR

The bridge will copy already CSV files here once processed

Text

No

.\data\{SECTION}\archive

C:\tmp\myserver-archive

REPORT DIR

The bridge will store individual swap update reports in this directory

Text

No

.\data\{SECTION}\report

C:\tmp\myserver-report

ROLLBACK DIR

The bridge will store rollback CSV files in this directory

Text

No

.\data\{SECTION}\rollback

C:\tmp\myserver-rollback

Also please note that parameter names are case insensitive, and any whitespace characters part of the name are ignored. Boolean-typed parameters can have either “Y” or “N” value.

Example configuration file

[DEFAULT]

DataDir=.

MT TRACING ENABLED=Y

MT TRACING LOGS MAX DAYS TO KEEP=14

EMAIL ADDRESS=email@company.com

EMAIL FROM ADDRESS=mtx-reports@company.com

EMAIL SMTP PASSWORD=password

EMAIL SMTP SERVER=smtp.sendgrid.net

EMAIL SMTP SERVER PORT=587

EMAIL SMTP USER=apikey

[SERVERS.MT4.srv1]

MtServerAddress=127.0.0.1:443

MtUserId=101

MtUserPassword=password

SwapUpdatePeriod=30 26 12 * * *

DryRunEnable=1

DryRunSwapUpdatePeriod=00 26 12 * * *

Google Doc

You must have Author or Collection Owner permission to create Guru Cards. Contact your team's Guru admins to use this template.