ARIMA_SAX_Hybrid_Forecaster/results/MALE5-ML/MALE5_ML_PROTOCOL.md

17 KiB

MALE5-ML — MULTIVARIATE MALE5 CLASSIFIER RESEARCH PROTOCOL (DESIGN)

Research family: MALE5-ML Protocol version: male5-ml-v0.1.0-frozen Status: DESIGN FROZEN — EXECUTION NOT AUTHORIZED. Project: ARIMA_SAX_Hybrid_Forecaster Project workspace (authoritative): D:\TradingTerminal\MetaTrader 5\MQL5\Shared Projects\ARIMA_SAX_Hybrid_Forecaster Project remote: https://forge.mql5.io/chiki2bum2/ARIMA_SAX_Hybrid_Forecaster.git

This document is a design artifact only for the new, independent MALE5-ML research family. It finalizes the research protocol design and records every reproducibility field. It does not execute any model, produce any prediction/experiment artifact, run a backtest, perform an OOS evaluation, or tune any parameter.

R1-R (CLOSED / IMMUTABLE) and R2-H (EXECUTED / NULL) are not reopened, re-analysed, or amended. R1-R and R2-H origin/protocol/manifest artifacts are referenced only as immutable inputs, never modified or regenerated.


1. Governance status

  • Dependency finalization: COMPLETE (see MALE5_v3.2.0_CANONICAL_DEPENDENCY_FINALIZATION.md).
  • This session: final protocol design only.
  • The required next governance gate is FORMAL DESIGN FREEZE (owner authorized), followed by a separate EXECUTION AUTHORIZATION gate before any execution.
  • Git rule: the agent does not auto-commit or push. Design freeze/commit is a separate owner instruction.

2. Exact dependency identity (frozen input)

field value
upstream URL https://github.com/MegaJoctan/MALE5
canonical tag v3.2.0
exact commit d6fb0695a7c2fbeaa03de379557a8b5447915384
archive SHA-256 ad161d75ae0b54ee54a1fd3b0d48c315cf776eebc97077a4b1ae7a629f0c0d4d
canonical local path D:\TradingTerminal\MetaTrader 5\MQL5\Include\MALE5
compile smoke 0 errors / 0 warnings (build 6140, AVX512)
predict_proba UNSUPPORTED (confirmed absent in all v3.2.0 .mqh)

Policy:

  • Use ONLY MALE5 v3.2.0 at the frozen commit.
  • Do not use v3.5.0. Do not use current MALE5 HEAD. Do not mix versions. Do not patch MALE5.
  • Because predict_proba is unsupported, MALE5-ML v0.1 is binary classification only.

3. Research question (final)

Can a fixed nonlinear multivariate MALE5 classifier extract out-of-sample directional information from XAUUSD (M1) that is not captured by Naive and Drift?

Scope notes:

  • Single fixed classifier (CRandomForestClassifier, frozen params).
  • No model comparison, no model search, no parameter search.
  • This is the first member (v0.1) of the independent MALE5-ML family.
  • Do not reopen R1-R or R2-H.

4. Primary horizon

  • H60 = 60 elapsed minutes (elapsed-time horizon, not bar count).
  • OOS origins: reuse frozen results/R2-H/origins_H060.csv.
    • Do not regenerate, do not modify.
    • Frozen provenance (R2-H screen): 3,169 origins; SHA-256 e7b5132c321f5350ec1e231d49d68dbc29468cdf9ee6a5014a2764aaf36eb9af.

5. Data provenance

  • Source: results/R1_real_data/XAUUSDc_M1_raw.json
    • M1, broker symbol XAUUSDc (Gold Spot Cent), 397,558 bars, 2025-06-02 01:00 → 2026-08-24 15:19 (server trade time).
    • Source SHA-256 (fresh R2-H provenance, reused as frozen input identity): 5472357e67f70f7d1bfef8f9de67fcce91ee6f26208072d7a6766b06c158ee6e.
  • Source CSV (derived, M1): results/R1_real_data/XAUUSDc_M1.csv.
  • Tick data: D:\TradingTerminal\MetaTrader 5\MQL5\Files\XAUUSD_mt5_ticks.csv — NOT used for any feature in MALE5-ML v0.1 (no tick features).
  • At execution, the dataset and origin hashes must be re-verified: any mismatch = HARD STOP.

6. Target definition (frozen)

