forked from animatedread/Warrior_EA
75 lines
4.5 KiB
Markdown
75 lines
4.5 KiB
Markdown
# The Mind - the trader behind the signal
| |||
| |||
`Mind/` turns Warrior_EA from "a signal that fires" into "a signal that fires and a trader who
| |||
looks at it, sizes it, writes it down and reviews the notebook". The validated dip-buy book is
| |||
untouched: the Mind is off the trade path in `MIND_OBSERVE` (the default) and can only take risk
| |||
*off* in the acting modes.
| |||
| |||
## Loop
| |||
| |||
| step | what | where |
| |||
|---|---|---|
| |||
| LOOK | every modality reads the closed signal bar into one `SMarketContext` | `Modality*.mqh` |
| |||
| RECALL | the reviewer asks how trades in similar conditions have gone | `JournalReviewer.mqh` |
| |||
| SIZE | P(win) -> fraction of base risk, never above 1 (AFML ch. 10) | `BetSizer.mqh` |
| |||
| WRITE | on close, the trade + context + outcome (R, MAE, MFE) go to a CSV and back to the reviewer | `TradeBook.mqh` |
| |||
| ORCHESTRATE | the only class that wires the four | `WarriorMind.mqh` |
| |||
| |||
Modalities: **price** (z, ATR-distances, regime, volatility percentile), **volume** (tick volume
| |||
with the hour-of-day removed, and effort-vs-result), **Wyckoff** (phase, last event, spring,
| |||
the reader's verdict), **breadth** (share of the other indices also dipping), **calendar**.
| |||
| |||
## Modes (`MindMode`)
| |||
| |||
- `MIND_OBSERVE` (default) - trades exactly as without it. Verified 2026-09-30: SP500 2023-01..09,
| |||
same two trades and the same final balance (100,239.27) with the Mind off and observing.
| |||
- `MIND_SIZE` - a setup the journal rates below the book's average gets `m(p)/m(p0)` of the base
| |||
risk (floor `MindMinScale`). Needs `MindMinTrades` closed trades first.
| |||
- `MIND_SIZE_GATE` - as SIZE, and a setup the journal rates a coin flip (`p <= 0.5`) is skipped.
| |||
| |||
## Reading the result
| |||
| |||
`Common\Files\Warrior_EA\Mind\book_<SYMBOL>_<TF>.csv` - one row per closed trade, 48 columns.
| |||
`python research/read_book.py` pools every book and ranks context fields by rank correlation with R,
| |||
with the multiple-testing count printed under the table. At the end of each run the Experts log
| |||
prints the reviewer's band table, the per-trade Sharpe, PSR(0) and an approximate DSR.
| |||
| |||
**How to use it honestly.** A field that looks good on the first backtest is a hypothesis. Run the
| |||
next period (or another index) with it fixed before believing it; `review_p` vs realised R in
| |||
`read_book.py` is the check that the journal's own forecast has any skill.
| |||
| |||
## Design rules (why it is shaped like this)
| |||
| |||
- **One column contract.** `ENUM_CTX` + `CtxName()` in `MarketContext.mqh`; modalities write it, the
| |||
book persists it, the reviewer buckets it. No other file spells a column.
| |||
- **Open/closed.** A new way of looking = a new `CModality` subclass registered in
| |||
`CWarriorMind::Init()`. Nothing else changes.
| |||
- **Authored rules are priors, not gates.** `CWyckoffReader::Bias()` encodes the Wyckoff books'
| |||
reading, but it only reaches the trade through a journal bucket, so the trades decide whether
| |||
"against the structure" is a worse place to buy a dip. In the first test a dip the reader scored
| |||
-0.75 ("distribution phase E") paid +0.50R - one trade, not a verdict, but the reason for this rule.
| |||
- **Causal.** Modalities read closed bars only; a trade enters the reviewer when it closes.
| |||
In the tester the book is truncated at Init so one run never informs the next.
| |||
| |||
## DRY changes made with it
| |||
| |||
- `System/RegimeMath.mqh` - the efficiency-ratio / variance-ratio arithmetic that lived inside
| |||
`CWarriorSignal`, now shared with the price modality (signal behaviour unchanged).
| |||
- `Mind/VolumeFeed.mqh` - the one definition of relative volume. `SignalNeural` and the management
| |||
net's crossing features now use it. **This changes their feature vectors** (names renamed so an
| |||
old model file cannot load): retrain, and do not compare against nets trained before 2026-09-30.
| |||
- `System/FeatureScale.mqh` - `FeatSquash`, shared by both.
| |||
- `mql5_patches/` holds older snapshots that no build includes (`FracDiff.mqh` has its own
| |||
`VolumeAt` with the old idea). Left alone; delete or migrate when someone needs them.
| |||
| |||
## Known limits
| |||
| |||
- The volume level-detrend (`Detrended`) is UNTESTED as a predictor; the book records `rvol_tod`
| |||
(detrended) and `rvol_tod_raw`, so the first journal is its test.
| |||
- The reviewer is additive over four dimensions (volatility, volume, Wyckoff verdict, breadth): it
| |||
cannot see interactions and says so in its header. With ~650 trades in five years there is not
| |||
data for more.
| |||
- Skipped setups (vol-gated dips, vetoes) are not booked, so the Mind cannot yet learn from the
| |||
trades it did not take.
| |||
- The DSR in the run summary uses the large-sample trial variance 1/(T-1); set `MindTrials` to the
| |||
number of configurations really tried.
|