×

Sign up and get MultiCharts free

Use its powerful simulation mode with data included out of the box. Just fill out the form and start honing your trading skills with a few clicks.

Changes - MultiCharts

Changes

Jump to navigation Jump to search

Performing Optimization

9,693 bytes added, 10:15, 23 February 2022
Once [[Understanding_Strategies|a strategy has been [[<span style="color: red;">'''LINK'''</span>0280_Backtesting/22-8002_Signals.html name="1"; |applied]] to a chart, strategy optimization can be performed.
<br>
To perform Exhaustive Search optimization:
# :1. Open the '''Format Objects''' window.<br><span>{{FormatObjectIS}}</span># :2. Select the '''Signals''' tab.# :3. Click the '''Optimize''' button.# :4. In the '''Select Choose the Optimization MethodType''' dialog box that appears, select '''Exhaustive SearchRegular Optimization''' and click '''Next'''.# :5. In the '''Exhaustive Search PropertiesSet Optimizable Inputs''' window that opens, select section 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 '''Optimizable InputsSignal Name''' column heading to enable optimization for all inputs (at least one input should be selected to perform optimization). :6. The '''Current Value''' tabcolumn shows input values that are currently selected for the signals applied on the chart.# :7. In the '''Start Value''' column, enter the desired starting values for each of the inputs.# :8. In the '''End Value''' column, enter the desired ending values for each of the inputs.# :9. In the '''Step''' column, enter the desired step size, for each of the inputs.# :10. The '''Step Count''' column shows current number of steps for an input. :11. Select '''Exhaustive''' radio button in the '''Set Optimization Method''' section.:12. Select the target function to be optimized in '''Optimize by''' section:In the '''Maximal/Minimal''' list, set the respective values to be selected at the end of optimization.From the next list one can select the function itself.<br>If '''Custom Criteria''' is selected, Edit button is available. Press it to write the script for the custom criteria. [[Performing_Optimization#Custom Criteria|Read more about Standard and Custom Criteria]].<br>In order to apply the desired function from code select ''' tabCustom Fitness Value'''. The custom value shall be specified by [[SetCustomFitnessValue]] keyword in the script.# :13. 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.:14. When '''Use Limitation''' checkbox is checked Optimization dialog window shows current best results for selected сriteria during optimization.:15. Click '''Optimize''' N '''combinations''' to run the optimization and generate the Optimization Report.<br><div style="background-color: #E3FBE5;">Since '''MultiCharts 10''' that is possible to start optimization from '''Chart Analysis''' toolbar (see [[MultiCharts_Work_Area# Enter Hiding_and_Redisplaying_Toolbars]]) by clicking on the desired number of best results in '''Optimize Strategy''' button: [[File:toolbar2_ChartAn_125.png]]</div> <br> == Running Genetic Algorithm Search ==  <div style="background-color: #E3FBE5;">Note: For detailed information on Genetic Algorithm properties, see [[Understanding Optimization#Understanding Genetic Algorithm Optimization|Understanding Genetic Algorithm Optimization]]</div> Optimization is performed from the '''Format Objects''' window: To perform Genetic Algorithm optimization: :1. Open the '''Show Format Objects''' window.<ibr>N<span>{{FormatObjectIS}}</ispan> best results:2. Select the '''Signals''' tab.:3. Click the '''Optimize''' button.:4. In the '''Choose the Optimization Type''' dialog box that appears, select '''Regular Optimization''' and click '''Next'''.:5. In the '''Set Optimizable Inputs''' section 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 boxto the left of the '''Signal Name''' column heading to enable optimization for all inputs (at least one input should be selected to perform optimization).# Select :6. The '''Current Value''' column shows input values that are currently selected for the signals applied on the chart.:7. In the '''Start Value''' column, enter the desired starting values for each of the best results criteria in inputs.:8. In the '''best results End Value''' column, enter the desired ending values foreach of the inputs.:9. In the '''Step''' list boxcolumn, enter the desired step size, for each of the inputs.# Select criteria:10. The '''Step Count''' column shows current number of steps for an input. #: 111. Select '''Standard CriteriaGenetic''' radio button in the '''Set Optimization Method'''section.#: 212. Select Selecting the target function to be optimized in the '''Optimize by:''' section:In the '''Maximal/Minimal''' list, set the respective individuals, which will take part in further selection and crossover, for the criteria from selected parameter.From the drop-down next list one can select the function itself.<br>If '''Custom Criteria''' is selected, Edit button is available. Press it to write the script for the custom criteria. [[Performing_Optimization#Standard Custom Criteria|More Read more about Standard and Custom Criteria]].<br>In order to apply the desired function from code select '''Custom Fitness Value'''. The custom value shall be specified by [[SetCustomFitnessValue]] keyword in the script. :13. Set Basic Genetic Algorithm Parameters.:14. An optimum population size value is automatically placed next to the '''Set Population Size''' box; if a different value is desired, check '''Set Population Size''' box and select the value.:15. In the '''Crossover Probability''' field, select the desired crossover probability; value range is 0-1, with a default of 0.95.:16. In the '''Mutation Probability''' field, select the desired mutation probability; value range is 0-1, with a default of 0.05. :17. In the '''Convergence Type''' section, select '''Number of Generations''' or'''Proximal Convergence'''.:18. If '''Number of Generations''' is selected:In the '''Number of Individuals in Population for Crossover''' field, enter the desired number of individuals in population for crossover.<br>In the '''Maximum Number of Generations''' field, enter the desired maximum number of generations.<br><div style="background-color: #E3FBE5;">Note: the above fields are grayed out if “Set Population Size” box is not checked in Basic Genetic Algorithm Parameters.</div>:19. If '''Proximal Convergence''' is selected: 1In the '''Number of Individuals in Population for Crossover''' field, enter the desired number of individuals in population for crossover.<br>In the '''Maximum Number of Generations''' field, enter the desired maximum number of generations. Select <br>In the '''Custom CriteriaMinimal Number of Generations'''field, enter the desired minimal number of generations.<br><div style="background-color: #E3FBE5;">Note: the above fields are grayed out if “Set Population Size” box is not checked in Basic Genetic Algorithm Parameters.</div>:20. If '''Proximal Convergence''' was selected, enter the desired convergence rate into the respective field. A value, approaching 1 is usually selected for the convergence rate; the default value is 0.99.: 221. Click In the '''Genetic Algorithm Subtype''' section, select '''Basic''' or '''Incremental'''Editalgorithm subtype. :22.If Basic algorithm subtype was selected, select '''Yes''' or '''No''' for '''Use Elitism''' option.:23.If Incremental algorithm subtype was selected, select the '''Replacement Scheme''' buttonbetween Worst, Parent and Random.#: 324. Write Click '''Optimize''' N '''combinations''' to run the script optimization and generate the Optimization Report.:25. Optimization dialogue window shows Average fitness value for current population during optimization. <br><div style="background-color: #E3FBE5;">Since '''MultiCharts 10''' that is possible to start optimization from '''Chart Analysis''' toolbar (see [[MultiCharts_Work_Area#Hiding_and_Redisplaying_Toolbars]]) by clicking on the custom criteria '''Optimize Strategy''' button: [[Performing_Optimization#File:toolbar2_ChartAn_125.png]]</div> <br>== Custom Criteria ==There are two types of criteria: standard and custom.<br>Standard Criteria lets the user select a criterion from a pre-defined list. For example, if the user selects Net Profit, the optimization will find the parameters that generate the highest Net Profit.<br>Custom Criteria|More about lets the user create his own criteria. Instead of choosing from a pre-defined list like in Standard Criteria, the user can script his own criteria. E.g., suppose the user wants to find the parameters that maximize the Net Profit / Max Drawdown ratio. This ratio isn't pre-defined under Standard Criteria]], so it won't be in the drop-down list. However, this ratio can be created using Custom Criteria. It is also possible to add additional criteria such as number of trades and winning percentage.#E.g., it is possible to specify: 4. Click '''OK''the result have more than 300 trades and a winning percentage that's greater than 50%'''''. <br><span style="background-color: # Select E3FBE5;">The scripting language is '''AscendingJavaScript''' or .</span> <br>'''DescendingCode Example''' option  The code below creates the Net Profit / Max Drawdown ratio: <code>&nbsp; &nbsp; &nbsp;&nbsp;<br>if (StrategyPerformance.MaxStrategyDrawDown != 0)&nbsp; &nbsp; &nbsp;&nbsp;<br>{&nbsp; &nbsp; &nbsp;&nbsp;<br>return StrategyPerformance.NetProfit / (-&nbsp; &nbsp; &nbsp;&nbsp;<br>StrategyPerformance.MaxStrategyDrawDown);&nbsp; &nbsp; &nbsp;&nbsp;<br>}</code> <br>Besides NetProfit and MaxStrategyDrawdown, there are many other properties that can be referenced. The table below shows the available properties. <br>For example, to sort reference the output number of trades, simply use StrategyPerformance.TotalTrades. To reference winning percentage, simply use StrategyPerformance.PercentProfitable. {| class="wikitable" width="65%"!width="33%"|Name of property in the object StrategyPerformance!width="25%"|Description!width="20%"|Available in MultiCharts!width="22%"|Available in Portfolio Optimization|-|NetProfit|Net Profit|align="center"|Yes|align="center"|Yes|-|GrossProfit|Gross Profit|align="center"|Yes|align="center"|Yes|-|GrossLoss|Gross Loss|align="center"|Yes|align="center"|Yes|-|TotalTrades|Total Trades|align="center"|Yes|align="center"|Yes|-|PercentProfitable|% Profitable|align="center"|Yes|align="center"|Yes|-|WinningTrades|Winning Trades|align="center"|Yes|align="center"|Yes|-|LosingTrades|Losing Trades|align="center"|Yes|align="center"|Yes|-|AvgTrade|Avg Trade|align="center"|Yes|align="center"|No|-|AvgWinningTrade|Avg Winning Trade|align="center"|Yes|align="center"|No|-|AvgLosingTrade|Avg Losing Trade|align="center"|Yes|align="center"|No|-|WinLossRatio|Win/Loss Ratio|align="center"|Yes|align="center"|No|-|MaxConsecWinners|Max Consecutive Winners|align="center"|Yes|align="center"|No|-|MaxConsecLosers|Max Consecutive Losers|align="center"|Yes|align="center"|No|-|AvgBarsInWinningTrades|Avg Bars in Winner|align="center"|Yes|align="center"|No|-|AvgBarsInLosingTrades|Avg Bars in ascending or descending order, respectivelyLoser|align="center"|Yes|align="center"|No|-|MaxStrategyDrawDown|Max Intraday Drawdown|align="center"|Yes|align="center"|Yes|-|ProfitFactor|Profit Factor|align="center"|Yes|align="center"|No|-|ReturnOnAccount|Return on Account|align="center"|Yes|align="center"|No|-|CustomFithessValue|Last [[SetCustomFitnessValue|SetCustomFitnessValue()]] calculation result.Will return 0 if [[SetCustomFitnessValue|SetCustomFitnessValue()]] was not calculated.# Click |align="center"|Yes|align="center"|Yes|}<br> == Pausing optimization ==  Since '''OKMultiCharts 10''' that is possible to run pause the optimization process in order to temporary decrease the load on the CPU. To pause optimization and generate click '''Pause''' in the '''Optimization ReportProgress''' window. To resume optimization click '''Resume'''<br>
[[Category:Optimization]]

Navigation menu