diff --git a/Classes/x-saherelm.x-bar.analyser.class.mq5 b/Classes/x-saherelm.x-bar.analyser.class.mq5 index 577fea6b..6fd75b1f 100644 --- a/Classes/x-saherelm.x-bar.analyser.class.mq5 +++ b/Classes/x-saherelm.x-bar.analyser.class.mq5 @@ -362,7 +362,8 @@ class XCBarAnalyser : public XCBase * Detect Price Consolidation ... * * @param bar: XOHCL instance Reference, Start Bar ... - * @param loopback: Integer, Consolidation Range Finder ... + * @param loopback: Integer, Consolidation Length Finder ... + * @param consolidationRange: Integer, Consolidation Range Finder ... * @param upper: Double Reference ... * @param lower: Double Reference ... * @param upperAppliedTo: ENUM_APPLIED_PRICE member, Upper Price ... @@ -375,6 +376,7 @@ class XCBarAnalyser : public XCBase double &upper, double &lower, int loopback = 30, + int consolidationRange = 70, ENUM_APPLIED_PRICE upperAppliedTo = PRICE_HIGH, ENUM_APPLIED_PRICE lowerAppliedTo = PRICE_LOW // ) @@ -399,8 +401,7 @@ class XCBarAnalyser : public XCBase return result; } - // - int consolidationRange = 30; + // double points = GetPoints(bar.symbol); int index = bar.Index(); diff --git a/Documents/BKP/1/signals/tmp.codes.signals.mq5 b/Documents/BKP/1/signals/tmp.codes.signals.mq5 index 0e982a59..000b3541 100644 --- a/Documents/BKP/1/signals/tmp.codes.signals.mq5 +++ b/Documents/BKP/1/signals/tmp.codes.signals.mq5 @@ -4582,4 +4582,893 @@ else if (isPriceInsideDemandZone) ///////////////////////////////////////////////////////////////////// + // // + // bool isPriceAboveUpper = + // // + // decisionZBar.high < conditions.workingZone.zoneUpper && + // decisionCBar.high < conditions.workingZone.zoneUpper && + // // + // decisionZBar.low > conditions.workingZone.upper && + // decisionCBar.low > conditions.workingZone.upper + // // + // ; + // if (isPriceAboveUpper) + // { + // // + // bullishPriority = X121SMC_XSUPDEMOBS_PRIORITY_NONE; + // bearishPriority = X121SMC_XSUPDEMOBS_PRIORITY_HIGH; + // } + + // // + // bool isPriceInQuarterOne = + // // + // decisionZBar.high < conditions.workingZone.upper && + // decisionCBar.high < conditions.workingZone.upper && + // // + // decisionZBar.low > conditions.workingZone.quarter1 && + // decisionCBar.low > conditions.workingZone.quarter1 + // // + // ; + // if (isPriceInQuarterOne) + // { + // // + // bullishPriority = X121SMC_XSUPDEMOBS_PRIORITY_NONE; + // bearishPriority = X121SMC_XSUPDEMOBS_PRIORITY_REGULAR; + // } + + // // + // bool isPriceInQuarterTwo = + // // + // decisionZBar.high < conditions.workingZone.quarter1 && + // decisionCBar.high < conditions.workingZone.quarter1 && + // // + // decisionZBar.low > conditions.workingZone.quarter2 && + // decisionCBar.low > conditions.workingZone.quarter2 + // // + // ; + // if (isPriceInQuarterTwo) + // { + // // + // bullishPriority = X121SMC_XSUPDEMOBS_PRIORITY_NONE; + // bearishPriority = X121SMC_XSUPDEMOBS_PRIORITY_LOW; + // } + + // // + // bool isPriceInQuarterThree = + // // + // decisionZBar.high < conditions.workingZone.quarter2 && + // decisionCBar.high < conditions.workingZone.quarter2 && + // // + // decisionZBar.low > conditions.workingZone.quarter3 && + // decisionCBar.low > conditions.workingZone.quarter3 + // // + // ; + // if (isPriceInQuarterThree) + // { + // // + // bullishPriority = X121SMC_XSUPDEMOBS_PRIORITY_LOW; + // bearishPriority = X121SMC_XSUPDEMOBS_PRIORITY_NONE; + // } + + // // + // bool isPriceInQuarterFour = + // // + // decisionZBar.high < conditions.workingZone.quarter3 && + // decisionCBar.high < conditions.workingZone.quarter3 && + // // + // decisionZBar.low > conditions.workingZone.lower && + // decisionCBar.low > conditions.workingZone.lower + // // + // ; + // if (isPriceInQuarterFour) + // { + // // + // bullishPriority = X121SMC_XSUPDEMOBS_PRIORITY_REGULAR; + // bearishPriority = X121SMC_XSUPDEMOBS_PRIORITY_NONE; + // } + + // // + // bool isPriceBelowLower = + // // + // decisionZBar.high < conditions.workingZone.lower && + // decisionCBar.high < conditions.workingZone.lower && + // // + // decisionZBar.low > conditions.workingZone.zoneLower && + // decisionCBar.low > conditions.workingZone.zoneLower + // // + // ; + // if (isPriceBelowLower) + // { + // // + // bullishPriority = X121SMC_XSUPDEMOBS_PRIORITY_HIGH; + // bearishPriority = X121SMC_XSUPDEMOBS_PRIORITY_NONE; + // } + ///////////////////////////////////////////////////////////////////// + + + // + // + // + + // + // Close ... + if (!ignoreCloseOnTPNearGuard) + { + // + double tpCloseDiff = (15 * points); + for (int i = 0; i < count; i++) + { + // + XPosition iPosition = ownPositions[i]; + + // + // Position Must be In Profit ... + if (iPosition.profit <= 0) + { + continue; + } + + // + bool isPricePassed = MathAbs(iPosition.tp - iPosition.price) <= tpCloseDiff; + if (!isPricePassed) + { + continue; + } + + // + bool isLong = IsLong(iPosition.type); + + // + bool iHasGuard = + // + isLong + ? // + false + // + : // + false + // + ; + if (iHasGuard) + { + // + X121SMCGuard iGuard; + + // + iGuard.time = cTime; + iGuard.symbol = symbol; + iGuard.provider = provider; + iGuard.action = X_121_SMC_GUARD_ACTION_CLOSE; + + // + iGuard.ticket = iPosition.ticket; + + // + AddGuard( + iGuard, + guards // + ); + } + } + } + + // + if (hasLongs) + { + // + if (!ignoreCloseLongsOnBearishTrendGuard) + { + // + bool hasGuard = false; // hasDecisionBearishTrend; + + // + if (hasGuard) + { + // + for (int i = 0; i < longsCount; i++) + { + // + XPosition iPosition = ownLongPositions[i]; + + // + // Position must be in Draw Down ... + if (iPosition.profit > 0) + { + continue; + } + + // + X121SMCGuard iGuard; + + // + iGuard.time = cTime; + iGuard.symbol = symbol; + iGuard.provider = provider; + iGuard.action = X_121_SMC_GUARD_ACTION_CLOSE; + + // + iGuard.ticket = iPosition.ticket; + + // + AddGuard( + iGuard, + guards // + ); + } + } + } + } + + // + if (hasShorts) + { + // + if (!ignoreCloseShortsOnBullishTrendGuard) + { + // + bool hasGuard = false; // hasDecisionBullishTrend; + + // + if (hasGuard) + { + // + for (int i = 0; i < shortsCount; i++) + { + // + XPosition iPosition = ownShortPositions[i]; + + // + // Position must be in Draw Down ... + if (iPosition.profit > 0) + { + continue; + } + + // + X121SMCGuard iGuard; + + // + iGuard.time = cTime; + iGuard.symbol = symbol; + iGuard.provider = provider; + iGuard.action = X_121_SMC_GUARD_ACTION_CLOSE; + + // + iGuard.ticket = iPosition.ticket; + + // + AddGuard( + iGuard, + guards // + ); + } + } + } + } + + // + // Close All ... + + // + // Close All Weekend ... + if (!ignoreCloseAllWeekendGuard) + { + // + MqlDateTime mDate; + bool hasDate = TimeCurrent(mDate); + if (hasDate) + { + // + ENUM_X_WEEK_DAYS dayOfWeek = GetDayOfWeek(); + + // + bool isWeekend = dayOfWeek == X_WEEK_DAY_FRIDAY; + if (isWeekend && mDate.hour == 23 && mDate.min == 30) + { + // + X121SMCGuard guard; + + // + guard.time = cTime; + guard.symbol = symbol; + guard.provider = provider; + guard.action = X_121_SMC_GUARD_ACTION_CLOSE_ALL; + + // + AddGuard( + guard, + guards // + ); + } + } + } + + // + // Close Longs ... + if (hasLongs) + { + // + bool hasGuard = + // + false + // + // hasAnalyseBearishTrend && + // hasDecisionBearishTrend + // + ; + + // + if (hasGuard) + { + // + X121SMCGuard guard; + + // + guard.time = cTime; + guard.symbol = symbol; + guard.provider = provider; + guard.action = X_121_SMC_GUARD_ACTION_CLOSE_LONGS; + + // + AddGuard( + guard, + guards // + ); + } + } + + // + // Close Shorts ... + if (hasShorts) + { + // + bool hasGuard = + // + false + // + // hasAnalyseBullishTrend && + // hasDecisionBullishTrend + // + ; + + // + if (hasGuard) + { + // + X121SMCGuard guard; + + // + guard.time = cTime; + guard.symbol = symbol; + guard.provider = provider; + guard.action = X_121_SMC_GUARD_ACTION_CLOSE_SHORTS; + + // + AddGuard( + guard, + guards // + ); + } + } + + // + // Partial Close ... + + // + if (!ignorePartialCloseOnTrendChangeGuard) + { + // + if (hasLongs) + { + // + bool hasGuard = + // + false + // + // hasTriggerBearishTrend || + // !hasDecisionBullishTrend + // + ; + + // + if (hasGuard) + { + // + for (int i = 0; i < longsCount; i++) + { + // + XPosition iPosition = ownLongPositions[i]; + + // + X121SMCGuard iGuard; + + // + iGuard.time = cTime; + iGuard.symbol = symbol; + iGuard.provider = provider; + iGuard.action = X_121_SMC_GUARD_ACTION_PARTIAL_CLOSE; + + // + iGuard.ticket = iPosition.ticket; + iGuard.volumeMultiplier = 0.5; + + // + AddGuard( + iGuard, + guards // + ); + } + } + } + + // + if (hasShorts) + { + // + bool hasGuard = + // + false + // + // hasTriggerBullishTrend || + // !hasDecisionBearishTrend + // + ; + + // + if (hasGuard) + { + // + for (int i = 0; i < shortsCount; i++) + { + // + XPosition iPosition = ownShortPositions[i]; + + // + X121SMCGuard iGuard; + + // + iGuard.time = cTime; + iGuard.symbol = symbol; + iGuard.provider = provider; + iGuard.action = X_121_SMC_GUARD_ACTION_PARTIAL_CLOSE; + + // + iGuard.ticket = iPosition.ticket; + iGuard.volumeMultiplier = 0.5; + + // + AddGuard( + iGuard, + guards // + ); + } + } + } + } + + // + // Trail Stop ... + if (!ignoreTrailStopGuard) + { + // + if (hasLongs) + { + // + bool hasTrendGuard = false; // hasDecisionBearishTrend; + + // + bool hasConsolidationGuard = + (hasConsolidationZone && + isConsolidationZoneBreaked && + isConsolidationZoneBreakedUp); + + // + bool hasDecisionPriceZoneGuard = + false; + // (hasDecisionPriceZone && + // isDecisionPriceZoneBullish && + // isDecisionPriceZoneValidForVale && + // isDecisionPriceZoneUpperBreakedUp); + + // + bool hasAnalysePriceZoneGuard = + false; + // (hasAnalysePriceZone && + // isAnalysePriceZoneBullish && + // isAnalysePriceZoneValidForVale && + // isAnalysePriceZoneUpperBreakedUp); + + // + bool hasVerificationPriceZoneGuard = + false; + // (hasVerificationPriceZone && + // isVerificationPriceZoneBullish && + // isVerificationPriceZoneValidForVale && + // isVerificationPriceZoneUpperBreakedUp); + + // + bool hasGuard = + // + hasTrendGuard || + hasConsolidationGuard || + hasDecisionPriceZoneGuard || + hasAnalysePriceZoneGuard || + hasVerificationPriceZoneGuard + // + ; + + // + double guardStop = + hasConsolidationGuard + ? consolidationZoneLower + : hasDecisionPriceZoneGuard + ? 0 // decisionPriceZoneLower + : hasAnalysePriceZoneGuard + ? 0 // analysePriceZoneLower + : hasVerificationPriceZoneGuard + ? 0 // verificationPriceZoneLower + : 0; + + // + if (hasGuard) + { + // + for (int i = 0; i < longsCount; i++) + { + // + XPosition iPosition = ownLongPositions[i]; + + // + // Position Must Be In Profit ... + if (iPosition.profit <= 0) + { + continue; + } + + // + if (hasTrendGuard) + { + // guardStop = decisionXConditions.strBuffer[1] - decisionXConditions.atrBuffer[1]; + } + + // + // Price Must Greater than Zone Lower ... + if (iPosition.price < guardStop) + { + continue; + } + + // + // Position Entry Must Lesser than Zone Lower ... + if (iPosition.entry > guardStop) + { + continue; + } + + // + // Position SL must be Zero or Lesser than Zone Lower ... + if (iPosition.sl != 0 && + iPosition.sl > guardStop) + { + continue; + } + + // + X121SMCGuard iGuard; + + // + iGuard.time = cTime; + iGuard.symbol = symbol; + iGuard.provider = provider; + iGuard.action = X_121_SMC_GUARD_ACTION_TRAIL_STOP; + + // + iGuard.sl = guardStop; + iGuard.ticket = iPosition.ticket; + + // + AddGuard( + iGuard, + guards // + ); + } + } + } + + // + if (hasShorts) + { + // + bool hasTrendGuard = false; // hasDecisionBullishTrend; + + // + bool hasConsolidationGuard = + (hasConsolidationZone && + isConsolidationZoneBreaked && + isConsolidationZoneBreakedDown); + + // + bool hasDecisionPriceZoneGuard = + false; + // (hasDecisionPriceZone && + // isDecisionPriceZoneBearish && + // isDecisionPriceZoneValidForPeak && + // isDecisionPriceZoneLowerBreakedDown); + + // + bool hasAnalysePriceZoneGuard = + false; + // (hasAnalysePriceZone && + // isAnalysePriceZoneBearish && + // isAnalysePriceZoneValidForPeak && + // isAnalysePriceZoneLowerBreakedDown); + + // + bool hasVerificationPriceZoneGuard = + false; + // (hasVerificationPriceZone && + // isVerificationPriceZoneBearish && + // isVerificationPriceZoneValidForPeak && + // isVerificationPriceZoneLowerBreakedDown); + + // + bool hasGuard = + // + hasTrendGuard || + hasConsolidationGuard || + hasDecisionPriceZoneGuard || + hasAnalysePriceZoneGuard || + hasVerificationPriceZoneGuard + // + ; + + // + double guardStop = + hasConsolidationGuard + ? consolidationZoneUpper + : hasDecisionPriceZoneGuard + ? 0 // decisionPriceZoneUpper + : hasAnalysePriceZoneGuard + ? 0 // analysePriceZoneUpper + : hasVerificationPriceZoneGuard + ? 0 // verificationPriceZoneUpper + : 0; + + // + if (hasGuard) + { + // + for (int i = 0; i < shortsCount; i++) + { + // + XPosition iPosition = ownShortPositions[i]; + + // + // Position Must Be In Profit ... + if (iPosition.profit <= 0) + { + continue; + } + + // + if (hasTrendGuard) + { + // guardStop = decisionXConditions.strBuffer[1] + decisionXConditions.atrBuffer[1]; + } + + // + // Price Must Lesser than Zone Upper ... + if (iPosition.price > guardStop) + { + continue; + } + + // + // Position Entry Must Greater than Zone Upper ... + if (iPosition.entry < guardStop) + { + continue; + } + + // + // Position SL must be Zero or Greater than Zone Upper ... + if (iPosition.sl != 0 && + iPosition.sl < guardStop) + { + continue; + } + + // + X121SMCGuard iGuard; + + // + iGuard.time = cTime; + iGuard.symbol = symbol; + iGuard.provider = provider; + iGuard.action = X_121_SMC_GUARD_ACTION_TRAIL_STOP; + + // + iGuard.sl = guardStop; + iGuard.ticket = iPosition.ticket; + + // + AddGuard( + iGuard, + guards // + ); + } + } + } + } + + // + // Trail Target ... + if (!ignoreTrailTargetGuard) + { + // + if (hasLongs) + { + // + bool hasAnalyseGuard = + // + false + // + // (hasAnalysePriceZone && + // isAnalysePriceZoneValidForPeak && + // isAnalysePriceZoneUpperRejected) + // + ; + + // + bool hasVerificationGuard = + // + false + // + // (hasVerificationPriceZone && + // isVerificationPriceZoneValidForPeak && + // isVerificationPriceZoneUpperRejected) + // + ; + + // + bool hasGuard = + // + hasAnalyseGuard || + hasVerificationGuard + // + ; + + // + double guardTP = + hasAnalyseGuard + ? 0 // analysePriceZoneUpper + : hasVerificationGuard + ? 0 // verificationPriceZoneUpper + : 0; + + // + if (hasGuard) + { + // + for (int i = 0; i < longsCount; i++) + { + // + XPosition iPosition = ownLongPositions[i]; + + // + // Position Must Be In Profit ... + if (iPosition.profit <= 0) + { + continue; + } + + // + X121SMCGuard iGuard; + + // + iGuard.time = cTime; + iGuard.symbol = symbol; + iGuard.provider = provider; + iGuard.action = X_121_SMC_GUARD_ACTION_TRAIL_TARGET; + + // + iGuard.tp = guardTP; + iGuard.ticket = iPosition.ticket; + + // + AddGuard( + iGuard, + guards // + ); + } + } + } + + // + if (hasShorts) + { + // + bool hasAnalyseGuard = + // + false + // + // (hasAnalysePriceZone && + // isAnalysePriceZoneValidForVale && + // isAnalysePriceZoneLowerRejected) + // + ; + + // + bool hasVerificationGuard = + // + false + // + // (hasVerificationPriceZone && + // isVerificationPriceZoneValidForVale && + // isVerificationPriceZoneLowerRejected) + // + ; + + // + bool hasGuard = + // + hasAnalyseGuard || + hasVerificationGuard + // + ; + + // + double guardTP = + hasAnalyseGuard + ? 0 // analysePriceZoneLower + : hasVerificationGuard + ? 0 // verificationPriceZoneLower + : 0; + + // + if (hasGuard) + { + // + for (int i = 0; i < shortsCount; i++) + { + // + XPosition iPosition = ownShortPositions[i]; + + // + // Position Must Be In Profit ... + if (iPosition.profit <= 0) + { + continue; + } + + // + X121SMCGuard iGuard; + + // + iGuard.time = cTime; + iGuard.symbol = symbol; + iGuard.provider = provider; + iGuard.action = X_121_SMC_GUARD_ACTION_TRAIL_TARGET; + + // + iGuard.tp = guardTP; + iGuard.ticket = iPosition.ticket; + + // + AddGuard( + iGuard, + guards // + ); + } + } + } + } + + // + // Hedge ... + if (!ignoreHedgeGuard) + { + } + +///////////////////////////////////////////////////////// \ No newline at end of file diff --git a/Libraries/x-saherelm.x-poi.lib.mq5 b/Libraries/x-saherelm.x-poi.lib.mq5 index 46e1a63e..f4208c51 100644 --- a/Libraries/x-saherelm.x-poi.lib.mq5 +++ b/Libraries/x-saherelm.x-poi.lib.mq5 @@ -68,9 +68,8 @@ enum ENUM_XPOIS X_POI_BEARISH_ORDERBLOCK, // Bearish Order Block ... // // Fair Value Gaps ... - X_POI_BULLISH_FVG, // Bullish Order Block ... - X_POI_BEARISH_FVG, // Bearish Order Block ... - X_POI_CONSOLIDATION_ZONE, // Consolidation Zone ... + X_POI_BULLISH_FVG, // Bullish Order Block ... + X_POI_BEARISH_FVG, // Bearish Order Block ... }; // @@ -5959,6 +5958,7 @@ struct XConsolidationZone // }; +// struct XBoxZone { // @@ -8293,6 +8293,46 @@ bool ToBox( return result; } +/** + * Converts to XBoxZone ... + * + * @return ( bool ) + */ +bool ToBox( + XBoxZone &box, + XConsolidationZone &item // +) +{ + // + bool result = false; + + // + box.Clean(); + + // + result = item.IsValid(); + if (!result) + { + return result; + } + + // + box.upper = item.upper; + box.lower = item.lower; + box.dir = item.breakDir; + box.from = item.initTime; + box.symbol = item.symbol; + box.period = item.period; + box.to = item.breakerBar.time; + box.type = "X_CONSOLIDATION_ZONE"; + + // + result = box.IsValid(); + + // + return result; +} + /** * Get Oldest Zone ... * diff --git a/Libraries/x-saherelm.x-trade.lib.mq5 b/Libraries/x-saherelm.x-trade.lib.mq5 index c3f992b3..666d803a 100644 --- a/Libraries/x-saherelm.x-trade.lib.mq5 +++ b/Libraries/x-saherelm.x-trade.lib.mq5 @@ -1118,7 +1118,8 @@ struct XSignal // // Traget ... - double target; // Force Risk Free On Target ... + double target; // Force Risk Free On Target ... + bool ignoreEAVolume; // Ignore EA Volume ... // // SL Trail ... @@ -1679,6 +1680,7 @@ struct XSignal // target = 0; + ignoreEAVolume = false; // trailSL = false; diff --git a/X121SMCEA/Classes/x-121.smc.base.strategy.class.mq5 b/X121SMCEA/Classes/x-121.smc.base.strategy.class.mq5 index c48daf2b..c4f9eba1 100644 --- a/X121SMCEA/Classes/x-121.smc.base.strategy.class.mq5 +++ b/X121SMCEA/Classes/x-121.smc.base.strategy.class.mq5 @@ -41,7 +41,8 @@ class XCX121SMCBaseStrategy : public XCBaseAlert // Public ... public: // - + XCAccount mAccount; + // // Constructor(s) ... XCX121SMCBaseStrategy( 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 7ae0786c..0d0aa293 100644 --- a/X121SMCEA/Classes/x-121.smc.market.cycle.helper.class.mq5 +++ b/X121SMCEA/Classes/x-121.smc.market.cycle.helper.class.mq5 @@ -106,6 +106,183 @@ class XC121SMCCycleHelper : public XCBase // // Getter/Setter(s) ... + // + int CountConsolidationZones() + { + return ArraySize(mConsolidationZones); + } + + // + bool HasConsolidationZones() + { + return HasChild(mConsolidationZones); + } + + // + bool GetConsolidationZone( + int idx, + XConsolidationZone &zone // + ) + { + // + bool result = false; + + // + zone.Clean(); + + // + result = HasConsolidationZones(); + if (!result) + { + return result; + } + + // + int count = CountConsolidationZones(); + result = idx >= 0 && + idx < count; + if (!result) + { + return result; + } + + // + zone = mConsolidationZones[idx]; + result = zone.IsValid(); + + // + return result; + } + + // + bool GetLastDirectionalConsolidationZone( + ENUM_X_DIRECTION forDir, + XConsolidationZone &zone // + ) + { + // + bool result = false; + + // + zone.Clean(); + + // + result = HasDirection(forDir); + if (!result) + { + return result; + } + + // + bool hasZones = HasConsolidationZones(); + int zonesCount = CountConsolidationZones(); + result = hasZones; + if (!result) + { + return result; + } + + // + for (int i = zonesCount - 1; i >= 0; i--) + { + // + XConsolidationZone iZone = mConsolidationZones[i]; + + // + if (!iZone.IsBreaked()) + { + continue; + } + + // + if (!HasDirection(iZone.breakDir)) + { + continue; + } + + // + if (iZone.breakDir != forDir) + { + continue; + } + + // + zone = iZone; + break; + } + + // + result = zone.IsValid(); + + // + return result; + } + + // + bool GetActiveConsolidationZone( + XConsolidationZone &zone // + ) + { + // + bool result = false; + + // + zone = mActiveConsolidationZone; + result = zone.IsValid(); + + // + return result; + } + + // + int FillConsolidationZones( + ENUM_X_DIRECTION forDir, + XConsolidationZone &zones[] // + ) + { + // + int result = 0; + + // + Clean(zones); + + // + bool hasZones = HasConsolidationZones(); + if (!hasZones) + { + return result; + } + + // + int count = CountConsolidationZones(); + for (int i = 0; i < count; i++) + { + // + XConsolidationZone iZone = mConsolidationZones[i]; + + // + bool isDirPassed = + (forDir == X_DIRECTION_ALL || + forDir == X_DIRECTION_NONE) + ? true + : forDir == iZone.breakDir; + if (isDirPassed) + { + // + AddRef( + iZone, + zones // + ); + } + } + + // + result = ArraySize(zones); + + // + return result; + } + // // Actions ... @@ -462,14 +639,18 @@ class XC121SMCCycleHelper : public XCBase ); // // - // XCConsolidationZoneObject *czObj; - // bool isCreated = mPOIDrawer.CreateConsolidationZone( - // mActiveConsolidationZone, - // czObj // - // ); - // if (isCreated) + // if (GetPeriod() == PERIOD_M5) // { - // mConsolidationObjects.Add(czObj); + // // + // XCConsolidationZoneObject *czObj; + // bool isCreated = mPOIDrawer.CreateConsolidationZone( + // mActiveConsolidationZone, + // czObj // + // ); + // if (isCreated) + // { + // mConsolidationObjects.Add(czObj); + // } // } // @@ -551,7 +732,7 @@ class XC121SMCCycleHelper : public XCBase ENUM_TIMEFRAMES mPeriod; // - CArrayObj mConsolidationObjects; + // CArrayObj mConsolidationObjects; XConsolidationZone mActiveConsolidationZone; XConsolidationZone mConsolidationZones[]; diff --git a/X121SMCEA/Experts/x-121.smc.expert.class.mq5 b/X121SMCEA/Experts/x-121.smc.expert.class.mq5 index 15c3bfa3..680898ad 100644 --- a/X121SMCEA/Experts/x-121.smc.expert.class.mq5 +++ b/X121SMCEA/Experts/x-121.smc.expert.class.mq5 @@ -22,8 +22,8 @@ // // Imports ... #include "../../Classes/x-saherelm.x-expert.class.mq5" -#include "../../Helpers/x-saherelm.x121.xct.helper.mq5" #include "../../Helpers/x-saherelm.x121.xcc.helper.mq5" +#include "../../Helpers/x-saherelm.x121.xct.helper.mq5" #include "../Classes/x-121.smc.x-tradehandler.class.mq5" #include "../Libraries/x-121.smc.lib.mq5" #include "../Strategy/x-121.smc.strategy.class.mq5" @@ -1609,6 +1609,12 @@ class XC121SMCExpert : public XCBaseExpert */ void ApplyVolumeOnSignal(XSignal &signal) { + // + if (signal.ignoreEAVolume) + { + return; + } + // double staticVolume = Volume(); double fVolume = staticVolume > 0 diff --git a/X121SMCEA/Libraries/x-121.smc.guard.lib.mq5 b/X121SMCEA/Libraries/x-121.smc.guard.lib.mq5 index b87a824d..f817f83c 100644 --- a/X121SMCEA/Libraries/x-121.smc.guard.lib.mq5 +++ b/X121SMCEA/Libraries/x-121.smc.guard.lib.mq5 @@ -30,22 +30,16 @@ bool DetectX121SMCGuards( string provider, // Provider ... X121SMCGuard &guards[], const XPosition &positions[], - // XC121SMCCycleHelper *triggerCycleHelper, XC121SMCCycleHelper *decisionCycleHelper, XC121SMCCycleHelper *analyseCycleHelper, - // XC121SMCCycleHelper *verificationCycleHelper, XC121SMCCycleHelper *consolidationCycleHelper, XC121SMCCycleHelper *visionCycleHelper, // // Guard Types ... - bool ignoreCloseOnTPNearGuard = false, - bool ignoreCloseLongsOnBearishTrendGuard = false, - bool ignoreCloseShortsOnBullishTrendGuard = false, - bool ignoreCloseAllWeekendGuard = false, - bool ignorePartialCloseOnTrendChangeGuard = false, - bool ignoreTrailStopGuard = false, - bool ignoreTrailTargetGuard = false, - bool ignoreHedgeGuard = false + ENUM_X_121_SMC_GUARD_ACTIONS &ignoreGuards[], + // + // Required Configurations ... + double breakEvenTPLevel = 2.0 // ) { @@ -53,19 +47,82 @@ bool DetectX121SMCGuards( bool result = false; // - bool isAllIgnore = + bool isCycleHelpersValid = // - ignoreCloseOnTPNearGuard && - ignoreCloseLongsOnBearishTrendGuard && - ignoreCloseShortsOnBullishTrendGuard && - ignoreCloseAllWeekendGuard && - ignorePartialCloseOnTrendChangeGuard && - ignoreTrailStopGuard && - ignoreTrailTargetGuard && - ignoreHedgeGuard + visionCycleHelper != NULL && + analyseCycleHelper != NULL && + decisionCycleHelper != NULL && + consolidationCycleHelper != NULL // ; - result = !isAllIgnore; + + // + // Ignore Guards ... + bool hasIgnoreGuards = HasChild(ignoreGuards); + bool isColseIgnored = + hasIgnoreGuards && + Contains( + X_121_SMC_GUARD_ACTION_CLOSE, + ignoreGuards // + ); + bool isColseAllIgnored = + hasIgnoreGuards && + Contains( + X_121_SMC_GUARD_ACTION_CLOSE_ALL, + ignoreGuards // + ); + bool isColseLongsIgnored = + hasIgnoreGuards && + Contains( + X_121_SMC_GUARD_ACTION_CLOSE_LONGS, + ignoreGuards // + ); + bool isColseShortsIgnored = + hasIgnoreGuards && + Contains( + X_121_SMC_GUARD_ACTION_CLOSE_SHORTS, + ignoreGuards // + ); + bool isPartialColseIgnored = + hasIgnoreGuards && + Contains( + X_121_SMC_GUARD_ACTION_PARTIAL_CLOSE, + ignoreGuards // + ); + bool isTrailStopIgnored = + hasIgnoreGuards && + Contains( + X_121_SMC_GUARD_ACTION_TRAIL_STOP, + ignoreGuards // + ); + bool isTrailTargetIgnored = + hasIgnoreGuards && + Contains( + X_121_SMC_GUARD_ACTION_TRAIL_TARGET, + ignoreGuards // + ); + bool isHedgeIgnored = + hasIgnoreGuards && + Contains( + X_121_SMC_GUARD_ACTION_HEDGE, + ignoreGuards // + ); + + // + bool isAllIgnores = + // + isColseIgnored && + isHedgeIgnored && + isColseAllIgnored && + isTrailStopIgnored && + isColseLongsIgnored && + isColseShortsIgnored && + isTrailTargetIgnored && + isPartialColseIgnored + // + ; + result = !isAllIgnores && + isCycleHelpersValid; if (!result) { return result; @@ -177,6 +234,8 @@ bool DetectX121SMCGuards( ); if (!result) { + // + result = HasChild(guards); return result; } @@ -189,6 +248,9 @@ bool DetectX121SMCGuards( ); if (!result) { + // + zBar.Clean(); + result = HasChild(guards); return result; } @@ -201,6 +263,27 @@ bool DetectX121SMCGuards( ); if (!result) { + // + zBar.Clean(); + cBar.Clean(); + result = HasChild(guards); + return result; + } + + // + XOHCL ppBar; + result = ppBar.Init( + symbol, + period, + ppIndex // + ); + if (!result) + { + // + zBar.Clean(); + cBar.Clean(); + pBar.Clean(); + result = HasChild(guards); return result; } @@ -211,32 +294,10 @@ bool DetectX121SMCGuards( double points = GetPoints(symbol); // - int swingLoopback = 3; - double ll = cBar.FindLowest(swingLoopback, MODE_LOW); - double hh = cBar.FindHighest(swingLoopback, MODE_HIGH); - double llDown = cBar.FindLowesttDown(swingLoopback); - double hhUp = cBar.FindHighestUp(swingLoopback); // // Cycles Conditions ... - // - // Trigger ... - // ENUM_XPOI_EVENTS triggerPoiEvents[]; - // ENUM_X_CYCLE_EVENTS triggerCycleEvents[]; - // X121SMCCycleConditions triggerConditions; - // result = triggerCycleHelper.GetConditions( - // triggerCycleEvents, - // triggerPoiEvents, - // triggerConditions, - // zIndex, - // loopback // - // ); - // if (!result) - // { - // return result; - // } - // // Decision ... ENUM_XPOI_EVENTS decisionPoiEvents[]; @@ -251,6 +312,12 @@ bool DetectX121SMCGuards( ); if (!result) { + // + zBar.Clean(); + cBar.Clean(); + pBar.Clean(); + ppBar.Clean(); + result = HasChild(guards); return result; } @@ -268,26 +335,24 @@ bool DetectX121SMCGuards( ); if (!result) { + // + zBar.Clean(); + cBar.Clean(); + pBar.Clean(); + ppBar.Clean(); + + // + Clean(decisionPoiEvents); + Clean(decisionCycleEvents); + + // + decisionConditions.Clean(); + + // + result = HasChild(guards); return result; } - // - // Verification ... - // ENUM_XPOI_EVENTS verificationPoiEvents[]; - // ENUM_X_CYCLE_EVENTS verificationCycleEvents[]; - // X121SMCCycleConditions verificationConditions; - // result = verificationCycleHelper.GetConditions( - // verificationCycleEvents, - // verificationPoiEvents, - // verificationConditions, - // zIndex, - // loopback // - // ); - // if (!result) - // { - // return result; - // } - // // Consolidation ... ENUM_XPOI_EVENTS consolidationPoiEvents[]; @@ -302,6 +367,28 @@ bool DetectX121SMCGuards( ); if (!result) { + // + zBar.Clean(); + cBar.Clean(); + pBar.Clean(); + ppBar.Clean(); + + // + Clean(decisionPoiEvents); + Clean(decisionCycleEvents); + + // + decisionConditions.Clean(); + + // + Clean(analysePoiEvents); + Clean(analyseCycleEvents); + + // + analyseConditions.Clean(); + + // + result = HasChild(guards); return result; } @@ -319,26 +406,51 @@ bool DetectX121SMCGuards( ); if (!result) { + // + zBar.Clean(); + cBar.Clean(); + pBar.Clean(); + ppBar.Clean(); + + // + Clean(decisionPoiEvents); + Clean(decisionCycleEvents); + + // + decisionConditions.Clean(); + + // + Clean(analysePoiEvents); + Clean(analyseCycleEvents); + + // + analyseConditions.Clean(); + + // + Clean(consolidationPoiEvents); + Clean(consolidationCycleEvents); + + // + consolidationConditions.Clean(); + + // + result = HasChild(guards); return result; } // // Cycles POI States ... - // XPOIState triggerState = triggerConditions.state; XPOIState decisionState = decisionConditions.state; XPOIState analyseState = analyseConditions.state; - // XPOIState verificationState = verificationConditions.state; XPOIState consolidationState = consolidationConditions.state; XPOIState visionState = visionConditions.state; // // Cycle X121Conditions ... - // X121Conditions triggerXConditions = triggerConditions.x121Conditions; - // X121Conditions decisionXConditions = decisionConditions.x121Conditions; - // X121Conditions analyseXConditions = analyseConditions.x121Conditions; - // X121Conditions verificationXConditions = verificationConditions.x121Conditions; - // X121Conditions consolidationXConditions = consolidationConditions.x121Conditions; - // X121Conditions visionXConditions = visionConditions.x121Conditions; + X121Conditions decisionXConditions = decisionConditions.x121Conditions; + X121Conditions analyseXConditions = analyseConditions.x121Conditions; + X121Conditions consolidationXConditions = consolidationConditions.x121Conditions; + X121Conditions visionXConditions = visionConditions.x121Conditions; // // @@ -348,121 +460,385 @@ bool DetectX121SMCGuards( // Detect Consolidation Zone ... // - int consolidationLoopback = 7; - double consolidationZoneLower = 0; - double consolidationZoneUpper = 0; - bool isConsolidationZoneBreaked = false; - bool isConsolidationZoneBreakedUp = false; - bool isConsolidationZoneBreakedDown = false; - bool hasConsolidationZone = x121SMCConsolidationZone.IsValid(); + // Detect Consolidation Zones ... // - if (!hasConsolidationZone) + XBoxZone lastBullishBox; + XBoxZone prevLastBullishBox; + bool hasLastBullishBox = false; + bool hasPrevLastBullishBox = false; + XConsolidationZone lastBullishZone; + bool isLastBullishAbovePrev = false; + bool isLastBullishBelowPrev = false; + XConsolidationZone prevLastBullishZone; + + // + XBoxZone lastBearishBox; + XBoxZone prevLastBearishBox; + bool hasLastBearishBox = false; + bool hasPrevLastBearishBox = false; + XConsolidationZone lastBearishZone; + bool isLastBearishAbovePrev = false; + bool isLastBearishBelowPrev = false; + XConsolidationZone prevLastBearishZone; + + // + int bullishConsolidationZonesCount = 0; + int bearishConsolidationZonesCount = 0; + bool hasBullishConsolidationZones = false; + bool hasBearishConsolidationZones = false; + XConsolidationZone bullishConsolidationZones[]; + XConsolidationZone bearishConsolidationZones[]; + bool hasConsolidationZones = decisionCycleHelper.HasConsolidationZones(); + int consolidationZonesCount = decisionCycleHelper.CountConsolidationZones(); + if (hasConsolidationZones) { // - double upper = 0; - double lower = 0; - // hasConsolidationZone = - // triggerCycleHelper - // .mBarAnalyser - // .IsConsolidate( - // cBar, - // upper, - // lower, - // consolidationLoopback // - // ); + bullishConsolidationZonesCount = decisionCycleHelper + .FillConsolidationZones( + X_DIRECTION_BULLISH, + bullishConsolidationZones // + ); + hasBullishConsolidationZones = IsValidSize(bullishConsolidationZonesCount); // - if (hasConsolidationZone) + bearishConsolidationZonesCount = decisionCycleHelper + .FillConsolidationZones( + X_DIRECTION_BEARISH, + bearishConsolidationZones // + ); + hasBearishConsolidationZones = IsValidSize(bearishConsolidationZonesCount); + + // + // + // + + // + if (hasBullishConsolidationZones && + bullishConsolidationZonesCount >= 2) { // - hasConsolidationZone = x121SMCConsolidationZone.Init( - cBar.symbol, - cBar.period, - upper, - lower, - consolidationLoopback // + lastBullishZone = bullishConsolidationZones[bullishConsolidationZonesCount - 1]; + prevLastBullishZone = bullishConsolidationZones[bullishConsolidationZonesCount - 2]; + + // + hasLastBullishBox = ToBox( + lastBullishBox, + lastBullishZone // ); + hasPrevLastBullishBox = ToBox( + prevLastBullishBox, + prevLastBullishZone // + ); + + // + isLastBullishAbovePrev = hasLastBullishBox && + hasPrevLastBullishBox && + IsBoxAbove( + lastBullishBox, + prevLastBullishBox // + ); + + // + isLastBullishBelowPrev = hasLastBullishBox && + hasPrevLastBullishBox && + IsBoxBelow( + lastBullishBox, + prevLastBullishBox // + ); } + + // + if (hasBearishConsolidationZones && + bearishConsolidationZonesCount >= 2) + { + // + lastBearishZone = bullishConsolidationZones[bullishConsolidationZonesCount - 1]; + prevLastBearishZone = bullishConsolidationZones[bullishConsolidationZonesCount - 2]; + + // + hasLastBearishBox = ToBox( + lastBearishBox, + lastBearishZone // + ); + hasPrevLastBearishBox = ToBox( + prevLastBearishBox, + prevLastBearishZone // + ); + + // + isLastBearishAbovePrev = hasLastBearishBox && + hasPrevLastBearishBox && + IsBoxAbove( + lastBearishBox, + prevLastBearishBox // + ); + + // + isLastBearishBelowPrev = hasLastBearishBox && + hasPrevLastBearishBox && + IsBoxBelow( + lastBearishBox, + prevLastBearishBox // + ); + } + + // } // - if (hasConsolidationZone) - { + // Detect High Probability Swings ... + bool isSwingLow = // - x121SMCConsolidationZone.Update(); + cBar.low > pBar.low && + ppBar.low > pBar.low && + // + zBar.low > pBar.low + // + ; + bool isSwingHigh = + // + cBar.high < pBar.high && + ppBar.high < pBar.high && + // + zBar.high < pBar.high + // + ; + bool isStrongSwingLow = + pBar.IsBullish() && + pBar.GetLowShadow() >= pBar.GetBody() * 2; + bool isStrongSwingHigh = + pBar.IsBearish() && + pBar.GetHighShadow() >= pBar.GetBody() * 2; - // - consolidationZoneUpper = x121SMCConsolidationZone.upper; - consolidationZoneLower = x121SMCConsolidationZone.lower; + // + bool isStrongSwingLowAboveLastBullishBox = + isStrongSwingLow && + hasLastBullishBox && + pBar.low > lastBullishBox.upper; - // - isConsolidationZoneBreaked = x121SMCConsolidationZone.IsBreaked(); - isConsolidationZoneBreakedUp = - isConsolidationZoneBreaked && - IsBullish(x121SMCConsolidationZone.breakDir); - isConsolidationZoneBreakedDown = - isConsolidationZoneBreaked && - IsBearish(x121SMCConsolidationZone.breakDir); - - // - // consolidationZoneUpper = triggerXConditions.peaksBuffer[1]; - // consolidationZoneLower = triggerXConditions.valesBuffer[1]; - - // - if (isConsolidationZoneBreaked) - { - x121SMCConsolidationZone.Clean(); - } - } + // + bool isStrongSwingHighBelowLastBearishBox = + isStrongSwingHigh && + hasLastBearishBox && + pBar.high < lastBearishBox.lower; // // Here We Have all Requirements for Guarding Positions ... // - // - // + // Available Guards: + // X_121_SMC_GUARD_ACTION_NONE + // X_121_SMC_GUARD_ACTION_CLOSE + // X_121_SMC_GUARD_ACTION_CLOSE_ALL + // X_121_SMC_GUARD_ACTION_CLOSE_LONGS + // X_121_SMC_GUARD_ACTION_CLOSE_SHORTS + // X_121_SMC_GUARD_ACTION_PARTIAL_CLOSE + // X_121_SMC_GUARD_ACTION_TRAIL_STOP + // X_121_SMC_GUARD_ACTION_TRAIL_TARGET + // X_121_SMC_GUARD_ACTION_HEDGE // - // Close ... - if (!ignoreCloseOnTPNearGuard) + // X_121_SMC_GUARD_ACTION_CLOSE: + // Close Specified Position on Specified Conditions ... + if (!isColseIgnored) { // - double tpCloseDiff = (15 * points); + } + + // + // X_121_SMC_GUARD_ACTION_CLOSE_ALL: + // Close All Positions on Specified Conditions ... + if (!isColseAllIgnored) + { + // + } + + // + // X_121_SMC_GUARD_ACTION_CLOSE_LONGS: + // Close All Long Positions on Specified Conditions ... + if (!isColseLongsIgnored) + { + // + } + + // + // X_121_SMC_GUARD_ACTION_CLOSE_SHORTS: + // Close All Short Positions on Specified Conditions ... + if (!isColseShortsIgnored) + { + // + } + + // + // X_121_SMC_GUARD_ACTION_PARTIAL_CLOSE: + // Partial Close Specified Position on Specified Conditions ... + if (!isPartialColseIgnored) + { + // + // Breake Even ... + // Usually Break Even Works on TP2 Reached ... + // when tp reached to required Level, we Close 50% of Entered Volume ... + bool canBreakEven = breakEvenTPLevel >= 0; + + // for (int i = 0; i < count; i++) { // XPosition iPosition = ownPositions[i]; // - // Position Must be In Profit ... - if (iPosition.profit <= 0) + bool isInProfit = iPosition.profit > 0; + + // + double reachedTPLevel = 0; + double reachedTPPrice = 0; + if (isInProfit) { - continue; + // + iPosition.CalculateReahedTP( + reachedTPLevel, + reachedTPPrice // + ); } // - bool isPricePassed = MathAbs(iPosition.tp - iPosition.price) <= tpCloseDiff; - if (!isPricePassed) + // Break Event ... + if (canBreakEven) { - continue; + // + // Position Must be In Profit ... + if (!isInProfit) + { + continue; + } + + // + bool canDoBreakEven = reachedTPLevel == breakEvenTPLevel && + reachedTPPrice > 0; + if (canDoBreakEven) + { + // + X121SMCGuard iGuard; + + // + iGuard.time = cTime; + iGuard.symbol = symbol; + iGuard.provider = provider; + iGuard.action = X_121_SMC_GUARD_ACTION_PARTIAL_CLOSE; + + // + iGuard.ticket = iPosition.ticket; + + // + iGuard.volumeMultiplier = 0.5; + + // + AddGuard( + iGuard, + guards // + ); + } } + } + } + + // + // X_121_SMC_GUARD_ACTION_TRAIL_STOP: + // Trail Stop Specified Position on Specified Conditions ... + if (!isTrailStopIgnored) + { + // + for (int i = 0; i < count; i++) + { + // + XPosition iPosition = ownPositions[i]; // bool isLong = IsLong(iPosition.type); + bool isInProfit = iPosition.profit > 0; // - bool iHasGuard = + double reachedTPLevel = 0; + double reachedTPPrice = 0; + if (isInProfit) + { // + iPosition.CalculateReahedTP( + reachedTPLevel, + reachedTPPrice // + ); + } + + // + // Trai Stop ... + if (!isInProfit) + { + continue; + } + + // + double trailedStop = 0; + + // + // Trail Stop Senarios ... + // - occures two same type consolidation zones in order of positions type; + // - occures a swing in order of consolidation zones ... + + // + bool canTrailBasedOnTwoZone = isLong - ? // - false + ? isLastBullishAbovePrev + : isLastBearishBelowPrev; + if (canTrailBasedOnTwoZone) + { + // + trailedStop = + isLong + ? prevLastBullishBox.lower + : prevLastBearishBox.upper; + } + + // + bool canTrailBasedOnZoneSwing = + trailedStop <= 0 && + (isLong + ? isStrongSwingLowAboveLastBullishBox + : isStrongSwingHighBelowLastBearishBox); + if (canTrailBasedOnZoneSwing) + { + // + trailedStop = + isLong + ? pBar.low + : pBar.high; + } + + // + bool canDoTrailStop = + trailedStop > 0 && + ( // - : // - false + iPosition.sl == 0 + ? (isLong + ? trailedStop > iPosition.entry && + trailedStop < iPosition.price + : trailedStop < iPosition.entry && + trailedStop > iPosition.price) + : (isLong + ? trailedStop > iPosition.sl && + trailedStop > iPosition.entry && + trailedStop < iPosition.price + : trailedStop < iPosition.sl && + trailedStop < iPosition.entry && + trailedStop > iPosition.price) + // + ) // ; - if (iHasGuard) + + // + if (canDoTrailStop) { // X121SMCGuard iGuard; @@ -471,11 +847,14 @@ bool DetectX121SMCGuards( iGuard.time = cTime; iGuard.symbol = symbol; iGuard.provider = provider; - iGuard.action = X_121_SMC_GUARD_ACTION_CLOSE; + iGuard.action = X_121_SMC_GUARD_ACTION_TRAIL_STOP; // iGuard.ticket = iPosition.ticket; + // + iGuard.sl = trailedStop; + // AddGuard( iGuard, @@ -486,721 +865,19 @@ bool DetectX121SMCGuards( } // - if (hasLongs) + // X_121_SMC_GUARD_ACTION_TRAIL_TARGET: + // Trail Target Specified Position on Specified Conditions ... + if (!isTrailTargetIgnored) { // - if (!ignoreCloseLongsOnBearishTrendGuard) - { - // - bool hasGuard = false; // hasDecisionBearishTrend; - - // - if (hasGuard) - { - // - for (int i = 0; i < longsCount; i++) - { - // - XPosition iPosition = ownLongPositions[i]; - - // - // Position must be in Draw Down ... - if (iPosition.profit > 0) - { - continue; - } - - // - X121SMCGuard iGuard; - - // - iGuard.time = cTime; - iGuard.symbol = symbol; - iGuard.provider = provider; - iGuard.action = X_121_SMC_GUARD_ACTION_CLOSE; - - // - iGuard.ticket = iPosition.ticket; - - // - AddGuard( - iGuard, - guards // - ); - } - } - } } // - if (hasShorts) + // X_121_SMC_GUARD_ACTION_HEDGE: + // Hedge all Positions on Specified Conditions ... + if (!isHedgeIgnored) { // - if (!ignoreCloseShortsOnBullishTrendGuard) - { - // - bool hasGuard = false; // hasDecisionBullishTrend; - - // - if (hasGuard) - { - // - for (int i = 0; i < shortsCount; i++) - { - // - XPosition iPosition = ownShortPositions[i]; - - // - // Position must be in Draw Down ... - if (iPosition.profit > 0) - { - continue; - } - - // - X121SMCGuard iGuard; - - // - iGuard.time = cTime; - iGuard.symbol = symbol; - iGuard.provider = provider; - iGuard.action = X_121_SMC_GUARD_ACTION_CLOSE; - - // - iGuard.ticket = iPosition.ticket; - - // - AddGuard( - iGuard, - guards // - ); - } - } - } - } - - // - // Close All ... - - // - // Close All Weekend ... - if (!ignoreCloseAllWeekendGuard) - { - // - MqlDateTime mDate; - bool hasDate = TimeCurrent(mDate); - if (hasDate) - { - // - ENUM_X_WEEK_DAYS dayOfWeek = GetDayOfWeek(); - - // - bool isWeekend = dayOfWeek == X_WEEK_DAY_FRIDAY; - if (isWeekend && mDate.hour == 23 && mDate.min == 30) - { - // - X121SMCGuard guard; - - // - guard.time = cTime; - guard.symbol = symbol; - guard.provider = provider; - guard.action = X_121_SMC_GUARD_ACTION_CLOSE_ALL; - - // - AddGuard( - guard, - guards // - ); - } - } - } - - // - // Close Longs ... - if (hasLongs) - { - // - bool hasGuard = - // - false - // - // hasAnalyseBearishTrend && - // hasDecisionBearishTrend - // - ; - - // - if (hasGuard) - { - // - X121SMCGuard guard; - - // - guard.time = cTime; - guard.symbol = symbol; - guard.provider = provider; - guard.action = X_121_SMC_GUARD_ACTION_CLOSE_LONGS; - - // - AddGuard( - guard, - guards // - ); - } - } - - // - // Close Shorts ... - if (hasShorts) - { - // - bool hasGuard = - // - false - // - // hasAnalyseBullishTrend && - // hasDecisionBullishTrend - // - ; - - // - if (hasGuard) - { - // - X121SMCGuard guard; - - // - guard.time = cTime; - guard.symbol = symbol; - guard.provider = provider; - guard.action = X_121_SMC_GUARD_ACTION_CLOSE_SHORTS; - - // - AddGuard( - guard, - guards // - ); - } - } - - // - // Partial Close ... - - // - if (!ignorePartialCloseOnTrendChangeGuard) - { - // - if (hasLongs) - { - // - bool hasGuard = - // - false - // - // hasTriggerBearishTrend || - // !hasDecisionBullishTrend - // - ; - - // - if (hasGuard) - { - // - for (int i = 0; i < longsCount; i++) - { - // - XPosition iPosition = ownLongPositions[i]; - - // - X121SMCGuard iGuard; - - // - iGuard.time = cTime; - iGuard.symbol = symbol; - iGuard.provider = provider; - iGuard.action = X_121_SMC_GUARD_ACTION_PARTIAL_CLOSE; - - // - iGuard.ticket = iPosition.ticket; - iGuard.volumeMultiplier = 0.5; - - // - AddGuard( - iGuard, - guards // - ); - } - } - } - - // - if (hasShorts) - { - // - bool hasGuard = - // - false - // - // hasTriggerBullishTrend || - // !hasDecisionBearishTrend - // - ; - - // - if (hasGuard) - { - // - for (int i = 0; i < shortsCount; i++) - { - // - XPosition iPosition = ownShortPositions[i]; - - // - X121SMCGuard iGuard; - - // - iGuard.time = cTime; - iGuard.symbol = symbol; - iGuard.provider = provider; - iGuard.action = X_121_SMC_GUARD_ACTION_PARTIAL_CLOSE; - - // - iGuard.ticket = iPosition.ticket; - iGuard.volumeMultiplier = 0.5; - - // - AddGuard( - iGuard, - guards // - ); - } - } - } - } - - // - // Trail Stop ... - if (!ignoreTrailStopGuard) - { - // - if (hasLongs) - { - // - bool hasTrendGuard = false; // hasDecisionBearishTrend; - - // - bool hasConsolidationGuard = - (hasConsolidationZone && - isConsolidationZoneBreaked && - isConsolidationZoneBreakedUp); - - // - bool hasDecisionPriceZoneGuard = - false; - // (hasDecisionPriceZone && - // isDecisionPriceZoneBullish && - // isDecisionPriceZoneValidForVale && - // isDecisionPriceZoneUpperBreakedUp); - - // - bool hasAnalysePriceZoneGuard = - false; - // (hasAnalysePriceZone && - // isAnalysePriceZoneBullish && - // isAnalysePriceZoneValidForVale && - // isAnalysePriceZoneUpperBreakedUp); - - // - bool hasVerificationPriceZoneGuard = - false; - // (hasVerificationPriceZone && - // isVerificationPriceZoneBullish && - // isVerificationPriceZoneValidForVale && - // isVerificationPriceZoneUpperBreakedUp); - - // - bool hasGuard = - // - hasTrendGuard || - hasConsolidationGuard || - hasDecisionPriceZoneGuard || - hasAnalysePriceZoneGuard || - hasVerificationPriceZoneGuard - // - ; - - // - double guardStop = - hasConsolidationGuard - ? consolidationZoneLower - : hasDecisionPriceZoneGuard - ? 0 // decisionPriceZoneLower - : hasAnalysePriceZoneGuard - ? 0 // analysePriceZoneLower - : hasVerificationPriceZoneGuard - ? 0 // verificationPriceZoneLower - : 0; - - // - if (hasGuard) - { - // - for (int i = 0; i < longsCount; i++) - { - // - XPosition iPosition = ownLongPositions[i]; - - // - // Position Must Be In Profit ... - if (iPosition.profit <= 0) - { - continue; - } - - // - if (hasTrendGuard) - { - // guardStop = decisionXConditions.strBuffer[1] - decisionXConditions.atrBuffer[1]; - } - - // - // Price Must Greater than Zone Lower ... - if (iPosition.price < guardStop) - { - continue; - } - - // - // Position Entry Must Lesser than Zone Lower ... - if (iPosition.entry > guardStop) - { - continue; - } - - // - // Position SL must be Zero or Lesser than Zone Lower ... - if (iPosition.sl != 0 && - iPosition.sl > guardStop) - { - continue; - } - - // - X121SMCGuard iGuard; - - // - iGuard.time = cTime; - iGuard.symbol = symbol; - iGuard.provider = provider; - iGuard.action = X_121_SMC_GUARD_ACTION_TRAIL_STOP; - - // - iGuard.sl = guardStop; - iGuard.ticket = iPosition.ticket; - - // - AddGuard( - iGuard, - guards // - ); - } - } - } - - // - if (hasShorts) - { - // - bool hasTrendGuard = false; // hasDecisionBullishTrend; - - // - bool hasConsolidationGuard = - (hasConsolidationZone && - isConsolidationZoneBreaked && - isConsolidationZoneBreakedDown); - - // - bool hasDecisionPriceZoneGuard = - false; - // (hasDecisionPriceZone && - // isDecisionPriceZoneBearish && - // isDecisionPriceZoneValidForPeak && - // isDecisionPriceZoneLowerBreakedDown); - - // - bool hasAnalysePriceZoneGuard = - false; - // (hasAnalysePriceZone && - // isAnalysePriceZoneBearish && - // isAnalysePriceZoneValidForPeak && - // isAnalysePriceZoneLowerBreakedDown); - - // - bool hasVerificationPriceZoneGuard = - false; - // (hasVerificationPriceZone && - // isVerificationPriceZoneBearish && - // isVerificationPriceZoneValidForPeak && - // isVerificationPriceZoneLowerBreakedDown); - - // - bool hasGuard = - // - hasTrendGuard || - hasConsolidationGuard || - hasDecisionPriceZoneGuard || - hasAnalysePriceZoneGuard || - hasVerificationPriceZoneGuard - // - ; - - // - double guardStop = - hasConsolidationGuard - ? consolidationZoneUpper - : hasDecisionPriceZoneGuard - ? 0 // decisionPriceZoneUpper - : hasAnalysePriceZoneGuard - ? 0 // analysePriceZoneUpper - : hasVerificationPriceZoneGuard - ? 0 // verificationPriceZoneUpper - : 0; - - // - if (hasGuard) - { - // - for (int i = 0; i < shortsCount; i++) - { - // - XPosition iPosition = ownShortPositions[i]; - - // - // Position Must Be In Profit ... - if (iPosition.profit <= 0) - { - continue; - } - - // - if (hasTrendGuard) - { - // guardStop = decisionXConditions.strBuffer[1] + decisionXConditions.atrBuffer[1]; - } - - // - // Price Must Lesser than Zone Upper ... - if (iPosition.price > guardStop) - { - continue; - } - - // - // Position Entry Must Greater than Zone Upper ... - if (iPosition.entry < guardStop) - { - continue; - } - - // - // Position SL must be Zero or Greater than Zone Upper ... - if (iPosition.sl != 0 && - iPosition.sl < guardStop) - { - continue; - } - - // - X121SMCGuard iGuard; - - // - iGuard.time = cTime; - iGuard.symbol = symbol; - iGuard.provider = provider; - iGuard.action = X_121_SMC_GUARD_ACTION_TRAIL_STOP; - - // - iGuard.sl = guardStop; - iGuard.ticket = iPosition.ticket; - - // - AddGuard( - iGuard, - guards // - ); - } - } - } - } - - // - // Trail Target ... - if (!ignoreTrailTargetGuard) - { - // - if (hasLongs) - { - // - bool hasAnalyseGuard = - // - false - // - // (hasAnalysePriceZone && - // isAnalysePriceZoneValidForPeak && - // isAnalysePriceZoneUpperRejected) - // - ; - - // - bool hasVerificationGuard = - // - false - // - // (hasVerificationPriceZone && - // isVerificationPriceZoneValidForPeak && - // isVerificationPriceZoneUpperRejected) - // - ; - - // - bool hasGuard = - // - hasAnalyseGuard || - hasVerificationGuard - // - ; - - // - double guardTP = - hasAnalyseGuard - ? 0 // analysePriceZoneUpper - : hasVerificationGuard - ? 0 // verificationPriceZoneUpper - : 0; - - // - if (hasGuard) - { - // - for (int i = 0; i < longsCount; i++) - { - // - XPosition iPosition = ownLongPositions[i]; - - // - // Position Must Be In Profit ... - if (iPosition.profit <= 0) - { - continue; - } - - // - X121SMCGuard iGuard; - - // - iGuard.time = cTime; - iGuard.symbol = symbol; - iGuard.provider = provider; - iGuard.action = X_121_SMC_GUARD_ACTION_TRAIL_TARGET; - - // - iGuard.tp = guardTP; - iGuard.ticket = iPosition.ticket; - - // - AddGuard( - iGuard, - guards // - ); - } - } - } - - // - if (hasShorts) - { - // - bool hasAnalyseGuard = - // - false - // - // (hasAnalysePriceZone && - // isAnalysePriceZoneValidForVale && - // isAnalysePriceZoneLowerRejected) - // - ; - - // - bool hasVerificationGuard = - // - false - // - // (hasVerificationPriceZone && - // isVerificationPriceZoneValidForVale && - // isVerificationPriceZoneLowerRejected) - // - ; - - // - bool hasGuard = - // - hasAnalyseGuard || - hasVerificationGuard - // - ; - - // - double guardTP = - hasAnalyseGuard - ? 0 // analysePriceZoneLower - : hasVerificationGuard - ? 0 // verificationPriceZoneLower - : 0; - - // - if (hasGuard) - { - // - for (int i = 0; i < shortsCount; i++) - { - // - XPosition iPosition = ownShortPositions[i]; - - // - // Position Must Be In Profit ... - if (iPosition.profit <= 0) - { - continue; - } - - // - X121SMCGuard iGuard; - - // - iGuard.time = cTime; - iGuard.symbol = symbol; - iGuard.provider = provider; - iGuard.action = X_121_SMC_GUARD_ACTION_TRAIL_TARGET; - - // - iGuard.tp = guardTP; - iGuard.ticket = iPosition.ticket; - - // - AddGuard( - iGuard, - guards // - ); - } - } - } - } - - // - // Hedge ... - if (!ignoreHedgeGuard) - { } // @@ -1212,28 +889,44 @@ bool DetectX121SMCGuards( Clean(ownShortPositions); // - // x121SMCAnalysePriceZone.Clean(); - // x121SMCDecisionPriceZone.Clean(); - // x121SMCConsolidationZone.Clean(); - // x121SMCVerificationPriceZone.Clean(); + zBar.Clean(); + cBar.Clean(); + pBar.Clean(); + ppBar.Clean(); // - // Release Arrays ... - Clean(ownPositions); - Clean(ownLongPositions); - Clean(ownShortPositions); - // Clean(triggerPoiEvents); - // Clean(triggerCycleEvents); - Clean(decisionPoiEvents); - Clean(decisionCycleEvents); + Clean(visionPoiEvents); Clean(analysePoiEvents); + Clean(visionCycleEvents); + Clean(decisionPoiEvents); Clean(analyseCycleEvents); - // Clean(verificationPoiEvents); - // Clean(verificationCycleEvents); + Clean(decisionCycleEvents); Clean(consolidationPoiEvents); Clean(consolidationCycleEvents); - Clean(visionPoiEvents); - Clean(visionCycleEvents); + + // + visionState.Clean(); + analyseState.Clean(); + decisionState.Clean(); + visionConditions.Clean(); + analyseConditions.Clean(); + visionXConditions.Clean(); + decisionConditions.Clean(); + consolidationState.Clean(); + analyseXConditions.Clean(); + decisionXConditions.Clean(); + consolidationConditions.Clean(); + consolidationXConditions.Clean(); + + // + lastBullishBox.Clean(); + lastBearishBox.Clean(); + lastBullishZone.Clean(); + lastBearishZone.Clean(); + prevLastBullishBox.Clean(); + prevLastBearishBox.Clean(); + prevLastBullishZone.Clean(); + prevLastBearishZone.Clean(); // count = ArraySize(guards); diff --git a/X121SMCEA/Libraries/x-121.smc.lib.mq5 b/X121SMCEA/Libraries/x-121.smc.lib.mq5 index 08456978..ec1251a7 100644 --- a/X121SMCEA/Libraries/x-121.smc.lib.mq5 +++ b/X121SMCEA/Libraries/x-121.smc.lib.mq5 @@ -71,11 +71,9 @@ struct X121SMCCycleConditions ENUM_TIMEFRAMES period; datetime time; - // - X121Conditions x121Conditions; - // XPOIState state; + X121Conditions x121Conditions; // void X121SMCStrategyConditions() @@ -98,7 +96,7 @@ struct X121SMCCycleConditions // state.Clean(); - // x121Conditions.Clean(); + x121Conditions.Clean(); // ZeroMemory(this); @@ -272,12 +270,6 @@ struct X121SMCStrategyConditions string provider; ENUM_X_DIRECTION signalDir; - // - // X121Conditions conditions; - // XPriceZones priceZones; - // XPriceZones decisionZones; - // XMarketStructure marketStructure; - // void X121SMCStrategyConditions() { @@ -303,12 +295,6 @@ struct X121SMCStrategyConditions provider = NULL; signalDir = X_DIRECTION_NONE; - // - // conditions.Clean(); - // priceZones.Clean(); - // decisionZones.Clean(); - // marketStructure.Clean(); - // ZeroMemory(this); } diff --git a/X121SMCEA/Signals/x-121.smc.xsupdemobs.signal.lib.mq5 b/X121SMCEA/Signals/x-121.smc.xsupdemobs.signal.lib.mq5 index eaeae2f9..0aab2640 100644 --- a/X121SMCEA/Signals/x-121.smc.xsupdemobs.signal.lib.mq5 +++ b/X121SMCEA/Signals/x-121.smc.xsupdemobs.signal.lib.mq5 @@ -920,6 +920,8 @@ struct X121SMCStrategyXSupDemOBSSignalConditions // double sl; double target; + double reward; + double amountPercent; ENUM_X_DIRECTION dir; ENUM_X_POSITION_TYPES type; @@ -935,7 +937,10 @@ struct X121SMCStrategyXSupDemOBSSignalConditions double point; // - // Working Area ... + ENUM_X121SMC_XSUPDEMOBS_PRIORITY priority; + + // + // Working Zone ... // XCSupplyZone *visionHighestSupplyZone; @@ -957,6 +962,9 @@ struct X121SMCStrategyXSupDemOBSSignalConditions XCSupplyZone *insideSupplyZone; XCDemandZone *insideDemandZone; + // + XConsolidationZone consolidationZone; + // XOBFVG obFVGs[]; @@ -1084,9 +1092,14 @@ struct X121SMCStrategyXSupDemOBSSignalConditions pivot = 0; point = 0; + // + reward = 0; + amountPercent = 0; + // Clean(obFVGs); workingZone.Clean(); + consolidationZone.Clean(); // insideOB = NULL; @@ -1107,6 +1120,9 @@ struct X121SMCStrategyXSupDemOBSSignalConditions ZeroMemory(visionHighestSupplyZone); ZeroMemory(consolidationLowestDemandZone); ZeroMemory(consolidationHighestSupplyZone); + + // + priority = X121SMC_XSUPDEMOBS_PRIORITY_NONE; } // @@ -2342,14 +2358,6 @@ bool DetectX121SMCXSupDemOBSSignalSetup( return result; } - // - // Re Draw Working Zone ... - RemoveX121SMCXSupDemOBSWorkingZoneDraws(); - DrawX121SMCXSupDemOBSWorkingZone( - conditions, - visionCycleHelper.mPOIDrawer // - ); - // // 3- Checking Price Inside Valid Quarters Based on Trend ... @@ -2374,101 +2382,75 @@ bool DetectX121SMCXSupDemOBSSignalSetup( ENUM_X121SMC_XSUPDEMOBS_PRIORITY bearishPriority = X121SMC_XSUPDEMOBS_PRIORITY_NONE; // - bool isPriceAboveUpper = - // - decisionZBar.high < conditions.workingZone.zoneUpper && - decisionCBar.high < conditions.workingZone.zoneUpper && - // - decisionZBar.low > conditions.workingZone.upper && - decisionCBar.low > conditions.workingZone.upper - // - ; - if (isPriceAboveUpper) + bool isInQuarter0 = CheckX121SMCXSupDemOBSPriceInside( + decisionZBar, + decisionCBar, + conditions.workingZone.zoneUpper, + conditions.workingZone.upper // + ); + bool isInQuarter1 = CheckX121SMCXSupDemOBSPriceInside( + decisionZBar, + decisionCBar, + conditions.workingZone.upper, + conditions.workingZone.quarter1 // + ); + bool isInQuarter2 = CheckX121SMCXSupDemOBSPriceInside( + decisionZBar, + decisionCBar, + conditions.workingZone.quarter1, + conditions.workingZone.quarter2 // + ); + bool isInQuarter3 = CheckX121SMCXSupDemOBSPriceInside( + decisionZBar, + decisionCBar, + conditions.workingZone.quarter2, + conditions.workingZone.quarter3 // + ); + bool isInQuarter4 = CheckX121SMCXSupDemOBSPriceInside( + decisionZBar, + decisionCBar, + conditions.workingZone.quarter3, + conditions.workingZone.lower // + ); + bool isInQuarter5 = CheckX121SMCXSupDemOBSPriceInside( + decisionZBar, + decisionCBar, + conditions.workingZone.lower, + conditions.workingZone.zoneLower // + ); + + // + if (isInQuarter0) { // bullishPriority = X121SMC_XSUPDEMOBS_PRIORITY_NONE; bearishPriority = X121SMC_XSUPDEMOBS_PRIORITY_HIGH; } - - // - bool isPriceInQuarterOne = - // - decisionZBar.high < conditions.workingZone.upper && - decisionCBar.high < conditions.workingZone.upper && - // - decisionZBar.low > conditions.workingZone.quarter1 && - decisionCBar.low > conditions.workingZone.quarter1 - // - ; - if (isPriceInQuarterOne) + else if (isInQuarter1) { // bullishPriority = X121SMC_XSUPDEMOBS_PRIORITY_NONE; bearishPriority = X121SMC_XSUPDEMOBS_PRIORITY_REGULAR; } - - // - bool isPriceInQuarterTwo = - // - decisionZBar.high < conditions.workingZone.quarter1 && - decisionCBar.high < conditions.workingZone.quarter1 && - // - decisionZBar.low > conditions.workingZone.quarter2 && - decisionCBar.low > conditions.workingZone.quarter2 - // - ; - if (isPriceInQuarterTwo) + else if (isInQuarter2) { // - bullishPriority = X121SMC_XSUPDEMOBS_PRIORITY_NONE; + bullishPriority = X121SMC_XSUPDEMOBS_PRIORITY_WEAK; bearishPriority = X121SMC_XSUPDEMOBS_PRIORITY_LOW; } - - // - bool isPriceInQuarterThree = - // - decisionZBar.high < conditions.workingZone.quarter2 && - decisionCBar.high < conditions.workingZone.quarter2 && - // - decisionZBar.low > conditions.workingZone.quarter3 && - decisionCBar.low > conditions.workingZone.quarter3 - // - ; - if (isPriceInQuarterThree) + else if (isInQuarter3) { // bullishPriority = X121SMC_XSUPDEMOBS_PRIORITY_LOW; - bearishPriority = X121SMC_XSUPDEMOBS_PRIORITY_NONE; + bearishPriority = X121SMC_XSUPDEMOBS_PRIORITY_WEAK; } - - // - bool isPriceInQuarterFour = - // - decisionZBar.high < conditions.workingZone.quarter3 && - decisionCBar.high < conditions.workingZone.quarter3 && - // - decisionZBar.low > conditions.workingZone.lower && - decisionCBar.low > conditions.workingZone.lower - // - ; - if (isPriceInQuarterFour) + else if (isInQuarter4) { // bullishPriority = X121SMC_XSUPDEMOBS_PRIORITY_REGULAR; bearishPriority = X121SMC_XSUPDEMOBS_PRIORITY_NONE; } - - // - bool isPriceBelowLower = - // - decisionZBar.high < conditions.workingZone.lower && - decisionCBar.high < conditions.workingZone.lower && - // - decisionZBar.low > conditions.workingZone.zoneLower && - decisionCBar.low > conditions.workingZone.zoneLower - // - ; - if (isPriceBelowLower) + else if (isInQuarter5) { // bullishPriority = X121SMC_XSUPDEMOBS_PRIORITY_HIGH; @@ -3334,13 +3316,6 @@ bool DetectX121SMCXSupDemOBSSignalSetup( return result; } - // - RemoveX121SMCXSupDemOBSDraws(); - DrawX121SMCXSupDemOBSConditions( - conditions, - visionCycleHelper.mPOIDrawer // - ); - // conditions.UpdateTo(cTime); @@ -3629,6 +3604,24 @@ bool DetectX121SMCXSupDemOBSSignalSetup( : shortPivot; } + // + double reward; + double amountPercent; + ENUM_X121SMC_XSUPDEMOBS_PRIORITY priority = + isBullish + ? bullishPriority + : bearishPriority; + bool hasRewardAmount = CalculateX121SMCXSupDemOBSRiskReward( + priority, + reward, + amountPercent // + ); + result = hasRewardAmount; + if (!result) + { + return result; + } + // // // @@ -3663,11 +3656,9 @@ bool DetectX121SMCXSupDemOBSSignalSetup( : X_DIRECTION_BEARISH; // - RemoveX121SMCXSupDemOBSDraws(); - DrawX121SMCXSupDemOBSConditions( - conditions, - visionCycleHelper.mPOIDrawer // - ); + conditions.reward = reward; + conditions.priority = priority; + conditions.amountPercent = amountPercent; // swingBar.Clean(); @@ -3944,6 +3935,22 @@ bool DetectX121SMCXSupDemOBSSignalTrigger( setupDir // ); + // + // Manipulate SL Based on Consolidation Zones ... + XConsolidationZone cZone; + bool hasCZone = decisionCycleHelper.GetActiveConsolidationZone(cZone); + bool hasCZones = decisionCycleHelper.HasConsolidationZones(); + int cZonesCount = decisionCycleHelper.CountConsolidationZones(); + if (!hasCZone && + hasCZones) + { + // + hasCZone = decisionCycleHelper.GetLastDirectionalConsolidationZone( + conditions.dir, + cZone // + ); + } + // double sls[]; Add( @@ -3951,6 +3958,31 @@ bool DetectX121SMCXSupDemOBSSignalTrigger( sls // ); + // + if (hasCZone) + { + // + conditions.consolidationZone = cZone; + + // + if (isBullish) + { + // + Add( + cZone.lower, + sls // + ); + } + else + { + // + Add( + cZone.upper, + sls // + ); + } + } + // double iAtr = decisionXConditions.atrBuffer[1]; iAtr *= 2; @@ -4010,7 +4042,10 @@ bool DetectX121SMCXSupDemOBSGuards( bool result = false; // - result = + Clean(guards); + + // + bool isCycleHelpersValid = // visionCycleHelper != NULL && analyseCycleHelper != NULL && @@ -4018,41 +4053,643 @@ bool DetectX121SMCXSupDemOBSGuards( consolidationCycleHelper != NULL // ; + + // + result = isCycleHelpersValid; if (!result) { return result; } // + int count = ArraySize(positions); + result = IsValidSize(count); + if (!result) + { + return result; + } + + // + string symbol = decisionCycleHelper.GetSymbol(); + ENUM_TIMEFRAMES period = decisionCycleHelper.GetPeriod(); string provider = ToString(X_121_SMC_PROVIDER_XSUPDEMOBS); - // // - // result = DetectX121SMCGuards( - // provider, - // guards, - // positions, - // // triggerCycleHelper, - // decisionCycleHelper, - // analyseCycleHelper, - // verificationCycleHelper, - // consolidationCycleHelper, - // visionCycleHelper, - // // - // true, // CloseOnTPNear Guard ... - // true, // CloseLongsOnBearishTrend Guard ... - // true, // CloseShortsOnBullishTrend Guard ... - // true, // CloseAllWeekend Guard ... - // true, // PartialCloseOnTrendChange Guard ... - // true, // TrailStop Guard ... - // true, // TrailTarget Guard ... - // true // Hedge Guard ... - // // - // ); + // + XPosition ownPositions[]; + XPosition ownLongPositions[]; + XPosition ownShortPositions[]; + for (int i = 0; i < count; i++) + { + // + XPosition iPosition = positions[i]; + bool isOwn = iPosition + .IsFiltersPassed( + symbol, + provider, + NULL, + X_POSITION_TYPE_ALL, + iPosition.magic // + ); + if (isOwn) + { + // + AddRef( + iPosition, + ownPositions // + ); + + // + bool isLong = IsLong(positions[i].type); + if (isLong) + { + // + AddRef( + iPosition, + ownLongPositions // + ); + } + else + { + // + AddRef( + iPosition, + ownShortPositions // + ); + } + } + } + + // + count = ArraySize(ownPositions); + + // + int longsCount = ArraySize(ownLongPositions); + bool hasLongs = IsValidSize(longsCount); + + // + int shortsCount = ArraySize(ownShortPositions); + bool hasShorts = IsValidSize(shortsCount); + + // + result = IsValidSize(count); + if (!result) + { + // + Clean(ownPositions); + Clean(ownLongPositions); + Clean(ownShortPositions); + + // + return result; + } + + // + // + // + + // + // Get Global and Common Guards ... + + // + ENUM_X_121_SMC_GUARD_ACTIONS ignoreGuards[]; + result = DetectX121SMCGuards( + provider, + guards, + positions, + decisionCycleHelper, + analyseCycleHelper, + consolidationCycleHelper, + visionCycleHelper, + // + ignoreGuards + // + ); + + // + // + // + + // + // Get Custom Implemented Guards ... + + // + // Here we Are Sure there is Positions to Guard ... + // based on Current Provider ... + + // + // Detect Required Data for Analyse Market to Guard Positions ... + + // + int zIndex = 0; + int cIndex = zIndex + 1; + int pIndex = cIndex + 1; + int ppIndex = pIndex + 1; + + // + int loopback = 10; + + // + XOHCL zBar; + result = zBar.Init( + symbol, + period, + zIndex // + ); + if (!result) + { + // + result = HasChild(guards); + return result; + } + + // + XOHCL cBar; + result = cBar.Init( + symbol, + period, + cIndex // + ); + if (!result) + { + // + zBar.Clean(); + result = HasChild(guards); + return result; + } + + // + XOHCL pBar; + result = pBar.Init( + symbol, + period, + pIndex // + ); + if (!result) + { + // + zBar.Clean(); + cBar.Clean(); + result = HasChild(guards); + return result; + } + + // + XOHCL ppBar; + result = ppBar.Init( + symbol, + period, + ppIndex // + ); + if (!result) + { + // + zBar.Clean(); + cBar.Clean(); + pBar.Clean(); + result = HasChild(guards); + return result; + } + + // + double ask = GetAsk(symbol); + double bid = GetBid(symbol); + datetime cTime = TimeCurrent(); + double points = GetPoints(symbol); + + // + + // + // Cycles Conditions ... + + // + // Decision ... + ENUM_XPOI_EVENTS decisionPoiEvents[]; + ENUM_X_CYCLE_EVENTS decisionCycleEvents[]; + X121SMCCycleConditions decisionConditions; + result = decisionCycleHelper.GetConditions( + decisionCycleEvents, + decisionPoiEvents, + decisionConditions, + zIndex, + loopback // + ); + if (!result) + { + // + zBar.Clean(); + cBar.Clean(); + pBar.Clean(); + ppBar.Clean(); + result = HasChild(guards); + return result; + } + + // + // Analyse ... + ENUM_XPOI_EVENTS analysePoiEvents[]; + ENUM_X_CYCLE_EVENTS analyseCycleEvents[]; + X121SMCCycleConditions analyseConditions; + result = analyseCycleHelper.GetConditions( + analyseCycleEvents, + analysePoiEvents, + analyseConditions, + zIndex, + loopback // + ); + if (!result) + { + // + zBar.Clean(); + cBar.Clean(); + pBar.Clean(); + ppBar.Clean(); + + // + Clean(decisionPoiEvents); + Clean(decisionCycleEvents); + + // + decisionConditions.Clean(); + + // + result = HasChild(guards); + return result; + } + + // + // Consolidation ... + ENUM_XPOI_EVENTS consolidationPoiEvents[]; + ENUM_X_CYCLE_EVENTS consolidationCycleEvents[]; + X121SMCCycleConditions consolidationConditions; + result = consolidationCycleHelper.GetConditions( + consolidationCycleEvents, + consolidationPoiEvents, + consolidationConditions, + zIndex, + loopback // + ); + if (!result) + { + // + zBar.Clean(); + cBar.Clean(); + pBar.Clean(); + ppBar.Clean(); + + // + Clean(decisionPoiEvents); + Clean(decisionCycleEvents); + + // + decisionConditions.Clean(); + + // + Clean(analysePoiEvents); + Clean(analyseCycleEvents); + + // + analyseConditions.Clean(); + + // + result = HasChild(guards); + return result; + } + + // + // Vision ... + ENUM_XPOI_EVENTS visionPoiEvents[]; + ENUM_X_CYCLE_EVENTS visionCycleEvents[]; + X121SMCCycleConditions visionConditions; + result = visionCycleHelper.GetConditions( + visionCycleEvents, + visionPoiEvents, + visionConditions, + zIndex, + loopback // + ); + if (!result) + { + // + zBar.Clean(); + cBar.Clean(); + pBar.Clean(); + ppBar.Clean(); + + // + Clean(decisionPoiEvents); + Clean(decisionCycleEvents); + + // + decisionConditions.Clean(); + + // + Clean(analysePoiEvents); + Clean(analyseCycleEvents); + + // + analyseConditions.Clean(); + + // + Clean(consolidationPoiEvents); + Clean(consolidationCycleEvents); + + // + consolidationConditions.Clean(); + + // + result = HasChild(guards); + return result; + } + + // + // Cycles POI States ... + XPOIState decisionState = decisionConditions.state; + XPOIState analyseState = analyseConditions.state; + XPOIState consolidationState = consolidationConditions.state; + XPOIState visionState = visionConditions.state; + + // + // Cycle X121Conditions ... + X121Conditions decisionXConditions = decisionConditions.x121Conditions; + X121Conditions analyseXConditions = analyseConditions.x121Conditions; + X121Conditions consolidationXConditions = consolidationConditions.x121Conditions; + X121Conditions visionXConditions = visionConditions.x121Conditions; + + // + // + // + + // + // Detect Consolidation Zone ... + + // + XBoxZone lastBullishBox; + XBoxZone prevLastBullishBox; + bool hasLastBullishBox = false; + bool hasPrevLastBullishBox = false; + XConsolidationZone lastBullishZone; + bool isLastBullishAbovePrev = false; + bool isLastBullishBelowPrev = false; + XConsolidationZone prevLastBullishZone; + + // + XBoxZone lastBearishBox; + XBoxZone prevLastBearishBox; + bool hasLastBearishBox = false; + bool hasPrevLastBearishBox = false; + XConsolidationZone lastBearishZone; + bool isLastBearishAbovePrev = false; + bool isLastBearishBelowPrev = false; + XConsolidationZone prevLastBearishZone; + + // + int bullishConsolidationZonesCount = 0; + int bearishConsolidationZonesCount = 0; + bool hasBullishConsolidationZones = false; + bool hasBearishConsolidationZones = false; + XConsolidationZone bullishConsolidationZones[]; + XConsolidationZone bearishConsolidationZones[]; + bool hasConsolidationZones = decisionCycleHelper.HasConsolidationZones(); + int consolidationZonesCount = decisionCycleHelper.CountConsolidationZones(); + if (hasConsolidationZones) + { + // + bullishConsolidationZonesCount = decisionCycleHelper + .FillConsolidationZones( + X_DIRECTION_BULLISH, + bullishConsolidationZones // + ); + hasBullishConsolidationZones = IsValidSize(bullishConsolidationZonesCount); + + // + bearishConsolidationZonesCount = decisionCycleHelper + .FillConsolidationZones( + X_DIRECTION_BEARISH, + bearishConsolidationZones // + ); + hasBearishConsolidationZones = IsValidSize(bearishConsolidationZonesCount); + + // + // + // + + // + if (hasBullishConsolidationZones && + bullishConsolidationZonesCount >= 2) + { + // + lastBullishZone = bullishConsolidationZones[bullishConsolidationZonesCount - 1]; + prevLastBullishZone = bullishConsolidationZones[bullishConsolidationZonesCount - 2]; + + // + hasLastBullishBox = ToBox( + lastBullishBox, + lastBullishZone // + ); + hasPrevLastBullishBox = ToBox( + prevLastBullishBox, + prevLastBullishZone // + ); + + // + isLastBullishAbovePrev = hasLastBullishBox && + hasPrevLastBullishBox && + IsBoxAbove( + lastBullishBox, + prevLastBullishBox // + ); + + // + isLastBullishBelowPrev = hasLastBullishBox && + hasPrevLastBullishBox && + IsBoxBelow( + lastBullishBox, + prevLastBullishBox // + ); + } + + // + if (hasBearishConsolidationZones && + bearishConsolidationZonesCount >= 2) + { + // + lastBearishZone = bullishConsolidationZones[bullishConsolidationZonesCount - 1]; + prevLastBearishZone = bullishConsolidationZones[bullishConsolidationZonesCount - 2]; + + // + hasLastBearishBox = ToBox( + lastBearishBox, + lastBearishZone // + ); + hasPrevLastBearishBox = ToBox( + prevLastBearishBox, + prevLastBearishZone // + ); + + // + isLastBearishAbovePrev = hasLastBearishBox && + hasPrevLastBearishBox && + IsBoxAbove( + lastBearishBox, + prevLastBearishBox // + ); + + // + isLastBearishBelowPrev = hasLastBearishBox && + hasPrevLastBearishBox && + IsBoxBelow( + lastBearishBox, + prevLastBearishBox // + ); + } + + // + } + + // + // Detect High Probability Swings ... + bool isSwingLow = + // + cBar.low > pBar.low && + ppBar.low > pBar.low && + // + zBar.low > pBar.low + // + ; + bool isSwingHigh = + // + cBar.high < pBar.high && + ppBar.high < pBar.high && + // + zBar.high < pBar.high + // + ; + bool isStrongSwingLow = + pBar.IsBullish() && + pBar.GetLowShadow() >= pBar.GetBody() * 2; + bool isStrongSwingHigh = + pBar.IsBearish() && + pBar.GetHighShadow() >= pBar.GetBody() * 2; + + // + bool isStrongSwingLowAboveLastBullishBox = + isStrongSwingLow && + hasLastBullishBox && + pBar.low > lastBullishBox.upper; + + // + bool isStrongSwingHighBelowLastBearishBox = + isStrongSwingHigh && + hasLastBearishBox && + pBar.high < lastBearishBox.lower; + + // + // Here We Have all Requirements for Guarding Positions ... + + // + // Available Guards: + // X_121_SMC_GUARD_ACTION_NONE + // X_121_SMC_GUARD_ACTION_CLOSE + // X_121_SMC_GUARD_ACTION_CLOSE_ALL + // X_121_SMC_GUARD_ACTION_CLOSE_LONGS + // X_121_SMC_GUARD_ACTION_CLOSE_SHORTS + // X_121_SMC_GUARD_ACTION_PARTIAL_CLOSE + // X_121_SMC_GUARD_ACTION_TRAIL_STOP + // X_121_SMC_GUARD_ACTION_TRAIL_TARGET + // X_121_SMC_GUARD_ACTION_HEDGE + + // + // X_121_SMC_GUARD_ACTION_CLOSE: + // Close Specified Position on Specified Conditions ... + + // + // X_121_SMC_GUARD_ACTION_CLOSE_ALL: + // Close All Positions on Specified Conditions ... + + // + // X_121_SMC_GUARD_ACTION_CLOSE_LONGS: + // Close All Long Positions on Specified Conditions ... + + // + // X_121_SMC_GUARD_ACTION_CLOSE_SHORTS: + // Close All Short Positions on Specified Conditions ... + + // + // X_121_SMC_GUARD_ACTION_PARTIAL_CLOSE: + // Partial Close Specified Position on Specified Conditions ... + + // + // X_121_SMC_GUARD_ACTION_TRAIL_STOP: + // Trail Stop Specified Position on Specified Conditions ... + + // + // X_121_SMC_GUARD_ACTION_TRAIL_TARGET: + // Trail Target Specified Position on Specified Conditions ... + + // + // X_121_SMC_GUARD_ACTION_HEDGE: + // Hedge all Positions on Specified Conditions ... + + // + // Cleanup Collections ... + + // + Clean(ownPositions); + Clean(ownLongPositions); + Clean(ownShortPositions); + + // + zBar.Clean(); + cBar.Clean(); + pBar.Clean(); + ppBar.Clean(); + + // + 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(); + decisionConditions.Clean(); + consolidationState.Clean(); + analyseXConditions.Clean(); + decisionXConditions.Clean(); + consolidationConditions.Clean(); + consolidationXConditions.Clean(); + + // + lastBullishBox.Clean(); + lastBearishBox.Clean(); + lastBullishZone.Clean(); + lastBearishZone.Clean(); + prevLastBullishBox.Clean(); + prevLastBearishBox.Clean(); + prevLastBullishZone.Clean(); + prevLastBearishZone.Clean(); + + // + count = ArraySize(guards); + result = IsValidSize(count); // return result; } +// +// +// + // // Add Conditions to Conditions Collection ... int AddX121SMCXSupDemOBSConditionsIfNotExists( @@ -4132,6 +4769,109 @@ int AddX121SMCXSupDemOBSConditionsIfNotExists( return result; } +// +bool CheckX121SMCXSupDemOBSPriceInside( + XOHCL &zBar, + XOHCL &cBar, + double upper, + double lower // +) +{ + // + bool result = false; + + // + result = zBar.IsValid() && + cBar.IsValid() && + upper > 0 && + lower > 0 && + upper > lower && + zBar.time > cBar.time; + if (!result) + { + return result; + } + + // + result = + // + zBar.high < upper && + cBar.high < upper && + // + zBar.low > lower && + cBar.low > lower + // + ; + + // + return result; +} + +// +bool CalculateX121SMCXSupDemOBSRiskReward( + ENUM_X121SMC_XSUPDEMOBS_PRIORITY priority, + double &reward, + double &amountPercent // +) +{ + // + bool result = false; + + // + reward = 0; + amountPercent = 0; + + // + result = priority != X121SMC_XSUPDEMOBS_PRIORITY_NONE; + if (!result) + { + return result; + } + + // + switch (priority) + { + // + case X121SMC_XSUPDEMOBS_PRIORITY_HIGH: + // + reward = 6; + amountPercent = 2; + break; + + // + case X121SMC_XSUPDEMOBS_PRIORITY_REGULAR: + // + reward = 6; + amountPercent = 1.5; + break; + + // + case X121SMC_XSUPDEMOBS_PRIORITY_LOW: + // + reward = 4; + amountPercent = 1; + break; + + // + case X121SMC_XSUPDEMOBS_PRIORITY_WEAK: + // + reward = 2; + amountPercent = 0.5; + break; + } + + // + result = + // + reward > 0 && + amountPercent > 0 + // + ; + + // + return result; +} + // // Draws ... // @@ -4142,6 +4882,12 @@ void RemoveX121SMCXSupDemOBSDraws() mX121SMCXSupDemOBSObjects.Clear(); } +// +void RemoveX121SMCXSupDemOBSWorkingZoneDraws() +{ + mX121SMCXSupDemOBSWorkingZoneObjects.Clear(); +} + // void DrawX121SMCXSupDemOBSOrderBlock( XCOrderBlock *ob, @@ -4757,20 +5503,24 @@ void DrawX121SMCXSupDemOBSConditions( mX121SMCXSupDemOBSObjects.Add(iObj); } } + + // + bool hasConsolidationZone = conditions.consolidationZone.IsValid(); + if (hasConsolidationZone) + { + // + XCConsolidationZoneObject *iObj; + isCreated = drawer.CreateConsolidationZone( + conditions.consolidationZone, + iObj // + ); + + // + if (isCreated) + { + mX121SMCXSupDemOBSObjects.Add(iObj); + } + } } -// -// -// - -// -void RemoveX121SMCXSupDemOBSWorkingZoneDraws() -{ - mX121SMCXSupDemOBSWorkingZoneObjects.Clear(); -} - -// -// -// - // \ No newline at end of file diff --git a/X121SMCEA/Strategy/x-121.smc.strategy.class.mq5 b/X121SMCEA/Strategy/x-121.smc.strategy.class.mq5 index 8b1c4138..07fb1d64 100644 --- a/X121SMCEA/Strategy/x-121.smc.strategy.class.mq5 +++ b/X121SMCEA/Strategy/x-121.smc.strategy.class.mq5 @@ -102,27 +102,23 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy void Destroy() override { // + // XSupDemOBS ... + RemoveX121SMCXSupDemOBSDraws(); + mX121SMCXSupDemOBSConditions.Clean(); Clean(mX121SMCXSupDemOBSConditionsCollection); + RemoveX121SMCXSupDemOBSWorkingZoneDraws(); // - // ZeroMemory(mTriggerCycleHelper); ZeroMemory(mDecisionCycleHelper); ZeroMemory(mAnalyseCycleHelper); - // ZeroMemory(mVerificationCycleHelper); ZeroMemory(mConsolidationCycleHelper); ZeroMemory(mVisionCycleHelper); // - // delete mTriggerCycleHelper; delete mDecisionCycleHelper; delete mAnalyseCycleHelper; - // delete mVerificationCycleHelper; delete mConsolidationCycleHelper; delete mVisionCycleHelper; - - // - RemoveX121SMCXSupDemOBSDraws(); - RemoveX121SMCXSupDemOBSWorkingZoneDraws(); } /** @@ -205,10 +201,14 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy // // XSupDemOBS Signal ... + X121SMCStrategyXSupDemOBSSignalConditions mXSupDemOBSConditions; if (useXSupDemOBSSignal && !hasSignal) { // - hasXSupDemOBSSignal = DetectXSupDemOBSSignal(conditions); + hasXSupDemOBSSignal = DetectXSupDemOBSSignal( + conditions, + mXSupDemOBSConditions // + ); hasSignal = hasXSupDemOBSSignal; } @@ -317,46 +317,107 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy // if (result) { - // - // Configure Signal Protector ... - // if (useXSTRPVSignal) - // { - // // - // signal.trailSL = false; - // signal.fullTPLevel = r2r; - // signal.partialCloseOnTPLevel = 2; - // signal.partialCloseMultiplier = 0.5; - // signal.trailSLStartOnReachTPLevel = 2; - // } - - // - // TODO: Remove this ... - // XCSignalObject *iObj; - // mPOIDrawer.DrawSignal(signal, iObj); - // Print(""); - // if (useXSupDemOBSSignal && hasXSupDemOBSSignal) { - // - // double sR2R = signal.GetRiskRewardRatio(); - // double risk = signal.GetRisk(); // - // double tp = signal.tp; - // double target = signal.tp + (risk * sR2R); + // Re Draw Working Zone ... + RemoveX121SMCXSupDemOBSWorkingZoneDraws(); + DrawX121SMCXSupDemOBSWorkingZone( + mXSupDemOBSConditions, + mVisionCycleHelper.mPOIDrawer // + ); // - // signal.tp = target; - // signal.target = tp; + // Re Draw Working Zone ... + RemoveX121SMCXSupDemOBSDraws(); + DrawX121SMCXSupDemOBSConditions( + mXSupDemOBSConditions, + mVisionCycleHelper.mPOIDrawer // + ); // + // Configuring Amount Percent and ETC ... + bool ignoreEAVolume = mXSupDemOBSConditions.reward > 0 && + mXSupDemOBSConditions.amountPercent > 0; + if (ignoreEAVolume) + { + // + double cReward = mXSupDemOBSConditions.reward; + double cAmountPercent = mXSupDemOBSConditions.amountPercent; + + // + double cRiskReward = risk * cReward; + double cTP = hasLong + ? entry + cRiskReward + : entry - cRiskReward; + + // + double balance = mAccount.GetBalance(); + double cRiskAmount = balance * cAmountPercent / 100; + double cRiskInPoints = risk / points; + double cVolume = mAccount.CalculateVolume( + signal.symbol, + cRiskAmount, + cRiskInPoints // + ); + cVolume = NormalizeVolume(cVolume, signal.symbol); + + // + if (cVolume > 0) + { + // + signal.ignoreEAVolume = ignoreEAVolume; + signal.volume = cVolume; + } + } + + // + // Fix Signal TP Based On Working Zone ... + double maxAllowedTP = + hasLong + ? mXSupDemOBSConditions.workingZone.upper + : mXSupDemOBSConditions.workingZone.lower; + bool canApplyMaxAlowedTP = (hasLong && + signal.tp > maxAllowedTP) || + (!hasLong && signal.tp < maxAllowedTP); + if (canApplyMaxAlowedTP) + { + signal.tp = maxAllowedTP; + } + + // + // Configuring Global Protector ... signal.trailSL = true; - signal.fullTPLevel = r2r; - signal.partialCloseOnTPLevel = 0; - signal.partialCloseMultiplier = 0; signal.trailSLStartOnReachTPLevel = 3; + signal.fullTPLevel = signal.GetRiskRewardRatio(); + } + + // + // Draw Signal Oject ... + XCSignalObject *iSignalObj; + bool isCreated = mVisionCycleHelper + .mPOIDrawer + .DrawSignal(signal, iSignalObj); + if (isCreated) + { + // + mSignalDrawnObjects.Add(iSignalObj); + + // + int maxAllowedDrawnSignals = 15; + int count = mSignalDrawnObjects.Total(); + if (count > maxAllowedDrawnSignals) + { + // + int to = count - maxAllowedDrawnSignals; + mSignalDrawnObjects.DeleteRange( + 0, + to // + ); + } } } @@ -365,6 +426,9 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy hasShort = false; } + // + mXSupDemOBSConditions.Clean(); + // return result; } @@ -431,6 +495,7 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy // // Props ... + CArrayObj mSignalDrawnObjects; // // XC121SMCCycleHelper *mTriggerCycleHelper; @@ -449,7 +514,8 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy // // XSupDemOBS Signal ... bool DetectXSupDemOBSSignal( - X121SMCStrategyConditions &conditions // + X121SMCStrategyConditions &conditions, + X121SMCStrategyXSupDemOBSSignalConditions &xSupDemOBSConditions // ) { // @@ -599,10 +665,8 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy mTmpConditions[i], symbol, period, - // mTriggerCycleHelper, mDecisionCycleHelper, mAnalyseCycleHelper, - // mVerificationCycleHelper, mConsolidationCycleHelper, mVisionCycleHelper // ); @@ -673,6 +737,12 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy conditions.signalDir = mConditions.dir; conditions.target = mConditions.target; + // + xSupDemOBSConditions = mConditions; + + // + mConditions.Clean(); + // return result; }