# Portfolio Optimization

**Understanding Optimization**

A strategy is created by implementing trading concepts, ideas, and observations of historical market behavior, into a trading system. The very idea of a trading system implies a degree of optimization to market behavior.

The process of strategy optimization further enhances and automates this process. Strategy optimization is the search for the set of optimum parameters for the defined criteria. By testing a range of signal input values, optimization aids in selecting the values that correspond, based on historical data, to the best strategy performance. Optimization aids in better understanding of strategy's characteristics and in creating new criteria for entries and exits.

Optimization can have detrimental effects if the user searches for the combination of inputs based solely on the best performance over a period of historical data and focuses too much on market conditions that may never occur again. This approach is known as over-optimization or curve-fitting. Performance will not be the same in real trading, since historical patterns are highly unlikely to be repeated.

**Optimization Methods**

There are two optimization methods: Exhaustive Search and Genetic Algorithm.

**Exhaustive**, also called **Brute-Force**, optimization systematically goes through all the potential combinations in search for the best solution. The length of time required is proportional to the total number of all possible solutions. Unless relatively few parameters are involved, the period of time required to reach a solution by this method may turn out to be unacceptably long. Thus, exhaustive optimization may only be suitable when there is a limited number of possible solutions.

**Genetic Algorithms** optimization evaluates only the more promising combinations, finding near-optimum solutions in a fraction of time that would be required by the brute-force approach, making Genetic Algorithm optimization powerful enough to analyze strategies with hundreds of parameters. Genetic Optimizer settings add flexibility to this technique.

To learn more about optimization techniques, see Understanding Optimization

**Running Portfolio Optimization**

- Open
**Portfolio Trader**window.- see
**how**.

- see

Once a portfolio has been created, strategy configured, and portfolio settings selected, portfolio optimization can be run.

## Contents

## Exhaustive Search Portfolio Optimization

To perform portfolio optimization:

- Click the
**Optimize**button on the toolbar, or select**Portfolio**in the main menu and then click**Run Optimization**. - In the
**Select Optimization Method**dialog box that appears, select**Exhaustive Search**. - In the
**Exhaustive Search Properties**window that appears, select the**Optimizable Inputs**tab. - Check/uncheck the check box to the left of the signal name and input name to enable/disable optimization for this input or check the check box to the left of the
**Signal Name**column heading to enable optimization for all inputs (at least one input should be selected to perform optimization). - The
**Current Value**column shows input values that are currently selected for the signals applied on the chart. - In the
**Start Value**column, enter the desired starting values for each of the inputs. - In the
**End Value**column, enter the desired ending values for each of the inputs. - In the
**Step**column, enter the desired step size, for each of the inputs. - The
**Step Count**column shows current amount of steps for an input. - Select the
**Optimization Criteria**tab. - Select the
**Use Limitation**checkbox to limit the output to a defined number of the best results; unselect the checkbox to list all the results in the optimization report. - When
**Use Limitation**checkbox is checked Optimization dialog window shows current best results for selected сriteria during optimization. - Enter the desired number of best results in the
**Show N best results**box. - Select the best results criteria in the
**best results for**list box. - Select
**Ascending**or**Descending**option to sort the output in ascending or descending order, respectively. - Click
**OK**to run the optimization and generate the Optimization Report.

## Genetic Algorithms Portfolio Optimization

To perform portfolio optimization:

- Click the
**Optimize**button on the toolbar, or select**Portfolio**in the main menu and then click**Run Optimization**. - In the
**Select Optimization Method**dialog box that appears, select**Genetic Algorithm**. - In the
**Genetic Algorithm Properties**window that appears, select the**Optimizable Inputs**tab. - Check/uncheck the check box to the left of the signal name and input name to enable/disable optimization for this input or check the check box to the left of the
**Signal Name**column heading to enable optimization for all inputs (at least one input should be selected to perform optimization). - The
**Current Value**column shows input values that are currently selected for the signals applied on the chart. - In the
**Start Value**column, enter the desired starting values for each of the inputs. - In the
**End Value**column, enter the desired ending values for each of the inputs. - In the
**Step**column, enter the desired step size, for each of the inputs. - The
**Step Count**column shows current amount of steps for an input. - Select the
**Algorithm-specific Properties**tab. - Select the best results criteria in the
**Criteria**list box. - Select
**Ascending**or**Descending**option to sort the output in ascending or descending order, respectively. - Set the Genetic Algorithm properties. For information on GA properties, see Understanding Genetic Algorithm Optimization
- Click
**OK**to run the optimization and generate the Optimization Report. - Optimization dialogue window shows Average fitness value for current population during optimization.

## Using Optimization Report

After the optimization process is complete, a Strategy Optimization Report is generated and displayed in the **Optimization Report** window. Only one Optimization Report window can be open at a time.

The report lists the results of all input combinations (subject to limitations options), arranged by the specified criteria in the specified order. Each row lists a set of performance results for each combination of inputs. The report can be sorted by values in any three of the criteria, in either ascending or descending order.

## Sorting the Optimization Report

To sort the report:

- Select the most significant sort criterion in the
**Sort by**list box at the top left of the report window, and then select**Ascending**or**Descending**to specify the sort order. - Select the second most significant sort criterion in the
**Then by**list box at the top center of the report window, and then select**Ascending**or**Descending**to specify the sort order. - Select the least significant sort criterion in the
**Then by**list box at the top right of the report window, and then select**Ascending**or**Descending**to specify the sort order.

## Applying an Inputs Combination to the Strategy

A combination of inputs listed in any row of the report can be applied directly to the portfolio strategy.

To apply an inputs combination:

- Double-click the row with the desired inputs combination.
- In the dialog box that appears, click
**Yes**to apply the input combination, or click**No**to cancel.

## 3D Optimization Charts

3D Optimization Chart is a visual representation of how the strategy's parameters affect its trading performance. The 3D graph reveals the most robust parameter zones, and is a great tool for avoiding over-optimization (curve-fitting). Robust parameter zones will appear to have gradual, rather then abrupt changes in the surface plot. Over-optimized zones will appear to have radical changes or spikes in the surface plot.

To view the 3D Optimization Chart, click the **View 3D Optimization Chart** button at the bottom left of the report window.

A 3D Chart will be displayed in the **3D Optimization Charts** window.

## Exporting Strategy Optimization Reports

Strategy Optimization Report can be exported to a standard .csv (comma-separated values) file. The .csv file can then be imported into a spreadsheet application for further analysis.

To export the Optimization Report:

- Click the
**Export**button at the bottom left of the of the report window. - In the
**Save Strategy Optimization Report As**dialog box that appears, navigate to the desired location, enter the file name, and click the**Save**button.