# DEVELOPMENT_LOG

Log of significant project activities. Intended as a source for a future technical article about developing a trading system with the help of an AI Assistant.

---

## Summary

- **Project name:** Trading System Development (MQL5 Expert Advisor) — working title to be finalized
- **Development start date:** 2026-11-04 18:02:55 (UTC+02:00)
- **Current status:** Stage 9 completed: the Expert Advisor has been designated a "risk-management framework, with no claim of profitability"; the frozen reference configuration is S1 0.35% GBPJPY H1, S2 0.35% EURGBP H1, S6 disabled. Risk-layer defects have been fixed (2% per-symbol limit, 3× cap on risk-budget overshoot caused by the minimum lot, de-risking at 20% drawdown). The configuration was tested over the full 2023–2026 window (+76.15 USD, PF 1.0186, 947 trades, 15.03% drawdown) and out of sample for 2023–2024 (−107.04 USD, PF 0.9545, 512 trades); no edge has been confirmed. Stage 8 context — subsection "Weight balancing, the 2023–2024 OOS run, and the S6 decision": the multi-symbol, multi-strategy EA was assembled and compiles without errors; 10 runs were completed (full 2023–2026 window, out-of-sample 2023–2024, 2025–2026 window, 0.35 and mixed weight settings, tighter limits, and separate S1/S2 contribution analysis). Conclusion: weights and limits do not drive the results; both operational modules lose money out of sample; S6 risk cannot be scaled as intended and its holding horizon exceeds the agreed scope. The user's decision was implemented: portfolio composition frozen, the search for an edge stopped, and the EA finalized as a framework.
- **Stages completed:** 9
- **Total measured time:** ≈ 22 h 55 min (Stage 2 includes a break while awaiting the user's reply; Stages 6–7 include idle time while waiting for compiler access to be restored; Stage 8 is counted using the measured 18:52–19:05 interval and includes work completed before the tool session was interrupted)
- **Compilations:** 15 (Stage 9: 1 successful, 0 errors and 0 warnings; Stage 8: 3 successful and 2 failed attempts involving `Portfolio_MultiStrategy.mq5` after initial creation, after fixing S6's lazy handles, and after correcting minimum-lot handling; all successful compilations had 0 errors and 0 warnings)
- **Compilation errors:** 5 (all in Stage 8, fixed)
- **Strategy Tester runs:** 45 (Stage 9: 4 — two full-window 2023–2026 runs, one out-of-sample 2023–2024 run, and a repeated full-window verification)

---

## Stage Log

### Stage 1. Creating the development log and recording the project start

- Start: 2026-11-04 18:02:55 (UTC+02:00)
- End: 2026-11-04 18:03:28 (UTC+02:00)
- Duration: 0 min 33 sec (total elapsed time; active time was not measured separately)
- Objective: Create `MQL5/DEVELOPMENT_LOG.md` and record the official project start for a future technical article.
- User request: Establish ongoing logging of all significant project activities, create a log file, and record the start time.
- Actions:
  - Performed mandatory pre-flight environment checks for the MetaEditor 5 and MetaTrader 5 servers.
  - Obtained the actual local time from the system clock.
  - Verified that no log file already existed in `MQL5/`.
  - Created `DEVELOPMENT_LOG.md` with a summary and stage-entry template.
- Files changed: `MQL5/DEVELOPMENT_LOG.md` (created)
- Errors and fixes: None found.
- Verification: File created on disk at `D:\ProgramFiles\CFI MEtaTrader 5\MQL5\DEVELOPMENT_LOG.md`.
- Outcome: Log created, project start recorded, and structure ready for future entries.
- Status: DONE

---

### Stage 2. Requirements discussion: selecting trading strategies

- Start: 2026-11-04 18:27:18 (UTC+02:00)
- End: 2026-11-05 15:09:32 (UTC+02:00)
- Duration: 20 h 42 min 14 sec (total elapsed time; includes a long break awaiting the user's reply; active time was not measured separately)
- Objective: Assemble a set of trading strategies based on different concepts and market regimes for a multi-strategy, multi-symbol EA, with correlation awareness, risk allocation, and a limit on total portfolio exposure.
- User request: Propose several systems based on different ideas so that signals arise under different market conditions; the ability to hold opposing positions on the same instrument is desirable.
- Actions:
  - Documented the key architectural requirements: multiple strategies, multiple symbols, correlation control, risk allocation, and an automatic total-exposure limit.
  - Prepared a set of candidate strategies organized by market regime, describing their logic, entries/exits, and mutual compatibility.
- Files changed: `MQL5/DEVELOPMENT_LOG.md` (stage entry added)
- Errors and fixes: —
- Verification: —
- Outcome: The user approved the initial requirements: a hedging account; three currency pairs with minimal correlation (selection delegated to the assistant); M5–H1 timeframes; staged development — implement each strategy separately on a single instrument before integration; spread/slippage restrictions are not yet considered; USD 3,000 deposit. The baseline strategy set was approved: S1 (trend breakout), S2 (mean reversion), and S6 (relative value).
- Status: DONE

---

### Stage 3. Correlation analysis and selection of three instruments

- Start: 2026-11-05 15:09:32 (UTC+02:00)
- End: 2026-11-05 15:12:50 (UTC+02:00)
- Duration: 3 min 18 sec (total elapsed time; includes waiting for the terminal to download historical data)
- Objective: Select three currency pairs with minimal mutual correlation for further strategy development, based on actual historical data.
- User request: Select three currency pairs with minimal correlation.
- Actions:
  - Checked the symbols available from the broker (Market Watch and hidden symbols).
  - Prepared a diagnostic MQL5 script to calculate a correlation matrix of logarithmic returns and rank three-instrument combinations.
  - Compiled and ran the script on D1/500 across 12 symbols; obtained a correlation matrix and a ranking of triples.
  - Checked current spreads for candidate instruments: EURGBP, USDCAD, EURCHF, NZDUSD, EURUSD — 1–2 points; USDJPY — 1 point; GBPJPY — 7 points (0.7 pip).
  - Selected the three instruments based not only on correlation, but also on liquidity and volatility.
- Files changed: `MQL5/Scripts/DevTools/CorrelationMatrix.mq5` (created)
- Errors and fixes: The first run used `InpTimeframe=0`, corresponding to `PERIOD_CURRENT` (the chart's H1 timeframe), so calculations used 500 hourly bars (~1 month) rather than daily bars. The error was identified from `CORR_PERIOD;PERIOD_CURRENT`. Fix: reran with `InpTimeframe=16408` (`PERIOD_D1`). The second run stalled for 5–6 seconds on symbols absent from Market Watch while history was loading; the symbols were added to Market Watch and the calculation completed.
- Verification: `CorrelationMatrix.mq5` compiled with 0 errors and 0 warnings. The script ran on an EURUSD,H1 chart; the results were read from the Experts log: 12 symbols, 500 daily bars, 2024-12-03…2026-11-05.
- Outcome: EURGBP, USDCAD, and GBPJPY selected. Pairwise |corr| on D1/500: EURGBP–USDCAD 0.064, GBPJPY–USDCAD 0.026, EURGBP–GBPJPY 0.375 (maximum within the triple). On H1/500 (~1 month), the corresponding values were 0.001, 0.154, and 0.151. For comparison: EURUSD–GBPUSD 0.809, AUDUSD–NZDUSD 0.872. The absolute statistical minimum — NZDUSD/EURGBP/EURCHF (max 0.040) — was rejected because it grouped similarly low-volatility instruments and did not cover the trending regime.
- Status: DONE

---

### Stage 4. Implementing S1 on a single instrument (GBPJPY)

- Start: 2026-11-05 15:41:56 (UTC+02:00)
- End: 2026-11-05 15:45:50 (UTC+02:00)
- Duration: 3 min 54 sec (total elapsed time; includes compilation and 14 Strategy Tester runs)
- Objective: Implement S1 (Donchian-channel trend breakout with ATR-based stops) as a standalone EA on GBPJPY, identify a suitable timeframe within M5–H1, and document the strategy rules.
- User request: Continue development and formulate the S1 rules at the end of the stage.
- Actions:
  - Documented the S1 v1 specification: Donchian-channel breakout, ADX and EMA filters, ATR-based stops and targets, and per-trade risk as a percentage of equity.
  - Created `S1_TrendBreakout.mq5`: Donchian-channel breakout, ADX filter, risk-based lot sizing, ATR-based SL/TP, optional trailing stop, optional exit at the opposite channel, and checks for trading mode, stop level, and volume constraints.
  - Ran a series of backtests on M5, M15, M30, and H1 to select the timeframe.
  - Made a structural revision: replaced fixed TP with an opposite-channel exit; tested disabling the EMA filter and ADX thresholds of 20/25/30/35.
  - Performed out-of-sample testing on 2023–2024 and full-window testing on 2023–2026 using two tick models.
  - Aligned the EA's default parameters with the configuration studied.
- Files changed: `MQL5/Experts/S1_TrendBreakout.mq5` (created)
- Errors and fixes: (1) The initial S1 with a fixed 3×ATR TP, EMA200 filter, and ADX 20 lost money on every timeframe (M5 −2790, M15 −1872, M30 −968, H1 −335, with a 3,000 deposit). (2) The hypothesis that the fixed TP was cutting profits short was tested by replacing it with an exit at the opposite Donchian channel (10); H1 improved to −233. (3) The EMA200 filter was found to be detrimental: disabling it produced −43 on H1 (PF 0.98). (4) Raising ADX to 30 produced +434 (PF 1.32) in 2025–2026, but the same configuration lost −289 (PF 0.84) out of sample in 2023–2024 — evidence of period-specific overfitting. (5) Tool limitations: multiline search in `replace_text_in_file` fails because of CRLF line endings, and simultaneous edits to the same file cause write races; edits were therefore made one line at a time, sequentially.
- Verification: `S1_TrendBreakout.mq5` was compiled four times, with 0 errors and 0 warnings each time. Tester runs (GBPJPY, USD 3,000 deposit, 1:100 leverage): M5/M15/M30/H1 with defaults; H1 with channel exit; H1 without EMA at ADX 20/25/30/35; M30 at ADX 30; H1 2023–2024 (out of sample) at ADX 30; H1 2023–2026 at ADX 25 using `open prices` and `m1 ohlc` models (closely matching results: −138.10 and −138.91). The final check of the defaults matched the last run (−138.10).
- Outcome: Selected timeframe: H1 (the only one with substantially better metrics: PF 0.97 versus 0.75–0.80 on M5–M30). Final configuration: channel 20, ADX(14) ≥ 25, no EMA filter, SL 2×ATR, no TP, exit at the opposite channel 10. Result for 2023–2026: −138.10 USD (−4.6%), PF 0.9659, 24.7% drawdown, 584 trades, negative recovery factor. Conclusion: S1 in its current form has no confirmed statistical edge on GBPJPY; the PF 1.32 configuration failed out-of-sample validation. The strategy was retained as a portfolio component but is not ready for live trading.
- Status: DONE

---

### Stage 5. S2 (mean reversion) specification and rationale for choosing EURGBP

- Start: 2026-11-05 17:06:53 (UTC+02:00)
- End: 2026-11-05 17:07:49 (UTC+02:00)
- Duration: 0 min 56 sec (total elapsed time; includes compiling and running a diagnostic script)
- Objective: Define the S2 trading idea and quantitatively justify EURGBP as an instrument for a countertrend strategy.
- User request: Review strategy S2 and justify the choice of EURGBP.
- Actions:
  - Prepared a diagnostic script to measure market regimes (ADX, return autocorrelation, variance ratio, efficiency ratio, ATR).
  - Compiled and ran the script for four symbols on H1/10000 bars.
  - Defined the S2 specification: z-score deviation from the mean, no-trend filter, target at the mean, ATR-based stop, and a holding-time limit.
  - Compared EURGBP, GBPJPY, USDCAD, and EURUSD using regime metrics; quantitatively justified choosing EURGBP.
- Files changed: `MQL5/Scripts/DevTools/RegimeStatistics.mq5` (created)
- Errors and fixes: The initial run through `chart_add_script` was rejected: input parameter values contained commas, while the parameter list itself is comma-delimited. Fix: changed the symbol-list separator to `;`, recompiled the script, and ran it without overriding the parameters.
- Verification: `RegimeStatistics.mq5` compiled with 0 errors and 0 warnings. The script ran on H1, 10,000 bars, 4 symbols; the result was read from the Experts log.
- Outcome: Regime metrics measured on H1/10000 bars. EURGBP: average ADX 29.13, share of bars with ADX<20 23.3%, return autocorrelation −0.0295, VR2 0.971, VR5 0.931, VR10 0.911, efficiency ratio 0.3073, ATR 56.8 points (0.0682% of price), spread 2 points. GBPJPY: 29.76 / 19.3% / −0.0300 / 0.970 / 0.947 / 0.923 / 0.3201 / 258.4 / 0.1214% / 6. USDCAD: 30.37 / 17.2% / −0.0435 / 0.957 / 0.916 / 0.918 / 0.3224 / 115.8 / 0.0829% / 1. EURUSD: 29.96 / 19.5% / −0.0126 / 0.988 / 0.958 / 0.963 / 0.3272 / 121.7 / 0.1085% / 1. EURGBP has the highest share of range-bound conditions, the lowest efficiency ratio, and the lowest VR10, making it the best fit for countertrend logic; the trade-off is the worst spread-to-ATR ratio (3.5% versus 0.9% for USDCAD).
- Status: DONE

---

### Stage 6. Implementing strategy S2 on EURGBP

- Start: 2026-11-06 17:59:20 (UTC+02:00)
- End: —
- Duration: —
- Objective: Implement S2 (z-score mean reversion) as a standalone EA on EURGBP and test it across timeframes.
- User request: Create an EA based on S2 and test it on different timeframes.
- Actions:
  - Created EA source `S2_MeanReversion.mq5`: Bollinger Band z-score, ADX filter, target at the mean, ATR-based stop, holding-time limit, and minimum target distance relative to the spread.
  - Attempted to compile it.
- Files changed: `MQL5/Experts/S2_MeanReversion.mq5` (created)
- Errors and fixes: Blocking environment issue. The metaeditor5 MCP server did not expose its tools in the current session: `metaeditor5__get_workspace_info` and `metaeditor5__compile_file` returned "tool is not available". A delegated subagent with the metaeditor5 extension also could not access these tools. Compilation, and therefore Strategy Tester runs, could not proceed until access was restored.
- Verification: Source file confirmed on disk (`MQL5/Experts/S2_MeanReversion.mq5`, 11,262 bytes). No `.ex5` file was present.
- Outcome (attempt 1): Source code ready; compilation and backtests not performed.

#### Stage 6. Retrying compilation (user request: "Try again")

- Start: 2026-11-06 18:02:00 (UTC+02:00)
- End: 2026-11-06 18:04:11 (UTC+02:00)
- Duration: 2 min 11 sec (total elapsed time; waiting for tool responses)
- Objective: Retry compilation of `S2_MeanReversion.mq5` and, if successful, launch backtests on M5/M15/M30/H1.
- Actions:
  - Rechecked the environment via MetaTrader MCP (`get_workspace_info`): MQL5 compiler build 6296 was reported as available (`can_compile_file: true`), and write access to `MQL5` was confirmed.
  - Checked the extension list: `metaeditor5` was enabled, but its tools had not been registered in the current session.
  - Searched for the compiled `S2_MeanReversion.ex5` in `MQL5/Experts` and in the terminal's list of available programs (filter `S2`, type expert).
  - Prepared Strategy Tester configurations for immediate execution once compilation became possible.
- Files changed:
  - `MQL5/Profiles/Tester/S2_EURGBP_M5.ini` (created)
  - `MQL5/Profiles/Tester/S2_EURGBP_M15.ini` (created)
  - `MQL5/Profiles/Tester/S2_EURGBP_M30.ini` (created)
  - `MQL5/Profiles/Tester/S2_EURGBP_H1.ini` (created)
  - `MQL5/Profiles/Tester/S2_EURGBP_H1_OOS.ini` (created)
  - `MQL5/Profiles/Tester/S2_EURGBP_H1_FULL.ini` (created)
- Errors and fixes: The issue remained unresolved. `metaeditor5__get_workspace_info` and `metaeditor5__compile_file` were absent from the session; an attempt with a delegated subagent also failed to provide compiler access. No workarounds were used: building outside MetaEditor through external processes was prohibited by the rules and was not attempted. Recommendation: restart the metaeditor5 MCP server (or the MetaEditor + MCP integration), or compile the file manually (F7 in MetaEditor); tester runs could then begin without further preparation.
- Verification: No `.ex5` was present in `MQL5/Experts`, and the S2 EA did not appear in the terminal's program list. Six tester configurations were created on disk (242–243 bytes each), matching the S1 configuration format: USD 3,000 deposit, 1:100 leverage, `open prices` model, period 2025.01.01–2026.10.01, out-of-sample 2023.01.01–2024.12.31.
- Outcome: Compilation could not be repeated because the compiler was unavailable in the session. The S2 testing infrastructure (six configurations) was prepared; a single compilation would unblock further work.
- Status: SUPERSEDED (attempt 2 closed; actual outcome documented in the subsection below)

#### Stage 6. Compilation and Strategy Tester runs (completion)

- Start: 2026-11-06 18:08:00 (UTC+02:00)
- End: 2026-11-06 18:09:13 (UTC+02:00)
- Duration: 1 min 13 sec (total elapsed time, 5 Strategy Tester runs)
- Objective: Confirm that the compiled EA is available after restarting MetaEditor/MCP, and complete the planned runs on M5/M15/M30/H1 plus an out-of-sample check.
- User request: "Check now — I've restarted it."
- Actions:
  - Rechecked `MQL5/Experts`: found `S2_MeanReversion.ex5` (45,014 bytes, build timestamp 2026-11-06 18:07:40), confirming that compilation had taken place after restarting MetaEditor.
  - Read EA metadata from `.ex5`: version 1.00, compiler build 6296, 19 parameters (15 inputs, 4 groups); defaults matched the specification (z-entry 2.0, ADX max 20.0, SL 2×ATR, time stop 24 bars).
  - Performed 5 tester runs using prepared configurations: USD 3,000 deposit, 1:100 leverage, `open prices` model, 0.5% per-trade risk, default parameters.
- Files changed: No source code changes; used `MQL5/Profiles/Tester/S2_EURGBP_M5.ini`, `S2_EURGBP_M15.ini`, `S2_EURGBP_M30.ini`, `S2_EURGBP_H1.ini`, `S2_EURGBP_H1_OOS.ini`, and `S2_EURGBP_H1_FULL.ini`.
- Errors and fixes: The environment blockage was resolved by restarting MetaEditor/MCP. Compiler output was still unavailable in the session (metaeditor5 tools had not been registered), so successful compilation was confirmed indirectly: `.ex5` had been created, and the terminal could read its metadata and run the EA in the Strategy Tester. Compiler warnings were not checked.
- Verification: EURGBP run results (0.5% risk per trade, default parameters):

| Timeframe | Period | Trades | Profit, USD | Profit Factor | Balance drawdown |
|---|---|---|---|---|---|
| M5 | 2025.01.01–2026.10.01 | 1157 | −2328.85 | 0.4196 | 77.82% |
| M15 | 2025.01.01–2026.10.01 | 412 | −694.27 | 0.7010 | 30.70% |
| M30 | 2025.01.01–2026.10.01 | 284 | −150.33 | 0.9119 | 12.08% |
| H1 | 2025.01.01–2026.10.01 | 170 | +88.79 | 1.0973 | 7.10% |
| H1 (out of sample) | 2023.01.01–2024.12.31 | 194 | −43.96 | 0.9624 | 5.08% |
| H1 (full window) | 2023.01.01–2026.10.01 | 367 | +52.10 | 1.0249 | 7.30% |

- Outcome: The only positive result for the recent test period was H1: +88.79 USD (+2.96%), PF 1.0973, 170 trades, 7.10% drawdown. The same configuration lost money out of sample in 2023–2024 (−43.96 USD, PF 0.9624); the combined 2023–2026 run was essentially flat (+52.10 USD, PF 1.0249, 367 trades). On M5/M15/M30, losses increased monotonically as the timeframe decreased (PF 0.42 / 0.70 / 0.91): costs and trading frequency erased the potential edge. Conclusion: S2's statistical edge was not confirmed; the key limiting factor is the spread-to-ATR ratio (3.5% on EURGBP, the worst of the three instruments according to Stage 5), so targets smaller than 0.5 ATR are not acceptable, and on lower timeframes the target becomes comparable to the spread. No parameter fitting was performed.
- Status: DONE


---

#### Stage 6. Extended S2 validation on USDCAD and GBPJPY

- Start: 2026-11-06 18:21:00 (UTC+02:00)
- End: 2026-11-06 18:22:19 (UTC+02:00)
- Duration: 1 min 19 sec (total elapsed time, 6 Strategy Tester runs)
- Objective: Distinguish a "bad idea" from a "bad instrument" by testing the same S2 logic with the same default parameters on the other two selected instruments (USDCAD and GBPJPY) on H1, including out-of-sample validation.
- User request: "Yes, check the other two symbols, USDCAD and GBPJPY."
- Actions:
  - Created six tester configurations: `S2_USDCAD_H1.ini`, `S2_USDCAD_H1_OOS.ini`, `S2_USDCAD_H1_FULL.ini`, `S2_GBPJPY_H1.ini`, `S2_GBPJPY_H1_OOS.ini`, `S2_GBPJPY_H1_FULL.ini` (USD 3,000 deposit, 1:100 leverage, `open prices` model, 0.5% risk, default EA parameters — no optimization).
  - Performed six runs: in-sample (2025.01.01–2026.10.01), out-of-sample (2023.01.01–2024.12.31), and full period (2023.01.01–2026.10.01) for each symbol.
- Files changed: `MQL5/Profiles/Tester/S2_USDCAD_H1*.ini`, `S2_GBPJPY_H1*.ini` (created). EA source code was unchanged.
- Errors and fixes: None; all runs completed normally and reports were obtained.
- Verification: Results across the three symbols, H1, identical parameters:

| Symbol | 2025–2026 | PF | 2023–2024 (OOS) | PF | 2023–2026 (full) | PF | Trades (full) | Drawdown (full) |
|---|---|---|---|---|---|---|---|---|
| EURGBP | +88.79 | 1.0973 | −43.96 | 0.9624 | +52.10 | 1.0249 | 367 | 7.30% |
| USDCAD | −67.65 | 0.9106 | +306.31 | 1.3261 | +249.30 | 1.1401 | 278 | 5.37% |
| GBPJPY | +107.37 | 1.1682 | −51.44 | 0.9345 | +58.51 | 1.0415 | 257 | 3.91% |

- Outcome: None of the three instruments was profitable in both periods: EURGBP was positive in the recent period and negative OOS, as was GBPJPY; USDCAD showed the reverse (negative recently, strongly positive OOS, PF 1.3261). The sign of the result reversed between periods on all three instruments, meaning that the positive full-window totals (+52.10 / +249.30 / +58.51, PF 1.02–1.14 over 257–367 trades) were statistically indistinguishable from zero and depended on the particular data window. The hypothesis that "the idea works but the instrument is wrong" was not supported; the main driver remained the period rather than the symbol. Conclusion: S2 in its current form was not included in the portfolio as a standalone strategy; parameters were not optimized or fitted.
- Status: DONE

---

### S2. Strategy rules (final specification and reason for rejection)

As decided by the user ("option 1"), S2 was closed as a standalone strategy, with a weight of 0 in the future portfolio.

- Instrument and timeframe: EURGBP, H1 (rationale: Stage 5, regime metrics: highest share of ADX<20, lowest efficiency ratio and VR10).
- Long entry: z = (Close[1] − BB_mid[1]) / σ ≤ −2.0; short entry: z ≥ +2.0. Here, σ = (BB_upper[1] − BB_mid[1]) / 2.0, using Bollinger Bands BB(20, 2.0) applied to Close.
- Regime filter: ADX(14)[1] < 20.0 — enter only when no trend is present.
- Target: BB middle line at the entry bar, with target distance no smaller than max(0.5×ATR(14), SYMBOL_TRADE_STOPS_LEVEL) — protection against targets comparable to the spread.
- Stop: 2.0×ATR(14) from entry price, normalized to tick size.
- Holding-time limit: forced close after 24 bars.
- Risk: 0.5% of equity per trade; lot size calculated from stop distance and rounded down to the volume step; Magic 20261106; deviation 20 points.
- Execution: closed-bar signal, no more than one entry per bar, checks for trading mode and stop/freeze levels.
- Reason for rejection (Stage 6 results):

| Test | Result | PF |
|---|---|---|
| EURGBP H1 2025–2026 | +88.79 USD | 1.0973 |
| EURGBP H1 2023–2024 (OOS) | −43.96 USD | 0.9624 |
| EURGBP H1 2023–2026 | +52.10 USD | 1.0249 |
| USDCAD H1 2025–2026 / OOS / full | −67.65 / +306.31 / +249.30 | 0.9106 / 1.3261 / 1.1401 |
| GBPJPY H1 2025–2026 / OOS / full | +107.37 / −51.44 / +58.51 | 1.1682 / 0.9345 / 1.0415 |
| EURGBP M5 / M15 / M30 (2025–2026) | −2328.85 / −694.27 / −150.33 | 0.4196 / 0.7010 / 0.9119 |

The sign of the profit changes with the testing period on all three instruments; none is profitable in both periods. Full-window runs (PF 1.02–1.14 over 257–367 trades) are statistically indistinguishable from zero. On M5–M30 there is no edge at all, confirming that costs dominate the expected reversion. Parameters were not fitted, and no attempt was made to "pick a favorable period."

---

### Stage 7. S6: Relative value — addressing the uncorrelated-triple problem

- Start: 2026-11-06 18:27:00 (UTC+02:00)
- End: 2026-11-06 18:45:54 (UTC+02:00)
- Duration: 18 min 54 sec (total elapsed time; includes compilation, 4 script runs, and historical-data downloads)
- Objective: Determine which instruments could support S6 (relative value / spread reversion), since the selected EURGBP–USDCAD–GBPJPY triple was deliberately uncorrelated and therefore unsuitable for S6; then prepare a specification and an EA.
- User request: "Okay, option 1. And continue with Stage 7 as planned"; then "The script has been compiled, continue."
- Actions:
  - Closed S2 (option 1: portfolio weight 0; its rules and reason for rejection are documented above under "S2. Strategy rules").
  - For S6, selected the approach of "adding a correlated pair as a separate portfolio instrument" rather than building a synthetic spread within one symbol: a pair produces two actual orders in a hedging account and can be tested in the Strategy Tester.
  - Created diagnostic script `SpreadScreening.mq5`: for each pair, it calculates correlation of log returns (full sample and two halves to assess relationship stability), OLS beta, the log spread of the hedged relationship, AR(1) persistence and half-life, the share of bars outside |z|≥2, average spread reversion after 1/3/5/10/20 bars following an event, two-leg trading costs in log terms, and their ratio to spread standard deviation.
  - Screening candidates: EURUSD/GBPUSD (correlation 0.809 from Stage 3), AUDUSD/NZDUSD (0.872), EURUSD/USDCHF (−0.829), EURJPY/GBPJPY (0.841), EURGBP/EURCHF.
  - Compiled the script (0 errors, 0 warnings) and ran it on H4 (5,000 bars), H1 (5,000 bars), and D1 (2,000 bars) for EURUSD/GBPUSD, AUDUSD/NZDUSD, EURUSD/USDCHF, EURJPY/GBPJPY, and EURGBP/EURCHF; daily history for some symbols was preloaded by requesting D1 bars.
- Files changed: `MQL5/Scripts/DevTools/SpreadScreening.mq5` (created, version 1.10 after fixes), `MQL5/Scripts/DevTools/SpreadScreening.ex5` (compiled).
- Errors and fixes: (1) In version 1.00, the reversion metric was calculated as a sum without dividing by the observation count and included every bar within an episode rather than only a fresh threshold crossing. `rev10`/`rev20` reached −13 standard deviations and were meaningless. Fix: introduced per-horizon counters, averaging, and counting only new threshold crossings. (2) Used `MathSign`, which does not exist in MQL5: `undeclared identifier 'MathSign'`; replaced it with the explicit conditional `((z > 0.0) ? -1.0 : 1.0)`. (3) The `beta <= 0.05` check rejected inversely correlated pairs; replaced it with an absolute-beta check. (4) D1 history was missing for USDCHF, EURJPY, EURGBP, EURCHF, and NZDUSD, causing `CopyClose` to return −1; measurements succeeded after loading daily bars. (5) Technical incident: overwriting `SpreadScreening.mq5` with version 1.10 erased the user's manual edit (the same `MathSign` replacement), causing the syntax check to fail again; the fix was restored and recorded in the code.
- Verification: `SpreadScreening.mq5` compiled with 0 errors and 0 warnings (compiler build 6296, AVX2). Measurement results:

| Pair | TF | corr (full / older half / newer half) | β | φ | Half-life, bars | rev20, sd |
|---|---|---|---|---|---|---|
| EURUSD/GBPUSD | H4 | 0.803 / 0.809 / 0.797 | 0.780 | 0.9987 | 521 | 0.31 |
| AUDUSD/NZDUSD | H4 | 0.872 / 0.890 / 0.854 | 0.859 | 1.0000 | nonstationary | 0.15 |
| EURUSD/USDCHF | H4 | −0.746 / −0.675 / −0.812 | −0.668 | 0.9952 | 146 | 0.52 |
| EURJPY/GBPJPY | H4 | 0.874 / 0.901 / 0.823 | 0.825 | 0.9987 | 536 | 0.30 |
| EURGBP/EURCHF | H4 | 0.118 / 0.158 / 0.073 | 0.099 | 0.9979 | 336 | 0.37 |
| EURUSD/GBPUSD | H1 | 0.839 / 0.849 / 0.827 | 0.769 | 1.0001 | nonstationary | 0.18 |
| AUDUSD/NZDUSD | H1 | 0.843 / 0.889 / 0.763 | 0.839 | 0.9985 | 462 | 0.23 |
| EURUSD/USDCHF | H1 | −0.804 / −0.822 / −0.780 | −0.650 | 0.9989 | 628 | 0.29 |
| EURJPY/GBPJPY | H1 | 0.876 / 0.851 / 0.904 | 0.823 | 1.0000 | nonstationary | 0.20 |
| EURUSD/GBPUSD | D1 | 0.711 / 0.656 / 0.807 | 0.590 | 0.9935 | 106 | 0.66 |
| EURUSD/USDCHF | D1 | −0.777 / −0.769 / −0.788 | −0.723 | 0.9982 | 391 | 0.29 |
| EURJPY/GBPJPY | D1 | 0.773 / 0.690 / 0.873 | 0.674 | 0.9972 | 243 | 0.35 |
| AUDUSD/NZDUSD | D1 | 0.883 / 0.898 / 0.865 | 0.884 | 0.9989 | 604 | 0.47 |

Two-leg costs are negligible relative to spread dispersion (`cost_to_sd` ≤ 0.003): the limiting factor is not cost but the absence of mean reversion.
- Outcome: None of the pairs met the prespecified selection criteria (stable correlation in both halves, 5–50-bar half-life, `cost_to_sd` < 0.25). On H1 and H4, the AR(1) coefficient ranged from 0.9985 to 1.0001: the hedged log spread behaved like a random walk, with half-life ranging from 146 bars to "nonstationary". On D1, some reversion appeared (half-life 106–604 days, average reversion 0.29–0.66 sd over 20 days), but this would require holding positions for weeks or months, beyond the agreed M5–H1 project range. Relationship stability on daily data was also low (EURUSD/GBPUSD: 0.656 in the older half versus 0.807 in the newer half). Conclusion: S6 as an intraday z-score relative-value strategy had no statistical basis; no S6 EA was created because no pair passed screening. Whether to replace the S6 concept or move it to a daily horizon was left for discussion.
- Status: DONE

---

### Stage 9. The EA as a framework without claims of profitability

- Start: 2026-11-09 ≈13:20 (UTC+02:00) — exact time of the first action was not recorded (the tool session was interrupted and context was restored); the first recorded file edit was `Include/Portfolio/PortfolioCore.mqh` at 13:34:43
- End: 2026-11-09 13:45:18 (UTC+02:00)
- Duration: ≈ 25 min (estimated from 13:20–13:45:18; 4 Strategy Tester runs, 1 compilation)
- Objective: Following the user's decision, freeze the working configuration, acknowledge the current results, stop searching for an edge, and bring the EA to the state of a framework without any claim of profitability.
- User request: "Regarding your remaining questions: 1. Freeze it. 2. Acknowledge the current result. 3. Don't look for an edge anymore. 4. Finish the EA as a framework without claims of profitability."
- Actions:
  - Updated `Experts/Portfolio_MultiStrategy.mq5` to version 1.10. Added the status `STATUS: RISK FRAMEWORK, NOT A PROFITABLE SYSTEM` to the file header, with actual module results (S1 −138.10 USD on GBPJPY in 2023–2026; S2 −43.96 USD out of sample; S6 showing no intraday spread reversion, AR(1) 0.9985–1.0001 on H1/H4) and an explicit statement that profitability is not guaranteed.
  - Froze defaults: `InpS1Enabled=true`, `InpS1Symbols=GBPJPY`, `InpS1RiskPercent=0.35`; `InpS2Enabled=true`, `InpS2Symbols=EURGBP`, `InpS2RiskPercent=0.35`; `InpS6Enabled=false`, `InpS6RiskPercent=0.35`.
  - Added new inputs: `InpMaxRiskOvershoot=3.0` (maximum minimum-lot overshoot relative to risk budget), `InpSymbolRiskPct=2.0` (open risk limit per symbol), `InpMaxDrawdownPct=20.0` (de-risking threshold based on equity drawdown).
  - Added `LotRiskMoney()` (monetary risk for a lot size given stop distance) and `LotFromRiskWithFloor()` to `Include/Portfolio/PortfolioCore.mqh` — risk-based lot sizing that permits the minimum lot only when the overshoot does not exceed `maxOvershoot`, otherwise rejects the setup. Added fields `m_symbolRiskPct`, `m_maxDrawdownPct`, `m_equityPeak`; methods `UpdateEquityPeak()`, `EquityDrawdownPct()`; a drawdown check at the start of `CanOpen()`; the per-symbol limit now uses `m_symbolRiskPct` rather than `m_totalRiskPct`; extended `Init()` with `symbolRiskPct` and `maxDrawdownPct` parameters.
  - Added `StratIdFromMagic()` (replacing magic-number arithmetic) and `OvershootLimit()` to the EA; switched lot sizing in `TryEnter()` and `ProcessPair()` to `LotFromRiskWithFloor()`, with explicit setup skipping and log messages when the minimum lot exceeds the risk budget by more than 3×.
  - Removed automatic upward adjustment of S6 lot sizes to the minimum: the pair is skipped instead of being resized. S6 symbols are no longer added to the trading universe when S6 is disabled (`for(int i = 0; i < (InpS6Enabled ? 2 : 0); i++)`).
  - Added startup `Print` messages describing FRAMEWORK mode, limits, and module results, as well as the risk-layer report `g_risk.Report()` in `OnDeinit`.
  - Created frozen reference parameter set `Profiles/Tester/PORT_frozen.set` (4,316 bytes) from the EA's new defaults.
- Files changed: `MQL5/Experts/Portfolio_MultiStrategy.mq5` (version 1.10), `MQL5/Include/Portfolio/PortfolioCore.mqh` (risk layer), `MQL5/Profiles/Tester/PORT_frozen.set` (created), `MQL5/DEVELOPMENT_LOG.md`
- Errors and fixes:
  1. `replace_text_in_file` failed on multiline searches (CRLF): `changed: false, replacements: 0`. Edits were performed one line at a time using single-line anchors.
  2. A call with identical `search` and `replace` values was rejected by the tool (`search and replace text are identical`) — replacement expressions were reformulated.
  3. An attempt to replace the entire header comment block (5 lines) returned `changed: false` — the comments were replaced line by line.
  4. Edits in `ProcessPair()` left blank lines and extra closing braces — the block was cleaned up through six single-line replacements.
  5. An orphaned `Print` fragment remained in `OnInit` (`"out of sample;"),` and `"standalone backtests showed no confirmed edge.");`) — corrected with two replacements into one valid line.
  6. A run without `inputs_path` loaded the last-used `.set` (`PORT_S2only.set`) and returned exactly +35.22 USD / 367 trades — `PORT_frozen.set` had to be generated and the test rerun.
  7. `tester_run_backtest` with `wait=true` returned `timed_out: true` even though the run continued; completion was awaited separately using `tester_wait`.
  8. A tester log discrepancy was resolved: the line `S1=GBPJPY 0.50%` (13:38:50) belonged to the previous run with `PORT_tight` (0.50%), not to the frozen reference configuration; the run with `PORT_frozen.set` (13:39:16) printed `S1=GBPJPY 0.35%`. The parameter set was applied correctly, which was confirmed by a repeated run.
- Verification:
  - `Portfolio_MultiStrategy.mq5` compilation: `Compilation succeeded: 0 errors, 0 warnings found` (733 ms, `AVX2 + FMA3`), `.ex5` 82,616 bytes.
  - Tester startup log lines confirmed: `Portfolio: started in FRAMEWORK mode (no confirmed edge). S1=GBPJPY 0.35% S2=EURGBP 0.35% S6 EURUSD/GBPUSD PERIOD_D1 z_entry=2.00 z_exit=0.30`, `Portfolio: limits symbol=2.00% cluster=1.50% total=3.00% gross=300% margin>=300% drawdown stop=20.0% floor-lot overshoot<=3.0x`, a warning that no edge had been confirmed; `OnDeinit` — `Portfolio: stopped, reason=1 | risk: open=0.00 (0.0%), gross=0 (0%), margin=0%`.
  - Full window 2023.01.01–2026.10.01 (Model=1, 23,275 bars, 5,550,404 ticks) with `PORT_frozen.set`: profit +76.15 USD, gross profit 4,177.67, gross loss 4,101.52, PF 1.0186, 947 trades (1,894 deals, 409 winning / 538 losing), balance drawdown 484.53 (15.03%), equity drawdown 15.62%, expected payoff 0.08, recovery factor 0.1503, Sharpe 0.1292, margin level 1,140.73%.
  - Out of sample 2023.01.01–2024.12.31 (Model=1, 12,407 bars, 2,955,749 ticks) with `PORT_frozen.set`: profit −107.04 USD, PF 0.9545, 512 trades (1,024 deals, 215 winning / 297 losing), balance drawdown 10.43%, equity drawdown 11.02%, expected payoff −0.21, Sharpe −0.3422, margin level 1,587.94%.
- Outcome:
  - The new safeguards did not materially change the result: full-window profit +76.15 USD versus the previous +78.70 USD (S1+S2 at 0.35/0.35 without the new limits), PF 1.0186 versus 1.0192, 947 trades versus 942. Out-of-sample performance was −107.04 USD versus −92.48 USD (worse by 14.56 USD due to three additional trades permitted by the minimum-lot rule).
  - The limits were not binding: neither the 2% per-symbol limit nor the 20% de-risking threshold was ever triggered; margin level was 1,140–1,588% against a 300% threshold. The only binding constraint was the minimum lot, which is now limited by the permitted overshoot rather than being silently rounded up.
  - The framework is frozen: the working configuration is S1 0.35% GBPJPY H1, S2 0.35% EURGBP H1, with S6 disabled. The risk-layer defects (incorrect per-symbol limit, unlimited upward lot adjustment, and missing de-risking) have been fixed. No edge has been confirmed, and that fact is stated in the source code, startup log messages, and report.
- Status: DONE (framework frozen; profitability has not been confirmed and is not promised)

---

## Stage entry template (for future entries)

### Stage 8. Multi-symbol, multi-strategy EA (S1 + S2 + S6 assumed profitable)

- Start: 2026-11-06 (exact time of the first action was not recorded — the tool session was interrupted; the first confirmed stage event was a compilation and tester run at 18:52)
- End: 2026-11-06 19:05 (UTC+02:00)
- Duration: at least 45 min of measured active time (the 18:52–19:05 interval plus work before the session interruption)
- Objective: Build the portfolio framework by assuming S1, S2, and S6 are profitable, integrating all three modules in one EA with a shared risk layer, correlation constraints, and exposure limits.
- User request: "Include S1, S2, and S6 in development as if they were profitable, and continue building the multi-symbol EA."
- Actions:
  - Created the risk layer and portfolio utilities in `Include/Portfolio/PortfolioCore.mqh`: `ENUM_STRAT_ID` (`STRAT_S1=0`, `STRAT_S2=1`, `STRAT_S6=2`), price/lot normalization, `LotFromRisk`, `PositionRiskMoney`, `MinStopDistance`, `TradingAllowed`, `SymbolTradeable`, `IsNewBar`, and the `CPortfolioRisk` class (rolling H1 correlation over 120 bars, clusters at |corr| ≥ 0.60, limits: per symbol, cluster 1.5%, portfolio 3%, gross notional 300% of equity, minimum margin level 300%).
  - Created the strategy layer in `Include/Portfolio/PortfolioStrategies.mqh`: `CStrategyBase`, `CStrategyBreakout` (S1: channel 20, channel exit 10, ADX ≥ 25, SL 2×ATR), `CStrategyMeanReversion` (S2: BB(20,2), z ≥ 2, ADX < 20, target at mean, SL 2×ATR, time stop 24 bars), `CStrategyPairValue` (S6: spread ln A − β ln B, beta window 200, z window 60, z-entry 2.0, z-exit 0.3, z-stop 3.5, SL 3×ATR per leg, time stop 40 bars, D1).
  - Created `Experts/Portfolio_MultiStrategy.mq5`: grouped inputs (Portfolio, S1 Breakout, S2 Mean Reversion, S6 Pair Value, Portfolio limits), magic-number scheme `InpMagicBase + strategy_id*1000 + symbol_slot`, timer-based polling through `InpPollSeconds`, processing of modules and paired legs with orphan-leg checks.
  - Created Strategy Tester configurations: `Profiles/Tester/PORT_GBPJPY_H1.ini` (Model=2, open prices), `PORT_GBPJPY_H1_M1.ini` (Model=1, 1 min OHLC), and parameter sets `PORT_noS6.set`, `PORT_all.set`.
  - Ran a series of backtests and diagnosed issues using Strategy Tester logs.
- Files changed: `MQL5/Include/Portfolio/PortfolioCore.mqh` (created), `MQL5/Include/Portfolio/PortfolioStrategies.mqh` (created, then edited twice), `MQL5/Experts/Portfolio_MultiStrategy.mq5` (created, then edited), `MQL5/Profiles/Tester/*.ini`, `MQL5/Profiles/Tester/*.set`, `MQL5/DEVELOPMENT_LOG.md`
- Errors and fixes:
  1. Compilation #1: `5 errors, 5 warnings` — `SYMBOL_TRADE_DISABLED` (does not exist) → `SYMBOL_TRADE_MODE_DISABLED`; `double base = SymbolInfoDouble(..., SYMBOL_CURRENCY_BASE)` → `string base = SymbolInfoString(...)`; `ArrayInitialize` is not supported for dynamic `string`/`datetime` arrays in MQL5 → removed these calls.
  2. Compilation #2: `2 errors, 4 warnings` — some `ArrayInitialize` calls remained; implicit `double`↔`string` conversions in `volumeNotional()` → changed local variable types to `string`.
  3. Compilation #3: successful, 0 errors, 0 warnings.
  4. Tester run with S6 enabled failed without producing results: `generated_bars: 0`, `error_id: 5570642`, `error_text: "EURUSD,H1"`. Cause: `g_risk.UpdateCorrelation(true)` in `OnInit` called `CopyClose` for S6 symbols before external-symbol history had synchronized. Solution: populate the correlation matrix lazily in `OnTimer`.
  5. Incomplete edit in `CStrategyPairValue::Init`: a call to nonexistent `EnsureHandles()` was inserted instead of creating `iATR` handles, and an orphaned `{ Print(...); return false; }` block remained alongside it, preventing compilation. Solution: added the declaration and implementation of `EnsureHandles()` (lazy creation of `m_hATRA`/`m_hATRB` when `INVALID_HANDLE`), made `Atr()` retry handle creation, and converted the orphaned block into a valid check with a log warning.
  6. S6 generated signals but did not open trades: the log showed `S6 legs rejected, lot A=0.0 lot B=0.0`. Cause: with risk at 0.5% of equity and a 3×ATR stop on the daily timeframe, the calculated EURUSD/GBPUSD lot size was rounded down to zero (minimum 0.01). Solution: added `MinLotIfZero()` and input `InpAllowMinLot` (default `true`): each leg opens at the minimum lot with a log message, while limits are checked against actual risk through `PositionRiskMoney()`.
  7. The S6 run in `Model=2` (`open prices`) failed: `EURUSD,H1: wrong timeframe request in Open Prices testing mode`, `rates base receive error`. Cause: in open-prices mode, the tester does not supply history for external symbols on other timeframes (S6 uses D1). Solution: created `PORT_GBPJPY_H1_M1.ini` with `Model=1` (1 minute OHLC); the run completed successfully.
- Tester results (GBPJPY H1, 2025.01.01–2026.10.01, USD 3,000 deposit, 1:100 leverage):

| Configuration | Model | Profit, USD | PF | Trades | Drawdown (balance) |
|---|---|---|---|---|---|
| S1 + S2 (S6 disabled) | open prices | +223.93 | 1.0834 | 432 | 414.20 (13.18%) |
| S1 + S2 (S6 disabled) | 1 min OHLC | +223.70 | 1.0833 | 432 | 414.43 (13.19%) |
| S1 + S2 + S6 | 1 min OHLC | +205.69 | 1.0710 | 460 | 429.47 (13.68%) |

- Verification: `Portfolio_MultiStrategy.mq5` compiled with 0 errors and 0 warnings; the S6-enabled run completed in full (10,844 bars, 2,588,917 ticks). The log recorded eight S6 paired entries (2025.10.29, 2025.11.04, 2025.11.13, 2026.01.26, 2026.01.29, 2026.03.09, 2026.06.23, 2026.07.15) with magic numbers 20263107/20263108 and the minimum lot of 0.01 per leg.
- Outcome: The portfolio framework works end to end: three modules coexist on one account, and the risk layer calculates correlation clusters, aggregate risk, gross notional, and margin level; S6 opens actual hedged pairs in the tester for the first time. S6 contributed negatively in this run (−18.01 USD in profit, +28 legs), consistent with the previously documented lack of a confirmed edge on intraday horizons and expected when treating profitability as an assumption.
- Status: DONE (framework assembled); the modules were treated as profitable by assumption, not on the basis of confirmed statistical evidence.

---

#### Stage 8. Weight balancing, the 2023–2024 OOS run, and the S6 decision

- Start: 2026-11-09 11:23:00 (UTC+02:00)
- End: 2026-11-09 11:44:56 (UTC+02:00)
- Duration: 21 min 56 sec (total elapsed time, 10 Strategy Tester runs)
- Objective: Answer three questions — how to balance module weights and risk limits, what the 2023–2024 out-of-sample check shows, and what to do with S6 (daily horizon versus the agreed M5–H1 range).
- User request: "Perform all the necessary steps and give me a report on these three questions so I understand."
- Actions:
  - Created out-of-sample configuration `Profiles/Tester/PORT_OOS_2023_2024.ini` (Model=1, 2023.01.01–2024.12.31) and full-window configuration `Profiles/Tester/PORT_FULL_M1.ini` (Model=1, 2023.01.01–2026.10.01); both for GBPJPY H1, USD 3,000 deposit, 1:100 leverage.
  - Created parameter sets for balancing: `PORT_w035.set` (0.35/0.35/0.35), `PORT_mix.set` (S1 0.5 / S2 0.35 / S6 0.25), `PORT_tight.set` (risks 0.5, cluster 1.0%, portfolio 2.0%, gross notional 200%), `PORT_w035_noS6.set`, plus `PORT_S1only.set` and `PORT_S2only.set` to isolate individual strategy contributions.
  - Performed 10 tester runs: OOS 2023–2024 (with S6, without S6, S1 only, S2 only, 0.35 weights with and without S6), full window 2023–2026 (0.35 weights with and without S6, mixed weights, tighter limits, S1 only, S2 only), and 2025–2026 with 0.35 weights.
  - Checked the risk layer through tester logs: recorded blocks `Portfolio: S6 blocked on EURUSD: cluster cap` and skipped signals `Portfolio: lot is zero for GBPJPY`.
- Files changed: `MQL5/Profiles/Tester/PORT_OOS_2023_2024.ini`, `PORT_FULL_M1.ini`, `PORT_w035.set`, `PORT_mix.set`, `PORT_tight.set`, `PORT_w035_noS6.set`, `PORT_S1only.set`, `PORT_S2only.set` (created), `MQL5/DEVELOPMENT_LOG.md`.
- Errors and fixes:
  1. `tester_run_backtest` with `wait=true` returned `timed_out: true` although the run continued in the background; completion was awaited separately using `tester_wait` (10 sec for the full window — about 3 min). No workaround was needed; the tool's behavior was taken into account.
  2. Found a risk-modeling defect: the minimum lot of 0.01 for each S6 leg with a 3×ATR D1 stop resulted in an actual risk of 48.55 USD (1.6% of equity), which exceeded the cluster limit of 1.5% after equity drawdown (`43.46` at equity of 2897 USD). S6 was blocked, meaning `InpS6RiskPercent` did not actually control S6 risk on a USD 3,000 deposit.
  3. A side effect of the same constraint: S1 periodically skipped signals with the log entry `lot is zero for GBPJPY risk=10.19` — the calculated lot size at 0.35% risk was below the minimum; minimum-lot substitution had been implemented only for S6 paired legs.
- Verification: All 10 runs completed normally and produced reports. Full window 2023.01.01–2026.10.01 (23,275 bars, 5,550,404 ticks):

| Configuration | Profit, USD | PF | Trades | Drawdown (balance) | Sharpe |
|---|---|---|---|---|---|
| S1 0.35% only | +30.13 | 1.0112 | 575 | 14.28% | 0.06 |
| S2 0.35% only | +35.22 | 1.0252 | 367 | 5.02% | 0.31 |
| S1+S2 (0.35/0.35) | +78.70 | 1.0192 | 942 | 14.84% | 0.13 |
| S1+S2+S6 (0.35/0.35/0.35) | +90.77 | 1.0203 | 990 | 14.74% | 0.14 |
| S1 0.5 / S2 0.35 / S6 0.25 | +17.64 | 1.0030 | 993 | 21.74% | 0.02 |
| 0.5/0.5/0.5 (baseline) | +30.59 | 1.0047 | 993 | 22.80% | 0.03 |
| 0.5/0.5/0.5, limits 1.0/2.0/200 | +32.51 | 1.0051 | 985 | 22.69% | 0.04 |
| 0.5/0.5/0.5 without S6 | +18.52 | 1.0031 | 946 | 22.98% | 0.02 |

Out-of-sample window 2023.01.01–2024.12.31 (12,407 bars, 2,955,749 ticks, same conditions):

| Configuration | Profit, USD | PF | Trades | Drawdown (balance) | Sharpe |
|---|---|---|---|---|---|
| S1 0.35% only | −44.26 | 0.9706 | 315 | 9.79% | −0.16 |
| S2 0.35% only | −47.62 | 0.9397 | 194 | 3.79% | −0.77 |
| S1+S2 (0.35/0.35) | −92.48 | 0.9603 | 509 | 10.06% | −0.30 |
| S1+S2+S6 (0.35/0.35/0.35) | −56.21 | 0.9771 | 529 | 9.21% | −0.17 |
| 0.5/0.5/0.5 (baseline) | −133.77 | 0.9632 | 530 | 14.86% | −0.28 |
| 0.5/0.5/0.5 without S6 | −178.49 | 0.9492 | 511 | 15.87% | −0.40 |

2025.01.01–2026.10.01 window (10,844 bars): 0.35 weights — +115.47 USD, PF 1.0570, 458 trades, 9.99% drawdown; 0.5 weights (baseline) — +205.69 USD, PF 1.0710, 460 trades, 13.68% drawdown.

- Outcome: (1) Weights and limits were not the primary drivers of results: all variants had PF 1.003–1.026 over 985–993 trades, and the variation in profit (+17.64 … +90.77 USD) was smaller than one average portfolio loss. Tightening limits (cluster 1.0%, portfolio 2.0%, gross 200%) barely changed the result (+32.51 versus +30.59): these limits were not binding because actual position sizes were small, with margin level 780–1,170% against a 300% threshold and gross notional never reaching 300% of equity. The only binding constraint was the minimum lot: it turned S6 into a fixed 1.6% risk instead of the specified 0.35–0.5%, and sometimes prevented S1 from entering trades altogether. (2) Both active modules lost money OOS in 2023–2024 (S1 −44.26, S2 −47.62 USD, PF 0.97 and 0.94), so all full-window profits came from 2025–2026: the assumed profitability of S1 and S2 was not confirmed. (3) S6 changed sign across periods: +36…+45 USD in 2023–2024, −18 USD in 2025–2026, +12 USD over the full window. On a USD 3,000 deposit, its weight cannot be scaled (always the minimum lot of 0.01 per leg), and its holding horizon (half-life 106–604 days) exceeds the agreed M5–H1 scope.
- Status: DONE (analysis and report delivered; portfolio-composition decision left to the user)

---

### Stage N. Title

- Start:
- End:
- Duration:
- Objective:
- User request: brief description
- Actions:
- Files changed:
- Errors and fixes:
- Verification:
- Outcome:
- Status: DONE / IN PROGRESS / FAILED
