From 202ae585ddc4a8584e77989d1c12801f66ac35ba Mon Sep 17 00:00:00 2001 From: Hadi Khazaee Asl Date: Sun, 9 Mar 2025 10:13:19 +0330 Subject: [PATCH] last ... --- Documents/BKP/workingZone.zone.box.mq5 | 36 ++-- .../Signals/x-121.smc.xwz.signal.class.mq5 | 56 +++---- .../Signals/x-121.smc.xwz.signal.lib.mq5 | 156 +++++++++++++++++- .../Strategy/x-121.smc.strategy.class.mq5 | 19 ++- 4 files changed, 217 insertions(+), 50 deletions(-) diff --git a/Documents/BKP/workingZone.zone.box.mq5 b/Documents/BKP/workingZone.zone.box.mq5 index 499b73b4..3fe43a34 100644 --- a/Documents/BKP/workingZone.zone.box.mq5 +++ b/Documents/BKP/workingZone.zone.box.mq5 @@ -1139,27 +1139,41 @@ bool IsBoxActivated( //////////////////////////////////////////////////////////////////////// +int activatedFVGIDX = -1; +int activatedZoneIDX = -1; +bool hasWaitingZones = false; + +// +// Remove Invalidate Zones ... +if (hasWaitingZones) +{ + // + // Validate Waiting Zones ... + workingZone.ValidateWaitingZones(zIndex); + hasWaitingZones = workingZone.HasWaitingZones(); +} + +// +// Detect Zones and Boxes ... +// hasWaitingZones = workingZone.DetectZone( +// provider // +// ); + +// +hasWaitingBoxes = workingZone.HasWaitingBoxes(); //////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////// - - -//////////////////////////////////////////////////////////////////////// - - -//////////////////////////////////////////////////////////////////////// - - -//////////////////////////////////////////////////////////////////////// - diff --git a/X121SMCEA/Signals/x-121.smc.xwz.signal.class.mq5 b/X121SMCEA/Signals/x-121.smc.xwz.signal.class.mq5 index f3142a7b..78fde82c 100644 --- a/X121SMCEA/Signals/x-121.smc.xwz.signal.class.mq5 +++ b/X121SMCEA/Signals/x-121.smc.xwz.signal.class.mq5 @@ -164,15 +164,12 @@ class XCX121SMCXWZSignalDetector : public XCBase double targets[]; double reward = 0; XBoxZone signalBox; + XBoxZone signalHolderBox; bool hasPriority = false; - int activatedFVGIDX = -1; - int activatedZoneIDX = -1; double amountPercent = -1; bool hasSignalBox = false; - bool hasWaitingZones = false; bool hasWaitingBoxes = false; bool hasRewardAmount = false; - bool isSignalBoxReversal = false; bool hasWorkingZoneOveralDirection = false; ENUM_X_DIRECTION wzOveralDir = X_DIRECTION_NONE; ENUM_X_DIRECTION signalBoxDir = X_DIRECTION_NONE; @@ -214,15 +211,6 @@ class XCX121SMCXWZSignalDetector : public XCBase hasWorkingZoneOveralDirection = workingZone .DetectOveralDirection(wzOveralDir); - // - // Detect Zones and Boxes ... - // hasWaitingZones = workingZone.DetectZone( - // provider // - // ); - - // - hasWaitingBoxes = workingZone.HasWaitingBoxes(); - // // Checking Working Zone Destory or not ... bool isWorkingZoneDestroyed = workingZone.IsDestroyed( @@ -284,6 +272,7 @@ class XCX121SMCXWZSignalDetector : public XCBase hasWorkingZone && workingZone.DetectSignalConditions( signalBox, + signalHolderBox, signalBoxDir, signalProvider, provider, @@ -327,16 +316,6 @@ class XCX121SMCXWZSignalDetector : public XCBase // // - // - // Remove Invalidate Zones ... - if (hasWaitingZones) - { - // - // Validate Waiting Zones ... - workingZone.ValidateWaitingZones(zIndex); - hasWaitingZones = workingZone.HasWaitingZones(); - } - // // Remove InValidate Boxes ... if (hasWaitingBoxes) @@ -357,6 +336,7 @@ class XCX121SMCXWZSignalDetector : public XCBase { // signalBox.Clean(); + signalHolderBox.Clean(); signalBoxDir = X_DIRECTION_NONE; } @@ -387,20 +367,37 @@ class XCX121SMCXWZSignalDetector : public XCBase bool has = false; // - XCBoxObject *iObj; + // Draw Signal Box ... + XCBoxObject *iSignalBoxObj; has = drawer.DrawBox( signalBox, - iObj // + iSignalBoxObj // ); if (has) { // - iObj.BoxWidth(1); - iObj.BoxColor(clrYellow); - iObj.BoxStyle(STYLE_SOLID); + iSignalBoxObj.BoxWidth(1); + iSignalBoxObj.BoxColor(clrYellow); + iSignalBoxObj.BoxStyle(STYLE_SOLID); // - workingZone.mDrawnObjects.Add(iObj); + workingZone.mDrawnObjects.Add(iSignalBoxObj); + } + + // + // Draw Signal Holder Box if Exists ... + if (signalHolderBox.IsValid()) + { + // + XCBoxObject *iSignalHolderBoxObj; + has = drawer.DrawBox( + signalHolderBox, + iSignalHolderBoxObj // + ); + if (has) + { + workingZone.mDrawnObjects.Add(iSignalHolderBoxObj); + } } // @@ -847,6 +844,7 @@ class XCX121SMCXWZSignalDetector : public XCBase // signalBox.Clean(); + signalHolderBox.Clean(); consolidationZBar.Clean(); // diff --git a/X121SMCEA/Signals/x-121.smc.xwz.signal.lib.mq5 b/X121SMCEA/Signals/x-121.smc.xwz.signal.lib.mq5 index 8ac09460..bea071bd 100644 --- a/X121SMCEA/Signals/x-121.smc.xwz.signal.lib.mq5 +++ b/X121SMCEA/Signals/x-121.smc.xwz.signal.lib.mq5 @@ -877,6 +877,7 @@ struct X121SMCStrategyXWZWorkingZone // bool DetectSignalConditions( XBoxZone &box, + XBoxZone &holderBox, ENUM_X_DIRECTION &dir, ENUM_X121SMC_XWZ_PROVIDERS &signalProvider, X121SMCStrategySignalProviderData &provider, @@ -891,6 +892,7 @@ struct X121SMCStrategyXWZWorkingZone // box.Clean(); + holderBox.Clean(); dir = X_DIRECTION_NONE; signalProvider = X121SMC_XWZ_PROVIDER_NONE; @@ -907,6 +909,11 @@ struct X121SMCStrategyXWZWorkingZone return result; } + // + int idx = -1; + int count = 0; + bool has = false; + // int zIDX = barIndex; int cIDX = zIDX + 1; @@ -953,7 +960,7 @@ struct X121SMCStrategyXWZWorkingZone // // Senario 1: // ---------- - bool useSenario1 = false; + bool useSenario1 = true; bool isSenario1Happend = false; bool isSenario1Bullish = false; bool isSenario1Bearish = false; @@ -1212,15 +1219,160 @@ struct X121SMCStrategyXWZWorkingZone box.from = pBar.time; } + // + // Detect Holder Box ... + XBoxZone tmpBoxes[]; + if (isSenario1Bullish) + { + // + // Demand Zones ... + XBoxZone tmp[]; + ToBox( + provider.visionState.demandZones, + tmp // + ); + Copy( + tmp, + tmpBoxes, + false // + ); + Clean(tmp); + + // + // Bullish Order Blocks ... + ToBox( + provider.visionState.bullishOrderBlocks, + tmp // + ); + Copy( + tmp, + tmpBoxes, + false // + ); + Clean(tmp); + + // + // Bullish Fair Value Gaps ... + ToBox( + provider.visionState.bullishFairValueGaps, + tmp // + ); + Copy( + tmp, + tmpBoxes, + false // + ); + Clean(tmp); + } + else + { + // + // Supply Zones ... + XBoxZone tmp[]; + ToBox( + provider.visionState.supplyZones, + tmp // + ); + Copy( + tmp, + tmpBoxes, + false // + ); + Clean(tmp); + + // + // Bearish Order Blocks ... + ToBox( + provider.visionState.bearishOrderBlocks, + tmp // + ); + Copy( + tmp, + tmpBoxes, + false // + ); + Clean(tmp); + + // + // Bearish Fair Value Gaps ... + ToBox( + provider.visionState.bearishFairValueGaps, + tmp // + ); + Copy( + tmp, + tmpBoxes, + false // + ); + Clean(tmp); + } + + // + has = HasChild(tmpBoxes); + if (has) + { + // + while (HasChild(tmpBoxes)) + { + // + idx = GetOldest(tmpBoxes); + has = IsValidIndex(idx); + if (!has) + { + break; + } + + // + XBoxZone iBox = tmpBoxes[idx]; + ArrayRemove( + tmpBoxes, + idx, + 1 // + ); + + // + has = IsBoxInside( + box, + iBox // + ); + if (has) + { + // + holderBox = iBox; + holderBox.to = TimeCurrent(); + iBox.Clean(); + break; + } + + // + iBox.Clean(); + } + } + + // + Clean(tmpBoxes); + // signalProvider = X121SMC_XWZ_PROVIDER_ACTIVATED_BOX; + + // + // Validate Conditions to Force Has Holder Box ... + // isSenario1Happend = + // holderBox.IsValid() && + // isSenario1Happend; + // if (!isSenario1Happend) + // { + // // + // isSenario1Bullish = false; + // isSenario1Bearish = false; + // } } } // // Senario 2: // ---------- - bool useSenario2 = true; + bool useSenario2 = false; bool isSenario2Happend = false; bool isSenario2Bullish = false; bool isSenario2Bearish = false; diff --git a/X121SMCEA/Strategy/x-121.smc.strategy.class.mq5 b/X121SMCEA/Strategy/x-121.smc.strategy.class.mq5 index 7ac22065..d271a7ac 100644 --- a/X121SMCEA/Strategy/x-121.smc.strategy.class.mq5 +++ b/X121SMCEA/Strategy/x-121.smc.strategy.class.mq5 @@ -42,6 +42,7 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy // // Props ... bool useXWZSignal; + bool useXWZSignalGuard; XCX121SMCXWZSignalDetector *mXWZSignalDetector; X121SMCStrategySignalProviderData cycleProvider; @@ -414,7 +415,8 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy // // XWZ Guard Detection ... - if (useXWZSignal) + if (useXWZSignal && + useXWZSignalGuard) { // X121SMCGuard xwzGuards[]; @@ -690,6 +692,7 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy { // useXWZSignal = true; + useXWZSignalGuard = false; // string symbol = GetSymbol(); @@ -788,7 +791,7 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy // // XPV ... - x121Inputs.xpvInputs.showSar = showAll || true; + x121Inputs.xpvInputs.showSar = showAll || false; x121Inputs.xpvInputs.showPeaks = showAll || true; x121Inputs.xpvInputs.showVales = showAll || true; x121Inputs.xpvInputs.showGoldenZones = showAll || true; @@ -797,8 +800,8 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy // XHK ... // - x121Inputs.xhkInputs.drawRawXHKCandles = showAll || true; - x121Inputs.xhkInputs.drawSmoothedXHKCandles = showAll || true; + x121Inputs.xhkInputs.drawRawXHKCandles = showAll || false; + x121Inputs.xhkInputs.drawSmoothedXHKCandles = showAll || false; // // XATR ... @@ -813,10 +816,10 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy // // XCHE ... - x121Inputs.xcheInputs.showLE1 = showAll || true; - x121Inputs.xcheInputs.showLE2 = showAll || true; - x121Inputs.xcheInputs.showSE1 = showAll || true; - x121Inputs.xcheInputs.showSE2 = showAll || true; + x121Inputs.xcheInputs.showLE1 = showAll || false; + x121Inputs.xcheInputs.showLE2 = showAll || false; + x121Inputs.xcheInputs.showSE1 = showAll || false; + x121Inputs.xcheInputs.showSE2 = showAll || false; // // XDON ...