Click here to Login




Money Management: Optimize a trading system

Updated on 2010-04-13





There are several ways to optimize a trading system in QuantShare. In the first post (Optimization of a trading system), we described two different ways to perform a trading system optimization. The first one consists of optimizing trading rules by specifying optimizable variables within vector-based formulas. The second one allows us to optimize trading strategy' settings, like the maximum number of positions, the initial capital...
In this post, we will describe how to perform an optimization using the Money Management scripting language. This technique is the most powerful and also the most advanced.

Optimization using the Money Management scripting language:
In the simulator form, click on "New" to add a trading system. To create a money management script, select "Money Management" then click on "Add a new money management script". To update a script, just click on "Update Script".
There are two ways to create optimizable variables; both can only be defined in the "OnStartSimulation" event.

The "Optimize" class:
Example: Optimize.OptimizeDouble("var1", 1, 100, 1);
The above line creates an optimizable variable called "var1", which varies between 1 and 100 with a step of one.

The "Functions" class:
Example: Functions.SetNumericInput("var1", 1, "");
This function creates an input. This input can be updated and optimized using a user-friendly control.



Click on the "Plus" button next to "Optimize" to enable the optimization of this input. The trading software internally creates an optimizable variable using the "OptimizeDouble" function.

In the script, the function "Variables.GetVariable("var1")" allows you to retrieve the content of the variable "var1". It returns a different value depending on the trading system's combination that is tested.

Here is an example:
You creates a script that stops trading for 20 days each time the trading system's drawdown drops below -10%.
In order to test different periods and different drawdown thresholds, you change the period (20) by specifying an input (Functions.SetNumericInput) and the drawdown threshold (-10%) by specifying another input.
After you specify different start and end periods for these two variables, and click on "Optimize" in the simulator form, the trading software backtests all the combinations of trading systems; changing the period and drawdown values on each run.

Optimize text variables using the Money Management scripting language:
As with numeric variables, you can optimize text variables using two different functions.
The first function directly optimizes the variable by getting a value from an array you provide (a different value for each optimization run).
Optimize.OptimizeText("var2", array);

The second function creates an input, which can be optimized using the user-friendly control.
Functions.SetTextInput("var2", "field1", "var2");



Values should be separated by a comma.

There are several cases where it is useful to optimize text variables. For example, you can specify several database fields, so each time the simulator creates a new trading system, a new database field is used in the trading decision process.











no comments (Log in)

QuantShare Blog
QuantShare
Search Posts




QuantShare
Recent Posts

Create Graphs using the Grid Tool
Posted 1461 days ago

Profile Graphs
Posted 1566 days ago

QuantShare
Previous Posts

Optimization of a trading system
Posted 5355 days ago

Short Index - Part 2
Posted 5390 days ago

Short Index - Part 1
Posted 5397 days ago

Historical Market Data
Posted 5418 days ago

Historical volatility estimators
Posted 5431 days ago


More Posts

Back







QuantShare
Product
QuantShare
Features
Create an account
Affiliate Program
Support
Contact Us
Trading Forum
How-to Lessons
Manual
Company
About Us
Privacy
Terms of Use

Copyright © 2024 QuantShare.com
Social Media
Follow us on Facebook
Twitter Follow us on Twitter
Google+
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.