Optimization is useful in many different ways. In trading, you can for example use an optimizer with a backtester or simulator engine to vary some parameters of a trading system and see if this can increase the overall portfolio performance, or you can use an optimizer to test multiple variations of a particular buy rule in a trading system. Almost every piece of a trading system or trading strategy can be optimized; you can optimize buy, sell, short or cover rules, order types, order limits, portfolio settings, stops... The optimization is performed using one of the following algorithms: Exhaustive optimization, Genetic algorithm and Population-based incremental learning or PBIL. The Exhaustive optimization, which is also called Brute force optimization, tests every possible solution. This technique should be applied only when you have a small number of combinations to test. As an example, a trading strategy with 5 factors to optimize (each factor vary from 1 to 10) creates 100,000 combinations. In case you have several hundreds or millions of combinations to test; you should consider using the Genetic algorithm and the PBIL algorithm. By using these algorithms in the QuantShare trading software, you can optimize millions of combinations of a trading system, as well as trading rules, ranking systems and neural network models. We will dig deeper into these algorithms in a future post. For now, let us use the exhaustive optimization to detail the factors or settings that can be optimized in QuantShare. Create a trading system: In the menu of your trading software, select "Analysis" then click on "Simulator". In the simulator form, click on "Add" to create a new trading system. Optimize trading rules: The main component of a trading system is its rules list. The buy, sell, short and cover rules are used by the simulator to decide which positions to enter and which positions to exit. These rules can be optimized directly with the formula editor or using the wizard. For example, under the "Buy at open of tomorrow", click on "Add Rule". Under the "Rule" panel, type "rsi(a)" (Relative Strength Index) in the first input field and "b" in the second input field. When done, two lines appears in the Grid; these lines let you define the minimum, maximum and step values of the variable you are about to optimize. In the "a" variable line, type "7" under the "Min" column, "14" under the "Max" column and "7" under the "Step" column. In the "b" variable line, type "40" under the "Min" column, "70" under the "Max" column and "10" under the "Step" column. Click on "Update" to save changes; the left panel displays "Rule0 (8)", which means that the rule has eight combinations. Click on "Close" to switch back to the trading strategy editor form. Select "Create trading system using the formula editor" tab to see how the trading system rules are translated into the QuantShare vector-based language. Optimize trading system' settings: In the "Create a trading strategy" form, select "Optimize" and then click on "Optimization". Click on "Add item" to create a new optimizable variable; double click on the cell under the "Variable" column to open a list of variables. Select for example "Number of Symbols" (This field defines the maximum number of securities that should be available in your portfolio at any given moment), type "6" under the "Min" column, "10" under the "Max" column, "2" under the "Step" column and click on "OK" to save your inputs. You now have created three more iterations or combinations. Your total number of combinations is 24 (8 * 3). In the next post, we will use the money management scripting language to create more combinations.
|