Optimizing a Trading Strategy
This post describes how optimization works.
Select an available strategy from the list on this page. Make sure that the strategy has been trained and that back testing produces acceptable results. Click on the optimize icon in the toolbar (funnel icon).
After a few moments, the optimization page should appear and look something like the screen below. You can change the applicable date range, if necessary, by clicking the calendar icon in the top toolbar and setting the required dates.
The screen has three main sections. The main chart is a bubble chart, where each bubble represents an individual test. Use your mouse wheel or equivalent to zoom in or out of the chart. Hovering the mouse over a bubble will display the metrics for that particular test. Clicking on a bubble, or one of the rows in the main table, will load up that test instance and display the results. The right summary panel is collapsed on smaller screens. To toggle the panel on a narrow screen, click the double arrow icon on the toolbar.
The data table lists all of the tests together with their performance metrics. Use the mouse wheel or sidebar scroll to view the entire table. Clicking on any row will load that test instance and compare it to the current strategy configuration. A green up arrow appears next to a metric when it is better than the current state. A red down arrow signifies that metric is worse than the current state.
The summary panel on the right of the screen shows a chart of the selected run at the top. This compares the optimized run performance to the current performance over the test period. The first run case in the table is initially shown. This test case has the best performance in terms of the parameters being optimized. To change to a different run case, just click on a table row or on one of the chart bubbles.
The performance tab compares the performance of the selected test case, with the current settings. Rows that are displayed in green are better than the current state, while those that are red are worse. Those in black are unchanged or are not measured.
The parameters table shows the differences in parameter settings between the two test cases. Rows in red are where there are changes, rows in black are unchanged.
To change the settings, click the cogs icon in the top toolbar. This will show the panel as in the screen above.
- Optimize for: Choose which parameter to optimize for
- Optimization method: Method of optimization
- Jump size: Jump size in optimizer algorithm
- Step size: Step size in optimizer algorithm
- Profit bins: Number of buckets for analyzing performance
- Run type: Random or deterministic run
- Search type: Fast or deep search
The first setting, Optimize for, lets you control which parameter will guide the optimizer and how it ranks results. There are two methods of optimization; gradient ascent and stochastic. Gradient ascent will try to incrementally improve on each run using a gradient optimization algorithm. A stochastic optimization will search randomly without any guidance. A stochastic run is better to give an idea of the distribution of possible returns. Gradient on the other hand is biased towards better run cases.
The jump size and step size control how the algorithm scans the search space.
Run type controls the internal randomization. With a deterministic run, the optimizer will return the same or similar results each time. With randomized sampling, the optimizer will vary conditions to give a different result set each time.
The search type gives you the choice between a fast but less accurate optimization or a slower but more thorough optimization.
The second tab in the main panel lets you choose which strategy parameters you want to optimize. To optimize on any parameter, set the switch on. If the range is left at zero, the optimizer will scan the entire range of possible values for that parameter. Alternatively, you can set a range by typing in a lower and upper bound. The optimizer will then stick within that range for that parameter.
The output panel lets you control how the main chart is drawn. The first two settings are the bubble x-axis and bubble y-axis. You can set these to any of the available parameters. This lets you plot metrics against one another and visualize the results.
The next two settings control the bubble color mapping and the bubble size. For example, if you set the bubble color map to drawdown (default), the chart will show run cases with low drawdown as green and those with high drawdown as red. The color range can be set from the two lower boxes.
You can zoom in or out of the main chart using the mouse wheel or your device’s equivalent. To preview any run case, simply double click the bubble on the chart.
Once you’ve reviewed the optimizer results you can copy any of the run case settings to your strategy. To do this, click the Use Selected button. The strategy will be updated with the new parameters and the back test result should be comparable with that shown in the optimizer.