#!/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)