Expert Advisor Strategy Design: Money Management Techniques

An important consideration as to whether or not an expert advisor can be used profitably in forex trading comes down to the money management it uses. Even if the most advanced logic is build into an expert advisor and backtests show amazing results over a long period – it will ultimately fail live if its money management inputs are not sound.

The problem is that most traders haven’t the slightest idea what money management really is or how it can be used to one’s advantage in automated forex trading.

In this article you can learn how to design an Expert Advisor strategy using solid money management techniques and implementing the expectancy of max drawdown and consecutive loss to help your EA trade the market for longer.

In essence, money management applies to the strategic manipulation of position sizes on different trades to ensure a positive outcome. With an intelligent money management system, losing trades are reigned in and losing streaks are accounted for, and position sizes grow steadily and modestly along with equity growth.

Every expert advisor is going to have losing streaks. When they come and how long they last – no one knows.  There will also be profitable winning streaks, but it is losing streaks that can wipe your account and thus need to worry about. Hence, before you even set the inputs of your EA’s money management, you must know in advance the potential degree of your losing streak.

The Expectancy of Max Draw Down and Consecutive Loss

Money management or position sizing depends mostly on your trading system’s expectancy for the worst case scenario – that is, the potential max consecutive losing trades and max draw down.

Assuming we are dealing with a 10 year backtest with accurate historical data, there is at least 2 different ways of determining your potential losing streak. The easiest way is to look at your max historical draw down and consecutive losing trade number.

As you can see, the Maximal drawdown is $1800, and it carries more weight than the percentage number beside it. The percentage number of 9.7% is the high to low equity drawdown, which is interesting, but to further handicap the system, you should imagine that the system started at the beginning of the drawdown and suffered $1800, which would make the percentage drawdown 18%. The other number to look at is the Maximum consecutive losses (losses in money), which is 12 (totaling $676) — and this gives us the size of a losing streak. Obviously, because the maximal drawdown of $1800 is much larger than the $676 losing streak, there must have been a few back to back losing streaks to get the maximal drawdown figure. Because the maximal drawdown of $1800 (18%) is the larger number, it becomes the baseline for the worst case scenario.

An alternative method to calculate the potential max consecutive losing trades (and maxmimal drawdown) is to look at Loss trades (percentage of total) to calculate the probabilities of consecutive losing streaks. For instance, if we take the performance of our 10-70 SMACross (Method2) on 0.1 lots, we have 70% losing trades. In two trades, there is a 0.70 * 0.70 = 0.49 or 49% chance of two losses and a 0.30 * 0.30 = 0.09 or 9% of two gains, while the rest is 100 – (49 +9) = 42% change of 1 gain and 1 loss. This is important because it shows how easy it is to have 2 consecutive losses while it is unlikely (but still possible) to have 2 consecutive gains. In order for a possibility to be significant it has to have at least a 5% chance of happening. If you multiple 0.7 by 0.7 seven times, it gives us 0.57 or a 5.7% chance of happening, meaning it is realistic to expect 7 consecutive losses. To further handicap our system, we have to imagine double that, or 14 consecutive losses, in a real trading scenario. Interestingly enough, this is close to the 12 consecutive losses we experienced in the 10 year backtest, which means we are on the right track in our calculations.

Once you know your max losing streak, you can then multiply it with either the average loss per trade or the stop loss of your trade to determine the max draw down of your system. If you multiplied 14 X average losing trade of 93 pips, you would have 1300 pip DD, and if you multiplied 14 X stop loss of 200 pips, you would have 2800 pips. The historical max draw down is somewhere in the middle at $1800 (or 1800 pips), and that is probably the best compromise between the two.

Max Risk Preference: No more than 25% DD

The objective of money management is to limit losses such that when the unfortunate event of experiencing that high number of consecutive losses we would still have enough equity to still trade and experience the gains.

Note:  if we lose 20%, the remaining 80% would need to gain 25% to recover (the 20% loss is equal to 25% of our remaining 80% equity). If however we lost 50%, the remaining 50% in equity would need to have 100% gains to recover, which is difficult to do. This is where risk preference comes into the picture. Let’s say we’re only comfortable with losing 25%, the remaining 75% would need 33% gain to recover to the original equity, which is a more achievable objective.

Another way of looking at this max risk preference is to see it as the UNCLE POINT or the amount of draw down that provokes a loss of confidence in either the investors or the fund management. If either the investors or the managers become demoralized and withdraw from the enterprise, then the fund or strategy dies. Generally the uncle point is 25% draw down, to issue a loss of confidence in the strategy and discontinuation of trading it.

So now we can bring in our calculated expectancy of 14 max consecutive losing trades of 128 pips each into the picture. We don’t want our 14 max consecutive losing trades of 100 pips each to exceed our 25% max risk preference.

What then do we make as a percentage to risk on each trade?

If each losing trade incurs approximately 100 pips, we would need those 14 losses to take 25% of our equity, 25 / 14 = 1.78. So each time we trade we would only put 1.78% of equity to ensure that at worse we would only have a 25% loss in equity.