y(o) = 1  if  Close[t_end] >  Close[o]
       0  if  Close[t_end] <= Close[o]

t_end = first valid M1 bar at or after  timestamp(o) + 60 minutes
P(x)  = close price of M1 bar x
  • y(o) is the binary up/down label over the 60-minute elapsed horizon.
  • Strict inequality (>): a zero move (Close[t_end] == Close[o]) is class 0.
  • Boundary endpoint rule and gap rule mirror the frozen R2-H H60 origin rule (tolerance 5 minutes; any inter-bar delta > 5 min within (o, t_end] excludes the origin).

7. Feature set (frozen) — M1 only, close-based, causal, deterministic

No scaler. No global normalization. No full-dataset preprocessing. All features are computed using only bars ≤ origin (causal) and are deterministic functions of the M1 close series and bar timestamps. No tick features.

Notation: C[i] = close of M1 bar i; ATR20(i) = close-only deterministic ATR proxy = rolling mean of |C[k] − C[k−1]| over the trailing 20 M1 bars (matching the R2-H / src/forecasting/target.py rolling_atr definition with high/low absent — NOT a Wilder ATR). SMA20(i) = mean of C[i−19..i].

feat name definition
F1 short momentum (C[o] − C[o−5]) / C[o−5] (5-bar return)
F2 medium momentum (C[o] − C[o−15]) / C[o−15] (15-bar return)
F3 trend slope OLS slope of log(C) over trailing 30 M1 bars, scaled slope × 30 / ATR20(o) (dimensionless, ATR units)
F4 distance from SMA20 C[o] / SMA20(o) − 1
F5 recent range (max10(o) − min10(o)) / ATR20(o), max10/min10 over trailing 10 closes
F6 normalized volatility ATR20(o) / C[o]
F7 session phase hour_of_day(o) / 24.0 (from the M1 bar timestamp; deterministic, causal)

Max feature lookback = 30 bars (F3) / 20 bars (F4, F6) / 10 bars (F5) / 15 bars (F2). A single deterministic feature warmup W = 40 M1 bars covers all lookbacks plus an ATR buffer. Any origin with fewer than W prior M1 bars has its features treated as unavailable.


8. Model and exact parameters (frozen candidate)

  • Class: CRandomForestClassifier — MALE5 v3.2.0, MALE5\Ensemble\Random Forest.mqh.
  • API (confirmed v3.2.0): constructor CRandomForestClassifier(uint n_trees=100, uint minsplit=NULL, uint max_depth=NULL, int random_state=-1); only fit(...) and predict(...) (hard labels). No predict_proba.
  • Frozen parameter set (one, fixed before execution):
param value
n_trees 100
minsplit 2
max_depth 10
random_state 42
  • Unsupportable / prohibited: min_samples_leaf, criterion, predict_proba, n_jobs, any non-v3.2.0 parameter.
  • Do not tune. These are frozen unless a formal revision is authorized.

9. Training window — deterministic causal dense-M1 construction (frozen rule)

No fixed arbitrary N_train. For every OOS origin o, the training sample T(o) is constructed deterministically and causally as follows.

A training (origin) bar t is a valid training example for origin o iff all of the following hold:

  1. t >= W (feature warmup W = 40 M1 bars — all F1–F7 available at t).
  2. t ∉ L (L = the frozen OOS origin list; the OOS origins are reserved exclusively for evaluation and are never used as training inputs).
  3. Target endpoint t_end(t) resolves: there exists a first M1 bar with timestamp >= timestamp(t) + 60 min, and no inter-bar gap > 5 min within (t, t_end(t)] (frozen gap rule).
  4. t_end(t) < o (strictly: the training label resolves before timestamp(o)), so no training label ever crosses into the OOS evaluation period and no future information leaks. Equivalently t + 60 min < timestamp(o).

Then:

  • Feature matrix X(o) = rows [F1..F7] evaluated at each valid t.
  • Label vector y(o) = y(t) for each valid t (binary up/down over the resolved 60-min window).
  • All feature information is ≤ t; all label information is within (t, t+60] and strictly < o.
  • The classifier is refit from scratch at each OOS origin o on T(o) (pure deterministic causal expanding-window walk forward). No incremental tree reuse, no persistence across origins, no cross-origin state.
  • No shuffle, no random split, no future preprocessing.

