MT4 Report Server extended replication
This tool extends the standard MetaQuotes Report server. It saves additional data from your MT4 server into a MySQL database, so other services can read everything they need from one place. Keeping the data in MySQL also reduces load on the MT4 server: calculations that suit a relational database can run against MySQL instead of repeatedly querying MT4.
The tool has two parts: a Windows service and an MT4 plugin.
It saves:
- Symbols (
mt4_symbolstable) - Symbol groups (
mt4_symbol_groups) - Groups (
mt4_group) - Ticks (MT4 plugin required) (
mt4_ticks) - Server journal (MT4 plugin required) (
mt4_logs)
Install and run
The application can be used in two ways: as a Windows service, or normally in console mode. You can obtain it from our package feed:
http://nuget.cplugin.com/feeds/apps/CPlugin.ExReplica.SyncService/versions
For testing it is more convenient to run in console and confirm that everything works. After that, install the application as a Windows service so it starts automatically with the server, with no need to log on and launch it manually every time.
Run in console
To run in console (if you don't want to install a service), run the .exe file with the -con argument.
To exit, press the Q key.
Run as a Windows service
First, install Microsoft .NET Framework 4.5.1 on your server.
Download the package and unpack it to any folder. You also have to put mtmanapi.dll and mtmanapi64.dll into this folder. We cannot distribute these files; you can find them under the /API/ subfolder of your MT4 Administrator.
To install as a service you can use the sc Windows utility. For example, run these commands from the console:
sc create "CPlugin.ExReplica.DbWriter" binPath=C:\CPlugin.ExReplica\CPlugin.ExReplica.DBWriter.exe start=auto
sc failure "CPlugin.ExReplica.DbWriter" actions=restart/60000/restart/60000/restart/60000 reset=INFINITE
Settings
All settings are in the CPlugin.ExReplica.DBWriter.exe.config XML file.
The most important section is configuration → connectionStrings → mysqlConnection, where you put your MySQL server address and credentials.
Other settings are in configuration → userSettings → CPlugin.ExReplica.DBWriter.Properties.Settings:
mt4_server— your MT4 server address.mt4_login— login of an account that has access to symbols, groups, journal and prices through the Manager API. It must be a manager.mt4_password— its password.proceed_mt4r— flag that controls whether files created by the plugin are processed (true/false).mt4r_path— path to those files.
To save ticks and journal messages from MT4 to MySQL, you have to install a dedicated plugin on your MT4 server.
MT4 plugin
Download CPlugin.ExReplica.dll and place it under your MT4 /plugins/ directory. Restart the MT4 server and confirm that the plugin initialized successfully. You should see something like:
0 12:59:13.398 CPlugin.ExReplica LogPath = C:\MT4ReplicaFiles
0 12:59:13.398 CPlugin.ExReplica Write ticks = 1
0 12:59:13.398 CPlugin.ExReplica Write logs = 1
0 12:59:13.399 CPlugin.ExReplica initialized (ver. 1.00, May 24 2016 12:55:36)
It writes one file per minute. Those files are consumed by the main tool automatically — no further action is needed from the operator. Just set the proceed_mt4r flag to true and the service does the rest.
It has these options:
LogPath— path to the folder where the plugin stores data to be processed by the database writer. Make sure you have enough free space there.Write ticks— flag that makes the plugin write ticks:0— do not write,1— write.Write logs— flag that makes the plugin write journal messages:0— do not write,1— write.

