Multi Account Manager (MAM)

The plugin is an effective extension of the MetaTrader 4 server. It allows one trading account, called the master account, to distribute the margin requirements between multiple sub-accounts.

The plugin is an effective extension of the MetaTrader 4 server. It allows one trading account, called the master account, to distribute the margin requirements between multiple sub-accounts.

For a quick overview, watch the introduction on YouTube: youtube.com/watch?v=rmDSxAx4QSg.

Installation

You are free to download the files from our private NuGet feed at nuget.cplugin.com/feeds/apps/CPlugin.MT4Plugin.MAM/versions.

Unpack it with any popular tool, such as 7-Zip. All you need is the DLL file.

The files provided are fully functional. However, without a valid license they are limited to 100 requests, after which the plugin switches to silent mode. Restart MT4 to reset the counter. Contact us to extend the trial limit or to purchase an unlimited license.

It requires the Visual C++ Redistributable Packages for Visual Studio 2013 (microsoft.com/en-US/download/details.aspx?id=40784) to be installed on the server where MT4 runs.

The default configuration uses the equity-based allocation method, with any remaining volume split evenly across sub-accounts, starting with the account that has the highest equity.

Copy the plugin

Copy the plugin dynamic-link library (DLL) file to the plugins location (MetaTrader4Server\plugins).

Restart the server

Restart the MetaTrader 4 server / service.

Open the configuration

Open the plugin's configuration from the MetaTrader 4 Administrator.

The same settings appear in your INI configuration file (CPlugin.MAM.ini):

Enable=1
ForbidInvestorTrading=0
Allocation Mode=Equity
Master1=1000;InvestGrpA
Master2=2000;InvestGrpB

Parameters

A single instance of the plugin supports the operation of up to 64 master accounts.

To add a new master account, simply add a parameter to the plugin configuration in the Administrator or Manager Terminal.

  • Enable = 0 | 1 — the global flag that enables or disables the plugin.
  • ForbidInvestorTrading = 0 | 1 — forbid investors from trading. If this feature is enabled, take care of execution: it must be set to Manual (Group settings → Securities → Execution).
  • Allocation Mode = Equity — the Equity allocation method splits the master's trade volume across sub-accounts based on each sub-account's equity share of the account it belongs to.
  • Master<1..64> = <Master Account>;<Sub-Accounts' Group>
    • Master Account — login, which should not belong to any of the groups specified next;
    • Sub-Accounts' Group — which should have the same deposit currency as the Master Account.

Payouts from the Master account to anybody else

  1. In the settings you can set up to four sessions and specify the day of week, from which day to which day a session is ongoing.

For example, if today is 17.06.2018:

Payment Week1=1-6 → period from 18.06.2018 00:00:00 to 23.06.2018 00:00:00
Payment Week2=1-6 → period from 18.06.2018 00:00:00 to 30.06.2018 00:00:00
Payment Week3=1-6 → period from 18.06.2018 00:00:00 to 07.07.2018 00:00:00
Payment Month=1-6 → period from 18.06.2018 00:00:00 to 14.07.2018 00:00:00
  1. Each master can have its own period. To do this, set the names of the periods (the names must match the example):
Master1=2000;demoforex;Week1
Master2=2001;demoUSD;Week2
Master3=2002;demoforex;Week3
Master4=2003;demoUSD;Month
  1. After start, the plugin calculates some parameters for internal use. These are the time periods in Unix time, and it adjusts the config settings to look like this:
Payment Week1=1-6;1529884800-1530316800
Payment Week2=1-6;1529884800-1530921600
Payment Week3=1-6;1529884800-1531526400
Payment Month=1-6;1529884800-1531526400

Records like 1529884800-1530316800 should not be adjusted manually, because the plugin decides the actual periods when MT4 restarts.

  1. Whenever you want to reset or update the days of week for a period, remove the 1529884800-1530316800 record so that it has the form shown in step 2 above.
  2. If you don't want to use periods for payouts and want to pay out after each closed position, leave the settings as they were before:
