Advanced Analytics

Download 0.61 Mb.
Size0.61 Mb.
1   ...   12   13   14   15   16   17   18   19   20

Trade System Optimizer

Trade System Optimizer (TSO) is a module within CQG that gives you a tool for testing the results of trade systems with different parameters. All combinations of the parameters you have selected are evaluated, and the results of each combination are reported in the TSO window. By looking at the results, you can determine which set of user-defined parameters produces the best results (expressed as the best value for the selected Optimize On statistic) when you apply a specific trade system to a chart.

TSO cannot load without a trade system.

The TSO window contains two tabs (Table and Graph). The Table view consists of 4 sections:

The TSO Summary section includes the basic setup information, except the parameters.

The Parameter Settings section

The Table Settings section

The Results Section

The Graph tab changes the display to show a 3-D model of the parameters in a TSO run.

TSO only works for those trade systems that have user-defined parameters. TSO cannot load without a trade system.

You can start TSO using either the TSO button on the toolbar or from within a chart.

Click the TSO button on the toolbar. TSO initially displays the Symbol and Trade System information from the previous TSO run. If this is the first time TSO is started, the Main window will be empty.

To start TSO from a chart:

88.Display a chart with the symbol you want to use for optimizing, with the trade system you want to use applied to that chart.

89.Right-click the Trade System that has been placed on the chart.

90.Select Optimize from the menu.

The Optimizer main view is displayed. In addition, every time the Optimizer is opened from a chart, a new TSO setup component is created. The system automatically names the run "unknownX" as displayed in the Runs section of the TSO Setup window and takes the run information taken from the chart (Symbol, Trade System, Time Interval, Time Range, Base Expression) and trade system (user-defined parameters and their values) from which the Optimizer was started. These system-created runs are saved until you delete them.

91.TSO Toolbar

The TSO toolbar includes these buttons:

Specify button

Click this button to specify optimization settings for a TSO run.

Start button

Click this button to start the optimizer.

Stop button

Click this button to stop the optimizer.

Clear button

Click this button to clear the optimizer results.

92.How to use TSO

  1. Display a chart and apply a Trade System to it.


93.Open the Optimizer using the right-click menu.

94.Specify settings for the Optimizer to use and close the TSO Setup window.

Check the trade system parameters you would like to optimize, set different Start Value and End Value for getting a range. The optimized value of the parameter will be located in the range. To calculate the numbers of steps of testing, see Trade System parameters.


95.Click Start.

96.Analyze all the results to figure out the optimized value for the trade system parameter.

97.Specifying Optimization Settings for a TSO Run

Click the Specify button to open the TSO Setup window.


TSO Setup allows users to:

Select the Optimizer run to use.

Set Trade System parameter information.

Set the chart characteristics and data used in evaluating the trade system.

Select which statistic to optimize.

Select which algorithm the optimizer should use.

Selecting the Optimizer Run

The Runs section of the TSO Setup window displays a list of optimizer runs. The selected run is bolded in the display.

You can select an existing run; create a new run; copy an existing run on which to base the new one; or delete runs you no longer want to save.

Selecting an Existing Run

When an existing trade system cell is selected, two buttons are displayed in the Trade System column. The button on the left is the drop-down list arrow. The button on the right opens Formula Builder.

  1. Click the drop down list arrow and select the trade system from the list.

  2. The TSO Setup window updates with the existing run's information.

To change an existing trade system or create a new trade system

  1. Click in the new run's Trade System column.

  2. Click the button on the right side of the column. This displays Formula Builder.

  3. Scroll through the list of runs until you see the one you want in the window.

  4. Click anywhere in that run's row.

To create a new run

Click the New button. Enter a name for the new run and click OK.

The TSO Setup window clears the Trade System Parameters section, and retains the last run's other settings, which you can either use as-is, or change.

To copy a previous run

  1. Click the New button to open the Copy a Run window.

  2. Enter a name for the new run and click OK.

The TSO Setup window clears the Trade System Parameters section, and retains the last run's other settings, which you can either use as-is, or change.

To delete a run

  1. Click the Delete button.

  2. Click the Delete Component button to dispose of the current run and close the Confirm window.

Run Info Section

