> For the complete documentation index, see [llms.txt](https://docs.optionomega.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.optionomega.com/backtesting/optimizer.md).

# Optimizer

## Overview

The Optimizer is a powerful addition to backtesting that allows you to iterate over one or more parameters as you refine the strategy and optimize performance.

For example, you may want to test various stop loss levels for a premium selling strategy and find which level performed best against historical data. Rather than having to choose a starting stop loss level, run a single test, log the result, adjust the level, re-run the test, and repeat for each stop loss, the Optimizer allows you to define your starting and ending values and step size then run tests against each stop loss level to compare and analyze results.

You can even optimize against multiple dimensions at once, testing different put side and call side stop levels, combining entry times with other entry conditions, or analyzing different combinations of short strike delta values and wing widths together.

Depending on your account tier, you can test up to 500 test iterations in a single run and run up to 250 optimizations per day. See [Optimizer Availability and Daily Limits](#optimizer-availability-and-daily-limits) for more information on what's available in each OO tier.

## Your First Optimization

An Optimization run starts with a [saved backtest](/backtesting/backtest-setup.md#save-and-share-a-backtest). If you have not yet created and saved one, please start with [your first backtest](/backtesting/backtest-setup.md#your-first-backtest). From the saved backtest page, click on the Puzzle icon (<img src="/files/ZVHu9oeC8xvoTMzQ79SW" alt="" data-size="line">) in the top right, next to the Recent Test Runs shortcut.

<figure><img src="/files/r1vkmZli2H6ZNSBI3HqP" alt="" width="563"><figcaption></figcaption></figure>

### Setup

The Optimizer will preload the start and end dates and starting funds of your base backtest. You can override the dates and starting funds here. For optimization runs with many concurrent tests, we recommend limiting the date range.

### Sweep Dimensions

Under Sweep Dimensions, use the dropdown menu to select your first Parameter to sweep over for the optimization. The list will include strategy setup parameters such as Strike Deltas, Leg Offsets, any entry criteria that are present on the base backtest, such as entry time, VIX conditions, or technical indicators, and exit conditions such as stop losses, profit targets, or early exit rules. Note that certain more complex conditions, such as profit actions or time actions are cannot be swept.&#x20;

{% hint style="info" %}
If you want to sweep over a parameter that is not shown on the list, you must first add it to the base backtest and save it. You can use a value on the extreme end of the range (such as Min VIX = 1) to enable the parameter in the optimizer without changing the results of the base backtest.
{% endhint %}

#### Parameter Sweep Range

For a selected parameter, the Base value and unit are displayed — this the value used on the base backtest. You can then specify a Start and End value and Step size. For example, if you are optimizing on delta for a short put, you might have a base value of 25 delta. You might want to test delta values from 10 to 40 in 5 delta steps. Set Start at 10, End at 40, and a Step size of 5, and the Optimizer will test 10, 15, 20, 25, 30, 35, and 40 delta, or 7 tests within the optimization run.

<figure><img src="/files/qsRL4RQddtlblVuszen5" alt=""><figcaption></figcaption></figure>

#### Offset Parameters

When testing strike offset parameters, values are relative to the reference value (such as the strike of the parent leg, or the spot price of the underlying). You will need to use negative values to sweep through lower strikes. For example, a 25-wide short vertical put spread has an offset of -25. To sweep through various wing widths, you may want to use a starting value of -10, ending value of -50, and step size of -5. The Optimizer will then test offsets of -10, -15, -20, -25, -30, -35, -40, -45, and -50, or 9 total tests within the optimization run.

<figure><img src="/files/XVgt2goRGjXN18ls8alt" alt=""><figcaption></figcaption></figure>

#### Fixed value parameters

Some parameters, such as SMA and EMA, use fixed values from a picklist. Rather than inputting numerical start and end values and a step size, the Optimizer will allow you to define the start and ending values from the fixed list and OO will step through each value within the range.

<figure><img src="/files/jQon7CV0k0Hpv3mKZuxy" alt=""><figcaption></figcaption></figure>

Note that the Optimizer currently supports Above and Below for SMA and EMA. We do not support Compare at this time (e.g. Enter when SMA\_X > SMA\_Y).&#x20;

### Multiple Parameters

You can sweep across multiple parameters (up to 5) in a single optimization run. Just click the Add Dimension button to add a new parameter row. Combining the two examples above, the Optimizer will run 63 total tests in a single run, as shown in the total test counter on the bottom right.

<figure><img src="/files/WLFcBeCNcI545ijOmnP7" alt=""><figcaption></figcaption></figure>

### Running an Optimization

Once the parameters are selected with start/end values and step sizes entered, click Run to proceed with the Optimization. A modal will appear with a progress bar as the optimization is being run. You can leave this running to wait for the results. Optionally, click Continue in Background to keep the Optimization running in the background. This will allow you to navigate elsewhere or even close the browser tab while the test continues to run.&#x20;

<figure><img src="/files/FJVOKngpAPsslh2WDczQ" alt="" width="375"><figcaption></figcaption></figure>

If Continue in Background is chosen, the Optimization progress can be viewed under the Optimizations tab on the base backtest. When completed, you can also click on the row to access the Optimization results.

<figure><img src="/files/Fi1aBlhbKwasQMIlk90c" alt="" width="563"><figcaption></figcaption></figure>

In the event an Optimization fails to run, see [Troubleshooting Possible Errors](#troubleshooting-possible-errors).

## Optimization Results

When complete, Optimization Results are displayed in a slider. The slider also opens if you click on a previous Optimization from the Backtest Results > Optimizations tab, where you'll find runs that were set to "Continue in Background" or any previously run Optimizations.

<figure><img src="/files/5oizlF0RfVUUjL5esGNv" alt=""><figcaption></figcaption></figure>

At the top left, you'll see the strategy name, the number of test iterations within the optimization run, the date range, starting capital, and the chips showing the parameter(s) optimized in this run. On the top right, you'll be able to download a CSV of the results (<img src="/files/IkMJcZmTFZFQZxRtCUKx" alt="" data-size="line">) as well as set up another optimization run (<img src="/files/ZVHu9oeC8xvoTMzQ79SW" alt="" data-size="line">) pre-filled with the same parameters.

### Robustness

For each Optimization, OO attempts to calculate the Robustness of the results to estimate whether test improvements from adjusting parameters are likely from curve fitting to historical data (lower curve-fit resistance) or if the improved results are likely to hold up to future trading (higher curve-fit resistance).

Expanding the Robustness section provides more information on how the score is calculated. OO looks at the top 10% of tests for the chosen performance metric, averaging the stability of neighboring parameter combinations. The Curve-Fit Resistance score is a composite of four weighted measures, scaled down when nearby tests are missing or errored:

* **Retention** (45%) - when evaluating the best parameter combination, do neighboring parameter values retain performance improvement (more robust)?
* **Plateau** (30%) - is the optimal parameter value part of a broader high-performing region (more robust) or an isolated peak (less robust)?
* **Smoothness** (15%) - does performance change gradually (more robust) or abruptly (less robust) as we iterate across parameter values?
* **Multi-metric** (10%) - does the best parameter combination for the chosen performance metric also perform consistently strong across other performance metrics (more robust)? Or does it trade-off performance (less robust)?

{% hint style="warning" %}
It's important to note that the Curve-Fit Resistance and other Robustness measures are generalized estimates. As with any backtesting results, past performance is NOT a guarantee of future results.
{% endhint %}

### Best Results

Below the expandable Robustness section, you'll see the best test results for Sharpe, Sortino, MAR, P/L, CAGR, Win %, Lowest Max DD, and Premium Capture %. Note that the best parameter combination for one metric is likely to be a different parameter combination for another. These are the best possible results for each individual metric across all tests in the optimization. Clicking on any of the metric panes will take you to the table view, sorting the test runs by the respective performance metric. See Table.

### Charts View

Below the Best Results panes, you can visualize Optimization results via Charts (default) or the raw data in a Table.

#### Single Barchart

This bar chart allows you to choose one performance metric and a single parameter (if the optimization contains more than one) from the controls on the top left. The chart will show performance on the Y-axis and parameter values on the X-axis.

By isolating a single parameter, you can more easily visualize how neighboring values perform, identify peaks/plateaus, and gauge smoothness of results to see if the optimization is robust or curve-fit.

Hover the mouse over a specific bar for more details on that specific parameter. You can also click on the bar to go to the table view, where the relevant backtest (for that parameter value) will be highlighted, allowing you to see more information on that specific test run. Note that if you have a multi-parameter optimization, each bar on the single parameter heat map aggregates the results across all other un-selected parameters.

<figure><img src="/files/q7hdslhbqEgMOAMvrb0w" alt="Single parameter bar chart"><figcaption><p>The highest Sortino values are centered around 40 delta. We also see performance retention in neighboring values, a broad plateau, and relatively smooth falloff on either side of the peak, suggesting that optimizing on Delta for this strategy is fairly robust and resistant to curve-fitting.</p></figcaption></figure>

#### Dual Parameter Heat Map

The dual parameter heat map is available when two or more parameters have been added to the optimization. Choose the performance metric and the X and Y-axis parameters using the controls on the top right.

The matrix shows all possible combinations of the two selected parameters and the color scale shows the best performing combinations in green and the worst performing (negative values) in red. The performance measure is also shown in each cell.

By visualizing two parameters in one matrix, you can find regions with the highest performance and also assess robustness — are the strongest (green) results in an orderly region (more robust) or are they scattered (random / curve fit)?

Hover the mouse over specific cells to see other performance results for that parameter combination at the bottom of the chart. You can also click on any cell to go to the table view, where the relevant backtest (for that parameter value combination) will be highlighted.

If more than two parameters are in the optimization, each cell will aggregate the results across any un-selected parameters.

<figure><img src="/files/PDmNE5PEWdu0NNxHmgqa" alt=""><figcaption></figcaption></figure>

#### Parameter Impact Analysis

The Parameter Impact analysis is shown when two or more parameters are present on the optimization. This section helps to identify which parameter(s) in the optimization make the biggest impact(s) in the results. By using ANOVA ([analysis of variance](https://en.wikipedia.org/wiki/Analysis_of_variance)), we can evaluate each parameter's relative influence on performance. This allows you to focus energy on optimizing for parameters that make the biggest impact.

In this example, we can see that Leg 1 Delta has a large effect on P/L, while the Profit Target has minimal impact. This leads to further investigation on whether the appropriate profit target range was tested, or if a profit target is even needed — perhaps other forms of exit (early exit, stop loss, or even holding to expiration) may produce a better result.

<figure><img src="/files/CsafxRUlyygD9OFdtTdC" alt=""><figcaption></figcaption></figure>

On the other hand, when we look at parameter impact for the same parameters but for a different strategy, we see both Profit Target and Leg 1 Delta contributing to performance, with the Profit Target having a great impact. This strategy may perform across a wider range of delta values but focusing on refining the Profit Target might yield better results against historical data.

<figure><img src="/files/pCPDI0rWv35HtMEucDCO" alt=""><figcaption></figcaption></figure>

### Table View

The table view allows you to see performance metrics for ALL tests (every possible combination of parameter values) in the optimization. Click any of the column headers to sort, or use the Best Metrics panes above.

The highlighted row shows the best test for a chosen performance metric. Or, if you clicked from one of the charts, it shows the relevant test that was clicked to get to the table.

The row representing the base test is shown with a "Baseline" chip, allowing you to see which results were better and which were worse than the base test.

<figure><img src="/files/D4J5BMMQPSYJbsKnFlep" alt=""><figcaption><p>The highlighted top row shows the "best" result for a chosen metric, while the Baseline shows the reference base backtest for comparison. </p></figcaption></figure>

#### Saving a Backtest with Optimized Parameters

To the far right on each row, clicking the triangle (<img src="/files/VMntmdl4tCQu4xo0VoLs" alt="" data-size="line">) icon will allow you to run a new backtest using the optimized parameters of that particular test row.

This is a shortcut that opens the [backtest setup](/backtesting/backtest-setup.md) slider, pre-populating it with the optimized values from the test to run a new backtest. You can then further analyze the backtest with trade log or CSV export as well as [saving the test](/backtesting/backtest-setup.md) to either update the base backtest or create a new backtest.

## Optimizations Tab

Once an Optimization has been run for a backtest (remember — Optimizations must originate from a *saved* base backtest), it can be found under the Optimizations tab on the backtest. Here you'll see completed, backtests, cancelled backtest, failed backtests, and any backtests that are in progress. In addition to the Optimization creation date and Status columns, you can find the dimensions / parameters which were tested, the number of tests, and the best result for various performance metrics.

You are able to click on a Completed backtest to review results, iterate through new Optimizations, or run New Backtests from the table view.

<figure><img src="/files/TUAb7NSTapqc2wQkh5RM" alt=""><figcaption><p>Example Optimization tab showing optimizations that are In progress, completed, failed, and canceled. </p></figcaption></figure>

Optimization runs are stored for 7 days, after which they are cleared from the Optimizations tab. If you encounter optimization results you wish to keep, the best practice is to run the backtest for the best result and either update the original base backtest or save it as a new one. You can use the description field to log notes on what optimizations have been performed.

## Optimizer Availability and Daily Limits

The Optimizer is available for Essential, Plus, and Premium OO tiers, as well as Trial accounts for Essential and Plus. The maximum number of concurrent tests per optimization and daily limits vary by account tier:

<table><thead><tr><th width="236.18359375">Account Tier</th><th width="154.234375" align="center">Max Parameters</th><th width="183.99609375" align="center">Max Tests per Optimization Run</th><th align="center">Daily Optimization Run Limit</th></tr></thead><tbody><tr><td>Trial (Essential and Plus)</td><td align="center">5</td><td align="center">50</td><td align="center">1</td></tr><tr><td>Essential, Plus*</td><td align="center">5</td><td align="center">50</td><td align="center">10</td></tr><tr><td>Premium</td><td align="center">5</td><td align="center">500</td><td align="center">250</td></tr></tbody></table>

* For all tiers, only one Optimization can be run at a time.
* The daily Optimization limit reset daily at 12am ET.
* Users on Essential or Plus tiers can upgrade to Premium at anytime to gain access to higher limits.
* Optimizations may run up to 20 minutes before timing out. See [possible errors](#possible-errors) for help troubleshooting timeouts or other failures.

## Troubleshooting Possible Errors

There are several reasons why an Optimization may fail to run.

Optimizations are resource intensive and are limited depending on tier. Your current daily usage and daily limit is shown at the bottom of the New Optimization slider:

<figure><img src="/files/b7Hz0t10IhyNFflhkPo3" alt="" width="563"><figcaption></figcaption></figure>

If you exceed the daily limit (10 for Essential and Plus tiers, 250 for Premium) you'll also see an error message. You can upgrade your tier to instantly unlock additional Optimizations.

<figure><img src="/files/jhIjvwYDkCA1Dtweg8zX" alt="" width="375"><figcaption></figcaption></figure>

Users may only run 1 Optimization at a time. If you attempt to run concurrent optimizations (such as in separate tabs) you'll get an error:

<figure><img src="/files/MGircyHz6p81Gybk95HV" alt="" width="375"><figcaption></figcaption></figure>

If the Optimization is projected to exceed the timeout limit of 20 minutes, you'll receive an error. You can try reducing the number of parameters, increasing the step size, and/or shortening the date range to reduce the compute load before re-attempting the Optimization.

<figure><img src="/files/GLdJ8BuBvA3w4ckZU5sJ" alt="" width="375"><figcaption></figcaption></figure>

In some cases, the projected runtime may not exceed the timeout limit so the test begins to run, but does not anticipate a timeout and the test may begin running, but the test takes longer than projected and it times out before completing. When this happens, the error will be shown under the Status column in the Optimizations tab. Try shortening the date range or reducing the number of tests by removing parameters, narrowing the start/end range, or increasing the step size.
