Fix weekend gap risk and short signal detection
Grid EA (v3.1): - Add weekend protection: close positions Friday before market close - New settings: InpCloseBeforeWeekend, InpWeekendCloseHour, InpCancelPendingBeforeWeekend - Prevents gap risk when market reopens Sunday/Monday - FIX: Restore missing #include statements Confluence EA (v1.14): - Fix short signal detection by removing restrictive 'belowPivot' check - Mirror BUY and SELL logic for symmetry - Relax harmonic pattern tolerances (0.3-1.0 vs 0.5-0.8) - Short signals now match buy signal generation Add verify-short-signals.py to test short signal generation
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
//+------------------------------------------------------------------+
|
||||
#property copyright "Copyright 2025, Abbey Road Tech"
|
||||
#property link "https://www.abbeyroadtech.com"
|
||||
#property version "1.13"
|
||||
#property version "1.14"
|
||||
#property strict
|
||||
|
||||
#include <Trade\Trade.mqh>
|
||||
@@ -309,29 +309,28 @@ void CheckSignals(int &buyCount, int &sellCount, string &sources)
|
||||
double distToR2 = MathAbs(close - r2);
|
||||
double distToP = MathAbs(close - p);
|
||||
|
||||
// Buy at support (price near support OR bounced off support)
|
||||
bool nearSupport = (distToS1 < threshold) || (distToS2 < threshold);
|
||||
bool bouncedFromSupport = (low <= s1 && close > s1) || (low <= s2 && close > s2) ||
|
||||
(low <= s1 * 1.0005 && close > s1); // Slight buffer
|
||||
bool abovePivot = close > p; // Above pivot = bullish context
|
||||
|
||||
if(nearSupport || (bouncedFromSupport && abovePivot))
|
||||
{
|
||||
buyCount++;
|
||||
sources += "P" + IntegerToString((int)(distToS1 < distToS2 ? distToS1*10000 : distToS2*10000)) + " ";
|
||||
}
|
||||
|
||||
// Sell at resistance (price near resistance OR rejected from resistance)
|
||||
bool nearResistance = (distToR1 < threshold) || (distToR2 < threshold);
|
||||
bool rejectedFromResistance = (high >= r1 && close < r1) || (high >= r2 && close < r2) ||
|
||||
(high >= r1 * 0.9995 && close < r1); // Slight buffer
|
||||
bool belowPivot = close < p; // Below pivot = bearish context
|
||||
|
||||
if(nearResistance || (rejectedFromResistance && belowPivot))
|
||||
{
|
||||
sellCount++;
|
||||
sources += "P" + IntegerToString((int)(distToR1 < distToR2 ? distToR1*10000 : distToR2*10000)) + " ";
|
||||
}
|
||||
// Buy at support (price near support OR bounced off support)
|
||||
bool nearSupport = (distToS1 < threshold) || (distToS2 < threshold);
|
||||
bool bouncedFromSupport = (low <= s1 && close > s1) || (low <= s2 && close > s2) ||
|
||||
(low <= s1 * 1.0005 && close > s1);
|
||||
|
||||
if(nearSupport || bouncedFromSupport)
|
||||
{
|
||||
buyCount++;
|
||||
sources += "P" + IntegerToString((int)(distToS1 < distToS2 ? distToS1*10000 : distToS2*10000)) + " ";
|
||||
}
|
||||
|
||||
// Sell at resistance (price near resistance OR rejected from resistance)
|
||||
bool nearResistance = (distToR1 < threshold) || (distToR2 < threshold);
|
||||
bool rejectedFromResistance = (high >= r1 && close < r1) || (high >= r2 && close < r2) ||
|
||||
(high >= r1 * 0.9995 && close < r1);
|
||||
|
||||
// FIXED: Removed restrictive belowPivot check - mirror buy logic
|
||||
if(nearResistance || rejectedFromResistance)
|
||||
{
|
||||
sellCount++;
|
||||
sources += "P" + IntegerToString((int)(distToR1 < distToR2 ? distToR1*10000 : distToR2*10000)) + " ";
|
||||
}
|
||||
|
||||
if(InpDebugMode && (nearSupport || nearResistance || bouncedFromSupport || rejectedFromResistance))
|
||||
{
|
||||
@@ -390,31 +389,31 @@ void CheckSignals(int &buyCount, int &sellCount, string &sources)
|
||||
double BC = MathAbs(C - B);
|
||||
double CD = MathAbs(D - C);
|
||||
|
||||
if(XA > 0 && AB > 0 && BC > 0)
|
||||
{
|
||||
double ab_xa = AB / XA;
|
||||
double bc_ab = BC / AB;
|
||||
double cd_bc = CD / BC;
|
||||
|
||||
// Bullish AB=CD
|
||||
if(X > A && A < B && B > C && C < D &&
|
||||
ab_xa >= 0.5 && ab_xa <= 0.8 &&
|
||||
bc_ab >= 0.5 && bc_ab <= 0.8 &&
|
||||
cd_bc >= 0.9 && cd_bc <= 1.1)
|
||||
{
|
||||
buyCount++;
|
||||
sources += "H ";
|
||||
}
|
||||
// Bearish AB=CD
|
||||
else if(X < A && A > B && B < C && C > D &&
|
||||
ab_xa >= 0.5 && ab_xa <= 0.8 &&
|
||||
bc_ab >= 0.5 && bc_ab <= 0.8 &&
|
||||
cd_bc >= 0.9 && cd_bc <= 1.1)
|
||||
{
|
||||
sellCount++;
|
||||
sources += "H ";
|
||||
}
|
||||
}
|
||||
if(XA > 0 && AB > 0 && BC > 0)
|
||||
{
|
||||
double ab_xa = AB / XA;
|
||||
double bc_ab = BC / AB;
|
||||
double cd_bc = CD / BC;
|
||||
|
||||
// Bullish AB=CD - relaxed tolerances
|
||||
if(X > A && A < B && B > C && C < D &&
|
||||
ab_xa >= 0.3 && ab_xa <= 1.0 &&
|
||||
bc_ab >= 0.3 && bc_ab <= 1.0 &&
|
||||
cd_bc >= 0.7 && cd_bc <= 1.3)
|
||||
{
|
||||
buyCount++;
|
||||
sources += "H ";
|
||||
}
|
||||
// Bearish AB=CD - relaxed tolerances
|
||||
else if(X < A && A > B && B < C && C > D &&
|
||||
ab_xa >= 0.3 && ab_xa <= 1.0 &&
|
||||
bc_ab >= 0.3 && bc_ab <= 1.0 &&
|
||||
cd_bc >= 0.7 && cd_bc <= 1.3)
|
||||
{
|
||||
sellCount++;
|
||||
sources += "H ";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user