WIP: 6+ weeks of uncommitted EA development and preset tuning

Confluence EA (v1.16 → v1.20):
- Per-EA realized P&L tracking via history deals
- Weekly drawdown protection
- Warmup bars, pivot cache, state persistence
- Point-scaled pivot thresholds, ranging ATR factor
- Market filling mode helper per symbol

Grid EA (v3.1 → v4.1):
- Adaptive filters, adaptive entry, spread filter
- Session filter, breakeven, correlation caps, range drift
- Profit protection (stop-after-profit, cycle reports)
- Edge cleanup v5.0 — close wrong-side positions outside grid
- Master one-shot shutdown, grid state persistence

Presets:
- Fix GetOut=Y shutdown bug on 4 grid presets
- Relax ADXMax 18→40, widen RSI 20/80 across grid presets
- Standardize daily drawdown 3%→5%, add weekly 10%
- Increase grid lots 0.01→0.03
- Normalize confluence ATR thresholds per pair
- Add XAGUSD, EURCHF, EURGBP, AUDNZD presets

Docs & DevOps:
- April 23 audit files (preset mismatch, code review, checklist)
- n8n workflow and validation infrastructure updates
- AI agent analyses in notes/

Known issues carried forward:
- Shared drawdown budget contamination (both EAs)
- Confluence ranging-market threshold inversion
- Older grid presets missing v4.1 safety controls
This commit is contained in:
2026-05-12 09:02:25 -04:00
parent b9b4e2b22b
commit 0894d18db4
72 changed files with 3869 additions and 1416 deletions
Regular → Executable
+43 -6
View File
@@ -25,11 +25,12 @@ This file provides context for AI assistants working on this codebase.
### 2. OrdersEA_Smart_Grid.mq5
- **Purpose:** Grid trading around daily pivot levels
- **Current Version:** v3.1
- **Current Version:** v5.0
- **Key Settings:**
- `MagicNum = 333`
- `UseAutoPivots = true`
- `InpCloseBeforeWeekend = true` (v3.1 new!)
- `InpCloseBeforeWeekend = true` (v3.1)
- `GridHigh`/`GridLow` now correctly uses ATR bands (v3.3 fix)
- `MaxLevels = 10`
## Common Tasks
@@ -83,6 +84,40 @@ if(nearResistance || (rejectedFromResistance && belowPivot))
if(nearResistance || rejectedFromResistance)
```
### v3.3 - Grid Range & Filter Fix
```cpp
// WRONG (uses PivotR1/S1, ignores ATR bands)
double actualHigh = (InpManualHigh > 0) ? InpManualHigh : PivotR1;
double actualLow = (InpManualLow > 0) ? InpManualLow : PivotS1;
// CORRECT (uses ATR-based GridHigh/GridLow)
double actualHigh = (InpManualHigh > 0) ? InpManualHigh : GridHigh;
double actualLow = (InpManualLow > 0) ? InpManualLow : GridLow;
```
### v5.0 - Edge Position Cleanup
```cpp
// WRONG (range filter cancels grid but leaves stranded positions)
if(!IsRangingMarket())
{
CancelAllOrders("Range filter tripped");
gridPlaced = false;
return; // positions bleed in the R2/S2 gap
}
// CORRECT (close wrong-side positions when price exits grid)
if(!IsRangingMarket())
{
CancelAllOrders("Range filter tripped");
gridPlaced = false;
if(currentPrice > actualHigh)
ClosePositionsBySide(POSITION_TYPE_SELL, "Edge cleanup — above GridHigh");
else if(currentPrice < actualLow)
ClosePositionsBySide(POSITION_TYPE_BUY, "Edge cleanup — below GridLow");
return;
}
```
### v3.1 - Weekend Gap Protection
```cpp
// Must check Friday before market close
@@ -139,10 +174,12 @@ Server infrastructure details saved in: `/home/garfield/devops/INFRASTRUCTURE.md
Before working on this codebase, read:
```
conversation-history/2026-03-21-mql-trading-bots.md
conversation-history/2026-03-29-session-save.md
conversation-history/2026-03-30-weekend-gap-short-signal-fix.md
conversation-history/2026-03-30-dns-whitelist.md
~/conversation-history/2026-03-21-mql-trading-bots.md
~/conversation-history/2026-03-29-session-save.md
~/conversation-history/2026-03-30-weekend-gap-short-signal-fix.md
~/conversation-history/2026-03-30-dns-whitelist.md
~/conversation-history/2026-04-07-confluence-ea-diagnosis.md
~/conversation-history/2026-04-13-new-account-grid-issue.md
```
## Notes for AI Agents