diff --git a/Indicators/x-saherelm.x121.xcatb.v1.mq5 b/Indicators/x-saherelm.x121.xcatb.v1.mq5 index 167b8097..0d683c67 100644 --- a/Indicators/x-saherelm.x121.xcatb.v1.mq5 +++ b/Indicators/x-saherelm.x121.xcatb.v1.mq5 @@ -646,12 +646,45 @@ XCBarAnalyser *mBarAnalyser; // // Temparory ... +bool mHas = false; ENUM_X_DIRECTION mDir; bool mHasSignal = false; bool mIsBullish = false; bool mIsBearish = false; +XDirectionShift mDirShift; string mTriggerBarConditions; +// +// Direction Shift ... + +// +XDirectionShift mBullishKIChanges[]; +XDirectionShift mBearishKIChanges[]; + +// +XDirectionShift mBullishSBChanges[]; +XDirectionShift mBearishSBChanges[]; + +// +XDirectionShift mBullishHKSChanges[]; +XDirectionShift mBearishHKSChanges[]; + +// +XDirectionShift mBullishSarChanges[]; +XDirectionShift mBearishSarChanges[]; + +// +XDirectionShift mBullishTrendChanges[]; +XDirectionShift mBearishTrendChanges[]; + +// +// Liquidities ... + +// +bool isLiquidity = false; +bool isBullishLiquidity = false; +bool isBearishLiquidity = false; + // // Trigger Bars Conditions ... @@ -715,6 +748,14 @@ bool isPeakUnderLast = false; bool isValeOverLast = false; bool isValeUnderLast = false; +// +bool isSamePeakOverLast = false; +bool isSamePeakUnderLast = false; + +// +bool isSameValeOverLast = false; +bool isSameValeUnderLast = false; + // bool isSamePeakGolden = false; bool isSamePeakGoldenP = false; @@ -731,6 +772,14 @@ bool isPeakGoldenUnderLast = false; bool isValeGoldenOverLast = false; bool isValeGoldenUnderLast = false; +// +bool isSamePeakGoldenOverLast = false; +bool isSamePeakGoldenUnderLast = false; + +// +bool isSameValeGoldenOverLast = false; +bool isSameValeGoldenUnderLast = false; + // // XSAR ... @@ -753,6 +802,14 @@ bool isBearishSarBreakedLast = false; // // XSB ... +// +double mSBMax = 0; +double mSBMin = 0; + +// +double mSBPMax = 0; +double mSBPMin = 0; + // bool isSBBullish = false; bool isSBBullishP = false; @@ -772,6 +829,14 @@ bool isBearishSBBreakedLast = false; // // XHKS ... +// +double mHKSMax = 0; +double mHKSMin = 0; + +// +double mHKSPMax = 0; +double mHKSPMin = 0; + // bool isHKSBullish = false; bool isHKSBullishP = false; @@ -812,6 +877,25 @@ bool isKISwitchedToBearish = false; bool isBullishKIBreakedLast = false; bool isBearishKIBreakedLast = false; +// +// XTREND ... + +// +bool isTrendBullish = false; +bool isTrendBullishP = false; + +// +bool isTrendBearish = false; +bool isTrendBearishP = false; + +// +bool isTrendSwitchedToBullish = false; +bool isTrendSwitchedToBearish = false; + +// +bool isBullishTrendBreakedLast = false; +bool isBearishTrendBreakedLast = false; + // // Event Handlers ... @@ -3166,6 +3250,25 @@ void PrepareMarketConditions( // // Start Preparing Conditions ... + // + // Liquidities ... + + // + isLiquidity = + mBarAnalyser + .IsRejected( + iBar, + mDir, + true, + true // + ); + isBullishLiquidity = + isLiquidity && + IsBullish(mDir); + isBearishLiquidity = + isLiquidity && + IsBearish(mDir); + // // Trigger Bars Conditions ... @@ -3175,7 +3278,7 @@ void PrepareMarketConditions( mBarAnalyser .IsValidForTrigger( iPBar, - triggerDir, + mDir, true, // Cond 1 ... false, // Cond 2 ... false, // Cond 3 ... @@ -3190,6 +3293,10 @@ void PrepareMarketConditions( isTriggerBarCond1Bearish = isTriggerBarCond1 && IsBearish(mDir); + if (isTriggerBarCond1) + { + mTriggerBarConditions += "1"; + } // // Cond 2 ... @@ -3197,7 +3304,7 @@ void PrepareMarketConditions( mBarAnalyser .IsValidForTrigger( iPBar, - triggerDir, + mDir, false, // Cond 1 ... true, // Cond 2 ... false, // Cond 3 ... @@ -3212,6 +3319,10 @@ void PrepareMarketConditions( isTriggerBarCond2Bearish = isTriggerBarCond2 && IsBearish(mDir); + if (isTriggerBarCond2) + { + mTriggerBarConditions += ",2"; + } // // Cond 3 ... @@ -3219,7 +3330,7 @@ void PrepareMarketConditions( mBarAnalyser .IsValidForTrigger( iPBar, - triggerDir, + mDir, false, // Cond 1 ... false, // Cond 2 ... true, // Cond 3 ... @@ -3234,6 +3345,10 @@ void PrepareMarketConditions( isTriggerBarCond3Bearish = isTriggerBarCond3 && IsBearish(mDir); + if (isTriggerBarCond3) + { + mTriggerBarConditions += ",3"; + } // // Cond 4 ... @@ -3241,7 +3356,7 @@ void PrepareMarketConditions( mBarAnalyser .IsValidForTrigger( iPBar, - triggerDir, + mDir, false, // Cond 1 ... false, // Cond 2 ... false, // Cond 3 ... @@ -3256,6 +3371,10 @@ void PrepareMarketConditions( isTriggerBarCond4Bearish = isTriggerBarCond4 && IsBearish(mDir); + if (isTriggerBarCond4) + { + mTriggerBarConditions += ",4"; + } // // Cond 5 ... @@ -3263,7 +3382,7 @@ void PrepareMarketConditions( mBarAnalyser .IsValidForTrigger( iPBar, - triggerDir, + mDir, false, // Cond 1 ... false, // Cond 2 ... false, // Cond 3 ... @@ -3278,6 +3397,10 @@ void PrepareMarketConditions( isTriggerBarCond5Bearish = isTriggerBarCond5 && IsBearish(mDir); + if (isTriggerBarCond5) + { + mTriggerBarConditions += ",5"; + } // // Cond 6 ... @@ -3285,7 +3408,7 @@ void PrepareMarketConditions( mBarAnalyser .IsValidForTrigger( iPBar, - triggerDir, + mDir, false, // Cond 1 ... false, // Cond 2 ... false, // Cond 3 ... @@ -3300,6 +3423,10 @@ void PrepareMarketConditions( isTriggerBarCond6Bearish = isTriggerBarCond6 && IsBearish(mDir); + if (isTriggerBarCond6) + { + mTriggerBarConditions += ",6"; + } // // Cond 7 ... @@ -3307,7 +3434,7 @@ void PrepareMarketConditions( mBarAnalyser .IsValidForTrigger( iPBar, - triggerDir, + mDir, false, // Cond 1 ... false, // Cond 2 ... false, // Cond 3 ... @@ -3322,6 +3449,10 @@ void PrepareMarketConditions( isTriggerBarCond7Bearish = isTriggerBarCond7 && IsBearish(mDir); + if (isTriggerBarCond7) + { + mTriggerBarConditions += ",7"; + } // // Summarizing Trigger Bar ... @@ -3360,51 +3491,87 @@ void PrepareMarketConditions( // XPV ... // - isSamePeak = false; - isSamePeakP = false; + isSamePeak = peakBuffer[pIndex] == peakBuffer[p2Index]; + isSamePeakP = peakBuffer[p2Index] == peakBuffer[p3Index]; // - isSameVale = false; - isSameValeP = false; + isSameVale = valeBuffer[pIndex] == valeBuffer[p2Index]; + isSameValeP = valeBuffer[p2Index] == valeBuffer[p3Index]; // - isPeakOverLast = false; - isPeakUnderLast = false; + isPeakOverLast = peakBuffer[pIndex] > peakBuffer[p2Index]; + isPeakUnderLast = peakBuffer[pIndex] < peakBuffer[p2Index]; // - isValeOverLast = false; - isValeUnderLast = false; + isValeOverLast = valeBuffer[pIndex] > valeBuffer[p2Index]; + isValeUnderLast = valeBuffer[pIndex] < valeBuffer[p2Index]; // - isSamePeakGolden = false; - isSamePeakGoldenP = false; + isSamePeakOverLast = + isSamePeakP && + isPeakOverLast; + isSamePeakUnderLast = + isSamePeakP && + isPeakUnderLast; // - isSameValeGolden = false; - isSameValeGoldenP = false; + isSameValeOverLast = + isSameValeP && + isValeOverLast; + isSameValeUnderLast = + isSameValeP && + isValeUnderLast; // - isPeakGoldenOverLast = false; - isPeakGoldenUnderLast = false; + isSamePeakGolden = peakGoldenBuffer[pIndex] == peakGoldenBuffer[p2Index]; + isSamePeakGoldenP = peakGoldenBuffer[p2Index] == peakGoldenBuffer[p3Index]; // - isValeGoldenOverLast = false; - isValeGoldenUnderLast = false; + isSameValeGolden = valeGoldenBuffer[pIndex] == valeGoldenBuffer[p2Index]; + isSameValeGoldenP = valeGoldenBuffer[p2Index] == valeGoldenBuffer[p3Index]; + + // + isPeakGoldenOverLast = peakGoldenBuffer[pIndex] > peakGoldenBuffer[p2Index]; + isPeakGoldenUnderLast = peakGoldenBuffer[pIndex] < peakGoldenBuffer[p2Index]; + + // + isValeGoldenOverLast = valeGoldenBuffer[pIndex] > valeGoldenBuffer[p2Index]; + isValeGoldenUnderLast = valeGoldenBuffer[pIndex] < valeGoldenBuffer[p2Index]; + + // + isSamePeakGoldenOverLast = + isSamePeakGoldenP && + isPeakGoldenOverLast; + isSamePeakGoldenUnderLast = + isSamePeakGoldenP && + isPeakGoldenUnderLast; + + // + isSameValeGoldenOverLast = + isSameValeGoldenP && + isValeGoldenOverLast; + isSameValeGoldenUnderLast = + isSameValeGoldenP && + isSameValeGoldenUnderLast; // // XSAR ... // - isSarBullish = false; - isSarBullishP = false; + isSarBullish = sarStateBuffer[pIndex] > 0; + isSarBullishP = sarStateBuffer[p2Index] > 0; // - isSarBearish = false; - isSarBearishP = false; + isSarBearish = sarStateBuffer[pIndex] < 0; + isSarBearishP = sarStateBuffer[p2Index] < 0; // - isSarSwitchedToBullish = false; - isSarSwitchedToBearish = false; + isSarSwitchedToBullish = + isSarBullish && + !isSarBullishP; + isSarSwitchedToBearish = + isSarBearish && + !isSarBearishP; // isBullishSarBreakedLast = false; @@ -3414,70 +3581,516 @@ void PrepareMarketConditions( // XSB ... // - isSBBullish = false; - isSBBullishP = false; + isSBBullish = sBarCloseBuffer[pIndex] > sBarOpenBuffer[pIndex]; + isSBBullishP = sBarCloseBuffer[p2Index] > sBarOpenBuffer[p2Index]; // - isSBBearish = false; - isSBBearishP = false; + isSBBearish = sBarCloseBuffer[pIndex] < sBarOpenBuffer[pIndex]; + isSBBearishP = sBarCloseBuffer[p2Index] < sBarOpenBuffer[p2Index]; // - isSBSwitchedToBullish = false; - isSBSwitchedToBearish = false; + isSBSwitchedToBullish = + isSBBullish && + !isSBBullishP; + isSBSwitchedToBearish = + isSBBearish && + !isSBBearishP; // isBullishSBBreakedLast = false; isBearishSBBreakedLast = false; + // + mSBMin = MathMin(sBarCloseBuffer[pIndex], sBarOpenBuffer[pIndex]); + mSBMax = MathMax(sBarCloseBuffer[pIndex], sBarOpenBuffer[pIndex]); + + // + mSBPMin = MathMin(sBarCloseBuffer[p2Index], sBarOpenBuffer[p2Index]); + mSBPMax = MathMax(sBarCloseBuffer[p2Index], sBarOpenBuffer[p2Index]); + // // XHKS ... // - isHKSBullish = false; - isHKSBullishP = false; + isHKSBullish = hkSBarCloseBuffer[pIndex] > hkSBarOpenBuffer[pIndex]; + isHKSBullishP = hkSBarCloseBuffer[p2Index] > hkSBarOpenBuffer[p2Index]; // - isHKSBearish = false; - isHKSBearishP = false; + isHKSBearish = hkSBarCloseBuffer[pIndex] < hkSBarOpenBuffer[pIndex]; + isHKSBearishP = hkSBarCloseBuffer[p2Index] < hkSBarOpenBuffer[p2Index]; // - isHKSSwitchedToBullish = false; - isHKSSwitchedToBearish = false; + isHKSSwitchedToBullish = + isHKSBullish && + !isHKSBullishP; + isHKSSwitchedToBearish = + isHKSBearish && + !isHKSBearishP; // isBullishHKSBreakedLast = false; isBearishHKSBreakedLast = false; + // + mHKSMin = MathMin(hkSBarCloseBuffer[pIndex], hkSBarOpenBuffer[pIndex]); + mHKSMax = MathMax(hkSBarCloseBuffer[pIndex], hkSBarOpenBuffer[pIndex]); + + // + mHKSPMin = MathMin(hkSBarCloseBuffer[p2Index], hkSBarOpenBuffer[p2Index]); + mHKSPMax = MathMax(hkSBarCloseBuffer[p2Index], hkSBarOpenBuffer[p2Index]); + // // XKI ... // - isKIBullish = false; - isKIBullishP = false; + isKIBullish = kiStateBuffer[pIndex] > 0; + isKIBullishP = kiStateBuffer[p2Index] > 0; // - isKIBearish = false; - isKIBearishP = false; + isKIBearish = kiStateBuffer[pIndex] < 0; + isKIBearishP = kiStateBuffer[p2Index] < 0; // - isKISame = false; - isBullishKISame = false; - isBearishKISame = false; + isKISame = kiBuffer[pIndex] == kiBuffer[p2Index]; + isBullishKISame = + isKISame && + isKIBullish; + isBearishKISame = + isKISame && + isKIBearish; // - isKISwitchedToBullish = false; - isKISwitchedToBearish = false; + isKISwitchedToBullish = + isKIBullish && + !isKIBullishP; + isKISwitchedToBearish = + isKIBearish && + !isKIBearishP; // isBullishKIBreakedLast = false; isBearishKIBreakedLast = false; + // + // XTREND ... + + // + isTrendBullish = trendStateBuffer[pIndex] > 0; + isTrendBullishP = trendStateBuffer[p2Index] > 0; + + // + isTrendBearish = trendStateBuffer[pIndex] < 0; + isTrendBearishP = trendStateBuffer[p2Index] < 0; + + // + isTrendSwitchedToBullish = + isTrendBullish && + !isTrendBullishP; + isTrendSwitchedToBearish = + isTrendBearish && + !isTrendBearishP; + + // + isBullishTrendBreakedLast = false; + isBearishTrendBreakedLast = false; + + // + // Creating Direction Shifts and it's related Conditions ... + + // + // XSB Shifts ... + + // + // Detection ... + if (isSBSwitchedToBullish || + isSBSwitchedToBearish) + { + // + mDirShift.at = iPBar.time; + mDirShift.symbol = _Symbol; + mDirShift.period = _Period; + + // + mDirShift.type = "XSBSHFT"; + + // + mDirShift.after = 0; + mDirShift.before = 0; + + // + if (isSBSwitchedToBullish) + { + // + mDirShift.after = mSBMax; + mDirShift.before = mSBPMax; + mDirShift.shiftTo = X_DIRECTION_BULLISH; + + // + if (mDirShift.IsValid()) + { + // + AddIfNotExists( + mDirShift, + mBullishSBChanges // + ); + } + } + + // + if (isSBSwitchedToBearish) + { + // + mDirShift.after = mSBMin; + mDirShift.before = mSBPMin; + mDirShift.shiftTo = X_DIRECTION_BEARISH; + + // + if (mDirShift.IsValid()) + { + // + AddIfNotExists( + mDirShift, + mBearishSBChanges // + ); + } + } + + // + mDirShift.Clean(); + } + + // + // Parsers ... + + // + mHas = isSBBullish && + HasChild(mBearishSBChanges); + if (mHas) + { + } + + // + mHas = isSBBearish && + HasChild(mBullishSBChanges); + if (mHas) + { + } + + // + // XSAR Shifts ... + + // + // Detection ... + if (isSarSwitchedToBullish || + isSarSwitchedToBearish) + { + // + mDirShift.at = iPBar.time; + mDirShift.symbol = _Symbol; + mDirShift.period = _Period; + + // + mDirShift.type = "XSARSHFT"; + + // + mDirShift.after = sarBuffer[pIndex]; + mDirShift.before = sarBuffer[p2Index]; + + // + if (isSarSwitchedToBullish) + { + // + mDirShift.shiftTo = X_DIRECTION_BULLISH; + + // + if (mDirShift.IsValid()) + { + // + AddIfNotExists( + mDirShift, + mBullishSarChanges // + ); + } + } + + // + if (isSarSwitchedToBearish) + { + // + mDirShift.shiftTo = X_DIRECTION_BEARISH; + + // + if (mDirShift.IsValid()) + { + // + AddIfNotExists( + mDirShift, + mBearishSarChanges // + ); + } + } + + // + mDirShift.Clean(); + } + + // + // Parsers ... + + // + mHas = isSarBullish && + HasChild(mBearishSarChanges); + if (mHas) + { + } + + // + mHas = isSarBearish && + HasChild(mBullishSarChanges); + if (mHas) + { + } + + // + // XHKS Shifts ... + + // + // Detection ... + if (isHKSSwitchedToBullish || + isHKSSwitchedToBearish) + { + // + mDirShift.at = iPBar.time; + mDirShift.symbol = _Symbol; + mDirShift.period = _Period; + + // + mDirShift.type = "XHKSSHFT"; + + // + mDirShift.after = 0; + mDirShift.before = 0; + + // + if (isHKSSwitchedToBullish) + { + // + mDirShift.after = mHKSMax; + mDirShift.before = mHKSPMax; + mDirShift.shiftTo = X_DIRECTION_BULLISH; + + // + if (mDirShift.IsValid()) + { + // + AddIfNotExists( + mDirShift, + mBullishHKSChanges // + ); + } + } + + // + if (isHKSSwitchedToBearish) + { + // + mDirShift.after = mHKSMin; + mDirShift.before = mHKSPMin; + mDirShift.shiftTo = X_DIRECTION_BEARISH; + + // + if (mDirShift.IsValid()) + { + // + AddIfNotExists( + mDirShift, + mBearishHKSChanges // + ); + } + } + + // + mDirShift.Clean(); + } + + // + // Parsers ... + + // + mHas = isHKSBullish && + HasChild(mBearishHKSChanges); + if (mHas) + { + } + + // + mHas = isHKSBearish && + HasChild(mBullishHKSChanges); + if (mHas) + { + } + + // + // XKI Shifts ... + + // + // Detection ... + if (isKISwitchedToBullish || + isKISwitchedToBearish) + { + // + mDirShift.at = iPBar.time; + mDirShift.symbol = _Symbol; + mDirShift.period = _Period; + + // + mDirShift.type = "XKISHFT"; + + // + mDirShift.after = kiBuffer[pIndex]; + mDirShift.before = kiBuffer[p2Index]; + + // + if (isKISwitchedToBullish) + { + // + mDirShift.shiftTo = X_DIRECTION_BULLISH; + + // + if (mDirShift.IsValid()) + { + // + AddIfNotExists( + mDirShift, + mBullishKIChanges // + ); + } + } + + // + if (isKISwitchedToBearish) + { + // + mDirShift.shiftTo = X_DIRECTION_BEARISH; + + // + if (mDirShift.IsValid()) + { + // + AddIfNotExists( + mDirShift, + mBearishKIChanges // + ); + } + } + + // + mDirShift.Clean(); + } + + // + // Parsers ... + + // + mHas = isKIBullish && + HasChild(mBearishKIChanges); + if (mHas) + { + } + + // + mHas = isKIBearish && + HasChild(mBullishKIChanges); + if (mHas) + { + } + + // + // XTREND Shifts ... + + // + // Detection ... + if (isTrendSwitchedToBullish || + isTrendSwitchedToBearish) + { + // + mDirShift.at = iPBar.time; + mDirShift.symbol = _Symbol; + mDirShift.period = _Period; + + // + mDirShift.type = "XTRENDSHFT"; + + // + mDirShift.after = trendBuffer[pIndex]; + mDirShift.before = trendBuffer[p2Index]; + + // + if (isTrendSwitchedToBullish) + { + // + mDirShift.shiftTo = X_DIRECTION_BULLISH; + + // + if (mDirShift.IsValid()) + { + // + AddIfNotExists( + mDirShift, + mBullishTrendChanges // + ); + } + } + + // + if (isTrendSwitchedToBearish) + { + // + mDirShift.shiftTo = X_DIRECTION_BEARISH; + + // + if (mDirShift.IsValid()) + { + // + AddIfNotExists( + mDirShift, + mBearishTrendChanges // + ); + } + } + + // + mDirShift.Clean(); + } + + // + // Parsers ... + + // + mHas = isTrendBullish && + HasChild(mBearishTrendChanges); + if (mHas) + { + } + + // + mHas = isTrendBearish && + HasChild(mBullishTrendChanges); + if (mHas) + { + } + + // + // + // + // // Cleanup Resources ... // iBar.Clean(); iPBar.Clean(); + mDirShift.Clean(); } /** diff --git a/Libraries/x-saherelm.x-poi.extensions.lib.mq5 b/Libraries/x-saherelm.x-poi.extensions.lib.mq5 index d4a5223a..3e398b96 100644 --- a/Libraries/x-saherelm.x-poi.extensions.lib.mq5 +++ b/Libraries/x-saherelm.x-poi.extensions.lib.mq5 @@ -584,10 +584,10 @@ bool IsBoxValid( * * @return ( int ) */ -bool FindBoxIndex( +bool FindIndex( int &index, - XBoxZone &box, - XBoxZone &boxes[] // + XBoxZone &item, + XBoxZone &items[] // ) { // @@ -597,8 +597,8 @@ bool FindBoxIndex( index = -1; // - int count = ArraySize(boxes); - result = box.IsValid() && + int count = ArraySize(items); + result = item.IsValid() && IsValidSize(count); if (!result) { @@ -609,10 +609,53 @@ bool FindBoxIndex( for (int i = 0; i < count; i++) { // - XBoxZone iBox = boxes[i]; + XBoxZone iBox = items[i]; // - bool isSame = box.IsSameAs(iBox); + bool isSame = item.IsSameAs(iBox); + if (isSame) + { + // + index = i; + break; + } + } + + // + result = IsValidIndex(index); + + // + return result; +} +bool FindIndex( + int &index, + XDirectionShift &item, + XDirectionShift &items[] // +) +{ + // + bool result = false; + + // + index = -1; + + // + int count = ArraySize(items); + result = item.IsValid() && + IsValidSize(count); + if (!result) + { + return result; + } + + // + for (int i = 0; i < count; i++) + { + // + XDirectionShift iItem = items[i]; + + // + bool isSame = item.IsSameAs(iItem); if (isSame) { // @@ -631,9 +674,9 @@ bool FindBoxIndex( /** * Remove Specified Box from Collection ... */ -bool RemoveBox( - XBoxZone &box, - XBoxZone &boxes[] // +bool Remove( + XBoxZone &item, + XBoxZone &items[] // ) { // @@ -641,8 +684,8 @@ bool RemoveBox( // result = - box.IsValid() && - HasChild(boxes); + item.IsValid() && + HasChild(items); if (!result) { return result; @@ -650,10 +693,10 @@ bool RemoveBox( // int idx = -1; - result = FindBoxIndex( + result = FindIndex( idx, - box, - boxes // + item, + items // ); if (!result) { @@ -662,7 +705,46 @@ bool RemoveBox( // result = ArrayRemove( - boxes, + items, + idx, + 1 // + ); + + // + return result; +} +bool Remove( + XDirectionShift &item, + XDirectionShift &items[] // +) +{ + // + bool result = false; + + // + result = + item.IsValid() && + HasChild(items); + if (!result) + { + return result; + } + + // + int idx = -1; + result = FindIndex( + idx, + item, + items // + ); + if (!result) + { + return result; + } + + // + result = ArrayRemove( + items, idx, 1 // ); @@ -674,7 +756,7 @@ bool RemoveBox( /** * Remove Specified Box from Collection ... */ -int RemoveBoxes( +int Removes( XBoxZone &items[], XBoxZone &sources[] // ) @@ -696,7 +778,54 @@ int RemoveBoxes( { // int idx = -1; - has = FindBoxIndex( + has = FindIndex( + idx, + items[i], + sources // + ); + if (has) + { + // + has = ArrayRemove( + sources, + idx, + 1 // + ); + + // + if (has) + { + result++; + } + } + } + + // + return result; +} +int Removes( + XDirectionShift &items[], + XDirectionShift &sources[] // +) +{ + // + int result = 0; + + // + bool has = HasChild(items) && + HasChild(sources); + if (!has) + { + return result; + } + + // + int count = ArraySize(items); + for (int i = 0; i < count; i++) + { + // + int idx = -1; + has = FindIndex( idx, items[i], sources // @@ -730,7 +859,7 @@ int RemoveBoxes( * * @return ( bool ) */ -bool AddBoxIfNotExists( +bool AddIfNotExists( XBoxZone &item, XBoxZone &sources[] // ) @@ -749,7 +878,46 @@ bool AddBoxIfNotExists( // // Check Item Exists or not ... int idx = -1; - bool isExists = FindBoxIndex( + bool isExists = FindIndex( + idx, + item, + sources // + ); + result = !isExists; + if (!result) + { + return result; + } + + // + AddRef( + item, + sources //; + ); + + // + return result; +} +bool AddIfNotExists( + XDirectionShift &item, + XDirectionShift &sources[] // +) +{ + // + bool result = false; + + // + // Validate Args ... + result = item.IsValid(); + if (!result) + { + return result; + } + + // + // Check Item Exists or not ... + int idx = -1; + bool isExists = FindIndex( idx, item, sources // @@ -778,7 +946,7 @@ bool AddBoxIfNotExists( * * @return ( int ) */ -int AddBoxIfNotExists( +int AddIfNotExists( XBoxZone &items[], XBoxZone &sources[] // ) @@ -801,7 +969,7 @@ int AddBoxIfNotExists( for (int i = 0; i < count; i++) { // - has = AddBoxIfNotExists( + has = AddIfNotExists( items[i], sources // ); @@ -816,6 +984,48 @@ int AddBoxIfNotExists( // return result; } +int AddIfNotExists( + XDirectionShift &items[], + XDirectionShift &sources[] // +) +{ + // + int result = 0; + + // + bool has = HasChild(items); + if (!has) + { + return result; + } + + // + int before = ArraySize(sources); + + // + int count = ArraySize(items); + for (int i = 0; i < count; i++) + { + // + has = AddIfNotExists( + items[i], + sources // + ); + } + + // + int after = ArraySize(sources); + + // + result = after > before; + + // + return result; +} + +// +// +// // void SortBoxes( diff --git a/Libraries/x-saherelm.x-poi.lib.mq5 b/Libraries/x-saherelm.x-poi.lib.mq5 index c655d3ae..3872ce9e 100644 --- a/Libraries/x-saherelm.x-poi.lib.mq5 +++ b/Libraries/x-saherelm.x-poi.lib.mq5 @@ -310,7 +310,7 @@ struct XBoxZone /** * Retrieve Box Applied Price ... - * + * * @return ( double ) */ double GetDirectionalPrice() @@ -336,7 +336,7 @@ struct XBoxZone /** * Retrieve Box Breaked Price ... - * + * * @return ( double ) */ double GetInDirectionalPrice() @@ -722,4 +722,4 @@ struct XDirectionShift } }; -// +// \ No newline at end of file diff --git a/XCATBEA/Classes/xcatbea.signaller.class.mq5 b/XCATBEA/Classes/xcatbea.signaller.class.mq5 index 5da4003a..68fc240f 100644 --- a/XCATBEA/Classes/xcatbea.signaller.class.mq5 +++ b/XCATBEA/Classes/xcatbea.signaller.class.mq5 @@ -2064,7 +2064,7 @@ class XCXCATBEASignaller : XCBase // // Check Box Added Before or not ... int idx = -1; - has = FindBoxIndex( + has = FindIndex( idx, box, unavailableZones // diff --git a/XCATBEA/Classes/xcatbea.x-poi.detector.class.mq5 b/XCATBEA/Classes/xcatbea.x-poi.detector.class.mq5 index d789c4b2..c514ffe2 100644 --- a/XCATBEA/Classes/xcatbea.x-poi.detector.class.mq5 +++ b/XCATBEA/Classes/xcatbea.x-poi.detector.class.mq5 @@ -2222,7 +2222,7 @@ class XCXCATBEAPOIDetector : public XCBase // int idx = -1; - bool isExists = FindBoxIndex( + bool isExists = FindIndex( idx, box, boxes // @@ -2281,7 +2281,7 @@ class XCXCATBEAPOIDetector : public XCBase { // int idx = -1; - bool isUnAvailable = FindBoxIndex( + bool isUnAvailable = FindIndex( idx, box, unavailables // @@ -2420,7 +2420,7 @@ class XCXCATBEAPOIDetector : public XCBase { // int idx = -1; - bool isExists = FindBoxIndex( + bool isExists = FindIndex( idx, box, invalidPivots // @@ -2639,7 +2639,7 @@ class XCXCATBEAPOIDetector : public XCBase { // int idx = -1; - bool isExists = FindBoxIndex( + bool isExists = FindIndex( idx, iBox, invalidPivots //