On the right side of the Runs section, under Run Info, you can type in information that is associated with the selected run. Additionally, this section lists the creator and time of the run. This field is displayed only on the TSO Setup window; it is not associated with the Note column in the TSO Results table. The Run Info area gives you a place to store information about the settings, parameters, values, or other characteristics that make this run unique.

Trade System Parameters

The Trade System Parameters section of the TSO Setup window displays all the user-defined parameters associated with the selected Trade System. The start values initially are those that were set in the Trade System. However, you can change those by clicking in the cell and entering a new value.

Select which parameters to use in the order you want the parameters run through optimizer. That way, both the Optimize Order column and the Use Column are completed.

To change the order, click in the Optimize Order column and select the correct order from the drop down list.

The Start Value and End Value determine the range of values you want to test for each parameter. Enter the first value you want the Optimizer to use for each parameter in Start Value. Enter the last value you want the Optimizer to use for each parameter in End Value.

The Step value determines how the Optimizer increments the parameter to change the parameter's value. If the start value and end value are both integers, a step of 1 means the Optimizer will test every value of the parameter between the Start Value and End value. A step of 5 means the Optimizer will test the Start Value, reset the parameter to Start Value +5, and then test again, until it reaches the End Value set for that parameter. That means only every fifth value of the parameter between its Start and End Value is tested.

The Optimizer changes only one parameter at a time, so all combinations of the specified parameter values are tested.

The Number of Steps indicates the number of test steps needed to test all combinations of the values for every parameter, based on your inputs in this section and the algorithm selected.

Example: The following values produce a number of steps value equal to 392 calculated as follows:

Start Value

End Value











Number of steps = (from 1 to 7inclusive) = 7

(from 1 to 8inclusive) = 8

(from 3 to 9inclusive) = 7

7 x 8 x 7 = 392 steps

Note: The parameters settings are displayed in the main TSO window. However, they can only be changed using the Formula Toolbox window.

Statistics Calculation can be per trade, or per contract or share.

98.Setting Chart Characteristics

If you want to change the data settings, use the drop down lists and Setup buttons to make your selections. These settings determine which kind of chart the TSO uses for its calculations and how a chart will be displayed if a chart display is requested for a specific result in the result table.

Choose chart type

Select the chart type you want to optimize. Choices are Bar, Percent Bar, No Gap, Fill Gap, Candlestick, Constant Volume Bar, Yield.

Click the Setup button to set the parameters for the selected chart type.

Choose interval and session

From the Chart Parameters section, you can select the bar interval and miscellaneous setup characteristics.

Select the chart interval to use in the chart. Options in the drop down list include: 1 min, 5 min, 10 min, 15, 30, 60, Daily, Weekly, Monthly, Quarterly, Semi-Annual and Annual. If you want an interval that is not in the list, enter that interval in the Interval box.

The All Sessions Setup button allows users to access the Misc and Bats tabs of the Chart Preferences window.

Set Bar Range


  1. To change the bar range, click the Edit button. The Define Bar Range window appears.

  2. Choose one of the three buttons in the From section, as described below.

  3. Select the top button in the From section for daily or longer bars.

  4. Click the drop down list button next to the date to display the Calendar and select the desired date.

  5. Input the desired time (for intraday bars) or select the second button for intraday bars.

  6. Input the desired number of bars to look back.

  7. Input the desired time (for intraday bars) or select the third button to start the bar range a specific number of days back.

  8. Input the number of days back to start the range.

  9. Click either the Current button in the To section or the button immediately below that to select a date and time to end the evaluation.

  10. Enter a date and time, if necessary (if the Current button has not been selected).

  11. Click the OK button to apply the selections and close the Define Bar Range window.

Setting Thresholds


Thresholds act as filters to limit the calculations that are reported in the results table. Only calculations whose calculation values meet all of the threshold settings appear in the results table. While TSO is stepping through the parameter values, the current step results are displayed, but unless a step meets the threshold criteria, no other rows are added to the results table.

  1. Click the Thresholds Setup button

  2. Click the parameter column to select the parameter to set the threshold value(s) on.

  3. Click the From column.

  4. Click the down arrow to display the list of threshold operators.

  5. Select from, less than, or greater than and enter a value. If you select from, you must also enter a to value.

  6. Click the Close button to enact the selections and dismiss the Thresholds window.

