# PHASE 1 NOTES: Miroscope_Scanner_P1.mq5

Built: 2026-09-22. Source: `source/Miroscope_Scanner_P1.mq5` (57,265 bytes).
Build script (reproducible): `build_p1.py` in this directory.

## What was changed and why

1. **Duplicate definitions removed** (the compile blocker).
   Deleted lines 1160-1298 of the original: the second copies of
   `double CalculateMLConfidence(int index)` and
   `void CalculateOverallStatus(int index)`.
   Kept the first copies (original lines 609 and 651), which carry the
   "SINGLE DEFINITION" marks and read pattern features via struct copy
   instead of a reference into an array element. Every function in the
   file is now defined exactly once (verified by grep).

2. **SortPairsByPriority no longer corrupts data** (review F2).
   The old code swapped whole `PairAnalysis` structs in `g_pairs[]`, but
   the indicator handle arrays stay keyed to the original symbol order, so
   from the second tick on the scanner attributed ATR/RSI/MA data to the
   wrong symbols. The new code sorts `g_displayOrder[]`, an index array
   initialized in `OnInit()`; `g_pairs[]` keeps its original order forever
   and the dashboard iterates the index array. Comparator logic is
   unchanged.

3. **ML-disabled status gate fixed** (review F3).
   With `InpEnableML=false`, `mlConfidence` is 0.5, which is below
   `InpMLMinConfidence` (0.55), so the old code could never show
   STRONG/FULL. The gate is now `!InpEnableML || mlConfidence >=
   InpMLMinConfidence`. Pattern detection and alert logic are untouched.

4. **GetPipSize 4-digit branch fixed** (review F5).
   Was `point * 100` (100x too large: 0.01 per pip on a 4-digit quote),
   which made risk/reward pip readouts 100x too small and FIXED_PIPS
   pullback zones 100x too wide. Now returns `point`. The 2-digit branch
   is intentionally unchanged: pip conventions on 2-digit metals vary by
   broker and need live confirmation.

5. **Rebrand.** Visible strings now say Miroscope: file header, copyright,
   version 1.00, dashboard title, short name, init print, alert prefix
   ("MIROSCOPE PATTERN:"), and setup types (MS-FULL/MS-STRONG/MS-FORMING/
   MS-NONE). "Matching EA V8.0" comments were kept: they document where
   the input defaults came from.

6. **Line endings normalized** CRLF -> LF. Cosmetic; MetaEditor accepts
   both.

## What was deliberately NOT changed

- `CheckRSICondition()` is still a tautology (always true). The working
  RSI gate lives inside `DetectPatternForPair()` and was left exactly
  as-is; inventing new filter behavior was out of scope.
- Vestigial inputs (`InpPatternExpiryBars`, `InpMLLotBoost`,
  `InpMLLotReduce`, `InpMLLookbackTrades`, `InpFontSize`, `g_lastMLUpdate`)
  are still declared but documented as unused.
- `#property strict` and the two unused `#include` lines were left alone
  (harmless).
- Pattern math, alert text format, cooldown logic, dashboard layout, ML
  confidence math: byte-for-byte behavior preserved except the fixes above.

## Scanner-only confirmation

Grep over the new file: zero hits for `OrderSend`, `CTrade`,
`PositionOpen`, `OrderCalc`, `HistoryDeal`. `CheckExistingTrade()` is
read-only position display. There is no live-trading code path in this
file. Nothing here can touch an account.

## Honestly unverified

There is no MQL5 compiler and no MetaTrader in this environment. The file
did NOT compile here and "compiles clean" is NOT claimed. Manual audit
performed instead: brace/paren balance (108/108, 656/656), one definition
per function, every changed region re-read, anchors asserted unique by the
build script. Compilation MUST be confirmed in MetaEditor before this file
is trusted on a live terminal. The core 1-2-3 detection logic is separately
exercised by the Python simulation in `tests/` (see TEST-RESULTS.md).
