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) IWM;IJR;VB;JKG;SPY;IOO;FEU;GCC;BAL;SGG;JJU;JJC;USO;DBP;DBE;CMD;BAL;BGU;BGZ;BIV;BND;BKT 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: str1 = "IWM;IJR;VB;JKG;SPY;IOO;FEU;GCC;BAL;SGG;JJU;JJC;USO;DBP;DBE;CMD;BAL;BGU;BGZ;BIV;BND;BKT"; 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. Example: nbelements = 3; str1 = "IWM;IJR;VB;JKG;SPY;IOO;FEU;GCC;BAL;SGG;JJU;JJC;USO;DBP;DBE;CMD;BAL;BGU;BGZ;BIV;BND;BKT"; 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; str1 = "IWM;IJR;VB;JKG;SPY;IOO;FEU;GCC;BAL;SGG;JJU;JJC;USO;DBP;DBE;CMD;BAL;BGU;BGZ;BIV;BND;BKT"; 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. Note 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.
|