All thresholds are summarized in the TSO Setup window in the Threshold field. If you can't see all the threshold summary information, expand it by clicking the square button in the field.

Selecting Statistic to Optimize On and the Optimization Order

The Statistic to optimize on is the statistic by which you want to measure the success of your Trade System. The default statistic to optimize on is Total Net Profit.

  1. Click the Optimize On drop down arrow and select the statistic on which you want TSO to optimize.

  2. Select whether you want the results to display sorted in increasing or decreasing order for this statistic.

The statistic that is optimized on is always the first statistics column (after the parameter listing) displayed in the summary result table. It is always visible.

Selecting TSO Algorithm

CQG offers 2 TSO Algorithms, exhaustive and genetic.

The Exhaustive algorithm evaluates the effectiveness of the trade system for each possible combination of all the parameters, as defined in the TSO Setup window. The best found parameter combination corresponds to the absolute maximum of effectiveness and cannot be further improved. The great disadvantage of the exhaustive algorithm is that it may take a long time.

The Genetic algorithm evaluates a subset of every possible combination of all the parameters defined in the TSO Setup window. The genetic algorithm takes its basic idea from biology and searches the most effective parameter combination according to biological laws. It does not guarantee the result, as does the exhaustive algorithm, but it probably finds the most effective combination, or one close to it, and it takes less time to run.


First, a number of living creatures (population size) are placed randomly in the knots of a parametric grid. Then these creatures live and reproduce themselves (crossing the genes and undergoing sometimes rare mutations) as would really take place in biology. The creature strength is defined by the effectiveness of the trade system with appropriate parameter combinations. After evaluating the effectiveness for all the creatures, the strongest creatures, selected from both “parents” and “descendants”, form the succeeding generation, which becomes the new “parents." It is the demonstration of the biological law: the weaker perishes, the stronger survives. Thus, generation-by-generation the strongest creatures are assumed to approach the absolute maximum.

If the process comes to a dead end (remember, we are not sure that we have found the absolute maximum), the part of the current generation, defined by the Discarding level is cancelled and replaced with the randomly selected creatures. This corresponds to influx of fresh blood in biology.

The Elite chromosome's set defines the capacity of the best chromosome buffer. That buffer keeps the best chromosome (creatures), which can never perish. Eugenics deals with this kind of selection in biology.

The number of steps means the total number of knots, where the effectiveness of the trade system should be evaluated. This number should be much less than the total number of knots, used in the Exhaustive algorithm, otherwise it makes no sense to apply the Genetic algorithm. Note that the number of generations is approximately equal to the number of steps divided by the population size.

  1. Click the Algorithm drop down arrow and select Genetic.

  2. Click the Setup button to display the Genetic Parameters window.

  3. Set the genetics parameters and click the Close button on the Genetic Parameters window.
Genetics Parameters

Genetics Parameter


Number of steps

The total number of times the effectiveness of the trade system should be evaluated. The algorithm increases its effectiveness when the number is increased, but the calculations will take longer.

Population size

The number of living creatures in population. These creatures are included in crossover and mutation processes. When each creature appears (after crossover and mutation processes) for the first time, its effectiveness must be estimated. This increases the number of executed calculations by 1. The Chromosome Number should be a few dozen, or may be a hundred or slightly more. It should be less than the total steps used in the Exhaustive algorithm.

Elite Chromosome's set

The capacity of the chromosome buffer, which keeps the best combinations of parameters that never perish. This buffer can be updated in each generation. This number must be less than the Chromosome Number in Population. Recommended values are 1/4 or 1/6 of the Chromosome Number in Population.

Discarding Level

Defines the number of generations, during which at least one new chromosome must appear among the Best Chromosomes. If this has not happened, the buffer is emptied and filled afresh from by the chromosomes from the Best Chromosome buffer and completed by the randomly selected ones. This parameter should not be very large, and probably should be in the range of 5 to 20.

Probability of mutation

Random change of the internal chromosome structure (bit representation) and its value. Like in biology, this should be a rare event. This value is expressed as a probability, and typical values are 0.01, 0.03 or 0.05. Although you can set the mutation probability greater than 0.1, it is not recommended for best results.

For additional information on the genetic algorithm, see Genetic Algorithms + Data Structures = Evolution Programs by Zbigniew Michalewicz

99.Setting the Results Table Characteristics


