diff --git a/Indicators/x-saherelm.x121.xsessions.mq5 b/Documents/BKP/x-saherelm.x121.xsessions.mq5 similarity index 100% rename from Indicators/x-saherelm.x121.xsessions.mq5 rename to Documents/BKP/x-saherelm.x121.xsessions.mq5 diff --git a/Indicators/x-saherelm.x121.xwz.mq5 b/Documents/BKP/x-saherelm.x121.xwz.mq5 similarity index 100% rename from Indicators/x-saherelm.x121.xwz.mq5 rename to Documents/BKP/x-saherelm.x121.xwz.mq5 diff --git a/Indicators/x-saherelm.x121.x3ma.mq5 b/Indicators/x-saherelm.x121.x3ma.mq5 index a16b3ced..7950817e 100644 --- a/Indicators/x-saherelm.x121.x3ma.mq5 +++ b/Indicators/x-saherelm.x121.x3ma.mq5 @@ -602,8 +602,9 @@ void CalculateValues( // // Calculate Applied Price ... + ENUM_X_PRICE mPType = ToXPrice(maAppliedTo); double iPrice = GetAppliedPrice( - maAppliedTo, + mPType, open, high, low, diff --git a/Indicators/x-saherelm.x121.xatr.mq5 b/Indicators/x-saherelm.x121.xatr.mq5 index d44a578d..c29dd91d 100644 --- a/Indicators/x-saherelm.x121.xatr.mq5 +++ b/Indicators/x-saherelm.x121.xatr.mq5 @@ -575,8 +575,9 @@ void CalculateAtrZones( // // Select Upper Price ... + ENUM_X_PRICE mUpperType = ToXPrice(atrUpperAppliedTo); double upperPrice = GetAppliedPrice( - atrUpperAppliedTo, + mUpperType, open, high, low, @@ -586,8 +587,9 @@ void CalculateAtrZones( // // Select Lower Price ... + ENUM_X_PRICE mLowerType = ToXPrice(atrLowerAppliedTo); double lowerPrice = GetAppliedPrice( - atrLowerAppliedTo, + mLowerType, open, high, low, diff --git a/Indicators/x-saherelm.x121.xstr.mq5 b/Indicators/x-saherelm.x121.xstr.mq5 index cccce4fb..bd69c202 100644 --- a/Indicators/x-saherelm.x121.xstr.mq5 +++ b/Indicators/x-saherelm.x121.xstr.mq5 @@ -491,8 +491,9 @@ void CalculateStr( { // // Calculated Price ... + ENUM_X_PRICE mPTYpe = ToXPrice(strAppliedTo); double price = GetAppliedPrice( - strAppliedTo, + mPTYpe, open, high, low, diff --git a/Indicators/x-saherelm.x121.xtrend.mq5 b/Indicators/x-saherelm.x121.xtrend.mq5 index a9925c40..1da2b39a 100644 --- a/Indicators/x-saherelm.x121.xtrend.mq5 +++ b/Indicators/x-saherelm.x121.xtrend.mq5 @@ -581,8 +581,9 @@ void CalculateTrend( ) { // + ENUM_X_PRICE mPType = ToXPrice(trendPriceType); double iPrice = GetAppliedPrice( - trendPriceType, + mPType, open, high, low, diff --git a/Indicators/x-saherelm.x121.xvwap.mq5 b/Indicators/x-saherelm.x121.xvwap.mq5 index 6b636009..ca2a2c46 100644 --- a/Indicators/x-saherelm.x121.xvwap.mq5 +++ b/Indicators/x-saherelm.x121.xvwap.mq5 @@ -615,8 +615,9 @@ void CalculateVWAPDataBuffers( ) { // + ENUM_X_PRICE mPType = ToXPrice(vwapAppliedTo); double price = GetAppliedPrice( - vwapAppliedTo, + mPType, open, high, low, diff --git a/Libraries/x-saherelm.common.extensions.lib.mq5 b/Libraries/x-saherelm.common.extensions.lib.mq5 index 9dada94a..c982c3e8 100644 --- a/Libraries/x-saherelm.common.extensions.lib.mq5 +++ b/Libraries/x-saherelm.common.extensions.lib.mq5 @@ -5930,10 +5930,10 @@ double GetPipPrice( */ double GetAppliedPrice( ENUM_X_PRICE mType, // Type of Price Selection - double &mOpen[], // Open Prices - double &mHigh[], // High Preices - double &mLow[], // Low Prices - double &mClose[], // Close Prices + const double &mOpen[], // Open Prices + const double &mHigh[], // High Preices + const double &mLow[], // Low Prices + const double &mClose[], // Close Prices int barIndex // Bar Index ) { 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 e628c4c3..16578f5f 100644 --- a/X121SMCEA/Classes/x-121.smc.market.cycle.helper.class.mq5 +++ b/X121SMCEA/Classes/x-121.smc.market.cycle.helper.class.mq5 @@ -2799,30 +2799,156 @@ struct X121SMCStrategyConditionParser IsBearish(iBarPosDir); // - // result = isBarValidForBullish || - // isBarValidForBearish; - // if (!result) - // { - // // - // zBar.Clean(); - // cBar.Clean(); - // pBar.Clean(); - // cState.Clean(); - // chState.Clean(); - // insideBox.Clean(); - // ZeroMemory(cHelper); - // cConditions.Clean(); - // cXConditions.Clean(); - // ZeroMemory(chHelper); - // chConditions.Clean(); - // chXConditions.Clean(); + XSignalBox iSignalBox; + count = ArraySize(waitingBoxes); + has = IsValidSize(count); + if (has) + { + // + for (int i = 0; i < count; i++) + { + // + XSignalBox iBox = waitingBoxes[i]; - // // - // return result; - // } + // + bool isBullish = iBox.ob.IsBullish(); + bool hasFVG = iBox.fvg.IsValid(); + + // + bool isFVGBullishRejected = + // + hasFVG && + cBar.low < iBox.fvg.upper && + cBar.GetDown() > iBox.fvg.upper + // + ; + + // + bool isFVGBearishRejected = + // + hasFVG && + cBar.high > iBox.fvg.lower && + cBar.GetUp() < iBox.fvg.lower + // + ; + + // + bool isOBBullishRejected = + // + cBar.low < iBox.ob.upper && + cBar.GetDown() > iBox.ob.upper + // + ; + + // + bool isOBBearishRejected = + // + cBar.high > iBox.ob.lower && + cBar.GetUp() < iBox.ob.lower + // + ; + + // + has = + isBullish + ? isBarValidForBullish && + (hasFVG + ? isFVGBullishRejected + : isOBBullishRejected) + : isBarValidForBearish && + (hasFVG + ? isFVGBearishRejected + : isOBBearishRejected); + if (has) + { + // + iSignalBox = iBox; + iBox.Clean(); + break; + } + + // + iBox.Clean(); + } + } + has = iSignalBox.IsValid(); // - // Detecting Signal Conditions ... + // Retest Signal ... + int retests = 0; + if (has) + { + // + bool hasFVG = iSignalBox.fvg.IsValid(); + XBoxZone iBox; + if (hasFVG) + { + iBox = iSignalBox.fvg; + } + else + { + iBox = iSignalBox.ob; + } + + // + int iFromIDX = GetBarIndex( + cBar.symbol, + cBar.period, + iBox.from // + ); + has = IsValidIndex(iFromIDX); + if (has) + { + // + // Counting Retests ... + for (int i = iFromIDX; i >= barIndex; i--) + { + // + XOHCL iBar; + has = iBar.Init( + cBar.symbol, + cBar.period, + i // + ); + + // + bool isBullishRetested = + // + iBar.low < iBox.upper && + iBar.GetDown() > iBox.upper + // + ; + + // + bool isBearishRetested = + // + iBar.high > iBox.lower && + iBar.GetUp() < iBox.lower + // + ; + + // + has = iBox.IsBullish() + ? isBullishRetested + : isBearishRetested; + if (has) + { + retests++; + } + + // + iBar.Clean(); + } + } + + // + iBox.Clean(); + } + + // + bool isSignalBoxRetested = retests > 1; + bool hasSignalBox = iSignalBox.IsValid(); + bool isSignalBoxBullish = IsBullish(iSignalBox.ob.dir); // // Bullish Conditions ... @@ -2831,11 +2957,10 @@ struct X121SMCStrategyConditionParser // Base Condition ... ( // - false - // cBar.IsBullish() && - // isBarValidForBullish && - // cBar.close > cXConditions.x3maFastBuffer[cIDX] && - // cXConditions.x3maFastBuffer[cIDX] < cXConditions.x3maSlowBuffer[cIDX] + hasSignalBox && + isSignalBoxBullish && + isSignalBoxRetested && + isBarValidForBullish // ) // @@ -2848,11 +2973,10 @@ struct X121SMCStrategyConditionParser // Base Condition ... ( // - false - // cBar.IsBearish() && - // isBarValidForBearish && - // cBar.close < cXConditions.x3maFastBuffer[cIDX] && - // cXConditions.x3maFastBuffer[cIDX] > cXConditions.x3maSlowBuffer[cIDX] + hasSignalBox && + !isSignalBoxBullish && + isSignalBoxRetested && + isBarValidForBearish // ) // @@ -2872,13 +2996,17 @@ struct X121SMCStrategyConditionParser : X_DIRECTION_BEARISH; // - box.dir = dir; + if (iSignalBox.fvg.IsValid()) + { + box = iSignalBox.fvg; + } + else + { + box = iSignalBox.ob; + } + + // box.to = TimeCurrent(); - // box.from = insideBox.from; - // box.upper = insideBox.upper; - // box.lower = insideBox.lower; - box.symbol = cXConditions.symbol; - box.period = cXConditions.period; } // @@ -2896,7 +3024,7 @@ struct X121SMCStrategyConditionParser pBar.Clean(); cState.Clean(); chState.Clean(); - // insideBox.Clean(); + iSignalBox.Clean(); ZeroMemory(cHelper); cConditions.Clean(); cStateEvents.Clean(); diff --git a/X121SMCEA/Signals/x-121.smc.xwz.signal.class.mq5 b/X121SMCEA/Signals/x-121.smc.xwz.signal.class.mq5 index 432f819c..589041bd 100644 --- a/X121SMCEA/Signals/x-121.smc.xwz.signal.class.mq5 +++ b/X121SMCEA/Signals/x-121.smc.xwz.signal.class.mq5 @@ -223,7 +223,7 @@ class XCX121SMCXWZSignalDetector : public XCBase // // Detectiong Signal Boxes ... hasWaitingBoxes = workingZone - .DetectSignalBoxes( + .DetectWaitingBoxes( X_CYCLE_ANALYSE, provider, zIndex // @@ -472,53 +472,23 @@ class XCX121SMCXWZSignalDetector : public XCBase iAtr = provider.decisionXConditions.atrBuffer[1]; iAtr *= 0; } - // else - // if (signalProvider == X121SMC_XWZ_PROVIDER_ACTIVATED_BOX) - // { - // // - // iAtr = provider.decisionXConditions.atrBuffer[1]; - // iAtr *= 1.5; + else if (signalProvider == X121SMC_XWZ_PROVIDER_XREJECTED_BOX) + { + // + iAtr = provider.decisionXConditions.atrBuffer[1]; + iAtr *= 0; - // // // - // // if (isBullish) - // // { - // // // - // // iSL = MathMin( - // // provider.decisionXConditions.le1Buffer[1], - // // provider.decisionXConditions.le2Buffer[1] // - // // ); - // // if (iSL > 0) - // // { - // // // - // // Add( - // // iSL, - // // sls // - // // ); - // // } - // // } - // // else - // // { - // // // - // // iSL = MathMax( - // // provider.decisionXConditions.se1Buffer[1], - // // provider.decisionXConditions.se2Buffer[1] // - // // ); - // // if (iSL > 0) - // // { - // // // - // // Add( - // // iSL, - // // sls // - // // ); - // // } - // // } - // } - // else if (signalProvider == X121SMC_XWZ_PROVIDER_ACTIVATED_AREA) - // { - // // - // iAtr = provider.decisionXConditions.atrBuffer[1]; - // iAtr *= 1.5; - // } + // + Clean(sls); + + // + // Prepare Box fro SL ... + iSL = signalBox.lower + ((signalBox.upper - signalBox.lower) / 2); + Add( + iSL, + sls // + ); + } // // Select Condition SL ... diff --git a/X121SMCEA/Signals/x-121.smc.xwz.signal.lib.mq5 b/X121SMCEA/Signals/x-121.smc.xwz.signal.lib.mq5 index f47983d6..257fe953 100644 --- a/X121SMCEA/Signals/x-121.smc.xwz.signal.lib.mq5 +++ b/X121SMCEA/Signals/x-121.smc.xwz.signal.lib.mq5 @@ -32,6 +32,7 @@ enum ENUM_X121SMC_XWZ_PROVIDERS { X121SMC_XWZ_PROVIDER_NONE, X121SMC_XWZ_PROVIDER_XHKMA, + X121SMC_XWZ_PROVIDER_XREJECTED_BOX, }; // @@ -466,7 +467,7 @@ struct X121SMCStrategyXWZWorkingZone * * @return ( bool ) */ - bool DetectSignalBoxes( + bool DetectWaitingBoxes( ENUM_X_CYCLES cycle, X121SMCStrategySignalProviderData &provider, int barIndex = 0 // @@ -524,46 +525,91 @@ struct X121SMCStrategyXWZWorkingZone if (has) { // + XCFVG *iFVG = NULL; XCOrderBlock *iOB = cState.orderBlocks[idx]; bool isBullish = iOB.IsBullish(); + // + // Detecting Inside FVG ... + has = cState.HasFairValueGaps(); + if (has) + { + // + XCFVG *tmpFVGs[]; + count = cState.CountFairValueGaps(); + for (int i = 0; i < count; i++) + { + // + XCFVG *jFVG = cState.fairValueGaps[i]; + + // + bool isDirPassed = jFVG.GetDirection() == iOB.GetDirection(); + bool isFromPassed = jFVG.From() >= iOB.From(); + bool isPlacePassed = IsInsideOrDiff( + jFVG, + iOB, + false // + ); + + // + has = isDirPassed && + isFromPassed && + isPlacePassed; + if (has) + { + // + Add( + jFVG, + tmpFVGs // + ); + } + + // + ZeroMemory(jFVG); + } + + // + // Selecting iFVG Based on Direction of OB ... + has = HasChild(tmpFVGs); + if (has) + { + // + idx = + isBullish + ? GetLowest(tmpFVGs) + : GetHighest(tmpFVGs); + has = IsValidIndex(idx); + if (has) + { + iFVG = tmpFVGs[idx]; + } + } + + // + Clean(tmpFVGs); + } + // XBoxZone iOBBox; XBoxZone iFVGBox; + if (iFVG != NULL) + { + // + has = ToBox( + iFVGBox, + iFVG // + ); + } + + // has = ToBox( iOBBox, iOB // ); - if (has) - { - // - // Detect FVGs ... - if (cStateEvents.hasNewFairValueGap) - { - // - int idx = - isBullish - ? GetLowest(cState.bullishFairValueGaps) - : GetHighest(cState.bearishFairValueGaps); - XCFVG *iFVG = - isBullish - ? cState.bullishFairValueGaps[idx] - : cState.bearishFairValueGaps[idx]; - has = IsValidIndex(idx); - if (has) - { - // - ToBox( - iFVGBox, - iFVG // - ); - } - } - } + // - has = iOBBox.IsValid() && - iFVGBox.IsValid(); + has = iOBBox.IsValid(); if (has) { // @@ -586,6 +632,8 @@ struct X121SMCStrategyXWZWorkingZone // iOBBox.Clean(); iFVGBox.Clean(); + ZeroMemory(iOB); + ZeroMemory(iFVG); } } @@ -1099,7 +1147,7 @@ struct X121SMCStrategyXWZWorkingZone // if (isSenario1Happend) { - signalProvider = X121SMC_XWZ_PROVIDER_XHKMA; + signalProvider = X121SMC_XWZ_PROVIDER_XREJECTED_BOX; } } @@ -1661,6 +1709,10 @@ struct X121SMCStrategyXWZWorkingZone ); if (has) { + // + iFVGBoxObj.BoxStyle(STYLE_SOLID); + + // mDrawnObjects.Add(iFVGBoxObj); } diff --git a/X121SMCEA/Strategy/x-121.smc.strategy.class.mq5 b/X121SMCEA/Strategy/x-121.smc.strategy.class.mq5 index b2b9bdeb..1b2c6870 100644 --- a/X121SMCEA/Strategy/x-121.smc.strategy.class.mq5 +++ b/X121SMCEA/Strategy/x-121.smc.strategy.class.mq5 @@ -798,7 +798,7 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy // x121Inputs.xhkInputs.drawRawXHKCandles = showAll || false; - x121Inputs.xhkInputs.drawSmoothedXHKCandles = showAll || false; + x121Inputs.xhkInputs.drawSmoothedXHKCandles = showAll || true; // // XMAS ... @@ -841,9 +841,9 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy // // X3MA ... - x121Inputs.x3maInputs.showX3MaFast = showAll || true; - x121Inputs.x3maInputs.showX3MaMid = showAll || true; - x121Inputs.x3maInputs.showX3MaSlow = showAll || true; + x121Inputs.x3maInputs.showX3MaFast = showAll || false; + x121Inputs.x3maInputs.showX3MaMid = showAll || false; + x121Inputs.x3maInputs.showX3MaSlow = showAll || false; // // Initialize Cycle Helpers ...