Thus, you can only expect to have 0.18 lot size at most on a 10K account size in order to have less than 25% DD (1.8 X 100 X 14 = 2520). Our 1.78% for each trade would give us less gain than when placing say 5% in each trade; however, we would also have significantly less chance of blowing up.

The KEY Is that when and exactly where the expert advisor takes a hit from the market, it must insulate your equity and hit back harder each time bringing your account back on track as quickly as possible. It must manage position sizing to ensure that in the long run your account remains on track to a respectable return.

Note: there is an indicator that you can place that works with your stoploss size (or substitute your average loss for your stoploss) and account equity to determine your lot size.

EA Built in Money Management Code: Percentage Risk per Trade.

There are many ways to determine the money management of an EA, but I am going to point out one that has gained some popularity in recent months. It is a money management mechanism adopted by Funyoo in his template – used in my MACross EA –that auto-calculates the lot sizes based on your account size and your pre-selected risk percentage and stop loss amount.

The external parameters look like this:

You can turn on the money management feature by setting MM=true. If MM=false, then lots = 0.1 or whatever you set for this field. The risk you set is the percentage of the account, and you also indicate the minlot and maxlot minimal and maximal lots allowed by your broker.

The code of the money management looks like this:

double lotsoptimized(){
double lot;
if(stoploss>0)lot=AccountBalance()*(risk/100)/(stoploss*pt/MarketInfo(Symbol(),MODE_TICKSIZE)
*MarketInfo(Symbol(),MODE_TICKVALUE));
else lot=NormalizeDouble((AccountBalance()/lotsize)
*minlot*risk,lotdigits);
return(lot);
}

Funyoo’s adoption of the money management mechanism is basically the % per trade risk rule in effect. It is calculated by taking the difference between your entry price and initial stop-loss exit and multiplying it with your trade size. This will give you the dollar loss if you are stopped out.

2% Per Trade Risk Formula
Account size x 2% = Risk Amount
$10,000 X 2% = $200

If you had a $10,000 account balance and 200 pip stop and selected 2% risk per trade, you would be able to trade only 0.1 lots because 0.1 lots stopped out at the 200 pips stop loss would be $200 or 2%.  If indeed the 10-70 MACross stopped out at 200 pips each, I would not want the risk percentage to be 2%, because it would not be able to handle more than 14 losing trades of 2% each and still be less than 25% max draw down. However, since the average losing trade is closer to $100 per trade, I can increase the risk percentage just a little, making it closer 2.5% in order to be less than 25% max draw down with 14 losing trades.

Let us see what the performance of the system would be with a 2.5% risk:

The system has near doubled in return, achieving $12500 while staying below the 25% maximum DD risk tolerance level. We achieved our goal of trying to get the most out each trade with a comfortable risk level. If we added any more percentage risk we would increasing our return at the expense of a greater, more uncomfortable draw down. It is always a fine balance between the two, and you should always err on the side of caution, that is, on the side that leads to less draw down. The drawdown of the future can always be much more than our backtest and calculations, and we should always expect and prepare for the worst.

Funyoo’s money management code automates the lot sizing for us – making the money management seem very simple. You just need to select the risk percentage – 2 or 3%– and the EA handles the rest. It is indeed very simple, so long as you are modest and fully aware of the worst case scenario. It is just as simple to increase this risk percentage to 10 or more, and consequently jeopardize the account. Money management is thus one of those powerful tools that can lead to more profits if controlled or more losses if not.

Conclusion

Profits and losses do not likely alternate with smooth regularity but instead appear as winning and losing streaks. When you realize that this is natural, it are more likely to stay the course during drawdowns, and also to stay appropriately modest during winning streaks.

In general, good risk management combines several elements. There must be a calculation and clarification of the potential max consecutive loss and drawdown of the system determined through backtesting and extrapolation. There must also be a clarification of the max risk preference of the system going forward, such as no more than 25% draw down. Once you have an idea of your system’s historical (and potential) max drawdown, you can begin to add a money management system (such as the offered by Funyoo) that auto-adjusts the lots only to the degree that each trade will not exceed its selected %risk (in relation to account size and stop loss) and that a accumulation of such losing trades in the form of a losing streak will not exceed your predetermined max risk tolerance.

Generally, in order for your system to be around for the long run, it should never exceed a 2% risk (of trading account size) on any given trade, but exceptions can be made if the average losing trade is much less than the stop loss. This smaller percent risk is an acknowledgment that 10+ losing streaks can and do happen, and you have to be able to comfortably survive them. If you are trading with concurrent systems, it is also important to never exceed an overall 6% risk (of your trading account size) at any given time. You can have three strategies with 2% risk each or 6 strategies with 1% risk each, but having more than 10% combined risk is asking for trouble –no matter how non-correlated you think the systems or currencies are to each other.

In sum, then, money management is all about taming the dragon – once you know that you can survive its claws (approaching gingerly with tight stop losses) and fire (stealing yourself against a losing streak), you may profitably mount and ride the beast upwards (steadily rise in equity). If you approach her with humility and respect, setting your risk inputs modestly, you can shield yourself from danger and come out the winner. If instead you approach her with greed and set your risk inputs for maximal gain, sooner or later your EA will turn against you and consume your account.