Documentation

Test Results

After every backtest (Test in Running code), the IDE opens Test Results for the file you ran. It’s the second view on the editor’s Code Editor / Test Results switch (Workspace layout), and it shows everything the engine produced for that run: charts, performance stats, trades, and an HTML export. Logs and plots during the run stream to the Output panel.

Each open file has its own Test Results — switching files brings up that file’s last result.


Where it appears

  • After clicking Test in the toolbar, the view switches to Test Results automatically when results are ready.
  • You can switch between Code Editor and Test Results any time using the small tab strip above the editor area.
  • Status banners at the top of the pane tell you what state the run is in:
    • Running backtest — <file> while the engine is working.
    • Backtest failed — <file> with the error stacktrace if something went wrong.
    • Backtest result — <file> when a single run finished successfully.
    • Optimization — <file> with a tab strip when you ran a parameter optimization (see Optimization runs at the end).

If a file has never been tested, you’ll see a friendly empty state pointing you back to the Test button.


Layout of a successful run

A successful backtest result is split top-to-bottom into three resizable, collapsible regions:

  1. Chart panel — the price chart with markers (and per‑symbol tabs for multi-symbol runs).
  2. Performance — equity & balance chart plus the metrics grid.
  3. Trades — closed trades and (when relevant) open positions at end of run.

1. Chart panel

The top region renders the OHLC bars used in the run with overlays from your strategy:

  • Trade markers are drawn at entry and exit points.
  • Indicator overlays appear here when your code added them via chart_indicators (see the Indicator Series docs). Lines and histograms render in the main pane or in a separate sub-pane below the candles, exactly as you configured.
  • Multi-symbol runs get a tab strip above the chart — one tab per ticker. Click a tab to switch which symbol’s chart you’re looking at.
  • A small chart toolbar above the chart hosts the Export HTML button (see below) and, in optimization views, the run’s parameter label.

If a result has no ohlcv.bars to plot, the chart area is replaced with a short note and the export toolbar so you can still save an HTML report.

2. Performance

Click Performance to expand the panel. It contains two parts:

Equity & balance chart

A line chart of your account over the run:

  • Equity — mark‑to‑market account value at every step.
  • Balance — settled cash balance over the same timeline.

The chart auto-downsamples for very long runs and uses time-based axis labels so you can read the timeline at a glance.

Metrics grid

A grid of summary statistics produced by account.refresh_metrics(...) at the end of the run. Color-coded badges highlight signed values (gains in green, losses in red).

MetricMeaning
Total returnFinal equity vs starting balance, expressed as a percentage.
Total P/LCumulative realized + unrealized profit/loss in account currency.
CAGRCompound annual growth rate over the run.
Max drawdownLargest peak-to-trough drop in equity.
VolatilityEquity volatility over the run.
SharpeRisk-adjusted return ratio.
SortinoDownside-risk-adjusted return ratio.
CalmarAnnualized return divided by max drawdown.
Profit factorGross profit / gross loss across closed trades.
Risk-adj. returnReturn scaled by risk taken.
Avg expectancyAverage expected P/L per trade.
Average winMean profit on winning trades.
Average lossMean loss on losing trades.
Current exposureExposure at the final bar.
Average exposureMean exposure across the run (0–100%).
Max exposurePeak exposure during the run (0–100%).

Cells show when a metric isn’t available for the run (for example, no closed trades means no profit factor).

3. Trades

The bottom region has up to two tables:

Closed trades

Every round-trip executed by account.open_trade(...) + account.close_trade(...). Columns include side, quantity, entry price, exit price, entry time, exit time, and realized P/L (color-coded).

  • Click Closed trades to collapse or expand the table.
  • Click any row’s entry/exit time to jump to that event on the chart.
  • Use Export CSV at the top of this section to save the closed trades to a .csv file (with a system Save As dialog when supported).

Open positions (end of run)

Shown only when the strategy ended the run with open positions still on the books. Same column conventions as closed trades, plus the position id used by your code.

Tip: the trades panel auto-resizes when you collapse it — collapse it to give the chart and Performance more vertical space.


HTML export

Use Export HTML (top-right of the chart toolbar) to save a single self-contained .html file with everything you see on screen:

  • Each chart panel (one image per symbol in multi-symbol runs).
  • The equity & balance chart.
  • The Performance metrics.
  • The closed trades table.
  • The report title (taken from the file name) and the time the report was generated.

How it works:

  1. The IDE briefly expands the Performance panel so the equity chart can be captured.
  2. It cycles through each chart tab and snapshots the chart as PNG.
  3. The result is bundled into a single HTML file and offered as a save dialog (filename like backtest-report-<timestamp>.html).

Open the file in any browser to share the run with someone who doesn’t have the IDE — no internet connection required.

The button shows Exporting… while it’s working. Don’t change tabs or close the IDE during export, or some panels may be missing from the saved file.


Run states (quick reference)

BannerWhat it means
Running backtest — <file>Engine is executing the run. The center shows “Results Loading, Waiting for engine…”.
Backtest result — <file>Successful single run. Charts, Performance, and Trades are filled in.
Backtest failed — <file>The run errored. Pane shows the engine’s error message in red.
Optimization — <file> (x/y)A parameter sweep is in progress; tabs appear as runs complete.

Optimization runs

When you tested with Optimize script parameters enabled, Test Results displays a tab strip — one tab per parameter combination — and any summary info such as total run count, the fitness metric for genetic runs, and progress while runs are still finishing.

  • Click a tab to load that run’s chart, Performance, and trades the same way as a single run.
  • The selected run’s parameter label is shown beside the chart toolbar so you always know which combination you’re looking at.
  • Export HTML uses the active run’s data, with the run label as the report title.
  • If the optimization was stopped early, a banner highlights that and only the completed runs are shown.

Tips

  • Collapse panels you don’t need (chart, Performance, or Trades) to focus on the rest.
  • Switching files swaps in that file’s last test results — your other tabs are not lost.
  • For very long backtests, the equity chart is downsampled for smoothness; the underlying numbers in the metrics grid are unaffected.
  • CSV is for closed trades; HTML is for everything. Use whichever fits how you want to share or analyze the run.