After all the settings and selections are made in the TSO Setup window and that window is closed, you are once again looking at the TSO Main view. Nothing is displayed in the table area until the optimizer is run.

The upper section of the window displays summary information about the settings and selections upon which the current run is based. This section can be contracted so the parameter settings and some TSO summary fields are not displayed, leaving more room to display result rows.

Expanding or Contracting the Summary Section

  1. Click the Up arrow button to contract the window. The Up arrow will turn into a down arrow.

  2. Click the Down arrow button to expand the sections so the summary fields and parameters show. The Down arrow will turn into an up arrow.

After the optimizer is run, the lower section of the window displays the detailed information about each step (parameter value) that makes up the run.

The results table will show information about the parameter values used and the summary results for the trade system.

If the Table settings are not displayed when you first open the window, click the plus sign next to Settings above the heading row of the table. The Settings information expands and is displayed to the left of the table. To collapse the settings so you can see more columns of data in the table, click the minus sign next to Settings.

Table settings determine the order in which results will be displayed, the number of results, and how and when the associated chart is displayed.

Displaying the Settings

Selecting the box next the word Settings displays the parameters whose results are shown in the table.

The results in the table can be sorted by any of the parameters or statistics that are shown in the table. The default Sort By value is the Optimize On parameter.

To select the column to sort by:

  1. Click the Sort By arrow and select the parameter or statistic to sort by.

  2. Select Descending or Ascending or click the column heading to sort by that column.

  3. Click again on the column heading to change the sort order.

The column heading for the current Sort By column is displayed in a different color, and the stack of lines next to the column name indicates whether it is descending (the lines get smaller from top to bottom) or ascending (the lines get larger from top to bottom).

Setting Max Best Results

This setting limits the number of rows to include in the results table. If this number is set to a number lower than the total number of steps, only the best results will be displayed. This value must be an integer in the range of 1-2000. The default setting is 100.

Display Chart With

These settings determine whether the chart display will be updated, and if it will, what values will be used for the update. Choices include:



Current Value

After x steps have been completed, displays the chart with the value for that row.

Best Value

After x steps, updates the chart with the best value (if it changed).

Best for Refresh

Displays the best value within x steps, and is updated after x steps.

No Update

The chart associated with this TSO run is not updated while TSO is running.

Setting After Steps

The after steps setting determines how often the chart is displayed or updated with the results table data. If No Update was selected in the Display Chart with box, you won't be able to set the after steps. This value must be an integer in the range of 1 to 100. The default setting is 5.

Customizing Columns in the Table

Users can customize the columns in the TSO window.

  1. Right-click the tab title.

100.Select Customize Columns.

By default, all parameters and statistics used in the Trade System are displayed as columns in the results table. However, you can select the parameters you want to see, and what order they'll be displayed in.

Even if you customize the columns, you can still display all the parameters or statistics quickly by clicking on the square buttons to the left of "Parameters" or "Statistics."

The square buttons next to Parameters and Statistics in the line above the column headings reflect whether the columns have been customized.

Button Label


Minus sign (-)

All Parameters or Statistics are displayed, but custom columns have been selected. Click to display custom columns only.

Plus sign (+)

Custom columns are displayed. To display all columns, click the button.

To select columns to include in the results table

  1. Click the Setup button or right-click Parameters or Statistics in the line above the column headings.

  2. Select Customize Columns.

  3. Select the Parameters tab or the Statistics tab. Both tabs work the same way, but these instructions will refer to Parameters, since that is the first tab and is the one shown above.

  4. Click the >> and << buttons to move parameters between the Shown and Not Shown columns. The default setting is to display all parameters and statistics.

  5. Select a parameter and click the Move Up or Move Down buttons to change the order in which the parameters are shown.

  6. When the Parameters and Statistics are arranged, click OK.

When the Parameters and Statistics buttons are pluses, the customize column settings are applied to the results table, and only those selections appear. If the buttons are minuses, that means that all parameters or statistics are shown.

To adjust a column's width

  1. Click the right side border of the column you want to adjust

  2. Drag the border to the right to expand or to the left to shrink the column width.

101.Starting the Optimizer

After you have set everything up in the TSO Setup window and the Table Settings area of the Optimizer window, it's time to optimize your Trade System.

