diff --git a/Libraries/x-saherelm.x-poi.state.lib.mq5 b/Libraries/x-saherelm.x-poi.state.lib.mq5 index 90b828de..b65b165b 100644 --- a/Libraries/x-saherelm.x-poi.state.lib.mq5 +++ b/Libraries/x-saherelm.x-poi.state.lib.mq5 @@ -386,6 +386,132 @@ struct XOBFVG return result; } + // + bool IsValidZone( + XOHCL &invalidBar, + int barIndex = 0 // + ) + { + // + bool result = false; + + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + invalidBar.Clean(); + + // + result = IsValid(); + if (!result) + { + return result; + } + + // + XCFVG *fvg; + result = GetMainFVG(fvg); + if (!result) + { + // + ZeroMemory(fvg); + return result; + } + + // + XOHCL startedBar; + bool isBodyOut = false; + result = fvg.IsStarted( + fvg.GetDirection(), + startedBar, + isBodyOut // + ); + if (!result) + { + // + ZeroMemory(fvg); + startedBar.Clean(); + + // + return result; + } + + // + XOHCL bar; + bool isBullish = fvg.IsBullish(); + + // + int fromIndex = iBarShift( + fvg.GetSymbol(), + fvg.GetPeriod(), + startedBar.NextAt() // + ); + result = IsValidIndex(fromIndex); + if (!result) + { + // + bar.Clean(); + ZeroMemory(fvg); + startedBar.Clean(); + + // + return result; + } + + // + bool isInited = false; + for (int i = barIndex; i < fromIndex; i++) + { + // + isInited = bar.Init( + fvg.GetSymbol(), + fvg.GetPeriod(), + i // + ); + if (!isInited) + { + // + bar.Clean(); + continue; + } + + // + bool isBarAbove = + bar.low > fvg.Upper(); + bool isBarBelow = + bar.high < fvg.Lower(); + + // + result = + isBullish + ? isBarAbove + : isBarBelow; + if (!result) + { + // + invalidBar = bar; + bar.Clean(); + + // + break; + } + + // + bar.Clean(); + } + + // + bar.Clean(); + ZeroMemory(fvg); + startedBar.Clean(); + + // + return result; + } + // bool ToZone(XBoxZone &box) { @@ -3926,7 +4052,7 @@ bool ToZoneBox( : box.upper; // - box.from = startedBar.time; + box.from = startedBar.NextAt(); // // 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 c5855ab9..10ed54cf 100644 --- a/X121SMCEA/Signals/x-121.smc.xwz.signal.class.mq5 +++ b/X121SMCEA/Signals/x-121.smc.xwz.signal.class.mq5 @@ -406,6 +406,13 @@ class XCX121SMCXWZSignalDetector : public XCBase analyseState, consolidationState // ); + if (hasWaitingZones) + { + // + // Validate Waiting Zones ... + workingZone.ValidateWaitingZones(zIndex); + hasWaitingZones = HasChild(workingZone.waitingZones); + } // // Checking Working Zone Destory or not ... diff --git a/X121SMCEA/Signals/x-121.smc.xwz.signal.lib.mq5 b/X121SMCEA/Signals/x-121.smc.xwz.signal.lib.mq5 index 404a357b..021d6ea7 100644 --- a/X121SMCEA/Signals/x-121.smc.xwz.signal.lib.mq5 +++ b/X121SMCEA/Signals/x-121.smc.xwz.signal.lib.mq5 @@ -605,6 +605,83 @@ struct X121SMCStrategyXWZWorkingZone return result; } + // + int ValidateWaitingZones( + int barIndex = 0 // + ) + { + // + int result = 0; + + // + bool has = false; + + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + has = IsValid() && + HasWaitingZones(); + if (!has) + { + return result; + } + + // + int removeIDX[]; + result = CountWaitingZones(); + for (int i = 0; i < result; i++) + { + // + XOBFVG iOBFVG = waitingZones[i]; + + // + XOHCL iInvalidBar; + has = iOBFVG.IsValidZone( + iInvalidBar, + barIndex // + ); + if (!has) + { + // + Add( + i, + removeIDX // + ); + + // + AddRef( + iOBFVG, + unavailableZones // + ); + } + + // + iInvalidBar.Clean(); + } + + // + has = HasChild(removeIDX); + if (has) + { + // + CleanupArray( + removeIDX, + waitingZones // + ); + } + Clean(removeIDX); + + // + result = CountWaitingZones(); + + // + return result; + } + // bool IsZoneRejected( XOBFVG &zone,