Optimiser Guide =============== The Optimiser automatically tests hundreds of parameter combinations and finds the settings that produced the best historical performance — saving you from manually running backtests one by one. .. note:: The Optimiser is available on **Silver and Gold** plans. ---- .. contents:: On this page :local: :depth: 1 ---- How it works ------------ Normally your strategy uses fixed values — RSI period 14, Stop Loss 5%, rebalance every 2 weeks. The Optimiser lets you provide *multiple* values for each parameter, then automatically runs every combination and returns a ranked table of results. **Example:** If you set: - RSI Period: ``7, 14, 21`` - Stop Loss: ``0.03, 0.05, 0.10`` - Primary Interval: ``1w, 2w`` The Optimiser runs ``3 × 3 × 2 = 18`` separate backtests and shows you all 18 results ranked by Sharpe Ratio. ---- Enabling the Optimiser ----------------------- 1. Open your **Config** block. 2. Set the **Optimizer** dropdown from ``Off`` → ``On``. 3. The parameter fields that support optimisation are highlighted in a different colour. Once enabled, you can enter comma-separated values in any highlighted field: .. code-block:: text Stop Loss: 0.03, 0.05, 0.07, 0.10 Take Profit: 0.10, 0.15, 0.20 Primary Interval: 1w, 2w .. tip:: You can also enter comma-separated values in indicator blocks — for example, RSI Period: ``7, 14, 21`` or Bollinger Bands Period: ``15, 20, 25``. All optimisable fields across the entire workspace are combined. ---- Reading the results table -------------------------- After the Optimiser run completes, a results table appears with one row per parameter combination: .. list-table:: :header-rows: 1 :widths: 25 75 * - Column - What it means * - **Parameters** - The specific values used in this combination. * - **Sharpe Ratio** - Risk-adjusted return. Primary sorting metric. * - **Total Return** - Raw percentage gain over the test period. * - **Max Drawdown** - Worst peak-to-trough decline. * - **# Trades** - Total number of trades executed. * - **Win Rate** - Percentage of profitable trades. **Sort by Sharpe Ratio**, not Total Return. Total Return is easy to inflate with a lucky parameter set; Sharpe penalises excessive risk-taking. ---- Choosing the best parameters ------------------------------ Do **not** blindly pick the top-ranked row. Instead, look for *stability clusters*: .. code-block:: text RSI 14, SL 5% → Sharpe 1.42 ← Best RSI 14, SL 7% → Sharpe 1.39 RSI 21, SL 5% → Sharpe 1.35 RSI 7, SL 3% → Sharpe 1.61 ← Higher but isolated RSI 7, SL 3% → Sharpe 0.82 (different period test) The top result (RSI 7, SL 3%) has the highest Sharpe but only works in one narrow configuration — classic overfitting. The **RSI 14 cluster** consistently delivers ~1.35–1.42 across multiple combinations — a much more reliable choice. **Rule:** Pick parameters that appear in a *neighbourhood of good results*, not an isolated peak. ---- How many combinations is too many? ------------------------------------ More combinations = more chances to accidentally find a parameter set that worked historically by pure luck. .. list-table:: :header-rows: 1 :widths: 25 75 * - Combinations - Risk level * - < 50 - Low. Results are usually meaningful. * - 50 – 200 - Moderate. Look for stability clusters. * - > 200 - High. Significant overfitting risk — validate carefully. A simple rule: **fewer, wider-spaced values are better** than many closely-spaced ones. - Good: ``7, 14, 28`` (spread across different regimes) - Risky: ``13, 14, 15`` (nearly identical — just noise) ---- Walk-Forward Validation ------------------------ The Optimiser's most powerful feature is **Walk-Forward** testing — repeatedly optimise on one window of data and test on the *next* window you haven't seen: .. code-block:: text Window 1: Optimise on 2005–2010 → Test on 2010–2012 Window 2: Optimise on 2007–2012 → Test on 2012–2014 Window 3: Optimise on 2009–2014 → Test on 2014–2016 ...and so on. This produces a series of **out-of-sample results** — the only truly honest way to evaluate whether your optimal parameters generalise to unseen data. If the walk-forward results closely match the full-period optimised results → the strategy is robust. If they diverge sharply → the strategy is overfit. .. note:: Walk-Forward is available on **Silver and Gold** plans and coming soon to the Optimiser interface. ---- Practical workflow ------------------- Here is the recommended process for using the Optimiser effectively: 1. **Split your data.** Reserve the last 20–30% of your date range as an out-of-sample test period. For example, if you have data 2000–2022, optimise on 2000–2016 and test on 2016–2022. 2. **Run the Optimiser** on the in-sample period (2000–2016). 3. **Pick parameters** from a stability cluster, not the single best row. 4. **Freeze those parameters** and run a *single* backtest on the out-of-sample period (2016–2022). 5. **Compare results.** If out-of-sample Sharpe is within ~30% of in-sample Sharpe, the strategy passes. If it collapses completely, the strategy is overfit — go back to step 2 with simpler parameters. .. warning:: Once you look at out-of-sample results, that period is "spent" — it can no longer serve as a clean test. Do not re-optimise based on out-of-sample results. If you do, you need a third, untouched period to validate. ---- Common mistakes ---------------- **Mistake 1 — Optimising too many parameters at once** Each additional parameter multiplies the search space. With 5 parameters and 4 values each, that's 1,024 combinations — most of which are spurious. Optimise 2–3 key parameters at most in a single run. **Mistake 2 — Picking the single best result** The #1 result is almost always overfit. Look for the parameter cluster where many nearby combinations also perform well. **Mistake 3 — Using the full date range for optimisation** If you optimise on all available data and report those results, you have no honest out-of-sample test. Always hold back a test period *before* you start. **Mistake 4 — Ignoring trade count** A combination with 8 trades and Sharpe 2.5 is statistically meaningless. The Sharpe calculation needs at least 30–50 trades to be reliable. Filter out any row with fewer than 30 trades.