Click here to Login

Select the best ETFs combination to maximize your return and reduce your investment risk

Updated on 2011-05-31

By the end of this article, you will learn how to get the best combinations of ETFs to maximize your return and reduce your investment risk.

You will be able to answer questions such as, should I invest my money in Aluminum, Gold and Small-cap ETFS or Oil, Bond, Silver or maybe Large-cap, Medium-Cap and Coffee ETFs.

ETFs Selection

The first step would be to select a diversified list of ETFs. You can search Google to find more info about different ETFs available in the market.
You can for example select a small-cap ETF (Shares Russell 2000 (IWM)), a mid-cap growth (IWP), a large cap fund (SPY), an international fund (FEU), a broad commodity ETF (DBC), a leveraged commodity ETF (UCD), a gold tracking ETF (GLD), a short oil ETF (SZO) ...

Create a list of 15 to 20 ETFs and then put them in the following format: (Symbol names separated by semicolons)

The best way to select these ETFs is to create a correlation matrix of the best performing ETFs and select the ones that are less correlated.
Here is a post that shows you how to perform this: How to create a correlation matrix of several securities

Lexicographical Index

The Lexicographical Index/Order is the rank or index of a combination. Given the above ETF symbols, we can create several combinations and then use the lexicographical index algorithm to determine the combination for a particular index.

The number of combinations depends on the number of elements we use to create these combinations:
1 element = 22 combinations -> Example: IWM
2 elements = 231 -> Example: IWM;GCC
3 elements = 1540 -> Example: IWM;JJU;BGZ
4 elements = 7315 -> Example: BAL;BGU;BIV;BKT
5 elements = 26334 -> Example: GCC;SGG;JJU;BIV;BND
6 elements = 74613 -> Example: FEU;GCC;BAL;SGG;JJU;BIV
18 elements = 7315
19 elements = 1540

The algorithm that allows you to determine whether a specific symbol belongs to a specific combination index can be downloaded here: Combination Element from Lexicographical Index.

Usage Example:

buy = CombinationIndex(str1, "GCC", 3, 10) == 1;

The above example returns TRUE if GCC (GreenHaven Continuous Commodity Index Fund) belongs to the combination number 10 (Each combination has three elements as specified by third parameter of the "CombinationIndex" function).

Create your trading system

Open the simulator manager by selecting "Analysis" in the main menu, then "Simulator".
Click on "New" to create a new trading system.

In this trading system, we will create several optimizations, where each one will backtest a combination specified by its lexicographical index. This will allow us to backtest all combinations and determine which combination leads us to the best results in terms of annual return and/or risk.

- Select "Symbols & Dates" tab, add a "Symbols Info -> Name" condition then type the symbol names we have created earlier (IWM;IJR;VB;JKG;SPY;IOO...).
- Select the Start and End date of the simulations (Example: 2007 to 2011)
- Select "Strategy" tab then enable the editor by selecting the "Create trading system using the formula editor" tab.

The total number of combinations is returned by the "CombinationIndex" function if we set the index parameter to -1.


nbelements = 3;
nb1 = CombinationIndex(str1, Name(), nbelements, -1);

If you want to create combinations with three elements (Combination of three ETFs), set the number of positions of the simulation to three then type the following formula:

nbelements = 3;
nb1 = CombinationIndex(str1, Name(), nbelements, -1);

Optimize("lexindex", 0, nb1 - 1, 1);
buy = CombinationIndex(str1, Name(), nbelements, lexindex) == 1;

The optimize function creates 1540 trading systems by varying the variable lexindex (from 0 to nb1 - 1).

- Click on the "Create Trading System" button to save the strategy
- Now, select the strategy in the "Trading Systems" panel and then click on "Optimize".

The simulator will test all ETF combinations and let you know which group performs best.


By using four elements/symbols in each combination instead of three, we increase the number of combinations and the computation time by 4.7 times.

It took me one hour and 30 minutes to complete the backtesting process of these 7315 trading systems.

no comments (Log in)

QuantShare Blog
Search Posts

Recent Posts

Create Graphs using the Grid Tool
Posted 1292 days ago

Profile Graphs
Posted 1397 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.