ProRealCode Studio is on its way. As soon as it is published, this button will take you straight to its Chrome Web Store page.
The optimizer runs your strategy once for every combination of its settings, up to 100,000 runs, and ranks them. It is quick to find a combination that did well on the past. This chapter also shows how to tell a setting that holds from a lucky one.
| In one optimization | Limit |
|---|---|
| Runs | 100,000 at most: the number of values of each setting, multiplied together. |
| Values per setting | 100,000 at most. |
| Settings it can vary | Those declared with input(): whole numbers, decimals, average types, switches, and texts with a list of options. |
input() (chapter 08). The window works on the chart's bars as they are when you open it.1input(len, 20, "Length", int, minval = 5, maxval = 60, step = 5)2input(stopPct, 2, "Stop %", float, minval = 0.5, maxval = 4, step = 0.5)3IF NOT LongOnMarket AND close CROSSES OVER Average[len](close) THEN4 BUY 1 SHARES AT MARKET5ENDIF6SET STOP %LOSS stopPct
| The window says | Because |
|---|---|
| “This strategy has no searchable input() parameters” | The code declares no setting the optimizer can vary. |
| “Apply a strategy to a live chart before optimizing it” | The strategy is not on a chart that is open. |
| “… keep the search inside the code's bounds” | A range goes past the minval or maxval of the code. |
| Net / max drawdown | at first |
| Net profit | |
| Profit factor | |
| Max drawdown % | lower is better |
| Average trade | |
| Win rate % | |
| Trades | |
| Trade mean / deviation | |
| Sortino (per trade) | |
| SQN | |
| Exposure % | lower is better |
“Min trades” (30 at first) and “Max drawdown %” (25 at first). A combination that misses one is still listed, after all those that pass.
“Use out-of-sample” keeps the last bars aside: 30 % at first, any whole number from 0 to 99. The window says it in one line: “Ranking uses the first … bars. The last … are scored and never used to rank.”
Four boxes: the number of runs, how many run “at a time · on this computer”, the time “per run”, measured on the first 8, and the total “estimated”.
A bar counts the runs done, “Calibrating on the first 8 runs”, then “about … left”. “Pause” and “Resume” keep what is done; “Stop” ends the search. “Now testing” names the combination being run, “Best so far” the leader.
One row per combination, 50 per page: its settings, the objective, “Robust”, “OOS” (the same figure on the bars kept aside), then Net, PF, DD %, Trades, Win %, μ/σ and “Flags”. Click a row to see it in detail (task 5).
| Flag | Means |
|---|---|
| Too few trades | Under “Min trades”. |
| Drawdown limit | Over “Max drawdown %”. |
| No finite profit factor | No losing trade, so the ratio has no value. |
| Loses out of sample | It lost money on the bars kept aside. |
| Plateau | Its neighbours, one step either side, score within 10 % of their average. |
| Isolated peak | It beats the average of its neighbours by more than half. |
| Run failed | The strategy stopped with an error on that combination. |
“Raw” or “Robust”. Raw ranks each combination on its own score. Robust, the setting at first, ranks it on the mean of its neighbours, one step either side on every setting that varies. It waits until those neighbours have run.
The sentence under the surface compares the two winners: “Best raw and robust agree on …”, or names both when they differ. When they differ, prefer the robust one.
Click a row of the ranking or a square of the surface. The detail of that combination opens beside the surface: its figures, its equity curve, and three buttons.
| In the detail | What to read |
|---|---|
| The tiles | Net, Net / DD, Max DD %, Trades, Profit factor, Win rate %, then “OOS net” and “OOS Net / DD” on the bars kept aside. |
| The curve | The equity over the bars it was ranked on, then over the bars kept aside, hatched. Red there means it lost money on bars it had never been ranked on. |
| The note under it | “One continuous run.” A trade opened before the split and closed after it counts on the side where it closed, so “OOS net” can hold gains made before the split. |
| Button | Effect |
|---|---|
| Apply to chart | Gives the strategy on the chart these settings, as its own Settings would. The code does not change. The status bar reads “Candidate applied to the chart”. |
| Write as defaults | Opens the code's Variables with these values ready; “Apply” there writes them into the code (chapter 08). For ProRealCode Script codes only. |
| Open run | Runs this combination again and opens it in the results window of chapter 18, with every trade. |
Try enough combinations and one of them will have fitted the past by chance. That is over-optimisation: the strategy learned the noise of those bars, not a behaviour of the market. Three habits limit it. Keep bars aside and read “OOS”. Prefer a plateau to a peak. Keep the number of runs small next to the number of trades: when a search makes more than 5 runs per trade of its winner, the window warns that it “may overfit”.
The ranges multiply to more than that. Raise a step, narrow a range or switch off a setting.
Yes. The chart stays live. “Pause” stops the search for now and keeps what is done.
Their neighbours have not all run, or some failed. Robust waits for a full set.
From minval, maxval and step in the code's input() lines. Changing them in the window does not touch the code.
No investment advice. An optimization ranks what combinations of settings would have done on past prices, under the assumptions of chapter 18. A high rank is not a forecast, not investment advice and not a recommendation to buy or sell anything. Past results do not predict future results.
Chapter 21 · The dashboard