Click here to Login

Several money management strategies in a trading system

Updated on 2011-09-22

A money management script (MM) is a set of instructions that lets you manage/update your portfolio, enter new orders and take trading decisions based on one or several set of rules.
You can create a script using the MM tool, which can be opened by selecting "Analysis" then "Advanced Money Management".

You can also find several ready-to-use scripts on the QuantShare sharing server. Examples:
Correlation Filter Money Management Strategy
Trading Strategy based on the Number of Buy Signals
Averaging Down Money Management Strategy
Futures and Forex historical data
Adaptive Trading System - Minimum Percent Winners and Percent Invested
Historical trading volatility-based system to adjust trade sizes
Design and backtest a trading system with two strategies
Hedge a portfolio strategy

How to add several money management strategies

It is possible to add several MM scripts to a single trading system. For example, you can add a script that adjusts the size of new positions and a script that updates the strategy exposure based on the portfolio maximum drawdown.

Here is how to add several MM scripts to a trading system:

- Open the "Simulator" manager by selecting "Analysis" then "Simulator"
- Select a trading system then click on "Update" (top bar)
- Click on the money management icon (on the top)
- Click on "Add an existing money management script" then select a script
- Perform the previous operation to add another script to your trading system

Notice how a new tab is added each time you add a new script.

- To remove a script, select its tab then click on "Delete Script"
- You can update a tab name by typing a new name in the text field (next to "Rename Script") then click on the "Rename Script" button
- To update a script, select its tab then click on "Update Script"

Note that two money management scripts can have an input variable (MM Variable) with the same name. This is because each script input variable has its own control. In the "Simulator" manager, you will have a different tabs for each MM script. The tab name is the same as the script name.

Order of Execution

For each event type (Example: OnStartSimulation), scripts are executed in the normal order during a backtest or portfolio rebalance. The first script is executed first, then the second one and so on.

In MM events, including the "OnEndPeriod", "OnNewPosition" and "OnClosePosition" events, updates and changes in one script are visible and available to the second script. For example, if in the first script, we have $9000 in cash and we enter a long order to buy Microsoft for $5000 then if we check the amount of available cash in the second money management script, we will find that we have only $4000 ($9000 - $5000). In addition, if we check the available open orders, we will find the previously entered order to buy Microsoft.

Potential problems and how to fix them

Example 1: Updating the same variable/field

This can occur if for example our first money management script sets the percent of capital to invest in the "Long" category to 50, and the second one updates the same variable (Percent of capital to invest) and sets it to a different number. The second script will override the change made by the first one.

Example 2: Incompatibility

Your scripts must work together or perform distinct operations; they should not work against each other.

Here is an example of two incompatible scripts:
The first script adjusts the number of shares to be bought. The script calculates the maximum potential loss for each stock and updates the number of shares to purchase so that the maximum amount, in dollars, the investor can lose is fixed.
The second script adjusts the number of shares based on asset volatility. In this example, you can clearly see that the second script will often, if not always, override the first script settings and thus using both scripts in the same trading strategy does not make sense.

How can these scripts communicate between themselves?

There some ways that allows you to enable communication and share variables between two money management scripts.
The easiest way to do this is by using the "Global" variable.
Using the "Global.SetVariable" function, you can create global variables that can be accessed by any other script.
To retrieve the value of a variable, you should use the "Global.GetVariable" function.
To check if a global variable exists, you should use the "Global.ContainsVariable" function.

Note that the "Global" variable allows you to share variables between other scripts too. Example: Global script, custom functions, composite, custom drawing tools, trading system metrics...

Related Articles

Here is a list of blog posts about the money management tool:

Money Management: Optimize a trading system
Create a trading strategy using the money management tool - Part 1
Create a trading strategy using the money management tool - Part 2
How to get buy and sell orders for a portfolio based on a trading system/strategy
How to combine long, short and custom portfolio strategies within a trading system

no comments (Log in)

QuantShare Blog
Search Posts

Recent Posts

Create Graphs using the Grid Tool
Posted 1320 days ago

Profile Graphs
Posted 1425 days ago

Previous Posts

More Posts


Create an account
Affiliate Program
Contact Us
Trading Forum
How-to Lessons
About Us
Terms of Use

Copyright 2024
Social Media
Follow us on Facebook
Twitter Follow us on Twitter
Follow us on Google+
RSS Trading Items

Trading financial instruments, including foreign exchange on margin, carries a high level of risk and is not suitable for all investors. The high degree of leverage can work against you as well as for you. Before deciding to invest in financial instruments or foreign exchange you should carefully consider your investment objectives, level of experience, and risk appetite. The possibility exists that you could sustain a loss of some or all of your initial investment and therefore you should not invest money that you cannot afford to lose. You should be aware of all the risks associated with trading and seek advice from an independent financial advisor if you have any doubts.