[Hyperparameter Optimisation]

Search strategy input.* values over N trials (TPE / random / grid) with holdout or walk-forward. Strategies only.

Hyperparameter Optimisation

AXIS can search Pine Script™ input.* values on a strategy() script and apply the best assignment for this symbol and bar window.

The search engine is pyne (POST /optimize / pynescript.optimize). AXIS is the plugin UI. Pyodide and engines without /optimize fall back to an isolated local loop (random only).

This is not a live trading optimiser and not a Pine builtin. Best-on-sample is not a guarantee out of sample.

Warning

Holdout is the default for a reason. In-sample-only search overfits. Winners on one symbol or timeframe often fail on another.

Open it

01

Load a strategy and bars

Open a script that declares strategy(). Load history. A first Run is optional but helps engine-exported inputs appear.

02

Open Optimise

Results drawer → Optimise, or command palette Optimise strategy. Indicators and libraries show a one-line disabled reason.

03

Set the space

Tick the input.int / float / bool / enum fields to search. Numeric fields need min and max (minval/maxval from the script, or typed in the table). Source, color, timeframe, symbol, session, and text stay at their current Script Settings values.

04

Start

Set trials, sampler, objective, and validation. Start runs the study. Cancel aborts the in-flight engine call. Trials do not paint the chart.

05

Apply

Apply best merges the winner into Script Inputs (other inputs stay). Apply + re-run also runs the winner so the Strategy tab matches. Export the trial table as CSV.

Study controls

ControlDefaultNotes
Trials30Hard cap 200
SamplerautoRandom if N<20, else TPE (TPE needs pyne /optimize)
ObjectivecompositeAlso net PnL, profit factor, Calmar-like
Validationholdout 30%Walk-forward or in-sample (warned)
Min trades5Fewer closed trades → trial rejected

Note

Grid is offered when the cartesian product fits the trial budget. On Pyodide (no /optimize) the UI falls back to random and says so.

Validation

ModeWhat happens
Holdout (default)Sampler sees the first ~70% of bars. Every trial is also scored on the last ~30%. Ranking prefers out-of-sample.
Walk-forwardRolling train/test windows. Engine runs ≈ N × folds (capped at 400).
In-sampleOne run on all bars. Warned in the UI.

Train and test are bar slices, not trade filters on a full-sample run.

Engines

EnginePath
server (Pro API)POST {endpoint}/optimize — parse-cached interpret loop, TPE / random / grid
Pyodide / missing /optimizeIsolated runScript — random only

Same-origin VPS / Docker must proxy /optimize to Flask (same as /run). Otherwise AXIS falls back to the slow client loop.

Overfitting

  • Prefer holdout. Treat in-sample net profit as a search score, not a live forecast.
  • Composite + min-trades rejects lottery-ticket parameter sets with 1–2 fills.
  • Apply + re-run on a later date range or another symbol before trusting a winner.

See also