diff --git a/Documents/BKP/1/signals/tmp.codes.signals.mq5 b/Documents/BKP/1/signals/tmp.codes.signals.mq5 index eb822501..0e982a59 100644 --- a/Documents/BKP/1/signals/tmp.codes.signals.mq5 +++ b/Documents/BKP/1/signals/tmp.codes.signals.mq5 @@ -4531,6 +4531,55 @@ bool TestFVG( ///////////////////////////////////////////////////////////////////// +else if (isPriceInsideSupplyZone) +{ + // + if (isPriceInsideVisionSupplyZone) + { + // + upper = conditions.visionHighestSupplyZone.Upper(); + lower = conditions.visionHighestSupplyZone.Lower(); + + // + isInsideZoneDirectionBullish = false; + isInsideZoneDirectionBearish = true; + } + else if (isPriceInsideConsolidationSupplyZone) + { + // + upper = conditions.consolidationHighestSupplyZone.Upper(); + lower = conditions.consolidationHighestSupplyZone.Lower(); + + // + isInsideZoneDirectionBullish = false; + isInsideZoneDirectionBearish = true; + } +} +else if (isPriceInsideDemandZone) +{ + // + if (isPriceInsideVisionDemandZone) + { + // + upper = conditions.visionLowestDemandZone.Upper(); + lower = conditions.visionLowestDemandZone.Lower(); + + // + isInsideZoneDirectionBullish = true; + isInsideZoneDirectionBearish = false; + } + else if (isPriceInsideConsolidationDemandZone) + { + // + upper = conditions.consolidationLowestDemandZone.Upper(); + lower = conditions.consolidationLowestDemandZone.Lower(); + + // + isInsideZoneDirectionBullish = true; + isInsideZoneDirectionBearish = false; + } +} + ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// diff --git a/Libraries/x-saherelm.x-poi.lib.mq5 b/Libraries/x-saherelm.x-poi.lib.mq5 index 704f6f90..5b9bf548 100644 --- a/Libraries/x-saherelm.x-poi.lib.mq5 +++ b/Libraries/x-saherelm.x-poi.lib.mq5 @@ -4323,7 +4323,7 @@ class XCTicksZone : public XCTwoBarZone { // bool result = false; - + // result = endBar.IsValid() && startBar.IsValid(); @@ -4333,7 +4333,8 @@ class XCTicksZone : public XCTwoBarZone } // - if (!IsSpecifiedValid(forPeriod)) { + if (!IsSpecifiedValid(forPeriod)) + { forPeriod = endBar.period; } @@ -7209,6 +7210,50 @@ bool IsBelow( return result; } +template +bool IsReject( + ENUM_X_DIRECTION forDir, + XOHCL &bar, + T *source, + XPOIState &state, + XOHCL &swingBar, + XOHCL &rejectBar, + XOHCL &breakerBar, + XOHCL &momentumBar, + bool forceSwingRejection = true // +) +{ + // + bool result = false; + + // + XBoxZone sourceBox; + result = ToBox( + sourceBox, + source // + ); + if (!result) + { + return result; + } + + // + result = IsRejectBox( + forDir, + bar, + sourceBox, + state, + swingBar, + rejectBar, + breakerBar, + momentumBar, + forceSwingRejection // + ); + + // + return result; +} + template void UpdateTo( T *&source[], @@ -7482,6 +7527,485 @@ bool IsBelowBox( return result; } +// +bool IsRejectBox( + ENUM_X_DIRECTION &forDir, + XOHCL &bar, + XBoxZone &box, + XPOIState &state, + XOHCL &swingBar, + XOHCL &rejectBar, + XOHCL &breakerBar, + XOHCL &momentumBar, + bool forceSwingRejection = true // +) +{ + // + bool result = false; + + // + swingBar.Clean(); + rejectBar.Clean(); + breakerBar.Clean(); + momentumBar.Clean(); + + // + result = bar.IsValid() && + box.IsValid() && + state.IsValid() && + state.HasChild() && + HasDirection(forDir); + if (!result) + { + return result; + } + + // + bool isBullish = IsBullish(forDir); + + // + double appliedPrice = + isBullish + ? box.upper + : box.lower; + + // + // Fetch Required Bars ... + + // + XOHCL cBar; + result = bar.GetPreviousBar(cBar); + if (!result) + { + return result; + } + + // + XOHCL pBar; + result = cBar.GetPreviousBar(pBar); + if (!result) + { + return result; + } + + // + XOHCL ppBar; + result = pBar.GetPreviousBar(ppBar); + if (!result) + { + return result; + } + + // + // Check Directional Swing Type ... + ENUM_X_SWING_TYPE swingType = + isBullish + ? X_SWING_LOW + : X_SWING_HIGH; + + // + bool isSwingLow = + // + pBar.low < ppBar.low && + pBar.low < cBar.low && + bar.open > pBar.low && + // + appliedPrice > pBar.low && + appliedPrice < pBar.GetDown() + // + ; + + // + bool isSwingHigh = + // + pBar.high > ppBar.high && + pBar.high > cBar.high && + bar.open < pBar.high && + // + appliedPrice < pBar.high && + appliedPrice > pBar.GetUp() + // + ; + + // + // Force Rejected By Swing ... + if (forceSwingRejection) + { + // + result = swingType == X_SWING_HIGH + ? isSwingHigh + : swingType == X_SWING_LOW + ? isSwingLow + : false; + if (!result) + { + return result; + } + } + + // + bool hasValidSwing = + isBullish + ? isSwingLow + : isSwingHigh; + if (hasValidSwing) + { + swingBar = pBar; + } + + // + bool isCBarBreaked = IsBarBreak( + appliedPrice, + forDir, + cBar // + ); + if (isCBarBreaked) + { + breakerBar = cBar; + } + bool isPBarBreaked = IsBarBreak( + appliedPrice, + forDir, + pBar // + ); + if (isPBarBreaked) + { + breakerBar = pBar; + } + bool isPPBarBreaked = IsBarBreak( + appliedPrice, + forDir, + ppBar // + ); + if (isPPBarBreaked) + { + breakerBar = ppBar; + } + bool isBoxBreaked = isCBarBreaked || + isPBarBreaked || + isPPBarBreaked; + + // + bool isCBarRejected = IsBarReject( + appliedPrice, + forDir, + cBar // + ); + if (isCBarRejected) + { + rejectBar = cBar; + } + bool isPBarRejected = IsBarReject( + appliedPrice, + forDir, + pBar // + ); + if (isPBarRejected) + { + rejectBar = pBar; + } + bool isPPBarRejected = IsBarReject( + appliedPrice, + forDir, + ppBar // + ); + if (isPPBarRejected) + { + rejectBar = ppBar; + } + bool isBoxRejected = isCBarRejected || + isPBarRejected || + isPPBarRejected; + + // + int count = 0; + + // + bool hasRejectionBar = false; + if (isBullish) + { + // + count = state.CountBullishRejectionBars(); + for (int i = 0; i < count; i++) + { + // + XCRejectionBar *iZone = state.bullishRejectionBars[i]; + + // + XOHCL iBar; + bool isFilled = iZone.FillBar(iBar); + if (!isFilled) + { + continue; + } + + // + int iBarIndex = iBar.Index(); + + // + hasRejectionBar = + // + (iBarIndex == cBar.Index() || + iBarIndex == pBar.Index()) + // + ; + if (hasRejectionBar) + { + // + if (!rejectBar.IsValid()) + { + rejectBar = iBar; + } + + // + break; + } + } + } + else + { + // + count = state.CountBearishRejectionBars(); + for (int i = 0; i < count; i++) + { + // + XCRejectionBar *iZone = state.bearishRejectionBars[i]; + + // + XOHCL iBar; + bool isFilled = iZone.FillBar(iBar); + if (!isFilled) + { + continue; + } + + // + int iBarIndex = iBar.Index(); + + // + hasRejectionBar = + // + (iBarIndex == cBar.Index() || + iBarIndex == pBar.Index()) + // + ; + if (hasRejectionBar) + { + // + if (!rejectBar.IsValid()) + { + rejectBar = iBar; + } + + // + break; + } + } + } + + // + bool hasMomentumBar = false; + if (isBullish) + { + // + count = state.CountBullishMomentumBars(); + for (int i = 0; i < count; i++) + { + // + XCMomentumBar *iZone = state.bullishMomentumBars[i]; + + // + XOHCL iBar; + bool isFilled = iZone.FillBar(iBar); + if (!isFilled) + { + continue; + } + + // + int iBarIndex = iBar.Index(); + + // + hasMomentumBar = + // + (iBarIndex == cBar.Index() || + iBarIndex == pBar.Index()) + // + ; + if (hasMomentumBar) + { + // + if (!momentumBar.IsValid()) + { + momentumBar = iBar; + } + + // + break; + } + } + } + else + { + // + count = state.CountBearishMomentumBars(); + for (int i = 0; i < count; i++) + { + // + XCMomentumBar *iZone = state.bearishMomentumBars[i]; + + // + XOHCL iBar; + bool isFilled = iZone.FillBar(iBar); + if (!isFilled) + { + continue; + } + + // + int iBarIndex = iBar.Index(); + + // + hasMomentumBar = + // + (iBarIndex == cBar.Index() || + iBarIndex == pBar.Index()) + // + ; + if (hasMomentumBar) + { + // + if (!momentumBar.IsValid()) + { + momentumBar = iBar; + } + + // + break; + } + } + } + + // + bool hasSwing = false; + if (isBullish) + { + // + count = state.CountSwingLows(); + for (int i = 0; i < count; i++) + { + // + XCSwing *iSwing = state.swingLows[i]; + + // + XOHCL iBar; + bool isFilled = iSwing.FillBar(iBar); + if (!isFilled) + { + continue; + } + + // + int iBarIndex = iBar.Index(); + + // + hasSwing = + // + (iBarIndex == cBar.Index() || + iBarIndex == pBar.Index()) + // + ; + if (hasSwing) + { + // + if (!swingBar.IsValid()) + { + swingBar = iBar; + } + + // + break; + } + } + } + else + { + // + count = state.CountSwingHighs(); + for (int i = 0; i < count; i++) + { + // + XCSwing *iSwing = state.swingHighs[i]; + + // + XOHCL iBar; + bool isFilled = iSwing.FillBar(iBar); + if (!isFilled) + { + continue; + } + + // + int iBarIndex = iBar.Index(); + + // + hasSwing = + // + (iBarIndex == cBar.Index() || + iBarIndex == pBar.Index()) + // + ; + if (hasSwing) + { + // + if (!swingBar.IsValid()) + { + swingBar = iBar; + } + + // + break; + } + } + } + + // + bool hasRequiredValidations = + // + (hasRejectionBar || + hasMomentumBar) + // + || + // + (hasRejectionBar || + hasSwing) + // + || + // + (hasMomentumBar || + hasSwing) + // + ; + + // + result = + // + (isBoxBreaked && + (hasRequiredValidations || + hasValidSwing)) + // + || + // + (isBoxRejected && + (hasRequiredValidations || + hasValidSwing)) + // + ; + + // + return result; +} + /** * Converts a Consolidation Zone ... * @@ -8044,13 +8568,14 @@ typedef void (*TOnPOIEvent)(ENUM_XPOI_EVENTS event, // /** - * Extract UnActivated Order Blocks ... + * Extract UnActivated Order Blocks / Fair Value Gaps ... * * @return ( int ) */ -int ExtractUnActivatedOrderBlocks( - XCOrderBlock *&source[], - XCOrderBlock *&dest[] // +template +int ExtractUnActivatedZones( + T *&source[], + T *&dest[] // ) { // @@ -8071,7 +8596,7 @@ int ExtractUnActivatedOrderBlocks( for (int i = 0; i < count; i++) { // - XCOrderBlock *iChild = source[i]; + T *iChild = source[i]; ENUM_X_DIRECTION iChildForDir = iChild.GetDirection(); // @@ -8144,16 +8669,135 @@ int ExtractUnActivatedOrderBlocks( } /** - * Extract Directinal Based Order Blocks ... + * Extract ctivated Order Blocks / Fair Value Gaps ... + * + * @return ( int ) + */ +template +int ExtractActivatedZones( + T *&source[], + T *&dest[], + bool ignoreBreaktion = false // +) +{ + // + int result = 0; + + // + Clean(dest); + + // + int count = ArraySize(source); + int hasChild = IsValidSize(count); + if (!hasChild) + { + return result; + } + + // + for (int i = 0; i < count; i++) + { + // + T *iChild = source[i]; + ENUM_X_DIRECTION iChildForDir = iChild.GetDirection(); + + // + // Validate Started Zones ... + XOHCL iChildStartedBar; + ENUM_X_DIRECTION iChildStartedDir; + bool isStarted = iChild.IsStarted( + iChildForDir, + iChildStartedBar, + iChildStartedDir // + ); + if (!isStarted) + { + continue; + } + + // + // Validate InActive Zone ... + XOHCL iChildActivatedBar; + ENUM_X_DIRECTION iChildActivatedDir; + bool isActivated = iChild.IsActivated( + iChildForDir, + iChildActivatedBar, + iChildActivatedDir // + ); + if (!isActivated) + { + continue; + } + + // + // Validate Zone Iverse Breake ... + if (!ignoreBreaktion) + { + // + XOHCL iChildBreakedBar; + ENUM_X_DIRECTION iChildBreakedDir; + bool isBreaked = iChild.IsBreaked( + Opposit(iChildForDir), + iChildBreakedBar, + iChildBreakedDir, + true // Ignore Activation ... + ); + if (isBreaked) + { + continue; + } + + // + isBreaked = iChild.IsBreaked( + iChildForDir, + iChildBreakedBar, + iChildBreakedDir, + true // Ignore Activation ... + ); + if (isBreaked) + { + continue; + } + } + + // + int iChildIDX = -1; + bool isIChildExists = FindIndex( + iChildIDX, + iChild, + dest // + ); + if (isIChildExists) + { + continue; + } + + // + Add( + iChild, + dest // + ); + } + + // + result = ArraySize(dest); + + // + return result; +} + +/** + * Extract Directinal Based Order Blocks / Fair Value Gaps ... * * @param forDir: ENUM_X_DIRECTION member ... * * @return ( int ) */ -int ExtractDirectionalOrderBlocks( +template +int ExtractDirectionalZones( ENUM_X_DIRECTION forDir, - XCOrderBlock *&source[], - XCOrderBlock *&dest[] // + T *&source[], + T *&dest[] // ) { // @@ -8174,15 +8818,15 @@ int ExtractDirectionalOrderBlocks( for (int i = 0; i < count; i++) { // - XCOrderBlock *iOB = source[i]; + T *iChild = source[i]; // - ENUM_X_DIRECTION iForDir = iOB.GetDirection(); + ENUM_X_DIRECTION iForDir = iChild.GetDirection(); if (forDir == iForDir) { // Add( - iOB, + iChild, dest // ); } @@ -8196,15 +8840,16 @@ int ExtractDirectionalOrderBlocks( } /** - * Sort Order Blocks based on Place and Remove unused ... + * Sort Order Blocks / Fair Value Gaps based on Place and Remove unused ... */ -void OrderedSortOrderBlocks( - XCOrderBlock *youngest, - XCOrderBlock *&orderBlocks[] // +template +void OrderedSortZones( + T *youngest, + T *&items[] // ) { // - int count = ArraySize(orderBlocks); + int count = ArraySize(items); if (youngest == NULL || !youngest.IsValid() || !IsValidSize(count)) @@ -8217,24 +8862,24 @@ void OrderedSortOrderBlocks( bool isBullish = IsBullish(dir); // - XCOrderBlock *tmp[]; - XCOrderBlock *lastOB = youngest; + T *tmp[]; + T *lastOB = youngest; while (IsValidSize(count)) { // // Detect Youngest of Collection ... - int idx = GetYoungest(orderBlocks); - XCOrderBlock *iOB = orderBlocks[idx]; + int idx = GetYoungest(items); + T *iChild = items[idx]; ArrayRemove( - orderBlocks, + items, idx, 1 // ); - count = ArraySize(orderBlocks); + count = ArraySize(items); // // Check Direction Must be Same ... - ENUM_X_DIRECTION iDir = iOB.GetDirection(); + ENUM_X_DIRECTION iDir = iChild.GetDirection(); bool isSameDir = dir == iDir; if (!isSameDir) { @@ -8243,7 +8888,7 @@ void OrderedSortOrderBlocks( // // Check Creation time Sequence ... - bool isFromPassed = lastOB.From() > iOB.From(); + bool isFromPassed = lastOB.From() > iChild.From(); if (!isFromPassed) { continue; @@ -8254,7 +8899,7 @@ void OrderedSortOrderBlocks( bool isPlacePassed = isBullish ? IsBelow( - iOB, + iChild, lastOB, true // Ignore Inside ... ) @@ -8270,9 +8915,9 @@ void OrderedSortOrderBlocks( // // Update Last OB ... - lastOB = iOB; + lastOB = iChild; Add( - iOB, + iChild, tmp // ); @@ -8291,6 +8936,135 @@ void OrderedSortOrderBlocks( ); } } +template +void OrderedSortZones( + T *&items[] // +) +{ + // + int count = ArraySize(items); + if (!IsValidSize(count)) + { + return; + } + + // + // Detect Youngest ... + int youngestIDX = GetYoungest( + items // + ); + bool hasYoungest = IsValidSize(youngestIDX); + if (!hasYoungest) + { + return; + } + + // + T *youngest = items[youngestIDX]; + ArrayRemove( + items, + youngestIDX, + 1 // + ); + count = ArraySize(items); + if (!IsValidSize(count)) + { + // + Add( + youngest, + items // + ); + + // + return; + } + + // + if (youngest == NULL || + !youngest.IsValid()) + { + return; + } + + // + ENUM_X_DIRECTION dir = youngest.GetDirection(); + bool isBullish = IsBullish(dir); + + // + T *tmp[]; + T *lastOB = youngest; + while (IsValidSize(count)) + { + // + // Detect Youngest of Collection ... + int idx = GetYoungest(items); + T *iChild = items[idx]; + ArrayRemove( + items, + idx, + 1 // + ); + count = ArraySize(items); + + // + // Check Direction Must be Same ... + ENUM_X_DIRECTION iDir = iChild.GetDirection(); + bool isSameDir = dir == iDir; + if (!isSameDir) + { + continue; + } + + // + // Check Creation time Sequence ... + bool isFromPassed = lastOB.From() > iChild.From(); + if (!isFromPassed) + { + continue; + } + + // + // Check Order Block Place ... + bool isPlacePassed = + isBullish + ? IsBelow( + iChild, + lastOB, + true // Ignore Inside ... + ) + : IsAbove( + iChild, + lastOB, + true // Ignore Inside ... + ); + if (!isPlacePassed) + { + continue; + } + + // + // Update Last OB ... + lastOB = iChild; + Add( + iChild, + tmp // + ); + + // + } + + // + // Update Ordered Sorted Order Blocks ... + count = ArraySize(tmp); + if (IsValidSize(count)) + { + // + Copy( + tmp, + items // + ); + } +} /** * Extract Order Flows Swing Points ... diff --git a/X121SMCEA/Signals/x-121.smc.xsupdemobs.signal.lib.mq5 b/X121SMCEA/Signals/x-121.smc.xsupdemobs.signal.lib.mq5 index 42d41e34..67e90fdb 100644 --- a/X121SMCEA/Signals/x-121.smc.xsupdemobs.signal.lib.mq5 +++ b/X121SMCEA/Signals/x-121.smc.xsupdemobs.signal.lib.mq5 @@ -30,6 +30,7 @@ enum ENUM_X121SMC_XSUPDEMOBS_PRIORITY { X121SMC_XSUPDEMOBS_PRIORITY_NONE, + X121SMC_XSUPDEMOBS_PRIORITY_WEAK, X121SMC_XSUPDEMOBS_PRIORITY_LOW, X121SMC_XSUPDEMOBS_PRIORITY_REGULAR, X121SMC_XSUPDEMOBS_PRIORITY_HIGH, @@ -53,10 +54,6 @@ struct XOBFVG XCFVG *unActivatedFVGs[]; XCOrderBlock *unActivatedOBs[]; - // - XCOrderBlock *insideOB; - XCFVG *insideFVG; - // XOBFVG() { @@ -624,20 +621,6 @@ struct XOBFVG // return result; } - - // - bool HasInsideOB() - { - return insideOB != NULL && - insideOB.IsValid(); - } - - // - bool HasInsideFVG() - { - return insideFVG != NULL && - insideFVG.IsValid(); - } }; // @@ -962,6 +945,18 @@ struct X121SMCStrategyXSupDemOBSSignalConditions XCDemandZone *visionLowestDemandZone; XCDemandZone *consolidationLowestDemandZone; + // + XCFVG *insideFVG; + XCOrderBlock *insideOB; + + // + XCFVG *rejectedFVG; + XCOrderBlock *rejectedOB; + + // + XCSupplyZone *insideSupplyZone; + XCDemandZone *insideDemandZone; + // XOBFVG obFVGs[]; @@ -1093,6 +1088,14 @@ struct X121SMCStrategyXSupDemOBSSignalConditions Clean(obFVGs); workingZone.Clean(); + // + insideOB = NULL; + insideFVG = NULL; + rejectedOB = NULL; + rejectedFVG = NULL; + insideSupplyZone = NULL; + insideDemandZone = NULL; + // visionLowestDemandZone = NULL; visionHighestSupplyZone = NULL; @@ -1608,6 +1611,22 @@ struct X121SMCStrategyXSupDemOBSSignalConditions consolidationHighestSupplyZone.To(value); } + // + bool hasInsideOB = insideOB != NULL && + insideOB.IsValid(); + if (hasInsideOB) + { + insideOB.To(value); + } + + // + bool hasInsideFVG = insideFVG != NULL && + insideFVG.IsValid(); + if (hasInsideFVG) + { + insideFVG.To(value); + } + // bool hasOBFVGs = HasOBFVGs(); int obFVGsCount = CountOBFVGs(); @@ -1643,20 +1662,6 @@ struct X121SMCStrategyXSupDemOBSSignalConditions obFVGs[i].unActivatedFVGs[j].To(value); } } - - // - bool hasInsideOB = obFVGs[i].HasInsideOB(); - if (hasInsideOB) - { - obFVGs[i].insideOB.To(value); - } - - // - bool hasInsideFVG = obFVGs[i].HasInsideFVG(); - if (hasInsideFVG) - { - obFVGs[i].insideFVG.To(value); - } } } } @@ -2135,6 +2140,117 @@ bool DetectX121SMCXSupDemOBSSignalSetup( hasWorkingZone = conditions.ExtractWorkingZone(); } + // + // Here we Can Detect Price Inside SupDem Zones ... + + // + bool isPriceInsideSupplyZone = false; + bool isPriceInsideDemandZone = false; + bool isPriceInsideVisionSupplyZone = false; + bool isPriceInsideVisionDemandZone = false; + bool isPriceInsideConsolidationSupplyZone = false; + bool isPriceInsideConsolidationDemandZone = false; + if (hasVisionLowestDemandZone) + { + // + double iUpper = conditions.visionLowestDemandZone.Upper(); + double iLower = conditions.visionLowestDemandZone.Lower(); + + // + isPriceInsideVisionDemandZone = + // + decisionZBar.high < iUpper && + decisionCBar.high < iUpper && + // + decisionZBar.low > iLower && + decisionCBar.low > iLower + // + ; + } + if (hasVisionHighestSupplyZone) + { + // + double iUpper = conditions.visionHighestSupplyZone.Upper(); + double iLower = conditions.visionHighestSupplyZone.Lower(); + + // + isPriceInsideVisionSupplyZone = + // + decisionZBar.high < iUpper && + decisionCBar.high < iUpper && + // + decisionZBar.low > iLower && + decisionCBar.low > iLower + // + ; + } + if (hasConsolidationLowestDemandZone) + { + // + double iUpper = conditions.consolidationLowestDemandZone.Upper(); + double iLower = conditions.consolidationLowestDemandZone.Lower(); + + // + isPriceInsideConsolidationDemandZone = + // + decisionZBar.high < iUpper && + decisionCBar.high < iUpper && + // + decisionZBar.low > iLower && + decisionCBar.low > iLower + // + ; + } + if (hasConsolidationHighestSupplyZone) + { + // + double iUpper = conditions.consolidationHighestSupplyZone.Upper(); + double iLower = conditions.consolidationHighestSupplyZone.Lower(); + + // + isPriceInsideConsolidationSupplyZone = + // + decisionZBar.high < iUpper && + decisionCBar.high < iUpper && + // + decisionZBar.low > iLower && + decisionCBar.low > iLower + // + ; + } + + // + isPriceInsideSupplyZone = isPriceInsideVisionSupplyZone || + isPriceInsideConsolidationSupplyZone; + if (isPriceInsideSupplyZone) + { + // + if (isPriceInsideVisionSupplyZone) + { + conditions.insideSupplyZone = conditions.visionHighestSupplyZone; + } + else if (isPriceInsideConsolidationSupplyZone) + { + conditions.insideSupplyZone = conditions.consolidationHighestSupplyZone; + } + } + + // + isPriceInsideDemandZone = isPriceInsideVisionDemandZone || + isPriceInsideConsolidationDemandZone; + if (isPriceInsideDemandZone) + { + // + if (isPriceInsideVisionDemandZone) + { + conditions.insideDemandZone = conditions.visionLowestDemandZone; + } + else if (isPriceInsideConsolidationDemandZone) + { + conditions.insideDemandZone = conditions.consolidationLowestDemandZone; + } + } + // // Check Working Zone Destroy ... isDestroyed = conditions.IsWorkingZoneDestroyed( @@ -2228,7 +2344,7 @@ bool DetectX121SMCXSupDemOBSSignalSetup( // // Re Draw Working Zone ... - // RemoveX121SMCXSupDemOBSWorkingZoneDraws(); + RemoveX121SMCXSupDemOBSWorkingZoneDraws(); DrawX121SMCXSupDemOBSWorkingZone( conditions, visionCycleHelper.mPOIDrawer // @@ -2287,7 +2403,7 @@ bool DetectX121SMCXSupDemOBSSignalSetup( if (isPriceInQuarterOne) { // - bullishPriority = X121SMC_XSUPDEMOBS_PRIORITY_NONE; + bullishPriority = X121SMC_XSUPDEMOBS_PRIORITY_WEAK; bearishPriority = X121SMC_XSUPDEMOBS_PRIORITY_REGULAR; } @@ -2339,7 +2455,7 @@ bool DetectX121SMCXSupDemOBSSignalSetup( { // bullishPriority = X121SMC_XSUPDEMOBS_PRIORITY_REGULAR; - bearishPriority = X121SMC_XSUPDEMOBS_PRIORITY_NONE; + bearishPriority = X121SMC_XSUPDEMOBS_PRIORITY_WEAK; } // @@ -2637,8 +2753,12 @@ bool DetectX121SMCXSupDemOBSSignalSetup( } // - result = hasUnActivatedOBs || - hasUnActivatedFVGs; + result = + (isPriceInsideSupplyZone || + isPriceInsideDemandZone) + ? true + : (hasUnActivatedOBs || + hasUnActivatedFVGs); if (!result) { // @@ -2679,185 +2799,419 @@ bool DetectX121SMCXSupDemOBSSignalSetup( return result; } - // - Clean(obs); - Clean(fvgs); - - // - Clean(visionPoiEvents); - Clean(analysePoiEvents); - Clean(visionCycleEvents); - Clean(decisionPoiEvents); - Clean(analyseCycleEvents); - Clean(decisionCycleEvents); - Clean(consolidationPoiEvents); - Clean(consolidationCycleEvents); - - // - visionState.Clean(); - analyseState.Clean(); - decisionState.Clean(); - visionConditions.Clean(); - analyseConditions.Clean(); - visionXConditions.Clean(); - consolidationState.Clean(); - decisionConditions.Clean(); - analyseXConditions.Clean(); - decisionXConditions.Clean(); - consolidationConditions.Clean(); - consolidationXConditions.Clean(); - // // Now We Have to Wait for Price Inside Box ... // - XCFVG *insideFVG = NULL; - XCOrderBlock *insideOB = NULL; - for (int i = 0; i < obFVGsCount; i++) + XOHCL swingBar; + XOHCL rejectBar; + XOHCL breakerBar; + XOHCL momentumBar; + bool isPriceRejected = false; + XCFVG *insideFVG = conditions.insideFVG; + XCFVG *rejectedFVG = conditions.rejectedFVG; + XCOrderBlock *insideOB = conditions.insideOB; + XCOrderBlock *rejectedOB = conditions.rejectedOB; + XCSupplyZone *insideSupplyZone = conditions.insideSupplyZone; + XCDemandZone *insideDemandZone = conditions.insideDemandZone; + + // + bool hasInsideOB = insideOB != NULL && + insideOB.IsValid(); + bool hasInsideFVG = insideFVG != NULL && + insideFVG.IsValid(); + bool hasInsideZone = hasInsideOB || + hasInsideFVG; + bool hasRejectedOB = rejectedOB != NULL && + rejectedOB.IsValid(); + bool hasRejectedFVG = rejectedFVG != NULL && + rejectedFVG.IsValid(); + bool hasRejectedZone = hasRejectedOB || + hasRejectedFVG; + bool hasInsideSupplyZone = insideSupplyZone != NULL && + insideSupplyZone.IsValid(); + bool hasInsideDemandZone = insideDemandZone != NULL && + insideDemandZone.IsValid(); + bool hasInsideSupDemZone = hasInsideSupplyZone || + hasInsideDemandZone; + if (!hasInsideZone) { // - bool iOBFVGHasInsideOB = conditions.obFVGs[i].HasInsideOB(); - bool iOBFVGHasInsideFVG = conditions.obFVGs[i].HasInsideFVG(); - - // - bool iOBFVGHasUnActivatedOBs = conditions.obFVGs[i].HasUnActivatedOBs(); - int iOBFVGUnActivatedOBsCount = conditions.obFVGs[i].CountUnActivatedOBs(); - - // - bool iOBFVGHasUnActivatedFVGs = conditions.obFVGs[i].HasUnActivatedFVGs(); - int iOBFVGUnActivatedFVGsCount = conditions.obFVGs[i].CountUnActivatedFVGs(); - - // - // Detect Inside Zones ... - - // - if (!iOBFVGHasInsideOB && - iOBFVGHasUnActivatedOBs) + for (int i = 0; i < obFVGsCount; i++) { // - int idx = -1; - for (int j = 0; j < iOBFVGUnActivatedOBsCount; j++) + bool iOBFVGHasUnActivatedOBs = conditions.obFVGs[i].HasUnActivatedOBs(); + int iOBFVGUnActivatedOBsCount = conditions.obFVGs[i].CountUnActivatedOBs(); + + // + bool iOBFVGHasUnActivatedFVGs = conditions.obFVGs[i].HasUnActivatedFVGs(); + int iOBFVGUnActivatedFVGsCount = conditions.obFVGs[i].CountUnActivatedFVGs(); + + // + // Detect Inside Zones ... + + // + if (!hasInsideOB && + iOBFVGHasUnActivatedOBs) { // - ENUM_X_DIRECTION iForDir = conditions.obFVGs[i].unActivatedOBs[j].GetDirection(); - bool isIBullish = IsBullish(iForDir); - - // - bool isInsideFromUpper = IsInside( - decisionZBar.low, - conditions.obFVGs[i].unActivatedOBs[j] // - ); - bool isInsideFromLower = IsInside( - decisionZBar.high, - conditions.obFVGs[i].unActivatedOBs[j] // - ); - - // - bool isInside = - isBullish - ? isInsideFromUpper - : isInsideFromLower; - if (isInside) + int idx = -1; + for (int j = 0; j < iOBFVGUnActivatedOBsCount; j++) { // - idx = j; - insideOB = conditions.obFVGs[i].unActivatedOBs[j]; - conditions.obFVGs[i].insideOB = insideOB; - break; + ENUM_X_DIRECTION iForDir = conditions.obFVGs[i].unActivatedOBs[j].GetDirection(); + bool isIBullish = IsBullish(iForDir); + + // + bool isInsideFromUpper = IsInside( + decisionZBar.low, + conditions.obFVGs[i].unActivatedOBs[j] // + ); + bool isInsideFromLower = IsInside( + decisionZBar.high, + conditions.obFVGs[i].unActivatedOBs[j] // + ); + + // + bool isInside = + isBullish + ? isInsideFromUpper + : isInsideFromLower; + if (isInside) + { + // + idx = j; + insideOB = conditions.obFVGs[i].unActivatedOBs[j]; + conditions.insideOB = insideOB; + break; + } + } + + // + if (IsValidIndex(idx)) + { + // + ArrayRemove( + conditions.obFVGs[i].unActivatedOBs, + idx, + 1 // + ); } } // - if (IsValidIndex(idx)) + if (insideOB == NULL && + !hasInsideFVG && + iOBFVGHasUnActivatedFVGs) { // - ArrayRemove( - conditions.obFVGs[i].unActivatedOBs, - idx, - 1 // - ); + int idx = -1; + for (int j = 0; j < iOBFVGUnActivatedFVGsCount; j++) + { + // + ENUM_X_DIRECTION iForDir = conditions.obFVGs[i].unActivatedFVGs[j].GetDirection(); + bool isIBullish = IsBullish(iForDir); + + // + bool isInsideFromUpper = IsInside( + decisionZBar.low, + conditions.obFVGs[i].unActivatedFVGs[j] // + ); + bool isInsideFromLower = IsInside( + decisionZBar.high, + conditions.obFVGs[i].unActivatedFVGs[j] // + ); + + // + bool isInside = + isBullish + ? isInsideFromUpper + : isInsideFromLower; + if (isInside) + { + // + idx = j; + insideFVG = conditions.obFVGs[i].unActivatedFVGs[j]; + conditions.insideFVG = insideFVG; + break; + } + } + + // + if (IsValidIndex(idx)) + { + // + ArrayRemove( + conditions.obFVGs[i].unActivatedFVGs, + idx, + 1 // + ); + } } } // - if (insideOB == NULL && - !iOBFVGHasInsideFVG && - iOBFVGHasUnActivatedFVGs) + hasInsideOB = insideOB != NULL && + insideOB.IsValid(); + hasInsideFVG = insideFVG != NULL && + insideFVG.IsValid(); + hasInsideZone = hasInsideOB || + hasInsideFVG; + + // + // Here Detect Inside or Rejected Zones inside Supply and Demand Zones ... + // For Using them for Positions ... + if (!hasInsideZone && + hasInsideSupDemZone) { // - int idx = -1; - for (int j = 0; j < iOBFVGUnActivatedFVGsCount; j++) + ENUM_X_DIRECTION forDir = + hasInsideSupplyZone + ? X_DIRECTION_BEARISH + : X_DIRECTION_BULLISH; + + // + bool isLookingForBullish = IsBullish(forDir); + + // + XCFVG *fvgs[]; + XCOrderBlock *obs[]; + int obsCount = 0; + int fvgsCount = 0; + bool hasOBs = false; + bool hasFVGs = false; + + // + if (isLookingForBullish) { // - ENUM_X_DIRECTION iForDir = conditions.obFVGs[i].unActivatedFVGs[j].GetDirection(); - bool isIBullish = IsBullish(iForDir); + obsCount = ExtractUnActivatedZones( + analyseState.bullishOrderBlocks, + obs // + ); + hasOBs = IsValidSize(obsCount); // - bool isInsideFromUpper = IsInside( - decisionZBar.low, - conditions.obFVGs[i].unActivatedFVGs[j] // + fvgsCount = ExtractUnActivatedZones( + analyseState.bullishFairValueGaps, + fvgs // ); - bool isInsideFromLower = IsInside( - decisionZBar.high, - conditions.obFVGs[i].unActivatedFVGs[j] // + hasFVGs = IsValidSize(fvgsCount); + } + else + { + // + obsCount = ExtractUnActivatedZones( + analyseState.bearishOrderBlocks, + obs // ); + hasOBs = IsValidSize(obsCount); // - bool isInside = - isBullish - ? isInsideFromUpper - : isInsideFromLower; - if (isInside) + fvgsCount = ExtractUnActivatedZones( + analyseState.bearishFairValueGaps, + fvgs // + ); + hasFVGs = IsValidSize(fvgsCount); + } + + // + OrderedSortZones(obs); + OrderedSortZones(fvgs); + + // + obsCount = ArraySize(obs); + fvgsCount = ArraySize(fvgs); + + // + hasOBs = IsValidSize(obsCount); + hasFVGs = IsValidSize(fvgsCount); + if (hasOBs || + hasFVGs) + { + // + if (hasOBs) { // - idx = j; - insideFVG = conditions.obFVGs[i].unActivatedFVGs[j]; - conditions.obFVGs[i].insideFVG = insideFVG; - break; + for (int i = 0; i < obsCount; i++) + { + // + ENUM_X_DIRECTION iForDir = obs[i].GetDirection(); + bool isIBullish = IsBullish(iForDir); + + // + isPriceRejected = IsReject( + iForDir, + decisionZBar, + obs[i], + decisionState, + swingBar, + rejectBar, + breakerBar, + momentumBar, + false // + ); + if (isPriceRejected) + { + // + rejectedOB = obs[i]; + conditions.rejectedOB = rejectedOB; + } + + // + bool isInsideFromUpper = IsInside( + decisionZBar.low, + obs[i] // + ); + bool isInsideFromLower = IsInside( + decisionZBar.high, + obs[i] // + ); + + // + bool isInside = + isBullish + ? isInsideFromUpper + : isInsideFromLower; + if (isInside) + { + // + insideOB = obs[i]; + conditions.insideOB = obs[i]; + break; + } + } + } + + // + hasInsideOB = insideOB != NULL && + insideOB.IsValid(); + // + hasRejectedOB = rejectedOB != NULL && + rejectedOB.IsValid(); + + // + if (hasFVGs && + !hasInsideOB && + !hasRejectedOB) + { + // + for (int i = 0; i < fvgsCount; i++) + { + // + ENUM_X_DIRECTION iForDir = fvgs[i].GetDirection(); + bool isIBullish = IsBullish(iForDir); + + // + isPriceRejected = IsReject( + iForDir, + decisionZBar, + fvgs[i], + decisionState, + swingBar, + rejectBar, + breakerBar, + momentumBar, + false // + ); + if (isPriceRejected) + { + // + rejectedFVG = fvgs[i]; + conditions.rejectedFVG = rejectedFVG; + } + + // + bool isInsideFromUpper = IsInside( + decisionZBar.low, + fvgs[i] // + ); + bool isInsideFromLower = IsInside( + decisionZBar.high, + fvgs[i] // + ); + + // + bool isInside = + isBullish + ? isInsideFromUpper + : isInsideFromLower; + if (isInside) + { + // + insideFVG = fvgs[i]; + conditions.insideFVG = fvgs[i]; + break; + } + } } } // - if (IsValidIndex(idx)) - { - // - ArrayRemove( - conditions.obFVGs[i].unActivatedFVGs, - idx, - 1 // - ); - } + Clean(obs); + Clean(fvgs); } // - // Use Detected Inside Zones ... + hasInsideOB = insideOB != NULL && + insideOB.IsValid(); + hasInsideFVG = insideFVG != NULL && + insideFVG.IsValid(); + hasInsideZone = hasInsideOB || + hasInsideFVG; // - if (insideOB == NULL && - insideFVG == NULL) + hasRejectedOB = rejectedOB != NULL && + rejectedOB.IsValid(); + hasRejectedFVG = rejectedFVG != NULL && + rejectedFVG.IsValid(); + hasRejectedZone = hasRejectedOB || + hasRejectedFVG; + } + + // + if (!hasInsideZone && + !hasRejectedZone && + hasInsideSupDemZone) + { + // + // Check Supply and Demand Zone Rejection ... + if (hasInsideSupplyZone) { // - if (iOBFVGHasInsideOB) - { - // - insideOB = conditions.obFVGs[i].insideOB; - break; - } - else if (iOBFVGHasInsideFVG) - { - // - insideFVG = conditions.obFVGs[i].insideFVG; - break; - } + isPriceRejected = IsReject( + X_DIRECTION_BEARISH, + decisionZBar, + insideSupplyZone, + decisionState, + swingBar, + rejectBar, + breakerBar, + momentumBar, + false // + ); + } + else if (hasInsideDemandZone) + { + // + isPriceRejected = IsReject( + X_DIRECTION_BULLISH, + decisionZBar, + insideDemandZone, + decisionState, + swingBar, + rejectBar, + breakerBar, + momentumBar, + false // + ); } } // - bool hasPriceInsideOB = insideOB != NULL; - bool hasPriceInsideFVG = insideFVG != NULL; - bool hasPriceInsideZone = hasPriceInsideOB || - hasPriceInsideFVG; - result = hasPriceInsideZone; + result = hasInsideZone || + hasRejectedZone || + isPriceRejected; if (!result) { // @@ -2865,10 +3219,59 @@ bool DetectX121SMCXSupDemOBSSignalSetup( decisionCBar.Clean(); decisionPBar.Clean(); + // + swingBar.Clean(); + rejectBar.Clean(); + breakerBar.Clean(); + momentumBar.Clean(); + + // + Clean(obs); + Clean(fvgs); + + // + Clean(visionPoiEvents); + Clean(analysePoiEvents); + Clean(visionCycleEvents); + Clean(decisionPoiEvents); + Clean(analyseCycleEvents); + Clean(decisionCycleEvents); + Clean(consolidationPoiEvents); + Clean(consolidationCycleEvents); + + // + visionState.Clean(); + analyseState.Clean(); + decisionState.Clean(); + visionConditions.Clean(); + analyseConditions.Clean(); + visionXConditions.Clean(); + consolidationState.Clean(); + decisionConditions.Clean(); + analyseXConditions.Clean(); + decisionXConditions.Clean(); + consolidationConditions.Clean(); + consolidationXConditions.Clean(); + + // + ZeroMemory(insideOB); + ZeroMemory(insideFVG); + ZeroMemory(rejectedOB); + ZeroMemory(rejectedFVG); + ZeroMemory(insideSupplyZone); + ZeroMemory(insideDemandZone); + // return result; } + // + RemoveX121SMCXSupDemOBSDraws(); + DrawX121SMCXSupDemOBSConditions( + conditions, + visionCycleHelper.mPOIDrawer // + ); + // conditions.UpdateTo(cTime); @@ -2882,7 +3285,7 @@ bool DetectX121SMCXSupDemOBSSignalSetup( bool isInsideZoneDirectionBearish = false; // - if (hasPriceInsideOB) + if (hasInsideOB) { // upper = insideOB.Upper(); @@ -2892,7 +3295,7 @@ bool DetectX121SMCXSupDemOBSSignalSetup( isInsideZoneDirectionBullish = insideOB.IsBullish(); isInsideZoneDirectionBearish = insideOB.IsBearish(); } - else if (hasPriceInsideFVG) + else if (hasInsideFVG) { // upper = insideFVG.Upper(); @@ -2902,13 +3305,174 @@ bool DetectX121SMCXSupDemOBSSignalSetup( isInsideZoneDirectionBullish = insideFVG.IsBullish(); isInsideZoneDirectionBearish = insideFVG.IsBearish(); } + else if (isPriceRejected) + { + // + bool hasRejectedOB = rejectedOB != NULL; + bool hasRejectedFVG = rejectedFVG != NULL; + + // + if (hasRejectedOB) + { + // + DrawX121SMCXSupDemOBSOrderBlock( + rejectedOB, + consolidationCycleHelper.mPOIDrawer // + ); + } + + // + if (hasRejectedFVG) + { + // + DrawX121SMCXSupDemOBSFairValueGap( + rejectedFVG, + consolidationCycleHelper.mPOIDrawer // + ); + } + + // // + // if (!hasRejectedOB && + // !hasRejectedFVG) + // { + // // + // if (hasInsideSupDemZone) + // { + // // + // double min = 0; + // double max = 0; + // bool canSetMin = false; + // bool canSetMax = false; + + // // + // if (swingBar.IsValid()) + // { + // // + // canSetMin = + // min == 0 || min > swingBar.low; + // if (canSetMin) + // { + // min = swingBar.low; + // } + + // // + // canSetMax = + // max == 0 || max < swingBar.high; + // if (canSetMax) + // { + // max = swingBar.high; + // } + // } + + // // + // if (rejectBar.IsValid()) + // { + // // + // canSetMin = + // min == 0 || min > rejectBar.low; + // if (canSetMin) + // { + // min = rejectBar.low; + // } + + // // + // canSetMax = + // max == 0 || max < rejectBar.high; + // if (canSetMax) + // { + // max = rejectBar.high; + // } + // } + + // // + // if (breakerBar.IsValid()) + // { + // // + // canSetMin = + // min == 0 || min > breakerBar.low; + // if (canSetMin) + // { + // min = breakerBar.low; + // } + + // // + // canSetMax = + // max == 0 || max < breakerBar.high; + // if (canSetMax) + // { + // max = breakerBar.high; + // } + // } + + // // + // if (momentumBar.IsValid()) + // { + // // + // canSetMin = + // min == 0 || min > momentumBar.low; + // if (canSetMin) + // { + // min = momentumBar.low; + // } + + // // + // canSetMax = + // max == 0 || max < momentumBar.high; + // if (canSetMax) + // { + // max = momentumBar.high; + // } + // } + + // // + // upper = max; + // lower = min; + + // // + // if (hasInsideSupplyZone) + // { + // // + // isInsideZoneDirectionBullish = false; + // isInsideZoneDirectionBearish = true; + + // // + // lower = GetEntry( + // conditions.symbol, + // POSITION_TYPE_SELL // + // ); + // } + + // // + // if (hasInsideDemandZone) + // { + // // + // isInsideZoneDirectionBullish = true; + // isInsideZoneDirectionBearish = false; + + // // + // upper = GetEntry( + // conditions.symbol, + // POSITION_TYPE_BUY // + // ); + // } + // } + // } + } // // Cleanup Unused Objects ... + // + decisionZBar.Clean(); + decisionCBar.Clean(); + decisionPBar.Clean(); // ZeroMemory(insideOB); ZeroMemory(insideFVG); + ZeroMemory(rejectedOB); + ZeroMemory(rejectedFVG); + ZeroMemory(insideSupplyZone); + ZeroMemory(insideDemandZone); // Clean(visionPoiEvents); @@ -3036,6 +3600,12 @@ bool DetectX121SMCXSupDemOBSSignalSetup( visionCycleHelper.mPOIDrawer // ); + // + swingBar.Clean(); + rejectBar.Clean(); + breakerBar.Clean(); + momentumBar.Clean(); + // return result; } @@ -3363,7 +3933,7 @@ bool DetectX121SMCXSupDemOBSGuards( XC121SMCCycleHelper *decisionCycleHelper, XC121SMCCycleHelper *analyseCycleHelper, XC121SMCCycleHelper *consolidationCycleHelper, - XC121SMCCycleHelper *visionCycleHelper + XC121SMCCycleHelper *visionCycleHelper // ) { @@ -3699,214 +4269,6 @@ void DrawX121SMCXSupDemOBSFairValueGap( } } -// -void DrawX121SMCXSupDemOBSConditions( - X121SMCStrategyXSupDemOBSSignalConditions &conditions, - XCPOIDrawer *drawer, - bool forceClean = false // -) -{ - // - if (drawer == NULL) - { - return; - } - - // - if (forceClean) - { - mX121SMCXSupDemOBSObjects.Clear(); - } - - // - bool isCreated = false; - - // - int obFVGsCount = ArraySize(conditions.obFVGs); - bool hasOBFVGs = IsValidSize(obFVGsCount); - if (hasOBFVGs) - { - // - for (int i = 0; i < obFVGsCount; i++) - { - // - XOBFVG iOBFVG = conditions.obFVGs[i]; - - // - DrawX121SMCXSupDemOBSOrderBlock( - iOBFVG.ob, - drawer // - ); - - // - DrawX121SMCXSupDemOBSFairValueGap( - iOBFVG.fvg, - drawer // - ); - - // - int hasUnActivatedOBs = iOBFVG.HasUnActivatedOBs(); - int unActivatedOBsCount = iOBFVG.CountUnActivatedOBs(); - if (hasUnActivatedOBs) - { - // - for (int j = 0; j < unActivatedOBsCount; j++) - { - // - DrawX121SMCXSupDemOBSOrderBlock( - iOBFVG.unActivatedOBs[j], - drawer // - ); - } - } - - // - int hasUnActivatedFVGs = iOBFVG.HasUnActivatedFVGs(); - int unActivatedFVGsCount = iOBFVG.CountUnActivatedFVGs(); - if (hasUnActivatedFVGs) - { - // - for (int j = 0; j < unActivatedFVGsCount; j++) - { - // - DrawX121SMCXSupDemOBSFairValueGap( - iOBFVG.unActivatedFVGs[j], - drawer // - ); - } - } - - // - int insideZoneWidth = 1; - color insideZoneColor = clrYellow; - bool hasInsideOB = iOBFVG.HasInsideOB(); - if (hasInsideOB) - { - // - bool isBullish = iOBFVG.insideOB.IsBullish(); - - // - XCBaseObject *iObj = NULL; - isCreated = false; - if (isBullish) - { - // - XCBullishOrderBlockObject *iiObj; - isCreated = drawer.CreateBullishOrderBlock( - iOBFVG.insideOB, - iiObj // - ); - - // - if (isCreated) - { - // - iiObj.ZoneColor(insideZoneColor); - iiObj.ZoneWidth(insideZoneWidth); - - // - iObj = (XCBaseObject *)iiObj; - } - } - else - { - // - XCBearishOrderBlockObject *iiObj; - isCreated = drawer.CreateBearishOrderBlock( - iOBFVG.insideOB, - iiObj // - ); - - // - if (isCreated) - { - // - iiObj.ZoneColor(insideZoneColor); - iiObj.ZoneWidth(insideZoneWidth); - - // - iObj = (XCBaseObject *)iiObj; - } - } - - // - if (isCreated) - { - mX121SMCXSupDemOBSObjects.Add(iObj); - } - } - - // - bool hasInsideFVG = iOBFVG.HasInsideFVG(); - if (hasInsideFVG) - { - // - bool isBullish = iOBFVG.insideFVG.IsBullish(); - - // - XCBaseObject *iObj = NULL; - isCreated = false; - if (isBullish) - { - // - XCBullishFairValueGapObject *iiObj; - isCreated = drawer.CreateBullishFairValueGap( - iOBFVG.insideFVG, - iiObj // - ); - - // - if (isCreated) - { - // - iiObj.ZoneColor(insideZoneColor); - iiObj.ZoneWidth(insideZoneWidth); - - // - iObj = (XCBaseObject *)iiObj; - } - } - else - { - // - XCBearishFairValueGapObject *iiObj; - isCreated = drawer.CreateBearishFairValueGap( - iOBFVG.insideFVG, - iiObj // - ); - - // - if (isCreated) - { - // - iiObj.ZoneColor(insideZoneColor); - iiObj.ZoneWidth(insideZoneWidth); - - // - iObj = (XCBaseObject *)iiObj; - } - } - - // - if (isCreated) - { - mX121SMCXSupDemOBSObjects.Add(iObj); - } - } - } - } -} - -// -// -// - -// -void RemoveX121SMCXSupDemOBSWorkingZoneDraws() -{ - mX121SMCXSupDemOBSWorkingZoneObjects.Clear(); -} - // void DrawX121SMCXSupDemOBSWorkingZone( X121SMCStrategyXSupDemOBSSignalConditions &conditions, @@ -4128,6 +4490,216 @@ void DrawX121SMCXSupDemOBSWorkingZone( } } +// +void DrawX121SMCXSupDemOBSConditions( + X121SMCStrategyXSupDemOBSSignalConditions &conditions, + XCPOIDrawer *drawer, + bool forceClean = false // +) +{ + // + if (drawer == NULL) + { + return; + } + + // + if (forceClean) + { + mX121SMCXSupDemOBSObjects.Clear(); + } + + // + bool isCreated = false; + + // + int obFVGsCount = ArraySize(conditions.obFVGs); + bool hasOBFVGs = IsValidSize(obFVGsCount); + if (hasOBFVGs) + { + // + for (int i = 0; i < obFVGsCount; i++) + { + // + XOBFVG iOBFVG = conditions.obFVGs[i]; + + // + DrawX121SMCXSupDemOBSOrderBlock( + iOBFVG.ob, + drawer // + ); + + // + DrawX121SMCXSupDemOBSFairValueGap( + iOBFVG.fvg, + drawer // + ); + + // + int hasUnActivatedOBs = iOBFVG.HasUnActivatedOBs(); + int unActivatedOBsCount = iOBFVG.CountUnActivatedOBs(); + if (hasUnActivatedOBs) + { + // + for (int j = 0; j < unActivatedOBsCount; j++) + { + // + DrawX121SMCXSupDemOBSOrderBlock( + iOBFVG.unActivatedOBs[j], + drawer // + ); + } + } + + // + int hasUnActivatedFVGs = iOBFVG.HasUnActivatedFVGs(); + int unActivatedFVGsCount = iOBFVG.CountUnActivatedFVGs(); + if (hasUnActivatedFVGs) + { + // + for (int j = 0; j < unActivatedFVGsCount; j++) + { + // + DrawX121SMCXSupDemOBSFairValueGap( + iOBFVG.unActivatedFVGs[j], + drawer // + ); + } + } + } + } + + // + int insideZoneWidth = 1; + color insideZoneColor = clrYellow; + bool hasInsideOB = conditions.insideOB != NULL && + conditions.insideOB.IsValid(); + if (hasInsideOB) + { + // + bool isBullish = conditions.insideOB.IsBullish(); + + // + XCBaseObject *iObj = NULL; + isCreated = false; + if (isBullish) + { + // + XCBullishOrderBlockObject *iiObj; + isCreated = drawer.CreateBullishOrderBlock( + conditions.insideOB, + iiObj // + ); + + // + if (isCreated) + { + // + iiObj.ZoneColor(insideZoneColor); + iiObj.ZoneWidth(insideZoneWidth); + + // + iObj = (XCBaseObject *)iiObj; + } + } + else + { + // + XCBearishOrderBlockObject *iiObj; + isCreated = drawer.CreateBearishOrderBlock( + conditions.insideOB, + iiObj // + ); + + // + if (isCreated) + { + // + iiObj.ZoneColor(insideZoneColor); + iiObj.ZoneWidth(insideZoneWidth); + + // + iObj = (XCBaseObject *)iiObj; + } + } + + // + if (isCreated) + { + mX121SMCXSupDemOBSObjects.Add(iObj); + } + } + + // + bool hasInsideFVG = conditions.insideFVG != NULL && + conditions.insideFVG.IsValid(); + if (hasInsideFVG) + { + // + bool isBullish = conditions.insideFVG.IsBullish(); + + // + XCBaseObject *iObj = NULL; + isCreated = false; + if (isBullish) + { + // + XCBullishFairValueGapObject *iiObj; + isCreated = drawer.CreateBullishFairValueGap( + conditions.insideFVG, + iiObj // + ); + + // + if (isCreated) + { + // + iiObj.ZoneColor(insideZoneColor); + iiObj.ZoneWidth(insideZoneWidth); + + // + iObj = (XCBaseObject *)iiObj; + } + } + else + { + // + XCBearishFairValueGapObject *iiObj; + isCreated = drawer.CreateBearishFairValueGap( + conditions.insideFVG, + iiObj // + ); + + // + if (isCreated) + { + // + iiObj.ZoneColor(insideZoneColor); + iiObj.ZoneWidth(insideZoneWidth); + + // + iObj = (XCBaseObject *)iiObj; + } + } + + // + if (isCreated) + { + mX121SMCXSupDemOBSObjects.Add(iObj); + } + } +} + +// +// +// + +// +void RemoveX121SMCXSupDemOBSWorkingZoneDraws() +{ + mX121SMCXSupDemOBSWorkingZoneObjects.Clear(); +} + // // //