Implementation note (execution-time, not a design change): per-origin refit over a growing dense sample is computationally heavy (≈3,169 fits with up to ≈400 k training rows × 100 trees). This does not alter the frozen design; if a future execution becomes infeasible, that is a new owner decision, not an improvised design change.


10. Preprocessing (frozen)

  • SCALER = OFF.
  • No global normalization, no full-dataset preprocessing, no feature scaling.
  • No unnecessary preprocessing degrees of freedom (tree models are scale-invariant for thresholds; F-values are already dimensionless or price-relative).

11. Baselines (frozen)

  1. Majority baseline (per-origin):
    • Majority label = modal class of the training labels y(o) of that origin's own causal training window T(o).
    • Tie-break (deterministic): if the counts of class 0 and class 1 are equal, predict class 0 (Down). Documented, frozen.
  2. Drift baseline (causal, fixed):
    • Existing DriftBaseline (src/baselines.py): linear slope over the last 40 closes projected H bars ahead.
    • Binary direction label: 1 if projected drift > 0, else 0. Causal, uses only bars ≤ origin.
  3. Naive baseline: zero-return forecast — used only as the classification reference and to frame the research question; Naive is not a competing binary classifier for the paired-error decision (predicts no change).

12. Metrics (frozen)

Primary (because predict_proba is unavailable — no Brier, no log-loss, no calibration, no synthetic probabilities):

  1. Balanced accuracy = mean of sensitivity (class-1 recall) and specificity (class-0 recall) over OOS origins. Reported with MBB 95% CI.
  2. Directional accuracy = fraction of OOS origins where MALE5 label equals the realized label. Reported with MBB 95% CI.
  3. Paired classification error vs Majority: d_maj(o) = err_majority(o) − err_male5(o) per origin (err = 1 − correct). Reported with MBB 95% CI; lower bound > 0 ⇒ MALE5 better than Majority.
  4. Paired classification error vs Drift: d_drift(o) = err_drift(o) − err_male5(o) per origin. Reported with MBB 95% CI; lower bound > 0 ⇒ MALE5 better than Drift.

Secondary (descriptive):

  • gross return/trade (sign-matched realized tau_H, ATR units);
  • net return/trade (= gross − cost_atr), ATR units;
  • gross/cost ratio;
  • cost/range ratio;
  • trade coverage (= n_traded / n_origins; 1.0 because the binary model always emits a direction);
  • time-normalized economics (per 60-min holding period);
  • EARLY / MIDDLE / LATE chronological descriptive results.

Gross and net are always reported separately.


13. Statistical inference (frozen)

  • Method: Moving Block Bootstrap (MBB) over the chronological OOS origin series.
  • Block length: B = 60 OOS origins (block unit = OOS evaluation points, each a distinct M1 elapsed origin).
  • Repetitions: 10,000.
  • Confidence: 95% percentile CI [2.5%, 97.5%].
  • Seed: 20260827 (independent seed for the MALE5-ML family).
  • Effective sample size: n_eff = floor(n_usable / B); with n_usable ≈ 3,169 OOS origins, n_eff ≈ 52. This is consistent with the R2-H H60 power profile (moderate effective sample). Low-power limitations are reported, never hidden.
  • Applied to: balanced accuracy, directional accuracy, and the two paired error differences, and (secondary) gross/net return per trade.
  • Coherence check (design): the paired error differences are defined per OOS origin on a common chronological series, so block resampling of the origin series with block length 60 is internally coherent and preserves chronological dependence. B, repetitions, and seed are fixed; they may not be modified after observing results.
  • No empirical tuning; no post-result changes.

14. Economic design (frozen)

  • Frozen project round-trip cost: 7.57 bps (median tick spread ≈ 1.57 bps
    • commission 6.00 bps; pre-registered global constant).
  • cost_atr(o) = (7.57 / 10000) × close(o) / ATR20(o).
  • Gross and net must remain separate.
  • Economic viability requires statistical predictive support (success criteria 1–4) PLUS positive net under the frozen cost.
  • Predictive but negative net ⇒ PREDICTIVE BUT NOT ECONOMICALLY VIABLE.
  • Sensitivity at 0.5× and 2× cost may be reported descriptively only; it cannot alter the primary decision.