Master1=2000;demoforex
Master2=2001;demoUSD
Master3=2002;demoforex
Master4=2003;demoUSD

To set up payout preferences, open the user configuration dialog in the Administrator or Manager Terminal.

The following tags should be added manually to every master account configuration in the comment field:

  • PA — the account which will receive payouts;
  • P% — the payout amount expressed as a percentage of the master's profitability.

There is a payout on the PA account after the closing of each profitable trade, with the comment payout 20% from #123456, and the following will be logged to the server journal:

'6001': withdraw #2472325 from master and deposit #2472326 to '1005' [ profit: 5.50 - 20 % from closed #2472324]

Payouts from Investor to Master

An investor also has the option to share income with its Master. To enable this, add a formula to the investor's account comment field:

P%=<value>

where value is the payout amount expressed as a percentage of the investor's profitability.

Only closed trades with a positive financial result will make such payouts.

Attaching and Detaching Sub-Accounts

To add or attach a new sub-account to an existing master account, move the account to the master attach group and press Update.

The following will be logged to the server journal in case of success:

'6001': start attaching '6105' to group ZTrader2Att
'6001': master balance updated #182490
'6001': investor account '6105' attached

Attaching a sub-account directly impacts the master account equity by adding the sub-account equity amount.

To remove or detach a sub-account from a master account, move the account to the master detach group and press the Update button.

As a result of a successful detaching operation, the following actions will be performed and logged to the server journal:

'6001': start detaching '6104' to group ZTrader2Det...
'6104': closed order #2472330 vol: 0.1 at 1.11645
'6001': partially closed order #2472329 closing vol: 0.1 initial vol: 0.5 at 1.11645
'6001': opened new order #2472332 vol: 0.4 at 1.11662
'6001': master balance updated #2472333
'6001': investor account '6104' detached

All positions of the detached sub-account will be closed, which will lead to partial closing of master account positions. Master account equity will drop by the amount of the sub-account balance.

To move an investor from one master to another, move the account from one attached group to another. This reattaches the investor, an operation that consists of detaching from one master and attaching to another.

If an investor's order could not open or close (no money or another reason), the investor account is detached from its master automatically and the comment DETACHED is set on the account. To attach the user to the master again, remove the comment and press user update.

Deposits and Withdrawals

Every time a deposit is performed on a sub-account, it also affects the master account by automatically updating its balance, thus directly impacting the master's margin and equity values.

As a result of a successful deposit or withdrawal operation, the following actions will be performed and logged to the server journal:

'6001': master balance updated #2472336
'10': changed balance #2472335 - 1000.00 for '6004' — 'Deposit'

with this comment in the balance transaction: Inv '6004' #2472335. Withdrawals work in a similar way.

Allocation Methods

Master account 6001 opens a trade of 10.00 lots EURUSD at the price of 1.12004. It is set up to work in Equity allocation mode and has the following sub-accounts attached, with their equity:

  • 6101 with $5000;
  • 6102 with $2500;
  • 6103 with $5000;
  • 6104 with $7500.

The following is the distribution of master order #182373 across the sub-accounts, confirmed by the server log:

'6001': investor '6101' open volume percent: 25%
'6001': investor '6201' open volume percent: 12%
'6001': investor '6103' open volume percent: 25%
'6001': investor '6204' open volume percent: 37%
'6001': opened order #182416 for investor '6101' []
'6001': opened order #182417 for investor '6102' []
'6001': opened order #182418 for investor '6103' []
'6001': opened order #182419 for investor '6104' []

Comments after the plugin does its duties

  • an investor, after trading, will have a comment like 100% '2001' #1269;
  • an investor, when a payout is done: payout 10% to '2001';
  • a master trader, after investor activity: payin 20% from '1002';
  • a master, when paying the broker: payout 20% to '1000'.