From 1d554ec21dddcfeeebc718729a32374ca6dc6c45 Mon Sep 17 00:00:00 2001 From: Hadi Khazaee Asl Date: Sat, 1 Mar 2025 04:52:23 +0330 Subject: [PATCH] last ... --- Classes/x-saherelm.x-bar.analyser.class.mq5 | 46 +- Classes/x-saherelm.x-poi.drawer.class.mq5 | 19 +- Libraries/x-saherelm.x-poi.lib.mq5 | 23 + .../Signals/x-121.smc.xwz.signal.class.mq5 | 399 ++++++++- .../Signals/x-121.smc.xwz.signal.lib.mq5 | 824 ++++++++++-------- 5 files changed, 882 insertions(+), 429 deletions(-) diff --git a/Classes/x-saherelm.x-bar.analyser.class.mq5 b/Classes/x-saherelm.x-bar.analyser.class.mq5 index dbe53f3a..05e6267f 100644 --- a/Classes/x-saherelm.x-bar.analyser.class.mq5 +++ b/Classes/x-saherelm.x-bar.analyser.class.mq5 @@ -1851,52 +1851,44 @@ class XCBarAnalyser : public XCBase */ bool HasFiboPressure( XOHCL &bar, - ENUM_X_DIRECTION &dir // + ENUM_X_DIRECTION forDir, + ENUM_X_FIBO_LEVELS level // ) { // bool result = false; // - dir = X_DIRECTION_NONE; - - // - result = bar.IsValid(); + result = bar.IsValid() && + HasDirection(forDir); if (!result) { return result; } // - double bearishFib382 = GetFibonacciLevel( + bool isBullish = IsBullish(forDir); + bool isBearish = IsBearish(forDir); + + // + double fiboLevelValue = GetFibonacciLevel( bar.high, bar.low, - 0.382, - 1 // - ); - double bullishFib382 = GetFibonacciLevel( - bar.high, - bar.low, - 0.382, - -1 // + level, + forDir // ); // - bool isBullish = bar.GetDown() > bearishFib382; - bool isBearish = bar.GetUp() < bullishFib382; + bool isBullishPressured = + isBullish && + bar.GetDown() > fiboLevelValue; + bool isBearishPressured = + isBearish && + bar.GetUp() < fiboLevelValue; // - result = isBullish || - isBearish; - if (!result) - { - return result; - } - - // - dir = isBullish - ? X_DIRECTION_BULLISH - : X_DIRECTION_BEARISH; + result = isBullishPressured || + isBearishPressured; // return result; diff --git a/Classes/x-saherelm.x-poi.drawer.class.mq5 b/Classes/x-saherelm.x-poi.drawer.class.mq5 index 4c3de25f..eb1e40e2 100644 --- a/Classes/x-saherelm.x-poi.drawer.class.mq5 +++ b/Classes/x-saherelm.x-poi.drawer.class.mq5 @@ -3185,6 +3185,7 @@ class XCPOIDrawer : public XCBase */ bool CreateBox( XCBoxObject *&object, + string name, double upper, double lower, datetime from, @@ -3207,10 +3208,14 @@ class XCPOIDrawer : public XCBase // string dateStr = ToFormatString(from) + "|" + ToFormatString(to); string dateMD5 = ToMD5(dateStr); - string name = "XBox_" + - ToString(upper) + "_" + - ToString(lower) + "_" + - dateMD5; + if (!IsValid(name)) + { + // + name = "XBox_" + + ToString(upper) + "_" + + ToString(lower) + "_" + + dateMD5; + } // result = @@ -3297,10 +3302,12 @@ class XCPOIDrawer : public XCBase ? BullishFVGColor() : BearishFVGColor(); ENUM_LINE_STYLE style = STYLE_DASHDOTDOT; + string name = box.GetTag(); // result = CreateBox( object, + name, box.upper, box.lower, box.from, @@ -3348,9 +3355,13 @@ class XCPOIDrawer : public XCBase return result; } + // + string name = box.GetTag(); + // result = CreateBox( object, + name, box.upper, box.lower, box.from, diff --git a/Libraries/x-saherelm.x-poi.lib.mq5 b/Libraries/x-saherelm.x-poi.lib.mq5 index 501a6830..16fc0947 100644 --- a/Libraries/x-saherelm.x-poi.lib.mq5 +++ b/Libraries/x-saherelm.x-poi.lib.mq5 @@ -5327,6 +5327,29 @@ struct XBoxZone // return result; } + + /** + * Retrieve Unique Identifier ... + * + * @return ( string ) + */ + string GetTag() + { + // + string result = + // + "XBOX" + "_" + + ToString(dir) + "_" + + symbol + "_" + + ToString(period) + "_" + + ToString(upper) + "_" + + ToString(lower) + // + ; + + // + return result; + } }; // diff --git a/X121SMCEA/Signals/x-121.smc.xwz.signal.class.mq5 b/X121SMCEA/Signals/x-121.smc.xwz.signal.class.mq5 index 10f59192..ef299734 100644 --- a/X121SMCEA/Signals/x-121.smc.xwz.signal.class.mq5 +++ b/X121SMCEA/Signals/x-121.smc.xwz.signal.class.mq5 @@ -302,6 +302,7 @@ class XCX121SMCXWZSignalDetector : public XCBase X121Conditions visionXConditions = visionConditions.x121Conditions; // + // Select Drawer Class ... XCPOIDrawer *drawer = visionCycleHelper.mPOIDrawer; // @@ -311,11 +312,14 @@ class XCX121SMCXWZSignalDetector : public XCBase double point = 0; double targets[]; double reward = 0; + XBoxZone signalBox; XOBFVG selectedZone; double amountPercent = 0; bool hasPriority = false; + bool hasSignalBox = false; bool hasRewardAmount = false; bool hasSelectedZone = false; + bool isSignalBoxReversal = false; bool isSelectedZoneReversal = false; bool hasSelectedConsolidationZone = false; XConsolidationZone selectedConsolidationZone; @@ -369,6 +373,10 @@ class XCX121SMCXWZSignalDetector : public XCBase bool hasWaitingZones = hasWorkingZone && workingZone.HasWaitingZones(); + // + // + // + // // Check Conditions if Has Inside Zones ... bool hasInsideZones = hasWorkingZone && @@ -422,7 +430,7 @@ class XCX121SMCXWZSignalDetector : public XCBase workingZone.HasBreakedZones(); if (hasBreakedZones) { - // + if (!hasSelectedZone) { // @@ -467,12 +475,189 @@ class XCX121SMCXWZSignalDetector : public XCBase } } + // + // + // + // bool hasInsideBoxes = hasWorkingZone && workingZone.HasInsideBoxes(); if (hasInsideBoxes) { - Print("Inside Boxes ..."); + // + XOHCL zBar; + XOHCL cBar; + int count = 0; + bool has = false; + XBoxZone tmpSelectedBox; + int tmpSelectedBoxIDX = -1; + + // + has = zBar.Init( + symbol, + period, + zIndex // + ); + has = has && + zBar.GetPreviousBar(cBar); + if (has) + { + // + count = workingZone.CountInsideBoxes(); + for (int i = 0; i < count; i++) + { + // + tmpSelectedBox = workingZone.insideBoxes[i]; + + // + bool isBullish = tmpSelectedBox.IsBullish(); + bool isBearish = tmpSelectedBox.IsBearish(); + + // + bool hasFiboPressure = + visionCycleHelper + .mBarAnalyser + .HasFiboPressure( + cBar, + tmpSelectedBox.dir, + X_FIBO_LEVEL_382 // + ); + + // + bool isBullishRejectedUpper = + cBar.low < tmpSelectedBox.upper && + cBar.GetDown() > tmpSelectedBox.upper; + + // + bool isBullishRejectedLower = + cBar.low < tmpSelectedBox.lower && + cBar.GetDown() > tmpSelectedBox.lower; + + // + bool isBearishRejectedUpper = + cBar.high > tmpSelectedBox.upper && + cBar.GetUp() < tmpSelectedBox.upper; + + // + bool isBearishRejectedLower = + cBar.high > tmpSelectedBox.lower && + cBar.GetUp() < tmpSelectedBox.lower; + + // + bool isBullishRejected = + // isBullishRejectedUpper || + isBullishRejectedLower; + + // + bool isBearishRejected = + isBearishRejectedUpper + // || isBearishRejectedLower + ; + + // + bool isMaWapBullish = + // + (decisionXConditions.isX3MaBullishState && + decisionXConditions.isX3MaBullishOrdered) + // + && + // + (decisionXConditions.isVWapBullishState && + decisionXConditions.isVWapBullishOrdered) + // + ; + + // + bool isMaWapBearish = + // + (decisionXConditions.isX3MaBearishState && + decisionXConditions.isX3MaBearishOrdered) + // + && + // + (decisionXConditions.isVWapBearishState && + decisionXConditions.isVWapBearishOrdered) + // + ; + + // + bool isX2MaWapInside = + // + (decisionXConditions.x3maFastBuffer[cIndex] < tmpSelectedBox.upper && + decisionXConditions.x3maMidBuffer[cIndex] < tmpSelectedBox.upper && + decisionXConditions.x3maFastBuffer[cIndex] > tmpSelectedBox.lower && + decisionXConditions.x3maMidBuffer[cIndex] > tmpSelectedBox.lower) + // + && + // + (decisionXConditions.vwapFastBuffer[cIndex] < tmpSelectedBox.upper && + decisionXConditions.vwapMidBuffer[cIndex] < tmpSelectedBox.upper && + decisionXConditions.vwapFastBuffer[cIndex] > tmpSelectedBox.lower && + decisionXConditions.vwapMidBuffer[cIndex] > tmpSelectedBox.lower) + // + ; + + // + bool isBullishConditions = + // + isBullish && + isMaWapBearish && + isX2MaWapInside && + hasFiboPressure && + isBullishRejected && + cBar.low < cBar.GetDown() + // + ; + + // + bool isBearishConditions = + // + isBearish && + isMaWapBullish && + isX2MaWapInside && + hasFiboPressure && + isBearishRejected && + cBar.high > cBar.GetUp() + // + ; + + // + has = isBullishConditions || + isBearishConditions; + if (!has) + { + // + tmpSelectedBox.Clean(); + continue; + } + + // + tmpSelectedBoxIDX = i; + signalBox = tmpSelectedBox; + + // + tmpSelectedBox.Clean(); + break; + } + } + + // + isSignalBoxReversal = false; + hasSignalBox = signalBox.IsValid(); + if (hasSignalBox) + { + // + ArrayRemove( + workingZone.insideBoxes, + tmpSelectedBoxIDX, + 1 // + ); + } + + // + zBar.Clean(); + cBar.Clean(); + tmpSelectedBox.Clean(); } // @@ -480,35 +665,17 @@ class XCX121SMCXWZSignalDetector : public XCBase workingZone.HasBreakedBoxes(); if (hasBreakedBoxes) { - Print("Breaked Boxes ..."); } // - // Checking Other Senario for Signals ... - // if (!hasWaitingZones && - // !hasSelectedZone) - // { - // // - // bool has = false; - // ENUM_X_DIRECTION dir; - - // // - // has = DetectX121Conditions( - // pivot, - // point, - // sls, - // targets, - // dir, - // analyseState, - // decisionState, - // decisionXConditions, - // drawer // - // ); - // } + // + // // // Double Check and Prepare Signal Conditions ... // including Targets and SLs ... + + // if (hasSelectedZone) { // @@ -640,7 +807,7 @@ class XCX121SMCXWZSignalDetector : public XCBase mConditions.priority = priority; mConditions.provider = provider; mConditions.dir = selectedZoneDir; - mConditions.signalZone = selectedZone; + mConditions.signalBox = signalBox; mConditions.amountPercent = amountPercent; } @@ -654,6 +821,137 @@ class XCX121SMCXWZSignalDetector : public XCBase selectedConsolidationZone.Clean(); } + // + if (hasSignalBox) + { + // + workingZone.mInsideZoneObjects.Clear(); + workingZone.mBreakedZoneObjects.Clear(); + workingZone.mWaitingZoneObjects.Clear(); + workingZone.mWorkingZoneObjects.Clear(); + + // + XCBoxObject *iObj; + signalBox.to = cTime; + bool isCreated = drawer.CreateBox( + signalBox, + iObj // + ); + + // + if (isCreated) + { + // + iObj.BoxWidth(2); + iObj.BoxColor(clrYellow); + iObj.BoxStyle(STYLE_SOLID); + } + + // + bool isSignalBoxBullishDir = signalBox.IsBullish(); + + // + // Calculate Priority ... + hasPriority = + hasWorkingZone && + workingZone + .DetectPriority( + priority, + signalBox.dir, + zIndex, + period // + ); + + // + // Calculate Risk Reward Ration based on Priority ... + hasRewardAmount = CalculateRiskReward( + priority, + reward, + amountPercent // + ); + + // + // Calculate Pivot and Point ... + + // + pivot = + isSignalBoxBullishDir + ? signalBox.lower + : signalBox.upper; + + // + point = + isSignalBoxBullishDir + ? signalBox.upper + : signalBox.lower; + + // + double defaultTarget = + isSignalBoxBullishDir + ? signalBox.upper + : signalBox.lower; + Add( + defaultTarget, + targets // + ); + + // + // Detect SLs ... + double iAtr = decisionXConditions.atrBuffer[0]; + iAtr *= 1.5; + + // + double defaultSL = + isSignalBoxBullishDir + ? decisionXConditions.valesBuffer[0] - iAtr + : decisionXConditions.peaksBuffer[0] + iAtr; + + // + Add( + defaultSL, + sls // + ); + + // + // Summaries Conditions ... + result = + pivot > 0 && + point > 0 && + hasPriority && + hasRewardAmount; + if (result) + { + // + isBullish = signalBox.IsBullish(); + isBearish = signalBox.IsBearish(); + + // + Copy( + sls, + mConditions.sls // + ); + Copy( + targets, + mConditions.targets // + ); + + // + mConditions.pivot = pivot; + mConditions.point = point; + mConditions.reward = reward; + mConditions.setupTime = cTime; + mConditions.priority = priority; + mConditions.provider = provider; + mConditions.dir = signalBox.dir; + mConditions.signalBox = signalBox; + mConditions.amountPercent = amountPercent; + } + + // + signalBox.Clean(); + hasSignalBox = false; + } + // UpdateTo(cTime); @@ -664,15 +962,15 @@ class XCX121SMCXWZSignalDetector : public XCBase // workingZone.Draw( drawer, - true, // Draw Waiting Zones .. - true, // Draw Inside Zones .. - false, // Draw Breaked Zones .. - false, // Draw Supply Zone .. - false, // Draw Demand Zone .. - false, // Draw Supply Zones .. - false, // Draw Demand Zones .. - false, // Draw Support Zones .. - false // Draw Resistance Zones .. + true, // Draw Waiting Zones ... + true, // Draw Inside Zones ... + true, // Draw Breaked Zones ... + true, // Draw Supply Zone ... + true, // Draw Demand Zone ... + true, // Draw Supply Zones ... + true, // Draw Demand Zones ... + false, // Draw Support Zones ... + false // Draw Resistance Zones ... ); // @@ -698,6 +996,39 @@ class XCX121SMCXWZSignalDetector : public XCBase // true, // Ignore BullishConsolidationZones ... // true // Ignore BearishConsolidationZones ... // ); + + // // + // int count = 0; + // bool has = false; + + // // + // has = workingZone.HasSupplyZones(); + // if (has) + // { + // } + + // // + // has = workingZone.HasDemandZones(); + // if (has) + // { + // // + // count = workingZone.CountDemandZones(); + // for (int i = 0; i < count; i++) + // { + // // + // XCDemandZone *iZone = workingZone.demandZones[i]; + + // // + // XCDemandZoneObject *iObj; + // bool isCreated = drawer.CreateDemandZone( + // iZone, + // iObj // + // ); + // } + // } + + // // + // Print(""); } // diff --git a/X121SMCEA/Signals/x-121.smc.xwz.signal.lib.mq5 b/X121SMCEA/Signals/x-121.smc.xwz.signal.lib.mq5 index 003dc1a8..b438b53e 100644 --- a/X121SMCEA/Signals/x-121.smc.xwz.signal.lib.mq5 +++ b/X121SMCEA/Signals/x-121.smc.xwz.signal.lib.mq5 @@ -630,6 +630,16 @@ struct X121SMCStrategyXWZWorkingZone continue; } + // + // Checking Price Validation ... + has = cBar.high < tmpSupplies[i].Lower(); + if (!has) + { + // + iBox.Clean(); + continue; + } + // Add( tmpSupplies[i], @@ -718,6 +728,16 @@ struct X121SMCStrategyXWZWorkingZone continue; } + // + // Checking Price Validation ... + has = cBar.low > tmpDemands[i].Upper(); + if (!has) + { + // + iBox.Clean(); + continue; + } + // Add( tmpDemands[i], @@ -728,7 +748,7 @@ struct X121SMCStrategyXWZWorkingZone iBox.Clean(); } } - Clean(demandZones); + Clean(tmpDemands); // // Support Zones ... @@ -806,6 +826,16 @@ struct X121SMCStrategyXWZWorkingZone continue; } + // + // Checking Price Validation ... + has = cBar.low > tmpSupports[i].Upper(); + if (!has) + { + // + iBox.Clean(); + continue; + } + // Add( tmpSupports[i], @@ -894,6 +924,16 @@ struct X121SMCStrategyXWZWorkingZone continue; } + // + // Checking Price Validation ... + has = cBar.high < tmpResistances[i].Lower(); + if (!has) + { + // + iBox.Clean(); + continue; + } + // Add( tmpResistances[i], @@ -909,353 +949,397 @@ struct X121SMCStrategyXWZWorkingZone // // STF TTF ... - // - // Supply Zones ... - count = stfState.FilterSupplyZones( - tmpSupplies, - NULL, - XZONE_STATE_PASSED, - false, - XZONE_STATE_FAILED, - false, - XZONE_STATE_FAILED, - false, - XZONE_STATE_IGNORED, - false // - ); - has = IsValidSize(count); - if (has) - { - // - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox; - has = ToBox( - iBox, - tmpSupplies[i] // - ); - if (!has) - { - // - iBox.Clean(); - continue; - } + // // + // // Supply Zones ... + // count = stfState.FilterSupplyZones( + // tmpSupplies, + // NULL, + // XZONE_STATE_PASSED, + // false, + // XZONE_STATE_FAILED, + // false, + // XZONE_STATE_FAILED, + // false, + // XZONE_STATE_IGNORED, + // false // + // ); + // has = IsValidSize(count); + // if (has) + // { + // // + // for (int i = 0; i < count; i++) + // { + // // + // XBoxZone iBox; + // has = ToBox( + // iBox, + // tmpSupplies[i] // + // ); + // if (!has) + // { + // // + // iBox.Clean(); + // continue; + // } - // - // Find Index ... + // // + // // Find Index ... - // - idx = FindIndex( - iBox, - insideBoxes // - ); - has = !IsValidIndex(idx); - if (!has) - { - // - iBox.Clean(); - continue; - } + // // + // idx = FindIndex( + // iBox, + // insideBoxes // + // ); + // has = !IsValidIndex(idx); + // if (!has) + // { + // // + // iBox.Clean(); + // continue; + // } - // - idx = FindIndex( - iBox, - breakedBoxes // - ); - has = !IsValidIndex(idx); - if (!has) - { - // - iBox.Clean(); - continue; - } + // // + // idx = FindIndex( + // iBox, + // breakedBoxes // + // ); + // has = !IsValidIndex(idx); + // if (!has) + // { + // // + // iBox.Clean(); + // continue; + // } - // - idx = FindIndex( - tmpSupplies[i], - supplyZones // - ); - has = !IsValidIndex(idx); - if (!has) - { - // - iBox.Clean(); - continue; - } + // // + // idx = FindIndex( + // tmpSupplies[i], + // supplyZones // + // ); + // has = !IsValidIndex(idx); + // if (!has) + // { + // // + // iBox.Clean(); + // continue; + // } - // - Add( - tmpSupplies[i], - supplyZones // - ); + // // + // // Checking Price Validation ... + // has = cBar.high < tmpSupplies[i].Lower(); + // if (!has) + // { + // // + // iBox.Clean(); + // continue; + // } - // - iBox.Clean(); - } - } - Clean(tmpSupplies); + // // + // Add( + // tmpSupplies[i], + // supplyZones // + // ); + + // // + // iBox.Clean(); + // } + // } + // Clean(tmpSupplies); + + // // + // // Demand Zones ... + // count = stfState.FilterDemandZones( + // tmpDemands, + // NULL, + // XZONE_STATE_PASSED, + // false, + // XZONE_STATE_FAILED, + // false, + // XZONE_STATE_FAILED, + // false, + // XZONE_STATE_IGNORED, + // false // + // ); + // has = IsValidSize(count); + // if (has) + // { + // // + // for (int i = 0; i < count; i++) + // { + // // + // XBoxZone iBox; + // has = ToBox( + // iBox, + // tmpDemands[i] // + // ); + // if (!has) + // { + // // + // iBox.Clean(); + // continue; + // } + + // // + // // Find Index ... + + // // + // idx = FindIndex( + // iBox, + // insideBoxes // + // ); + // has = !IsValidIndex(idx); + // if (!has) + // { + // // + // iBox.Clean(); + // continue; + // } + + // // + // idx = FindIndex( + // iBox, + // breakedBoxes // + // ); + // has = !IsValidIndex(idx); + // if (!has) + // { + // // + // iBox.Clean(); + // continue; + // } + + // // + // idx = FindIndex( + // tmpDemands[i], + // demandZones // + // ); + // has = !IsValidIndex(idx); + // if (!has) + // { + // // + // iBox.Clean(); + // continue; + // } + + // // + // // Checking Price Validation ... + // has = cBar.low > tmpDemands[i].Upper(); + // if (!has) + // { + // // + // iBox.Clean(); + // continue; + // } + + // // + // Add( + // tmpDemands[i], + // demandZones // + // ); + + // // + // iBox.Clean(); + // } + // } + // Clean(tmpDemands); + + // // + // // Support Zones ... + // count = ttfState.FilterSupportZones( + // tmpSupports, + // period, + // XZONE_STATE_PASSED, + // false, + // XZONE_STATE_FAILED, + // false, + // XZONE_STATE_FAILED, + // false, + // XZONE_STATE_IGNORED, + // false // + // ); + // has = IsValidSize(count); + // if (has) + // { + // // + // for (int i = 0; i < count; i++) + // { + // // + // XBoxZone iBox; + // has = ToBox( + // iBox, + // tmpSupports[i] // + // ); + // if (!has) + // { + // // + // iBox.Clean(); + // continue; + // } + + // // + // // Find Index ... + + // // + // idx = FindIndex( + // iBox, + // insideBoxes // + // ); + // has = !IsValidIndex(idx); + // if (!has) + // { + // // + // iBox.Clean(); + // continue; + // } + + // // + // idx = FindIndex( + // iBox, + // breakedBoxes // + // ); + // has = !IsValidIndex(idx); + // if (!has) + // { + // // + // iBox.Clean(); + // continue; + // } + + // // + // idx = FindIndex( + // tmpSupports[i], + // supportZones // + // ); + // has = !IsValidIndex(idx); + // if (!has) + // { + // // + // iBox.Clean(); + // continue; + // } + + // // + // // Checking Price Validation ... + // has = cBar.low > tmpSupports[i].Upper(); + // if (!has) + // { + // // + // iBox.Clean(); + // continue; + // } + + // // + // Add( + // tmpSupports[i], + // supportZones // + // ); + + // // + // iBox.Clean(); + // } + // } + // Clean(tmpSupports); + + // // + // // Resistance Zones .. + // count = ttfState.FilterResistanceZones( + // tmpResistances, + // period, + // XZONE_STATE_PASSED, + // false, + // XZONE_STATE_FAILED, + // false, + // XZONE_STATE_FAILED, + // false, + // XZONE_STATE_IGNORED, + // false // + // ); + // has = IsValidSize(count); + // if (has) + // { + // // + // for (int i = 0; i < count; i++) + // { + // // + // XBoxZone iBox; + // has = ToBox( + // iBox, + // tmpResistances[i] // + // ); + // if (!has) + // { + // // + // iBox.Clean(); + // continue; + // } + + // // + // // Find Index ... + + // // + // idx = FindIndex( + // iBox, + // insideBoxes // + // ); + // has = !IsValidIndex(idx); + // if (!has) + // { + // // + // iBox.Clean(); + // continue; + // } + + // // + // idx = FindIndex( + // iBox, + // breakedBoxes // + // ); + // has = !IsValidIndex(idx); + // if (!has) + // { + // // + // iBox.Clean(); + // continue; + // } + + // // + // idx = FindIndex( + // tmpResistances[i], + // resistanceZones // + // ); + // has = !IsValidIndex(idx); + // if (!has) + // { + // // + // iBox.Clean(); + // continue; + // } + + // // + // // Checking Price Validation ... + // has = cBar.high < tmpResistances[i].Lower(); + // if (!has) + // { + // // + // iBox.Clean(); + // continue; + // } + + // // + // Add( + // tmpResistances[i], + // resistanceZones // + // ); + + // // + // iBox.Clean(); + // } + // } + // Clean(tmpResistances); // - // Demand Zones ... - count = stfState.FilterDemandZones( - tmpDemands, - NULL, - XZONE_STATE_PASSED, - false, - XZONE_STATE_FAILED, - false, - XZONE_STATE_FAILED, - false, - XZONE_STATE_IGNORED, - false // - ); - has = IsValidSize(count); - if (has) - { - // - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox; - has = ToBox( - iBox, - tmpDemands[i] // - ); - if (!has) - { - // - iBox.Clean(); - continue; - } - - // - // Find Index ... - - // - idx = FindIndex( - iBox, - insideBoxes // - ); - has = !IsValidIndex(idx); - if (!has) - { - // - iBox.Clean(); - continue; - } - - // - idx = FindIndex( - iBox, - breakedBoxes // - ); - has = !IsValidIndex(idx); - if (!has) - { - // - iBox.Clean(); - continue; - } - - // - idx = FindIndex( - tmpDemands[i], - demandZones // - ); - has = !IsValidIndex(idx); - if (!has) - { - // - iBox.Clean(); - continue; - } - - // - Add( - tmpDemands[i], - demandZones // - ); - - // - iBox.Clean(); - } - } - Clean(demandZones); - // - // Support Zones ... - count = ttfState.FilterSupportZones( - tmpSupports, - period, - XZONE_STATE_PASSED, - false, - XZONE_STATE_FAILED, - false, - XZONE_STATE_FAILED, - false, - XZONE_STATE_IGNORED, - false // - ); - has = IsValidSize(count); - if (has) - { - // - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox; - has = ToBox( - iBox, - tmpSupports[i] // - ); - if (!has) - { - // - iBox.Clean(); - continue; - } - - // - // Find Index ... - - // - idx = FindIndex( - iBox, - insideBoxes // - ); - has = !IsValidIndex(idx); - if (!has) - { - // - iBox.Clean(); - continue; - } - - // - idx = FindIndex( - iBox, - breakedBoxes // - ); - has = !IsValidIndex(idx); - if (!has) - { - // - iBox.Clean(); - continue; - } - - // - idx = FindIndex( - tmpSupports[i], - supportZones // - ); - has = !IsValidIndex(idx); - if (!has) - { - // - iBox.Clean(); - continue; - } - - // - Add( - tmpSupports[i], - supportZones // - ); - - // - iBox.Clean(); - } - } - Clean(tmpSupports); - // - // Resistance Zones .. - count = ttfState.FilterResistanceZones( - tmpResistances, - period, - XZONE_STATE_PASSED, - false, - XZONE_STATE_FAILED, - false, - XZONE_STATE_FAILED, - false, - XZONE_STATE_IGNORED, - false // - ); - has = IsValidSize(count); - if (has) - { - // - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox; - has = ToBox( - iBox, - tmpResistances[i] // - ); - if (!has) - { - // - iBox.Clean(); - continue; - } - - // - // Find Index ... - - // - idx = FindIndex( - iBox, - insideBoxes // - ); - has = !IsValidIndex(idx); - if (!has) - { - // - iBox.Clean(); - continue; - } - - // - idx = FindIndex( - iBox, - breakedBoxes // - ); - has = !IsValidIndex(idx); - if (!has) - { - // - iBox.Clean(); - continue; - } - - // - idx = FindIndex( - tmpResistances[i], - resistanceZones // - ); - has = !IsValidIndex(idx); - if (!has) - { - // - iBox.Clean(); - continue; - } - - // - Add( - tmpResistances[i], - resistanceZones // - ); - - // - iBox.Clean(); - } - } - Clean(tmpResistances); // // Consolidation Zones ... @@ -2222,6 +2306,33 @@ struct X121SMCStrategyXWZWorkingZone } } + // + // Demand Zone ... + if (drawDemandZone) + { + // + has = HasDemandZone(); + if (has) + { + // + XCDemandZoneObject *iObj; + isCreated = drawer.CreateDemandZone( + demandZone, + iObj // + ); + + // + if (isCreated) + { + mWorkingZoneObjects.Add(iObj); + } + } + } + + // + // + // + // // Supply Zones ... if (drawSupplyZones) @@ -2250,29 +2361,6 @@ struct X121SMCStrategyXWZWorkingZone } } - // - // Demand Zone ... - if (drawDemandZone) - { - // - has = HasDemandZone(); - if (has) - { - // - XCDemandZoneObject *iObj; - isCreated = drawer.CreateDemandZone( - demandZone, - iObj // - ); - - // - if (isCreated) - { - mWorkingZoneObjects.Add(iObj); - } - } - } - // // Demand Zones ... if (drawDemandZones) @@ -2357,6 +2445,10 @@ struct X121SMCStrategyXWZWorkingZone } } + // + // + // + // // Waiting Zones ... if (drawWaitingZones) @@ -2503,6 +2595,10 @@ struct X121SMCStrategyXWZWorkingZone } } + // + // + // + // // Quarters ... has = IsValid(); @@ -2692,7 +2788,7 @@ struct X121SMCStrategyXWZSignalConditions double targets[]; // - XOBFVG signalZone; + XBoxZone signalBox; // ENUM_X121SMC_XWZ_PRIORITY priority; @@ -2825,7 +2921,7 @@ struct X121SMCStrategyXWZSignalConditions // Clean(sls); Clean(targets); - signalZone.Clean(); + signalBox.Clean(); // provider = X121SMC_XWZ_PROVIDER_NONE; @@ -3107,7 +3203,7 @@ bool DetectSelectedZoneConditions( * * @return ( bool ) */ -bool DetectSelectedZoneConditions( +bool DetectSelectedBoxConditions( bool &isReversal, XBoxZone &zone, XPOIState &state,