diff --git a/Documents/BKP/x-saherelm.x-poi.extensions.lib.mq5 b/Documents/BKP/x-saherelm.x-poi.extensions.lib.mq5 index 7f984fa4..abde4f03 100644 --- a/Documents/BKP/x-saherelm.x-poi.extensions.lib.mq5 +++ b/Documents/BKP/x-saherelm.x-poi.extensions.lib.mq5 @@ -1361,6 +1361,9 @@ bool IsBoxValid( // bool result = false; + // + return true; + // result = box.IsValid(); if (!result) diff --git a/Indicators/x-saherelm.x121.xcatb.v1.mq5 b/Indicators/x-saherelm.x121.xcatb.v1.mq5 index 61aebf42..8874da18 100644 --- a/Indicators/x-saherelm.x121.xcatb.v1.mq5 +++ b/Indicators/x-saherelm.x121.xcatb.v1.mq5 @@ -3016,7 +3016,7 @@ void DoProcess( // bool isTriggerBar = // - triggerBarPushers > 1 && + triggerBarPushers >= 1 && (isBullishTriggerBar || isBearishTriggerBar) // @@ -3029,6 +3029,9 @@ void DoProcess( // // Reading Required Info ... + // + // HK Signal Bar ... + // double iHKSOpen = hkSBarOpenBuffer[barIndex]; double iHKSClose = hkSBarCloseBuffer[barIndex]; @@ -3039,13 +3042,24 @@ void DoProcess( // bool isHKSBullish = hkSBarOpenBuffer[barIndex] < hkSBarCloseBuffer[barIndex]; + bool isPHKSBullish = hkSBarOpenBuffer[barIndex + 1] < hkSBarCloseBuffer[barIndex + 1]; + + // bool isHKSBearish = hkSBarOpenBuffer[barIndex] > hkSBarCloseBuffer[barIndex]; + bool isPHKSBearish = hkSBarOpenBuffer[barIndex + 1] > hkSBarCloseBuffer[barIndex + 1]; + + // bool isHKSSwitchedToBullish = - hkSBarOpenBuffer[barIndex] < hkSBarCloseBuffer[barIndex] && - hkSBarOpenBuffer[barIndex] >= hkSBarCloseBuffer[barIndex]; + isHKSBullish && + !isPHKSBullish; + + // bool isHKSSwitchedToBearish = - hkSBarOpenBuffer[barIndex] > hkSBarCloseBuffer[barIndex] && - hkSBarOpenBuffer[barIndex] <= hkSBarCloseBuffer[barIndex]; + isHKSBearish && + !isPHKSBearish; + + // + // TREND ... // double iTrend = trendBuffer[barIndex]; @@ -3058,6 +3072,94 @@ void DoProcess( trendStateBuffer[barIndex] < 0 && trendStateBuffer[barIndex + 1] >= 0; + // + // RSI ... + + // + bool isRSIOverOB = rsiBuffer[barIndex] > rsiOBLevel; + bool isPRSIOverOB = rsiBuffer[barIndex + 1] > rsiOBLevel; + + // + bool isRSIUnderOB = rsiBuffer[barIndex] < rsiOBLevel; + bool isPRSIUnderOB = rsiBuffer[barIndex + 1] < rsiOBLevel; + + // + bool isRSICrossedOverOB = + isRSIOverOB && + !isPRSIOverOB; + + // + bool isRSICrossedUnderOB = + isRSIUnderOB && + !isPRSIUnderOB; + + // + bool isRSIOverOS = rsiBuffer[barIndex] > rsiOSLevel; + bool isPRSIOverOS = rsiBuffer[barIndex + 1] > rsiOSLevel; + + // + bool isRSIUnderOS = rsiBuffer[barIndex] < rsiOSLevel; + bool isPRSIUnderOS = rsiBuffer[barIndex + 1] < rsiOSLevel; + + // + bool isRSICrossedOverOS = + isRSIOverOS && + !isPRSIOverOS; + + // + bool isRSICrossedUnderOS = + isRSIUnderOS && + !isPRSIUnderOS; + + // + // ADX ... + + // + bool isADXOverThreshold = adxBuffer[barIndex] > adxThreshold; + bool isPADXOverThreshold = adxBuffer[barIndex + 1] > adxThreshold; + + // + bool isADXUnderThreshold = adxBuffer[barIndex] < adxThreshold; + bool isPADXUnderThreshold = adxBuffer[barIndex + 1] < adxThreshold; + + // + bool isADXCrossedOverThreshold = + isADXOverThreshold && + !isPADXOverThreshold; + + // + bool isADXCrossedUnderThreshold = + isADXUnderThreshold && + !isPADXUnderThreshold; + + // + bool isADXBullish = adxpBuffer[barIndex] > adxnBuffer[barIndex]; + bool isPADXBullish = adxpBuffer[barIndex + 1] > adxnBuffer[barIndex + 1]; + + // + bool isADXBearish = adxpBuffer[barIndex] < adxnBuffer[barIndex]; + bool isPADXBearish = adxpBuffer[barIndex + 1] < adxnBuffer[barIndex + 1]; + + // + bool isADXSwitchedToBullish = + isADXBullish && + !isPADXBullish; + + // + bool isADXSwitchedToBearish = + isADXBearish && + !isPADXBearish; + + // + bool isADXFullySwitchedToBullish = + isADXSwitchedToBullish && + isADXCrossedOverThreshold; + + // + bool isADXFullySwitchedToBearish = + isADXSwitchedToBearish && + isADXCrossedUnderThreshold; + // bool isTriggerBarOverHKS = iBar.low > iHKSMax; @@ -3076,8 +3178,12 @@ void DoProcess( // ( // - isHKSBullish && - isTrendBullish + // isHKSBullish && + // isTrendBullish + // + // isRSICrossedOverOS + // + isHKSSwitchedToBullish // ) // @@ -3091,14 +3197,19 @@ void DoProcess( // ( // - isHKSBearish && - isTrendBearish + // isHKSBearish && + // isTrendBearish + // + // isRSICrossedUnderOB + // + isHKSSwitchedToBearish // ) // ; // + // Summarizing Result ... isTriggerBar = // isBullishTriggerBar || @@ -3410,8 +3521,8 @@ void ValidatePOIs( { // int count = 0; - XBoxZone tmp[]; bool has = false; + int barsLength = 3; datetime to = GetBarTime( _Symbol, _Period, @@ -3422,90 +3533,31 @@ void ValidatePOIs( // Liquidities ... // + // Bullish Liquidities ... count = ArraySize(mBullishLiquidities); has = IsValidSize(count); if (has) { // - Clean(tmp); - for (int i = 0; i < count; i++) - { - // - has = IsBoxValid( - mBullishLiquidities[i], - barIndex // - ); - if (!has) - { - // - AddRef( - mBullishLiquidities[i], - tmp // - ); - } - } - - // - has = HasChild(tmp); - if (has) - { - // - RemoveBoxes( - tmp, - mBullishLiquidities // - ); - - // - SortBoxes(mBullishLiquidities); - } - - // - Clean(tmp); + ValidateBoxes( + mBullishLiquidities, + barIndex, + barsLength // + ); } // + // Bearish Liquidities ... count = ArraySize(mBearishLiquidities); has = IsValidSize(count); if (has) { // - Clean(tmp); - for (int i = 0; i < count; i++) - { - // - mBearishLiquidities[i].to = to; - - // - has = IsBoxValid( - mBearishLiquidities[i], - barIndex // - ); - if (!has) - { - // - AddRef( - mBearishLiquidities[i], - tmp // - ); - } - } - - // - has = HasChild(tmp); - if (has) - { - // - RemoveBoxes( - tmp, - mBearishLiquidities // - ); - - // - SortBoxes(mBearishLiquidities); - } - - // - Clean(tmp); + ValidateBoxes( + mBearishLiquidities, + barIndex, + barsLength // + ); } } diff --git a/Libraries/x-saherelm.x-poi.extensions.lib.mq5 b/Libraries/x-saherelm.x-poi.extensions.lib.mq5 index 22dc931c..d4a5223a 100644 --- a/Libraries/x-saherelm.x-poi.extensions.lib.mq5 +++ b/Libraries/x-saherelm.x-poi.extensions.lib.mq5 @@ -524,6 +524,7 @@ bool IsBoxValid( for (int i = barIndex; i <= toIDX; i++) { // + // Initialize Indexed Bar ... result = iBar.Init( box.symbol, box.period, @@ -531,11 +532,16 @@ bool IsBoxValid( ); // + // Checking Price ... result = + // + // Checking Bar Validation ... result && + // + // Checking Price Breaked or not ... (isBullish - ? iBar.close < appliedPrice - : iBar.close > appliedPrice); + ? iBar.close < box.lower + : iBar.close > box.upper); if (result) { edgeBreakes++; @@ -556,12 +562,15 @@ bool IsBoxValid( iBar.Clean(); } + // + iBar.Clean(); + // // return true; // result = - edgeBreakes >= barsLength; + edgeBreakes < barsLength; // return result; @@ -907,4 +916,88 @@ bool IsBoxPlaceValidForBar( return result; } +// +void ValidateBoxes( + XBoxZone &boxes[], + int barIndex = 0, + int barsLength = 3, + bool forceSorting = false // +) +{ + // + bool has = false; + + // + // Normalize Args ... + barIndex = NormalizeInt(barIndex, 0); + barsLength = NormalizeInt(barsLength, 3); + + // + // Validate Args ... + has = HasChild(boxes); + if (!has) + { + return; + } + + // + // Copy Boxes to tmp ... + XBoxZone tmp[]; + Copy( + boxes, + tmp // + ); + Clean(boxes); + + // + // Looping Through Exists Boxes ... + while (HasChild(tmp)) + { + // + // Select Indexed Box ... + XBoxZone iBox = tmp[0]; + + // + // Remove Indexed Box ... + ArrayRemove( + tmp, + 0, + 1 // + ); + + // + // Check Box Validating ... + has = IsBoxValid( + iBox, + barIndex, + barsLength // + ); + if (has) + { + // + AddRef( + iBox, + boxes // + ); + } + } + + // + // Sorting ... + if (forceSorting) + { + // + // Check Has Result or not ... + has = HasChild(boxes); + if (has) + { + // + // Sorting ... + SortBoxes(boxes); + } + } + + // +} + // \ No newline at end of file