Welcome to How to Use the Optimizer

 

The optimizer helps find the best inputs to use on a single study for a specific symbol and timespan.  Finding good inputs is more of an art than an easy run of the optimizer.  Most of the time you have to choose between good total return, or good percent positive trades, or high significance, for a good gain to loss ratio.  There is rarely one outstanding combination of inputs that produces the perfect study.

 

Optimizer

 

You can load the optimizer form the main menu "Main Menu" ==> "Components" ==> "Optimizer"

 

Or from "Menu Circle" ==> "New" ==> "Optimizer" or from a study title right click menu. This will bring up the optimizer window.

 

 

This window has 6 areas described below

 

Studies To Optimize

 

This panel lists which studies you want to optimize. 

 

 

All the studies that have buy and sell signals will be listed in the list.  Just click on a study title to toggle the check mark off and on.  Only the studies with check marks will be optimized.  Something to remember is the speed of the optimization is dependent on the number of inputs.  The optimizer will only run a maximum of 4 inputs which will run slowly.

 

You can clear or check all the studies at once using the right click menu.

 

Timespans to Optimize

 

This panel lists which timespans you want to optimize the studies on.

 

 

Click on the timespan to toggle the choice on and off. You can clear or check all the timespans at once using the right click menu

 

Filter, Results, and Setup

 

This panel contains filters to limit the results of the optimization.  These filters can frequently result in no results being returned.  If you want to see the raw results set "Turn Off Filters" to true.

 

 

Symbol - The symbol to optimizer against.

 

Filters

 

Good Trades Above - This will only allow results with the percent of positive trades greater than the value listed.  The default is to ignore all input combinations where the number of profitable trades is below 24%.

 

Maximum Trades - This will limit results to a maximum number of trades.  This is to prevent a set of inputs that flips the signal every bar.  If you set this to 50 all results that produce more than 50 total trades over the history of the stock data will be ignored.  The default is -1 which means do not limit the maximum number of trades.

 

Minimum Trades - This will limit results to a minimum number of trades.  This is to prevent a set of inputs that produce only one or two trades with no significance.  If you set this to 10 all results that produce less than 10 total trades over the history of the stock data will be ignored.  The default is 20 which means a trade must have at least 20 trades.

 

Significance Above - This will only allow results with a student's t test significance above the listed value.  The default value is 0.8 which means there must be at least an 80% chance of the results being significant (.9 does not mean 90%).  At 50% significance the results are random or the buy and sell are equal to the flipping of a coin.  The higher the significance the more likely the results are not the result of chance.

 

Total Return Above - This will only allow results with a total return above this value.  The default is  zero meaning no results that produce a net total loss will be listed.

 

Trades to Exclude - Many time results can be distorted by a single large trade.  You can ignore the highest and lowest result value  by entering a 1.  If you enter 2 then the top two and bottom 2 trades will be excluded.  The default Is 0 means do not exclude any trades.

 

Turn Off Filters - When true no filters will be used to exclude any results.

 

Results

 

Display Results - This determines how the study results appear on a chart when a result is selected. 

 

  • Color bars - Show the buy and sells of a result as color bars.
  • Buy Sell Arrows - Show the result as buy and sell arrows on the chart
  • None - Do not show the buys and sells of the study in the result.

 

Sort On - This determine the field in the results to sort on

 

  • Total Return - sort by total return or the net return when all trade gains and losses are totaled.
  • Percent Positive Trades - sort by what percent of the trades were profitable.
  • Median Gain - Sort by the gain or loss of the trade in the middle of the trade results.
  • Significance - Sort by how significant the result is when compared to random fluctuations as determined by a student's t test. This is the default.
  • Gain Loss Return- Sort by the ratio of the average gain dived by the average loss.

 

Trades - Determine which type of trades to optimized on.

 

  • Long and Short  - Calculate gain and loss going both long and short when encountering a studies buy and sell signals.
  • Long Only - Only calculate trade results using trades that start with a buy and end with a sell.
  • Short Only - Only calculate trade results using trades that start with a sell and end with a buy.

 

Setup

 

Buy Sell Trigger - This determine when to close a trade.  This is important because some study have a buy, a sell, and a neutral signal.

 

  • Signal Cross - The trade will end when the next buy or sell is encountered.  For example, if you start a trade with a buy, the trade will not close until a sell is encountered, a neutral will be ignored.
  • Signal Positive - The trade will end when the current signal ends.  For example, if the current trade started with a buy, the trade will end when the buy disappears and it doesn’t matter whether it changed to sell or neutral.

 

