Compress MT4 database
Brief
This is a tool to compress an overgrown orders.dat file in place.
It has a few modes:
- remove orphaned orders (where login equals zero);
- remove expired pending orders;
- aggregate closed orders profit;
- aggregate balance orders profit;
- aggregate expired (on the current date) credit operations profit.
It reads the file directly from disk and writes a compressed database back to disk. By default, it makes a backup of the original database. The tool uses the users.dat database to double-check its algorithms against the relevant users' balances twice: on start and at the end.
It needs the MT4 server to be stopped, so the database files are unlocked and the app can read and write them.
There is an option to specify user groups via the -groups parameter with a corresponding regular expression. The same option (-logins) is available for logins.
Files can be downloaded from our package feed: nuget.cplugin.com/feeds/apps/CPlugin.Tools.CompressMT4DB/versions
Licensing
The license grants usage of the tool on a single computer.
Even without a license, the program runs in read-only mode to calculate and demonstrate a possible result. You are welcome to try it without worrying about the consistency of your files, and to estimate the outcome in your environment before purchase.
Quick start
To see how much smaller your database might become, run the tool in read-only mode without specifying a starting and/or ending date. You must, however, explicitly specify each mode you intend to use.
CPlugin.CompressMT4DB.exe -orders=c:\metatrader4\bases\orders.dat -users=c:\metatrader4\bases\users.dat -balance -closed -credit -orphaned -pending
Once you are satisfied with the results, run in read/write mode by specifying the -go flag.
Usage
Example of the built-in help, shown by running the app with the -? parameter:
Utility to compress orders.dat
-? : This help
-go : permit tool make its job, otherwise read-only mode will be used
-orders=<value> : full path to 'orders.dat' file
Type:System.String, Default value:'orders.dat'
-users=<value> : full path to 'users.dat' file
Type:System.String, Default value:'users.dat'
-nobackup : do NOT backup current file
-balance : compress balance trades
-closed : compress closed trades
-credit : compress credit trades
-orphaned : delete orphaned trades
-pending : delete expired pending orders
-groups=<value> : user groups to proceed (MQ mask)
Type:System.String, Default value:'*'
-logins=<value> : user logins to proceed (MQ mask)
Type:System.String, Default value:'*'
-starting=<value> : starting date
Type:System.String, Default value:'01.01.0001'
-ending=<value> : ending date
Type:System.String, Default value:'31.12.9999'
It uses a [starting, ending) half-open interval when checking whether a time falls within the range.
Spaces are not allowed in parameters, so the starting and ending fields can only contain a date.

