Files
mql-trading-bots/verify-short-signals.py
garfield 0894d18db4 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
2026-05-12 09:02:25 -04:00

106 lines
3.5 KiB
Python
Executable File

#!/usr/bin/env python3
"""
Short Signal Verification Script for MultiSignal Confluence EA
Tests that both BUY and SELL signals can fire
"""
import sys
import re
from pathlib import Path
EA_FILE = Path("/home/garfield/mql-trading-bots/MultiSignal_Confluence_EA.mq5")
def verify_short_signals():
content = EA_FILE.read_text()
print("=" * 60)
print("SHORT SIGNAL VERIFICATION REPORT")
print("=" * 60)
issues = []
fixes = []
# Check 1: belowPivot restriction removed
if "bool belowPivot = close < p;" in content:
# Count usage
below_pivot_count = content.count("belowPivot")
if below_pivot_count > 1: # Definition + usage
issues.append(
f"'belowPivot' still used {below_pivot_count} times - may restrict shorts"
)
else:
fixes.append("⚠️ 'belowPivot' variable exists but check usage")
else:
fixes.append("'belowPivot = close < p' removed")
# Check 2: nearResistance logic
near_resistance_pattern = r"if\(nearResistance \|\| rejectedFromResistance\)"
if re.search(near_resistance_pattern, content):
fixes.append(
"✅ SELL logic: nearResistance || rejectedFromResistance (balanced)"
)
else:
issues.append("❌ SELL logic may still have restrictive conditions")
# Check 3: harmonic pattern tolerances
if "ab_xa >= 0.3 && ab_xa <= 1.0" in content:
fixes.append("✅ Harmonic patterns relaxed (0.3-1.0 instead of 0.5-0.8)")
else:
issues.append("⚠️ Harmonic tolerances may still be too tight")
# Check 4: strength calculation for sells
strength_neg = re.findall(r"strength = -\(.*?\)", content)
if strength_neg:
fixes.append(f"✅ Negative strength calculation found: {strength_neg[0]}")
# Check 5: OpenSellPosition exists and is called
if "OpenSellPosition" in content:
fixes.append("✅ OpenSellPosition() function exists")
if "if(sellCount >= InpMinConfluence" in content:
fixes.append("✅ SELL signals can trigger when sellCount >= min confluence")
# Check 6: Verify symmetry between BUY and SELL
buy_patterns = [r"nearSupport", r"bouncedFromSupport"]
sell_patterns = [r"nearResistance", r"rejectedFromResistance"]
buy_found = all(re.search(p, content) for p in buy_patterns)
sell_found = all(re.search(p, content) for p in sell_patterns)
if buy_found and sell_found:
fixes.append("✅ BUY and SELL patterns are symmetric")
elif buy_found and not sell_found:
issues.append("❌ SELL patterns may be incomplete compared to BUY")
print("\n📋 FIXES APPLIED:")
for f in fixes:
print(f" {f}")
if issues:
print("\n⚠️ ISSUES FOUND:")
for i in issues:
print(f" {i}")
print("\n" + "=" * 60)
# Summary
if len(issues) == 0:
print("✅ SHORT SIGNAL FIXES: PASSED")
print("\nTo verify in MT5 Strategy Tester:")
print("1. Load EA on a chart with recent bearish price action")
print("2. Enable DebugMode and watch Expert Advisor log")
print("3. Look for '🔴 CONFLUENCE SELL' messages")
print("4. Check 'sellCount' is >= InpMinConfluence (default 2)")
else:
print("❌ SHORT SIGNAL FIXES: NEED REVIEW")
for i in issues:
print(f" - {i}")
print("=" * 60)
return len(issues) == 0
if __name__ == "__main__":
success = verify_short_signals()
sys.exit(0 if success else 1)