Commission per Trade - This commission will be subtracted from the result of each trade.  This can help turn micro positive results negative and reduce the importance of the micro gain trades.

 

Number of Bars - This is number of bars of historical data to be requested from the data supplier.  The amount of data returned will be the lesser of this value and the maximum amount of data the data vendor will provide.

 

Shares Per Trade - This is how many shares will be bought or sold in each trade to calculate return.

 

Stop Loss Per Trade - If this value is non zero, a trade will automatically be closed if this percent loss from the entry on the trade is hit in the opposite direction.

 

Running an Optimization

 

There are three buttons in the lower right corner of the window.

 

Optimize - This will start a full optimization.  Each study will be calculated for each timespan using either a Phiseries or a Fibonacci series of numbers in each input.  The status will be shown in the status bar at the bottom of the window.  Also once started a new button will appear "Stop Optimizer".  This will stop the current optimization.

 

Back Test  - This will run the optimize for the default study input and will not replace the input values with a series of numbers.

 

Exit - Exit the Program.

 

Optimization Results

 

After you click the optimize button,  the tab at the top will change and you will get a results page listing all the results that passed the filters.  Click on the various column headers to sort by that column.  In that way you can see which inputs produce the best results for each category.

 

 

When you want a visual display of the result click on the row and it will popup a chart showing the buy and sell points.

 

 

The result columns are as follows:

 

Study - The name of the study being optimized.

 

Timespan -The timespan of the chart being optimized.

 

Input1 - 4 - The inputs of the study and the values that were used for the result.

 

Total - The Total return for the result. This is the total of all the buys and sell in the result.

 

Return - The total return normalized to a 22 day period for comparison between different timespans or charts.

 

Significance - The statistical significance of the result.  The higher the better.

 

Trades - The number of completed trades in the result

 

Pct Good - The percent of trades that were profitable.

 

Average -The average gain for all trades in the result.

 

Median - The gain of the middle trade when all the trades are sorted by gain.

 

Avg Gain - The average of the just the trades that were profitable.

 

Avg Loss - The average of the just the trades that had losses.

 

GL Ratio - The ratio of Average Gain to Average loss.

 

To modify the optimize, click the Optimize Tab to go back

 

 

Dependencies

 

To see any dependencies in each trade, click the results row, then click the dependencies tab  or right click on the result line and select see dependencies..

 

 

This is what you should see on the dependencies tab

 

 

This page shows any dependencies where a trade or series of trades might have an influence on the next trade.

 

Trades

 

To see each trade in a result  click the result row, then click the Trades Tab or right click on the result row and select see trades.

 

 

The trades tab will show you all the trades in the result

 

 

The bottom part of the window will show summary information. If you click on the entry or exit date of a trade The info window cursor will be placed on the associated chart to show where the entry or exit point is on the chart.

 

 

This window has the following columns

 

Trade - List whether the trade was a buy or sell

 

Shares - The number of shares traded.

 

Ticker - The symbol of the chart

 

Entry Date Time - The date and time of the entry trade.

 

Entry price - The price of the trade entry.

 

Exit Date Time - The date and time of the exit trade.

 

Exit Price - The price the trade closed.

 

Gross - The net profit or loss on the trade

 

Commission - the commission to subtract from the trade.

 

Net - The profit or loss on the trade after commission.

 

Net% - The percent net gain or loss after commission.

 

You can either return to the optimizer tab and run a new optimize or click on the results tab and select another result to see all the trades on it.

 

Saving and Opening an Optimizer Result

 

Save - If you wish to save the optimizer setup and result, right click in the optimizer and select "File" ==>"Save". Or click "Save" in the window top toolbar.  A dialog will popup, just entry in a name and click save.

 

Open - If you wish to open a saved optimizer, right click in the window and select "File" ==> "Open" or select "Open" from the window top toolbar.  A dialog will popup, just click on the name you want to open and click open. You can also use the pull down in the window top toolbar to open a saved optimizer file.

 

Export To Excel

 

If you want to export a table to excel right click in the table and select "Export Table to Excel".  A xls file will be saved with the contents of the table.  If you have excel on your computer it should then launch and load the file.