SuperCharting
Sign in Get started Account Open charts

Learn / Strategies

Strategy optimiser: find the best inputs without overfitting the past

The SuperCharting strategy optimiser backtests a strategy across input ranges to find the best settings, with filters, criteria and checks against overfitting.

The strategy optimiser runs your strategy again and again with different input values and ranks the results by the measure you choose, such as net profit or profit factor. In SuperCharting it is built into the Strategy Tester: you tick the inputs to search, give each a From, To and Step, pick a search method and run. The chart does not change until you apply a result.

An optimiser always finds settings that fit the past well. That is not the same as settings that will work next month. Past results do not guarantee future results, and the second half of this page is about using the optimiser without fooling yourself.

How to optimise a strategy in SuperCharting

  1. Add a strategy to the chart, for example the EMA crossover from write your first strategy on XAUUSD 1 hour.
  2. Click the blue Optimise button in the Strategy Tester toolbar, or right-click the strategy's name in the chart legend and choose Optimise strategy…. The Optimise strategy dialog opens with the strategy, symbol and timeframe in its title.
  3. On the Optimise tab, choose the objective: tick Maximise (untick it to minimise) and pick the measure, for example Net profit.
  4. Choose a Method and the number of Cycles. The note beside it shows the size of the parameter space in combinations.
  5. In the table, tick Active for the inputs to search and set From, To and Step. For an option list, type the choices separated by ";".
  6. Optionally set a Result filter and Save criteria.
  7. Click Run optimisation. A progress bar shows the cycle count; Stop ends the run early.
  8. Open the Results tab and click Apply best to chart, or click any row to apply that set instead.

The settings, one by one

Objective

The measure the optimiser ranks by. The list includes Total P&L, Net profit, Net profit %, Gross profit, Gross loss, Profit factor, Max drawdown, Max drawdown %, Total trades, Percent profitable, Avg trade, Ratio avg win / avg loss, Largest winning and losing trade, Avg bars in trade, Commission paid, Net profit long and short, and Recovery factor. To find the smallest drawdown, untick Maximise and choose Max drawdown %.

Search methods

The Priority column sets the order in which inputs are walked. By default the first cycle tests the settings already on the chart, so you can see whether anything beats them; tick Skip the current settings as a starting point to leave them out.

Result filter and Save criteria

The Result filter keeps results above (Keep ≥) or below (Keep ≤) a value of one measure; for example keep Total trades ≥ 30. Save criteria are extra rules that must all pass, such as Percent profitable > 50 and Max drawdown % < 15, added with + Add criterion. A result that fails is still listed, greyed, but can never become the best.

Sweep across timeframes

Tick Sweep across timeframes and type a list such as 15m, 1h, 4h, 1D. The whole search is repeated on each timeframe, which tells you quickly whether an idea only works on one of them.

Templates and results

Get template downloads the input table as a CSV with the columns Parameter, From, To, Step, Default and Priority; Upload CSV loads one back, and Reset ranges starts the table again. On the Results tab, Download CSV saves every test, and the Chart tab plots one input against the objective, or two inputs against each other.

An example run

On XAUUSD 1 hour, search the EMA crossover's Fast length from 5 to 20 step 1 and Slow length from 20 to 60 step 5. That is 16 × 9 = 144 combinations, so Brute force with 144 cycles tests them all. Set the objective to Profit factor and a Result filter of Total trades ≥ 30, so a set with five lucky trades cannot win. Then open the Chart tab with Fast length on X: a broad hill of good values is a much better sign than one tall spike surrounded by losses.

How to avoid overfitting

Overfitting means the settings have learned the noise in one stretch of history. These habits keep it in check:

The optimiser's own Help tab gives the same advice: the best backtest is fitted to the past, so check it on another period or symbol before trusting it.

Frequently asked questions

Does the optimiser change my chart while it runs?

No. Each cycle is a separate backtest on the chart's loaded bars. The chart only changes when you apply a result.

How many cycles should I run?

Around 100 to 200 is a good start with Random or Annealing. Use Brute force when the parameter space is small enough to test completely.

Can TV Pilot optimise for me?

On accounts where the site owner has enabled it, TV Pilot can run an optimisation over input ranges you describe in chat. The same overfitting cautions apply.

Is the optimiser free?

SuperCharting is currently free to use, and the optimiser is part of the Strategy Tester on every account.

Try it on a live chart

SuperCharting runs in your browser: charts, Pine-compatible scripts, the Strategy Tester, alerts and the screener, with Indian and global markets.

Create a free account More guides