Click Start.

The first row in the table is the current step result, regardless of the table sorting settings. After the optimization is completed, the current line is no longer displayed.

As each step runs, the Optimizer's progress is reported in the top section of the window and rows are added to the table. Every other row is colored, to make the results easier to read. The default colors display negative numbers in red.

You can look at the results of a run in a chart format by double-clicking on a cell in the row you want to see on the chart. The Trade System graph at the bottom of the chart will reflect the values in the results table.

102.Creating a New Trade System

If the results of a run indicate that one step's parameter settings are providing the results you want, you might want to create a new trade system that uses those parameters. TSO provides a quick and easy way to create a new trade system with a new name, but with the parameters of the selected row.

  1. Right-click a row.

  2. Select Create Tsys Copy with Parameters.

  3. Enter the new trade system name, and click OK.

The trade system is created and the new trade system name appears in the Notes column for that row.

103.Launching a Chart with Parameters

After the optimizer has filled in the results table, you might want to view the results as they would appear in a chart. There are two ways to launch a chart with selected parameters.

Right-click a row, and select Launch Chart with Parameters or double click a row.

The chart is displayed, and the Trade System reflects the settings of the selected results table row.

A new TSO, with the current chart information is created whenever a TSO is displayed from a chart.

104.Displaying the TSO Graph in 3D

The CQG 3D TSO graph gives users a clear picture of the interaction of three variables that were used in the TSO run.

  1. Run the TSO.

  2. Click the Graph tab.

  3. Set up the XY-Axis with the parameter you put a range on, and set up the Z-Axis with the profit parameter you would like to maximize or minimize.


From the 3D Control Properties window you can set the display and motion characteristics related to the 3D TSO graph display. The values plotted in each axis are displayed in the Plot area. If the trade system uses other parameters, they are displayed in the Other Params area, where you can adjust their values and immediately view the changes to the graph.

To access the 3D Control Properties window:

  1. Right-click in a 3D TSO window.

  2. Select Properties.

105.Adjusting the Values in the 3-D Graph

The Settings button turns on or off the display of the Plot and Other Params areas. With these settings hidden, the graph expands. When they are displayed, you can make changes that are immediately reflected in the graph.

The Plot Area allows you to select values for the X-Axis, Y-Axis, and Z-Axis of the 3-D display.

  1. Click the any of the drop down list buttons to select the desired trade systems to be displayed on the X and Y axes and the desired TSO statistic to be displayed on the Z axis.

  2. Click the Graph tab.

  3. Click any Axis list to display the available values.

  4. Click to select a value.

The graph updates immediately to display the selected value on the selected axis.

Note: Your axes settings won't change when you specify different TSO runs. However, they do revert back to the default settings when you close TSO and reopen it.

The Other Parameters area allows you to adjust the values of other parameters that are not used as an axis, but are part of the Trade system upon which the current TSO run is based.

To change the value of one of these Other Params

Click the parameter's value and select a value from the list. The 3-D graph adjusts to reflect the new parameter value.

To pause the optimizer

You can pause the TSO before it completes its run, then complete the run, or clear the values and start another run. To start another run, either using the current Optimizer settings, or new ones, the current results must first be cleared.

To pause the run:

Click the Stop button on the Application toolbar. The Stop button becomes unavailable; the progress bar shows where the run was paused; and the results table is only partially filled.

To continue the run:

Click Start. The run continues from the point at which it was paused.

To clear the results table

Once TSO has written results to the results table, a new TSO run cannot be started until the results table is cleared.

Click Clear. The results table is cleared, the step progress report is reset to 0, and the start button is available.

To copy the grid to the clipboard

TSO allows you to copy the table results data to the clipboard so you can paste it into another application, such as Microsoft Excel.

  1. Click the Setup button.

  2. Select Copy All Grid to Clipboard.

  3. The grid data is copied to the clipboard.

To save results to a text file

The table results can be saved to a text file.

  1. Click the Setup button.

  2. Select Save Results to TXT File. The Save As window is displayed.

  3. Enter the file name and location to which you want the text version of the results table saved. A text version of the results table and setup information is saved to the file.

Download 0.61 Mb.

Share with your friends:
1   ...   12   13   14   15   16   17   18   19   20

The database is protected by copyright © 2023
send message

    Main page