From 86a4ae2be0f3eb8b9d4837dac58f1c39bdf3f3e5 Mon Sep 17 00:00:00 2001 From: Hadi Khazaee Asl Date: Tue, 11 Mar 2025 03:53:43 +0330 Subject: [PATCH] Try to Complete Senario 2 (Using Breaked Boxes on Overal Trend) ... --- Documents/BKP/workingZone.zone.box.mq5 | 27 +++- .../x-121.smc.market.cycle.helper.class.mq5 | 139 +++++++++++++++--- .../Signals/x-121.smc.xwz.signal.class.mq5 | 38 +++-- .../Strategy/x-121.smc.strategy.class.mq5 | 10 +- 4 files changed, 181 insertions(+), 33 deletions(-) diff --git a/Documents/BKP/workingZone.zone.box.mq5 b/Documents/BKP/workingZone.zone.box.mq5 index f67e1e34..25f4aaaf 100644 --- a/Documents/BKP/workingZone.zone.box.mq5 +++ b/Documents/BKP/workingZone.zone.box.mq5 @@ -1672,7 +1672,32 @@ if (useSenario1) isBearish = false; } -//////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////// + + // + // Here we Looking for Detectiong Signal Conditions ... + if (result) + { + // + insideBox.from = insideBox.to; + insideBox.to = zBar.time; + + // + XCBoxObject *iObj; + has = ttfHelper.mPOIDrawer.DrawBox( + insideBox, + iObj // + ); + if (has) + { + // + iObj.Width(2); + iObj.BoxColor(clrGray); + } + + // + Print("Has Inside Box ..."); + } //////////////////////////////////////////////////////////////////////// diff --git a/X121SMCEA/Classes/x-121.smc.market.cycle.helper.class.mq5 b/X121SMCEA/Classes/x-121.smc.market.cycle.helper.class.mq5 index 1b5ec7fc..467f776a 100644 --- a/X121SMCEA/Classes/x-121.smc.market.cycle.helper.class.mq5 +++ b/X121SMCEA/Classes/x-121.smc.market.cycle.helper.class.mq5 @@ -2917,7 +2917,9 @@ struct X121SMCStrategyConditionParser XBoxZone &box, ENUM_X_DIRECTION &dir, X121SMCStrategySignalProviderData &provider, - int barIndex = 0 // + int barIndex = 0, + bool forceBarType = false, + bool forceFiboPressure = false, // ) { // @@ -2977,6 +2979,9 @@ struct X121SMCStrategyConditionParser barIndex = 0; } + // + // Define Resources ... + // int idx = -1; int count = 0; @@ -3061,6 +3066,7 @@ struct X121SMCStrategyConditionParser : false; // + // Check Inside ... if (isInside) { // @@ -3077,6 +3083,7 @@ struct X121SMCStrategyConditionParser } // + // Check Inside Box is Valid or not ... result = insideBox.IsValid(); if (!result) { @@ -3092,33 +3099,120 @@ struct X121SMCStrategyConditionParser } // - if (result) + // Update Inside Box From and To ... + // Based on Breaked ... + insideBox.from = insideBox.to; + insideBox.to = cTime; + + // + // Detect Breaked Box Direction ... + bool isInsideBoxBullish = insideBox.IsBullish(); + bool isInsideBoxBearish = insideBox.IsBearish(); + + // + // Detect Inside Box Rejection ... + + // + bool isUpperBearishReject = + cBar.high >= insideBox.upper && + cBar.GetUp() < insideBox.upper; + + // + bool isUpperBullishReject = + cBar.low <= insideBox.upper && + cBar.GetDown() > insideBox.upper; + + // + bool isLowerBearishReject = + cBar.high >= insideBox.lower && + cBar.GetUp() < insideBox.lower; + + // + bool isLowerBullishReject = + cBar.low <= insideBox.lower && + cBar.GetDown() > insideBox.lower; + + // + // Apply Force Bar Type ... + if (forceBarType) { // - insideBox.from = insideBox.to; - insideBox.to = zBar.time; + isUpperBearishReject = + isUpperBearishReject && + cBar.IsBearish(); // - XCBoxObject *iObj; - has = ttfHelper.mPOIDrawer.DrawBox( - insideBox, - iObj // - ); - if (has) { - // - iObj.Width(2); - iObj.BoxColor(clrGray); - } + isUpperBullishReject = + isUpperBullishReject && + cBar.IsBullish(); // - Print("Has Inside Box ..."); + isLowerBearishReject = + isLowerBearishReject && + cBar.IsBearish(); + + // + isLowerBullishReject = + isLowerBullishReject && + cBar.IsBullish(); + } + + // + // Apply Force Fibo Pressure ... + if (forceBarType) + { + // + isUpperBearishReject = + isUpperBearishReject && + ttfHelper + .mBarAnalyser + .HasFiboPressure( + cBar, + X_DIRECTION_BEARISH, + X_FIBO_LEVEL_382 // + ); + + // + isUpperBullishReject = + isUpperBullishReject && + ttfHelper + .mBarAnalyser + .HasFiboPressure( + cBar, + X_DIRECTION_BULLISH, + X_FIBO_LEVEL_382 // + ); + + // + isLowerBearishReject = + isLowerBearishReject && + ttfHelper + .mBarAnalyser + .HasFiboPressure( + cBar, + X_DIRECTION_BEARISH, + X_FIBO_LEVEL_382 // + ); + + // + isLowerBullishReject = + isLowerBullishReject && + ttfHelper + .mBarAnalyser + .HasFiboPressure( + cBar, + X_DIRECTION_BULLISH, + X_FIBO_LEVEL_382 // + ); } // // Bullish Conditions ... isBullish = ( // - false + hasBullishTrend && + isInsideBoxBearish && + isLowerBullishReject // ); @@ -3126,7 +3220,9 @@ struct X121SMCStrategyConditionParser // Bearish Conditions ... isBearish = ( // - false + hasBearishTrend && + isInsideBoxBullish && + isUpperBearishReject // ); @@ -3137,6 +3233,14 @@ struct X121SMCStrategyConditionParser isBearish; if (result) { + // + box = insideBox; + + // + dir = + isBullish + ? X_DIRECTION_BULLISH + : X_DIRECTION_BEARISH; } // @@ -3158,6 +3262,7 @@ struct X121SMCStrategyConditionParser // ttfState.Clean(); + insideBox.Clean(); ZeroMemory(ttfHelper); ttfConditions.Clean(); ttfXConditions.Clean(); diff --git a/X121SMCEA/Signals/x-121.smc.xwz.signal.class.mq5 b/X121SMCEA/Signals/x-121.smc.xwz.signal.class.mq5 index 2f51adb5..6a3c2a0e 100644 --- a/X121SMCEA/Signals/x-121.smc.xwz.signal.class.mq5 +++ b/X121SMCEA/Signals/x-121.smc.xwz.signal.class.mq5 @@ -302,6 +302,32 @@ class XCX121SMCXWZSignalDetector : public XCBase if (hasSignalBox) { // + // Remove Signal Box from UnAvailable Box ... + // if Exists ... + bool hasUnAvailableBoxes = workingZone + .HasUnavailableBoxes(); + if (hasUnAvailableBoxes) + { + // + int idx = FindIndex( + signalBox, + workingZone.unavailableBoxes // + ); + bool has = IsValidIndex(idx); + if (has) + { + // + ArrayRemove( + workingZone.unavailableBoxes, + idx, + 1 // + ); + } + } + + // + // Add Signal Box to UnAvailable Boxes ... + // if Exists in Waiting Boxes ... if (hasWaitingBoxes) { // @@ -320,15 +346,6 @@ class XCX121SMCXWZSignalDetector : public XCBase ); } } - - // - AddRef( - signalBox, - workingZone.unavailableBoxes // - ); - - // - signalBox.to = cTime; } // @@ -420,6 +437,7 @@ class XCX121SMCXWZSignalDetector : public XCBase } // + // Detect Signal Direction ... isBullish = IsBullish(signalBoxDir); isBearish = IsBearish(signalBoxDir); @@ -502,7 +520,7 @@ class XCX121SMCXWZSignalDetector : public XCBase // double iAtr = provider.decisionXConditions.atrBuffer[1]; - iAtr *= 2; + iAtr *= 1.5; // // Select Condition SL ... diff --git a/X121SMCEA/Strategy/x-121.smc.strategy.class.mq5 b/X121SMCEA/Strategy/x-121.smc.strategy.class.mq5 index 69fb8d5d..e428c4aa 100644 --- a/X121SMCEA/Strategy/x-121.smc.strategy.class.mq5 +++ b/X121SMCEA/Strategy/x-121.smc.strategy.class.mq5 @@ -804,10 +804,10 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy // // XPV ... - x121Inputs.xpvInputs.showSar = showAll || true; - x121Inputs.xpvInputs.showPeaks = showAll || true; - x121Inputs.xpvInputs.showVales = showAll || true; - x121Inputs.xpvInputs.showGoldenZones = showAll || true; + x121Inputs.xpvInputs.showSar = showAll || false; + x121Inputs.xpvInputs.showPeaks = showAll || false; + x121Inputs.xpvInputs.showVales = showAll || false; + x121Inputs.xpvInputs.showGoldenZones = showAll || false; // // XHK ... @@ -823,7 +823,7 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy // // XSTR ... - x121Inputs.xstrInputs.showStr = showAll || true; + x121Inputs.xstrInputs.showStr = showAll || false; x121Inputs.xstrInputs.showStrUpper = showAll || false; x121Inputs.xstrInputs.showStrLower = showAll || false;