From 5160ea1c829ef74ac014718dce93e0d0d263ee0e Mon Sep 17 00:00:00 2001 From: Hadi Khazaee Asl Date: Thu, 6 Mar 2025 03:09:33 +0330 Subject: [PATCH] last ... --- Libraries/x-saherelm.x-poi.state.lib.mq5 | 35 ++++- .../Signals/x-121.smc.xwz.signal.class.mq5 | 23 ++-- .../Signals/x-121.smc.xwz.signal.lib.mq5 | 126 +++++++++++++++++- 3 files changed, 169 insertions(+), 15 deletions(-) diff --git a/Libraries/x-saherelm.x-poi.state.lib.mq5 b/Libraries/x-saherelm.x-poi.state.lib.mq5 index c69b2bf0..90b828de 100644 --- a/Libraries/x-saherelm.x-poi.state.lib.mq5 +++ b/Libraries/x-saherelm.x-poi.state.lib.mq5 @@ -3855,6 +3855,9 @@ bool ToZoneBox( return result; } + // + bool isBullish = fvg.IsBullish(); + // // Retrieve Main Fair Value Gap's Started Bar ... XOHCL startedBar; @@ -3893,11 +3896,37 @@ bool ToZoneBox( return result; } + // + // Validate Start Bar ... + result = + isBullish + ? startedBar.high >= fvg.Upper() && + startedBar.low < fvg.Upper() + : startedBar.low <= fvg.Lower() && + startedBar.high > fvg.Lower(); + if (!result) + { + // + box.Clean(); + ZeroMemory(fvg); + startedBar.Clean(); + + // + return result; + } + // // Update Box using Started Bar ... - box.lower = startedBar.low; - box.upper = startedBar.high; - box.from = startedBar.NextAt(); + box.lower = isBullish + ? box.lower + : startedBar.low; + box.upper = + isBullish + ? startedBar.high + : box.upper; + + // + box.from = startedBar.time; // // Check Box Validation ... diff --git a/X121SMCEA/Signals/x-121.smc.xwz.signal.class.mq5 b/X121SMCEA/Signals/x-121.smc.xwz.signal.class.mq5 index c5c62539..c5855ab9 100644 --- a/X121SMCEA/Signals/x-121.smc.xwz.signal.class.mq5 +++ b/X121SMCEA/Signals/x-121.smc.xwz.signal.class.mq5 @@ -399,12 +399,12 @@ class XCX121SMCXWZSignalDetector : public XCBase // hasWaitingZones = workingZone.DetectZone( drawer, + consolidationPoiEvents, analysePoiEvents, - decisionPoiEvents, - analysePoiEvents, + consolidationPoiEvents, + consolidationState, analyseState, - decisionState, - analyseState // + consolidationState // ); // @@ -466,13 +466,14 @@ class XCX121SMCXWZSignalDetector : public XCBase // // Detect Signal Box ... - hasSignalBox = hasWorkingZone && - hasWaitingZones && - workingZone.IsZoneOBRejected( - activatedZone, - decisionXConditions, - zIndex // - ); + hasSignalBox = + hasWorkingZone && + hasWaitingZones && + workingZone.IsZoneValidForSignal( + activatedZone, + decisionXConditions, + zIndex // + ); if (hasSignalBox) { // diff --git a/X121SMCEA/Signals/x-121.smc.xwz.signal.lib.mq5 b/X121SMCEA/Signals/x-121.smc.xwz.signal.lib.mq5 index 0925ac87..404a357b 100644 --- a/X121SMCEA/Signals/x-121.smc.xwz.signal.lib.mq5 +++ b/X121SMCEA/Signals/x-121.smc.xwz.signal.lib.mq5 @@ -729,6 +729,7 @@ struct X121SMCStrategyXWZWorkingZone } // + // TODO: Remove this ... bool IsZoneOBRejected( XOBFVG &zone, X121Conditions &conditions, @@ -797,7 +798,7 @@ struct X121SMCStrategyXWZWorkingZone // result = delta == 0 || - delta < points * 2; + delta < points * 2; } // @@ -821,6 +822,129 @@ struct X121SMCStrategyXWZWorkingZone return result; } + // + bool IsZoneValidForSignal( + XOBFVG &zone, + X121Conditions &conditions, + int barIndex = 0 // + ) + { + // + bool result = false; + + // + // Cleanup Result ... + zone.Clean(); + + // + // Normalize Bar Index ... + if (barIndex < 0) + { + barIndex = 0; + } + + // + if (barIndex == 0) + { + barIndex = 1; + } + + // + // Validate ... + result = IsValid() && + HasWaitingZones(); + if (!result) + { + return result; + } + + // + XOHCL bar; + result = bar.Init( + symbol, + period, + barIndex // + ); + if (!result) + { + // + bar.Clean(); + zone.Clean(); + + // + return result; + } + + // + double peak = conditions.peaksBuffer[1]; + double vale = conditions.valesBuffer[1]; + + // + int count = CountWaitingZones(); + for (int i = 0; i < count; i++) + { + // + XOBFVG iOBFVG = waitingZones[i]; + + // + ENUM_X_DIRECTION iDir = iOBFVG.GetDirection(); + bool isBullish = iOBFVG.IsBullish(); + + // + XBoxZone iBox; + result = iOBFVG.ToZone(iBox); + if (!result) + { + // + iBox.Clean(); + iOBFVG.Clean(); + + // + continue; + } + + // + // XCFVG *fvg; + // result = iOBFVG.GetMainFVG(fvg); + // if (!result) + // { + // // + // iOBFVG.Clean(); + // ZeroMemory(fvg); + + // // + // continue; + // } + + // + result = + isBullish + ? vale < iBox.upper && + vale > iBox.lower + : peak < iBox.upper && + peak > iBox.lower; + if (result) + { + // + zone = iOBFVG; + break; + } + + // + iBox.Clean(); + iOBFVG.Clean(); + } + + // + result = zone.IsValid(); + + // + bar.Clean(); + + // + return result; + } + // bool IsExists(XOBFVG &zone) {