In the previous article (Trading the strategy equity curve), we explained how you can combine different trading systems to create a meta-strategy then trade each system's equity curve using the QuantShare programming language.
In this article, we will show you how you can optimize your meta-strategy and backtest multiple combinations.
We already saw in the previous article how to create a meta-strategy formula that exists any strategy/equity curve whose drawdown drops below -15%.
Let us see now how we can optimize that drawdown threshold and see if we can improve our meta-strategy overall performance by varying the drawdown threshold.
The original formula was:
d = drawdown() * 100;
buy = d > -15;
sell = d <= -15;
We should now update it to:
Optimize("dt", 5, 50, 5);
d = drawdown() * 100;
buy = d > -dt;
sell = d <= -dt;
The first line creates an optimizable variable that starts from 5 and increases by 5 until it reaches 50.
The third and fourth lines uses the optimizable "dt" variable instead of the fixed value 15.
After you save your meta-strategy, click on the "Optimize -> Exhaustive Optimization" button at the top to generate 10 different backtests, each one with a different drawdown threshold.
Optimize Strategies Selection
We are referring here to the ability to combine different systems together and see which combination works best.
This type of combination is very easy to implement:
- Click on the "Add/Remove Trading Systems" (after you create or update a meta-strategy)
- Check the trading systems you want to include in the meta-strategy
- Click on "Load Checked Item(s)"
- Check the "Optimize Strategies Selection" checkbox at the bottom
- Type the number of (unchecked) strategies to invest it
If you type, let us say three, then QuantShare will create all combinations that consist of investing in three different trading systems among all the systems you previously added.
If you check any of the strategies, then that strategy will be always included in the meta-strategy backtest and will not be included in the optimization.
Optimize Trading Systems' Weights
You can also optimize each trading system's weight.
When you create or update a trading system, you can define the relative weight of each system by typing the appropriate value under the "Relative Weight" column.
If for one or several strategies, you want to test different weights then simply type different values separated by semi-colons. Example: 5;10;20
Optimize Money Management Variables
As you probably know, you can also create custom money management scripts for your meta-strategies. Just keep in mind that instead of trading securities, you are trading strategies (equity curve) here.
In the money management script, you can also define optimizable variables and optimize them as you would do with a single trading system.
For more information on how to optimize money management scripts, please check the following blog posts:
Money Management: Optimize the scale-in strategy
Money Management: Scale-in Trading Strategy
It is important to note that all these different optimizations will be combined. This means that if you create optimizable variables that would generate 100 combinations, enable strategies selection (50 combinations as an example) then create three different weights for two of your strategies (3*3 = 9 combinations) then the total number of meta-strategy backtest QuantShare will perform is (100 * 50 * 9 = 45,000 backtests).