Home Products Metatrader Indicators Metatrader Money Management Tool

Metatrader Money Management Tool


A lightweight Metatrader money management tool. As well as advising on current risk exposure, this indicator will compute stops and trades sizes to keep trading losses within certain limits.

This Metatrader indicator is designed to help encourage better money management. The tool can be used manually but is also capable of providing input to an expert advisor. It is compatible with the Metatrader strategy tester and will generate the correct output according to historical market rates and account settings. It’s compatible with all standard forex pairs, as well as most CFDs (commodities and indices).

In brief the indicator does the following:

  • Calculates lot size to keep trades within fixed loss limits
  • Calculates stop size to keep trades within fixed loss limits
  • Accept/reject orders flag to keep entire account within loss limits
  • Displays maximum loss if all of your positions reach stop levels
  • Displays notional value of trading positions in account currency
  • Displays base leverage

The tool will monitor these values and provide warnings if the risk limits are exceeded. In all cases the indicator only provides advisory outputs. It is up to the trader (or trading logic) to decide whether to place the trade or not.



The inputs to the indicator are as follows:

  • Maximum to risk per trade: Set as a percentage or amount in deposit currency
  • Maximum total risk on account: Set as percentage or amount in deposit currency
  • Limit type: Defines which type of risk settings are to be used – percentage or fixed amount
  • Stop loss: Fixed stop loss in pips or set to zero to calculate
  • Lots per trade: Fixed lot value or set to zero to calculate
  • Maximum base leverage: Fix the base leverage (see below for definition)
  • Limit bars for computation: Set the history bars to be processed (for automation)
  • Interactive mode: When set the graphic panel will be displayed otherwise chart values are displayed
  • Output to journal: The indicator will output detailed messages to the journal
Figure 1: Indicator settings box
Figure 1: Indicator settings box © forexop

The indicator will calculate either the stop loss, or the trade size. Not both. To allow the trader maximum flexibility, the lot value returned is not rounded to the nearest lot step size. The stop loss is also returned less the spread.


The first line in the panel displays the symbol and the input settings. The first value being the “trade risk” and the second is the “account risk”. Monetary values are displayed in the deposit currency of the account. Below, the panel displays the advised trade settings namely the lot and stop loss values.

Figure 2: Example money manager panel display
Figure 2: Example money manager panel display © forexop

Lots: The advised lot size (for given risk settings)
Stop loss: The advised stop (for given risk settings)

The current account position displays:

Current equity: The account balance plus any floating profit or losses from existing positions
Notional value: The total base instrument’s contract value of the of open positions (see below)
Maximum loss: The total loss if all open positions reach the stop levels
Current P&L: The floating profit/loss on open trades

Notional and base leverage

When trading forex and CFDs the margin and leverage as defined by the broker is often unhelpful in understanding the actual risk on the account. For this reason the indicator displays something called the notional value and base leverage. This provides the contract amounts of open positions in the account currency on the side of the base instrument. For example, if spot EUR/USD is at 1.2, a holding of 10 mini lots would have a base notional value of:

Notional = 10 x 0.1 x 100,000 = EUR 100,000

On opening the position, this will be matched by an equal but opposite notional amount in the quoted currency. In the EUR/USD case, it will be USD 120,000. So at opening the net value of the contract is zero because the notional amounts offset each other.

It is this offset of notionals that allows forex and CFDs to trade with very low margin requirements. This is because major currencies (as well as metals, indices and so on) are unlikely to become completely worthless as for example a single company share could.

But the low required margins can lead to an underestimation of the true risk and exposure on the account. For example in early 2015 the Swiss National Bank removed its currency cap against the euro. This led to movements in some pairs of 30%. This left many trading accounts with negative balances and in some cases brokers pursuing clients to repay the debts.

For this reason we define base leverage as the ratio of the base notional to the account equity. So in the above if the account equity were USD 50,000, the base leverage would be:

Base leverage = 100,000 x 1.2 / 50,000 = 2.4

Warning messages

The indicator will display warnings if the calculated stop loss/lot combination is outside of the risk settings. A warning is also displayed if the risk on an individual trade is greater than 1% of equity or if the maximum loss on the account is more than 70% of equity. If the base leverage exceeds the input value, this line will be highlighted.

Figure 3: Warning messages highlighting risky trading
Figure 3: Warning messages highlighting risky trading © forexop


Fixed Limit Money Management

In the most basic setup, the trader may simply want to know where to set the trade stop levels in order to be able to limit losses to a set amount in the account currency. For example, suppose the trader wants to limit losses on all trades to USD50 (where the account currency is also in USD).

This is done by setting the inputs as follows:

Example 1:

Maximum risk per trade=USD 50
Limit type=Limit in deposit currency (no compounding)
Stop loss=Unset (0)

The tool will calculate the stop levels for any instrument to limit the loss on each trade to USD 50. For example:

Symbol Lots Stop (pips) Loss
USDCAD 0.1 65 50
USDJPY 0.1 59.88 50
EURGBP 0.1 32.8 50
EURUSD 0.1 50 50
UK100GBP *0.01 32.8 50
XAUAUD 0.1 687.55 50

In the case of UK100GBP (FTSE-100) the lot size was set to 0.01 to achieve a valid stop.

Good money management also requires that the trader restricts total losses on the account as well as individual trades. The tool can be used to restrict the total risk on the account as follows:

Example 2:

Maximum total risk on account=USD 275
Limit type=Limit in deposit currency (no compounding)

Current holdings:

# Symbol Size Stop (pips) Loss Advisory
1 USDCAD 0.2 65 100 Allow
2 USDJPY 0.2 59.88 100 Allow
3 GBPUSD 0.1 50 50 Allow
4 EURUSD 0.1 50 50 Reject

