Files
conversation-history/Trading/MT5/2026-04-19 Confluence EA - Opportunities Plan.md
T

154 lines
7.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 2026-04-19 — MultiSignal Confluence EA: Opportunities & Fix Plan
> **STATUS: Tier 1 IMPLEMENTED as v1.19 on 2026-04-19.** All 7 Tier 1 items applied (per-EA DD, equity-based sizing, symbol-queried filling mode, fail-closed indicators with warm-up gate, point-scaled pivot threshold, ATR-scaled ranging tolerance, cached daily pivots). File: 1044 → 1233 lines. Tier 2-3 still open.
>
> **UPDATE 2026-04-19 (same day):** Multi-horizon drawdown structure added: daily default raised 3% → 5%, new `InpMaxWeeklyDrawdown` = 10% with Monday 00:00 broker reset. Either limit trips = block new trades. Tracks per-EA via history scan. Existing `.set` files may still pin `InpMaxDailyDrawdown=3.0` — EURUSD preset was already 5.0, others vary.
**Source code reviewed:** `MultiSignal_Confluence_EA.mq5` (v1.18, 1044 lines)
**Context:** Running on 8 pairs, magic 777771-777780. Currently blocked by per-pair ATR/ADX thresholds (fixed Apr 7). About to re-enable Grid EA v4.0 which now has per-EA DD — Confluence still has account-level DD, creating asymmetric starvation risk.
Related notes:
- [[2026-04-07-confluence-ea-diagnosis]]
- [[2026-04-07-confluence-ea-atr-fix]]
- [[2026-04-03-confluence-ea-analysis]]
- [[2026-04-05-grid-shutdown-analysis]]
- [[2026-04-19 OrdersEA Smart Grid - Opportunities Plan]]
- [[confluence_ea_diagnostic]]
---
## Tier 1 — Wrong code (fix before re-enabling Grid)
### 1.1 Shared daily drawdown with Grid EA [CRITICAL]
**Where:** `CheckDailyDrawdown()` lines 728-769
**What:** Uses `AccountInfoDouble(ACCOUNT_EQUITY)`. Once Grid v4.0 is back, both EAs independently measure *account* drawdown against their own 3% limit — whoever loses first starves the other.
**Fix:** Port the per-EA pattern from Grid v4.0 (`GetRealizedPnLToday()` + `GetFloatingPnL()`, filtered by magic+symbol, measured against dollar limit).
**Effort:** ~40 lines.
### 1.2 Risk sizing uses BALANCE not EQUITY
**Where:** `CalculateLotSize()` line 526: `accountBalance = AccountInfoDouble(ACCOUNT_BALANCE)`
**What:** During drawdown, balance lags equity by open-position P&L. EA opens new positions sized against the stale higher number.
**Fix:** `MathMin(balance, equity)`.
**Effort:** 1 line.
### 1.3 `ORDER_FILLING_IOC` hardcoded
**Where:** Line 85
**Fix:** Port `GetMarketFilling()` from Grid v4.0 (queries `SYMBOL_FILLING_MODE` at init).
**Effort:** 5 lines.
### 1.4 Indicator failures fail-open
**Where:** `CheckVolatilityFilter()` lines 315, 322, 344, 351; `CheckTrendFilter()` line 209
**What:** If an indicator handle is INVALID or CopyBuffer returns 0, the function returns `true` (allow trade). Broken ADX handle ⇒ silently-disabled filter.
**Fix:** Return `false` on indicator failure. Add warm-up guard (block trades until ATR/ADX have N bars of data).
**Effort:** ~10 lines.
### 1.5 Hardcoded pivot threshold not point-scaled
**Where:** `CheckSignals()` line 402: `double threshold = 0.0010;`
**What:** 10 pips on 4-digit FX, 100 pips on 3-digit JPY pairs, ~$0.001 on XAUUSD.
**Fix:** `threshold = 100 * SymbolInfoDouble(_Symbol, SYMBOL_POINT)`.
**Effort:** 1 line.
### 1.6 Ranging detection uses percentage, not volatility
**Where:** `CheckRangingMarket()` lines 253-254: `close <= s1 * 1.002`
**What:** 0.2% means different things across symbols (XAUUSD noise vs JPY real move).
**Fix:** Use ATR-scaled: `MathAbs(close - s1) <= atr * 0.3`.
**Effort:** 5 lines.
### 1.7 Pivots calculated twice per bar
**Where:** `CheckRangingMarket()` line 245, `CheckSignals()` line 398
**Fix:** Cache daily pivots; recompute once at day-rollover. Both callers read cache.
**Effort:** 10 lines.
---
## Tier 2 — Design concerns
### 2.1 Signal strength threshold is near-redundant with MinConfluence
`strength = 0.6 + (count * 0.15)`. At MinConfluence=2 → strength=0.9, always passes thresholds 0.70-0.85. The "quality" dimension doesn't differentiate.
**Fix:** Per-source confidence weights (harmonic, pivot, candlestick get different weights). Weighted sum ≥ InpMinStrength becomes a real gate.
### 2.2 Trailing stop runs every tick
**Fix:** Throttle to once/second or bar-gate.
### 2.3 No ADX direction check (+DI / -DI)
ADX main line only; doesn't verify direction matches signal.
**Fix:** Read +DI (buffer 1) and -DI (buffer 2). Require alignment.
### 2.4 Harmonic pattern tolerances are very loose
`ab_xa >= 0.3 && ab_xa <= 1.0` fires on almost any zigzag. Real Gartley/Bat/Crab patterns have tight Fib ratios.
**Options:**
- (a) Tighten toward 0.382, 0.618, 0.786, 1.272, 1.618 ±0.05
- (b) Drop harmonic entirely — likely contributing noise, not edge
### 2.5 Candlestick library is thin
Only hammer, shooting star, engulfing. Missing: morning/evening star, three soldiers/crows, piercing, dark cloud, doji at S/R.
**Fix:** Add 4-6 more patterns to broaden signal sources under a confluence-required regime.
### 2.6 Ranging-detection ADX threshold hardcoded at 20
**Where:** Line 262: `adxWeak = (adxValue[0] < 20.0)`
**Fix:** Expose as `InpRangingADXThreshold` or derive as `InpMinADX - 2`.
### 2.7 No daily-equity state persistence
`dailyStartEquity` + `lastEquityReset` lost on reattach. Persist via `GlobalVariable*` keyed by magic+symbol (same pattern as Grid v4.0).
### 2.8 EURUSD weekend close at 14:00 vs 17:00 elsewhere
Unexplained. May be intentional (London close) or misconfigured `.set` file.
**Action:** Verify with user; add comment or normalize.
---
## Tier 3 — Opportunities
### 3.1 Session filter
Block trades outside liquid hours. Per-symbol config.
### 3.2 News/economic calendar avoidance
Manual window inputs first (`InpNoTradeStart`/`InpNoTradeEnd`); API integration later.
### 3.3 Correlation cap across EA instances
GlobalVariable counter for distinct-symbol longs/shorts under the same EA. Prevents 8-pair pile-on.
### 3.4 Breakeven jump before trailing
As soon as profit ≥ 1×spread, park SL at `entry + buffer`. Then let `InpTrailingStart` take over. Protects near-entry trades from noise pullbacks.
### 3.5 Partial take-profit (scale out)
Half at TP*0.5, half at TP. Improves equity curve smoothness.
### 3.6 Weighted strength (from 2.1) — gives `InpMinStrength` real meaning.
### 3.7 Log prefix `[_Symbol:magic]` — journal is unreadable with 8 charts otherwise.
### 3.8 GBPJPY / AUDUSD coverage gap
Two pairs without Confluence EA. Free capacity if signals backtest OK.
---
## Proposed execution order
**Phase 1 — before Grid re-enable (today):**
1.1 (per-EA DD) → 1.2 (equity not balance)
**Phase 2 — robustness:**
1.3 → 1.4 → 1.5 → 1.6 → 1.7 → 2.7 (state persistence) → 3.7 (log prefix)
**Phase 3 — signal quality:**
2.1/3.6 (weighted strength) → 2.4 (harmonic decision) → 2.5 (more candlesticks) → 2.3 (ADX direction) → 2.6 (ranging ADX config)
**Phase 4 — defensive:**
3.1 (session) → 3.3 (correlation cap) → 3.4 (breakeven jump) → 3.5 (partial TP)
**Phase 5 — non-code:**
EURUSD 14:00 check (2.8) → GBPJPY/AUDUSD deploy (3.8)
---
## Open decisions for user
- [ ] Port Grid v4.0's per-EA DD pattern verbatim, or simpler variant?
- [ ] Keep harmonic signals (tighten ratios) or drop entirely?
- [ ] Version bump to v2.0 or stay on v1.19 incrementally?
- [ ] Deploy GBPJPY/AUDUSD coverage now or after signal-quality fixes?
---
*Plan author: Claude Opus 4.7 (1M context). Verify file:line citations against current source before implementing.*