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 898e7710..c489dfa8 100644 --- a/X121SMCEA/Classes/x-121.smc.market.cycle.helper.class.mq5 +++ b/X121SMCEA/Classes/x-121.smc.market.cycle.helper.class.mq5 @@ -2834,6 +2834,284 @@ struct X121SMCStrategyConditionParser bool hasSignalBox = iSignalBox.IsValid(); bool isSignalBoxBullish = IsBullish(iSignalBox.ob.dir); + // + // Checking Other Conditions ... + bool isVWapSlowPassed = + isSignalBoxBullish + ? cXConditions.isVWapSlowBullish + : cXConditions.isVWapSlowBearish; + + // + // Bullish Conditions ... + isBullish = + // + // Base Condition ... + ( + // + hasSignalBox && + isVWapSlowPassed && + isSignalBoxBullish && + isBarValidForBullish + // + ) + // + ; + + // + // Bearish Conditions ... + isBearish = + // + // Base Condition ... + ( + // + hasSignalBox && + isVWapSlowPassed && + !isSignalBoxBullish && + isBarValidForBearish + // + ) + // + ; + + // + // Filling Requirements ... + result = + isBullish || + isBearish; + if (result) + { + // + dir = + isBullish + ? X_DIRECTION_BULLISH + : X_DIRECTION_BEARISH; + + // + box = iSignalBox; + box.UpdateTo(TimeCurrent()); + } + + // + // Check All Conditions ... + result = + box.IsValid() && + HasDirection(dir) && + (isBullish || + isBearish); + + // + // Cleanup Resources ... + zBar.Clean(); + cBar.Clean(); + pBar.Clean(); + cState.Clean(); + iSignalBox.Clean(); + selectedBox.Clean(); + ZeroMemory(cHelper); + cConditions.Clean(); + cStateEvents.Clean(); + cXConditions.Clean(); + + // + return result; + } + + // + // Activated Boxe ... + bool HasActivatedBoxConditions( + ENUM_X_CYCLES cycle, + XSignalBox &box, + ENUM_X_DIRECTION &dir, + XSignalBox &waitingBoxes[], + X121SMCStrategySignalProviderData &provider, + int barIndex = 0 // + ) + { + // + bool result = false; + + // + box.Clean(); + dir = X_DIRECTION_NONE; + + // + // Checking Waiting Baoxes Exists ... + result = HasChild(waitingBoxes); + if (!result) + { + return result; + } + + // + // Fil Selected Data ... + XPOIState cState; + X121Conditions cXConditions; + XPOIStateEvents cStateEvents; + XC121SMCCycleHelper *cHelper; + X121SMCCycleConditions cConditions; + result = provider.SelectCycle( + cycle, + cState, + cStateEvents, + cXConditions, + cHelper, + cConditions // + ); + if (!result) + { + // + cState.Clean(); + ZeroMemory(cHelper); + cConditions.Clean(); + cXConditions.Clean(); + cStateEvents.Clean(); + + // + return result; + } + Parse(cXConditions); + + // + // Normalize Args ... + + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + int idx = -1; + int count = 0; + bool has = false; + + // + int zIDX = barIndex; + int cIDX = zIDX + 1; + int pIDX = cIDX + 1; + int ppIDX = pIDX + 1; + + // + bool isBullish = false; + bool isBearish = false; + + // + XOHCL zBar; + XOHCL cBar; + XOHCL pBar; + + // + // Initial Bars ... + result = zBar.Init( + cState.symbol, + cState.period, + barIndex // + ); + result = + result && + zBar.GetPreviousBar(cBar); + result = + result && + cBar.GetPreviousBar(pBar); + if (!result) + { + // + zBar.Clean(); + cBar.Clean(); + pBar.Clean(); + cState.Clean(); + ZeroMemory(cHelper); + cConditions.Clean(); + cXConditions.Clean(); + + // + return result; + } + + // + // Checking Bar Based on Positions State ... + ENUM_X_DIRECTION iBarPosDir; + bool isBarValidForDir = cHelper + .mBarAnalyser + .IsValidForPosition( + cBar, + iBarPosDir // + ); + bool isBarValidForBullish = + isBarValidForDir && + IsBullish(iBarPosDir); + bool isBarValidForBearish = + isBarValidForDir && + IsBearish(iBarPosDir); + + // + // Extract Selected Boxes ... + XBoxZone selectedBox; + XSignalBox iSignalBox; + count = ArraySize(waitingBoxes); + has = IsValidSize(count); + if (has) + { + // + for (int i = 0; i < count; i++) + { + // + XSignalBox iBox = waitingBoxes[i]; + + // + bool isBullish = iBox.ob.IsBullish(); + + // + has = cBar.low < iBox.sharp.upper && + cBar.low > iBox.sharp.lower && + cBar.high > iBox.sharp.lower && + cBar.high < iBox.sharp.upper; + + // + // Force Using OB ... + if (has) + { + // + iSignalBox = iBox; + if (!selectedBox.IsValid()) + { + selectedBox = iBox.ob; + } + iBox.Clean(); + break; + } + + // + iBox.Clean(); + } + } + result = + iSignalBox.IsValid() && + selectedBox.IsValid(); + if (!result) + { + // + zBar.Clean(); + cBar.Clean(); + pBar.Clean(); + cState.Clean(); + iSignalBox.Clean(); + selectedBox.Clean(); + ZeroMemory(cHelper); + cConditions.Clean(); + cXConditions.Clean(); + + // + return result; + } + + // + bool hasSignalBox = iSignalBox.IsValid(); + bool isSignalBoxBullish = IsBullish(iSignalBox.ob.dir); + + // + // Checking Other Conditions ... + // // Bullish Conditions ... isBullish = diff --git a/X121SMCEA/Signals/x-121.smc.xwz.signal.lib.mq5 b/X121SMCEA/Signals/x-121.smc.xwz.signal.lib.mq5 index 8ebbfcfc..ae777057 100644 --- a/X121SMCEA/Signals/x-121.smc.xwz.signal.lib.mq5 +++ b/X121SMCEA/Signals/x-121.smc.xwz.signal.lib.mq5 @@ -1505,6 +1505,31 @@ struct X121SMCStrategyXWZWorkingZone if (!isSenario1Happend && useSenario2) { + // + isSenario2Happend = cParser.HasActivatedBoxConditions( + X_CYCLE_DECISION, + box, + dir, + waitingBoxes, + provider, + barIndex // + ); + + // + isSenario2Bullish = + isSenario2Happend && + IsBullish(dir); + + // + isSenario2Bearish = + isSenario2Happend && + IsBearish(dir); + + // + if (isSenario2Happend) + { + signalProvider = X121SMC_XWZ_PROVIDER_XACTIVATED_BOX; + } } //