The first three trades are “allowed” because together the maximum loss is within the USD 275 limit defined by the trader. When the first three trades are open, trade number 4 is rejected because the total loss of USD 300 would exceed the risk limit on the account. To accept the fourth, the loss on the trade would need to be reduced to below USD 25.

Fixed Fractional Money Management

With fixed fractional money management the trade size (exposure) can adjust up and down according to the amount of equity in the account. For example the indicator can be set up follows:

Example 3:

Maximum to risk per trade=0.5%
Stop loss=150 pips
Lots=Unset (0)
Limit type=Limit % of account equity (compounding)

Equity (USD) Risk Symbol Stop Lots
1,000 0.50% EURUSD 150 0.01
1,500 0.50% EURUSD 150 0.02
2,000 0.50% EURUSD 150 0.03
2,500 0.50% EURUSD 150 0.03
3,000 0.50% EURUSD 150 0.04

The table above shows how the lot size will scale up as the account equity grows. Of course if the account equity shrinks the lots size will then scale down. This serves to protect the account capital from unmanageable losses.

As an alternative, the trader could choose to fix the lot size and adjust the stop loss up or down in proportion as the account equity grows (or shrinks).

Example 4:

Maximum to risk per trade=0.5%
Stop loss=Unset (0)
Limit type=Limit % of account equity (compounding)

Equity (USD) Risk Symbol Stop Lots
1,000 0.50% USDJPY 59.8 0.01
1,500 0.50% USDJPY 89.7 0.01
2,000 0.50% USDJPY 119.6 0.01
2,500 0.50% USDJPY 149.5 0.01
3,000 0.50% USDJPY 179.4 0.01


Scaling the lot size is a form of compounding, and this can have a major impact on profits over the long term. The following tests show the powerful effects of fractional money management or lot compounding over a ten year period.

Test# Compounding Leverage Total trades Balance (USD) Net profit (USD) Payoff
1 None 1 14,778 253,968 153,968 10.42
2 0.25% 1 14,776 543,019 443,019 29.98
3 0.60% 2 14,753 2,287,872 2,187,872 148.3
4 0.90% 3 12,382 4,797,087 4,697,087 379.35

The four tests all use the same strategy. The first is without compounding. The next three tests show different compounding ratios. The starting balance in each case was USD 100k. In the first test, the trade size was held fixed at 0.1 lots with a maximum exposure of one lot. This corresponds to a base leverage of 1 at the outset.

Figure 4: 10-year strategy back test: No compounding (1 x leverage) giving profit USD 153k
Figure 4: 10-year strategy back test: No compounding (1 x leverage) giving profit USD 153k © forexop

In the second test, the lot size was allowed to scale up and down as the account balance grew (or fell) to keep leverage constant. The risk per trade was set as 0.25% of equity. So for example with a USD 100k start balance, this produces a starting trade size of 0.1 lots to match the first test case. When equity reaches USD 200k, the trade size is then 0.2 lots to maintain the required risk levels. Thus the base leverage was fixed at 1 throughout.

Figure 5: Compounding set to 0.25% (1 x leverage) giving profit USD 443k
Figure 5: Compounding set to 0.25% (1 x leverage) giving profit USD 443k © forexop

In the third and fourth test, the compounding ratio was increased to 0.6% and 0.9% of equity respectively. This corresponds to base leverage of 2 and 3. See table above.

Figure 6: Compounding set 0.9% (3 x leverage) giving profit USD 4.7M
Figure 6: Compounding set 0.9% (3 x leverage) giving profit USD 4.7M © forexop

When compounding at 0.25% is applied the strategy produces nearly three times the profit. When compounding at 0.6% is used, which corresponds to constant leverage of 2, the strategy produces over 14 times the profit. When compounding is set to 0.9% the profit is USD 4.7M which is 30 times greater than when no compounding was used. This illustrates how lot compounding can grow profits exponentially.


The indicator can provide input to an expert advisor to generate trade sizes or stop loss values. The indicator outputs are as follows:

Mode Description
0 The lot value
1 The stop loss value
2 Loss amount at current stops
3 Base leverage

Important: When using automation the “show panel” setting must be set to false in order to generate the numerical outputs. For efficiency it’s also recommended to set the limit bars. This is especially relevant if any of the settings are altered on each call to the indicator (for example changing the stop setting).

Example code for use as custom indicator in an expert advisor:

double max_risk_trade=0.3;
double max_risk_acc=50;
int mtype=0;
double stop_loss=100;
double lot_mult=0;
double leverage_limit=2;
int limit_bars=2;
bool ShowPanel=false;
bool JournalOutput=false;

double lots=iCustom(NULL,PERIOD_CURRENT,”examples\Mmanager”, max_risk_trade,max_risk_acc,mtype,

double sl=iCustom(NULL,PERIOD_CURRENT,”examples\Mmanager”, max_risk_trade,max_risk_acc,mtype,

double max_drop=iCustom(NULL,PERIOD_CURRENT,”examples\Mmanager”, max_risk_trade,max_risk_acc,mtype,

double base_lev=iCustom(NULL,PERIOD_CURRENT,”examples\Mmanager”, max_risk_trade,max_risk_acc,mtype,

In the above, replace the text “examples\Mmanager” with the name of the indicator in the local Metatrader folder.

If limit bars is set to zero, the indicator will recalculate on all of the bars in the chart in each call. This can be very slow. If limit bars is set to 10 for example, only the previous 10 bars will be calculated on each call. The value chosen should be at least as great as the maximum “shift value” that will be used in calls to the indicator.

Current version 1.32