Adding Improved Money Management

Top  Previous  Next

We are going to build on the Tutorial system we created in the last section, so if you are starting here, you might want to go back and quickly create that system to catch up.

 

What we did in the last tutorial was set the unitSize to 1 in our Basic Money Manager Block. This is obviously not the best Money Management technique available, so let's move on to our fixed fractional model. In this model, we put on the number of units that correspond to some defined percent of equity.

 

The Fixed Fractional Money Manager Block that is included with the system looks like this. There is one parameter that is a percent type and allows the user to enter the percent risk per trade, and one script which sets the unitSize accordingly.

 

tutorialfixedfractionalsetup

Let's look at the script in detail:

 

VARIABLES: riskEquity, dollarRisk TYPE: money

VARIABLES: quantity TYPE: floating

 

This defines the variables we need to use.

 

' Compute the risk equity.

riskEquity = system.tradingEquity * riskPerTrade

 

This sets the amount of equity to risk equal to the trading equity available to the system at this time multiplied by the risk per trade as set by the user. The available trading equity starts at the equity set in the global parameters section, but is increased/reduced every day by trades. So at any given time, you can access the available equity using the variable system.tradingEquity. So if system.tradingEquity is $10,000 and riskPerTrade is 1%, then riskEquity is $100.

 

' Compute the dollar risk.

dollarRisk = order.entryRisk * instrument.bigPointValue

 

This says that the dollar risk for this trade (that is about to be placed) is equal to the entry risk of the trade (in points) times the big point value of the instrument. So what is the entryRisk variable? This comes from the difference between the entry and stop price in the broker statement. So if we said broker.enterLongOnOpen( 90 ) and the open was at 100, then the risk in points is 10. Multiply this by the bigPointValue of the instrument and we get the dollars risked on this trade (per contract).

 

' Adjust the unit to this percentage.

quantity = riskEquity / dollarRisk

order.SetQuantity( quantity )

 

This calculates the number of contracts we can place on this trade. If we have a riskEquity of $100, and a dollarRisk of $50, then quantity will be 2.

 

You will notice that our Tutorial example needs a stop price in order to calculate entry risk, so we can determine a good unit size. One common way to do this is to use Average True Range (ATR) stops. By using an ATR stop, we can set the stop as some percent of the average true range which is advantageous because we limit exposure based on volatility.

 

Add the Average True Range parameter to our Tutorial System Entry Block. The normal value for this calculation is 39.

 

tutorialaveragetruerange

Also create an ATR stop parameter as a floating point. We will use this parameter in the script to set the stop amount. So if the user enters 1, then we use 1 ATR as the stop amount. If they enter 2.5 then we use 2.5 ATR as the stop amount. Notice that we set this as a Floating Point type so the user can enter fractions (decimals).

 

tutorialatrparameter

 

And create an Average True Range indicator:

 

tutorialatrindicator

Now we can use this averageTrueRange indicator and atrStop in our Entry script. We will set the stop to be the close plus/minus the average true range times the ATR stop. Now our Money Manager Block will have an entry risk to use in calculating the trade quantity. Press OK to exit the Blox Editor.

 

tutorialstops

Launch the System Editor, click on our Tutorial system, then click on the Basic Money Manager block in the middle and click Remove. Now click on the Fixed Fractional Money Manager and click Add to add this new money manager to our system. We now have the following:

 

tutorialeditsystem

 

Press OK, and now back in the main screen you will notice that our Tutorial system now has different parameters. We can set the risk per trade and ATR stop as appropriate, and run a test to see how it works. Step through the parameters and see what combination works the best. Remember that the ATR Stop and the Risk Per Trade are linked, so if you increase the ATR Stop the Entry Risk goes up and the trade quantity goes down. See if you can run a test to prove this to yourself.

 

clip0063