15. Success criteria (frozen) — MALE5 primary success requires ALL

  1. Better than Majority: MBB 95% CI lower bound of d_maj (valid, majority-classified origins) > 0.
  2. Better than Drift: MBB 95% CI lower bound of d_drift > 0.
  3. Dependence-aware statistical support: the paired-error CIs in (1)–(2) are significant, and balanced accuracy / directional accuracy CIs are reported so the improvement is not an artifact of class imbalance or trend timing.
  4. No material reversal across EARLY / MIDDLE / LATE: in every chronological third, the point estimate of the advantage over both baselines is ≥ 0 (MALE5 never worse than the worse baseline in any segment, point estimate).
  5. Positive gross for any trading claim: if an economic claim is made, MBB 95% CI lower bound of gross return/trade > 0.
  6. Positive net for economic viability: MBB 95% CI lower bound of net return/trade (gross − cost_atr) > 0.

Do not use accuracy > 50% alone. All success conditions are frozen.


16. Hard-stop conditions (frozen)

STOP (no further design/execution) if any of the following:

  • MALE5 dependency identity cannot be confirmed (version/commit/SHA mismatch).
  • predict_proba or any non-v3.2.0 API is required.
  • Random Forest constructor parameters not supported by the frozen v3.2.0 API.
  • Frozen origin list (origins_H060.csv) is modified, regenerated, or its hash no longer verifies.
  • Source dataset hash no longer verifies.
  • No-lookahead failure (mutation testing on training/target construction; any feature or label uses future info relative to its origin).
  • Any attempt to tune model parameters, MBB parameters, seed, or cost from results.
  • Protocol contradiction or unresolved specification.
  • Any attempt to execute / backtest / forecast / tune before a separate EXECUTION AUTHORIZATION gate.
  • Accidental modification of R1-R or R2-H artifacts.

An unresolved scientific ambiguity is returned to the owner — it is not resolved by improvisation.


17. No-lookahead / forensic gates (frozen, to be run at execution)

gate item classification
F1 feature construction (F1–F7 causal) OBSERVED / DECISION
F2 target construction (y(o)) OBSERVED / DECISION
F3 ATR20 construction (close-only) OBSERVED / DECISION
F4 SMA20 / range / slope windows OBSERVED / DECISION
F5 training data boundary (t_end(t) < o, t ∉ L) OBSERVED / DECISION
F6 normalization / scaler (OFF) OBSERVED / DECISION
F7 horizon endpoint determination OBSERVED / DECISION
F8 cost information (7.57 bps) OBSERVED / DECISION
F9 tick-derived information (none used) OBSERVED / DECISION
  • Mutation testing: perturbing a future bar must not alter predictions at any tested OOS origin. Minimum spot checks: ≥ 3 origins.
  • Any no-lookahead failure = INVALID / HARD STOP.

18. Reproducibility manifest

The companion MALE5_ML_MANIFEST.json records (identically to §2–§17):

  • project identity/path; MALE5 upstream URL; tag; commit; archive SHA-256; canonical local path;
  • relevant source hashes (RF dependency closure per the canonical report);
  • source dataset + hash; OOS origin list + hash;
  • target; feature definitions; model + parameters; training-window rule; preprocessing; baselines; metrics; statistical method; seed; cost; success criteria; hard-stop conditions.

19. Required outputs and exclusions (this session)

  • Create only:
    • results/MALE5-ML/MALE5_ML_PROTOCOL.md
    • results/MALE5-ML/MALE5_ML_MANIFEST.json
  • These are design artifacts only.
  • Do not create prediction, backtest, OOS, tuning, or experiment artifacts.

20. Outcome matrix (adopted, MALE5-ML)

outcome definition
SUCCESS all 6 success criteria satisfied (predictive AND economically viable)
PREDICTIVE BUT NOT ECONOMICALLY VIABLE criteria 1–4 hold but net CI lower bound ≤ 0
NULL no better-than-baseline signal (fails 1 and/or 2)
INCONCLUSIVE underpowered OOS sample prevents decision; or ambiguous specification
INVALID no-lookahead / provenance / protocol violation → HARD STOP

21. Version / freeze metadata

field value
protocol id male5-ml-v0.1.0-frozen
status DESIGN FROZEN — EXECUTION NOT AUTHORIZED
design session date 2026-08-26
freeze date 2026-08-27
branch main
required next gate EXECUTION AUTHORIZATION (separate gate)

DESIGN FROZEN — EXECUTION NOT AUTHORIZED.

End of MALE5-ML protocol design.