From 04535223ea66f4913b888b9dc58e58354750955a Mon Sep 17 00:00:00 2001 From: Hadi Khazaee Asl Date: Thu, 17 Apr 2025 21:22:14 +0330 Subject: [PATCH] last ... --- Experts/x-saherelm.xcaea.ea.mq5 | 2 +- Helpers/x-saherelm.x121.xca.helper.mq5 | 6 +- Indicators/x-saherelm.x121.xca.mq5 | 12 +- Libraries/x-saherelm.x-poi.lib.mq5 | 9 +- XCAEA/Classes/xcaea.x-poi.detector.class.mq5 | 968 +++++++++++++++---- XCAEA/Libraries/xcaea.signaller.lib.mq5 | 16 +- XCAEA/Signals/xcaea.signaller.class.mq5 | 578 +++++++---- 7 files changed, 1210 insertions(+), 381 deletions(-) diff --git a/Experts/x-saherelm.xcaea.ea.mq5 b/Experts/x-saherelm.xcaea.ea.mq5 index bd643f44..d83c3749 100644 --- a/Experts/x-saherelm.xcaea.ea.mq5 +++ b/Experts/x-saherelm.xcaea.ea.mq5 @@ -346,7 +346,7 @@ void OnTick() // Execute Signal ... // - has =eaTradeManager.Execute( + has = eaTradeManager.Execute( eaSignal, eaConditions // ); diff --git a/Helpers/x-saherelm.x121.xca.helper.mq5 b/Helpers/x-saherelm.x121.xca.helper.mq5 index b33d5114..e5561919 100644 --- a/Helpers/x-saherelm.x121.xca.helper.mq5 +++ b/Helpers/x-saherelm.x121.xca.helper.mq5 @@ -51,13 +51,13 @@ enum ENUM_X121_XCA_BUFFERS X121_XCA_FIBO_L3_LINE = 16, X121_XCA_SAR_LINE = 17, X121_XCA_TREND_LINE = 18, - X121_XCA_TREND_STATE_LINE = 24, X121_XCA_KI_LINE = 20, - X121_XCA_KI_STATE_LINE = 25, X121_XCA_SWING_LOW_LINE = 22, X121_XCA_SWING_HIGH_LINE = 23, X121_XCA_TKI_LINE = 24, - X121_XCA_TKI_STATE_LINE = 30, + X121_XCA_TREND_STATE_LINE = 26, + X121_XCA_KI_STATE_LINE = 27, + X121_XCA_TKI_STATE_LINE = 28, }; // diff --git a/Indicators/x-saherelm.x121.xca.mq5 b/Indicators/x-saherelm.x121.xca.mq5 index e068635f..5b1b1e16 100644 --- a/Indicators/x-saherelm.x121.xca.mq5 +++ b/Indicators/x-saherelm.x121.xca.mq5 @@ -479,17 +479,17 @@ double trendStateBuffer[]; double kiStateBuffer[]; // -#define supBufferIndex mLastBufferIndex + 3 +#define tkiStateBufferIndex mLastBufferIndex + 3 +double tkiStateBuffer[]; + +// +#define supBufferIndex mLastBufferIndex + 4 double supBuffer[]; // -#define resBufferIndex mLastBufferIndex + 4 +#define resBufferIndex mLastBufferIndex + 5 double resBuffer[]; -// -#define tkiStateBufferIndex mLastBufferIndex + 5 -double tkiStateBuffer[]; - // // Variables, Properties and etc ... diff --git a/Libraries/x-saherelm.x-poi.lib.mq5 b/Libraries/x-saherelm.x-poi.lib.mq5 index 35c08fd5..a906e266 100644 --- a/Libraries/x-saherelm.x-poi.lib.mq5 +++ b/Libraries/x-saherelm.x-poi.lib.mq5 @@ -5458,6 +5458,11 @@ struct XBoxZone */ string GetTag() { + // + int digits = GetDigits(symbol); + double nUpper = NormalizeDouble(NormalizePrice(upper, symbol), digits); + double nLower = NormalizeDouble(NormalizePrice(lower, symbol), digits); + // string typeStr = IsValid(type) ? type + "_" @@ -5468,8 +5473,8 @@ struct XBoxZone ToString(dir) + "_" + symbol + "_" + ToString(period) + "_" + - ToString(upper) + "_" + - ToString(lower) + ToString(nUpper) + "_" + + ToString(nLower) // ; diff --git a/XCAEA/Classes/xcaea.x-poi.detector.class.mq5 b/XCAEA/Classes/xcaea.x-poi.detector.class.mq5 index 8582d08a..3aa81855 100644 --- a/XCAEA/Classes/xcaea.x-poi.detector.class.mq5 +++ b/XCAEA/Classes/xcaea.x-poi.detector.class.mq5 @@ -36,8 +36,14 @@ enum ENUM_XCA_PIVOTS XCA_SWH, // SWH XCA_VALE, // VALE XCA_PEAK, // PEAK + XCA_KI_BULL, // KIBull + XCA_KI_BEAR, // KIBear + XCA_TKI_BULL, // TKIBull + XCA_TKI_BEAR, // TKIBear XCA_PEAKSWHRES, // PeakSWHRes XCA_VALESWLSUP, // ValeSWLSup + XCA_TREND_BULL, // Trend Bullish + XCA_TREND_BEAR, // Trend Bearish }; // @@ -79,6 +85,9 @@ struct XCAPivot ENUM_XCA_PIVOTS type; ENUM_TIMEFRAMES period; + // + double values[]; + // // Constructor ... XCAPivot() @@ -102,6 +111,9 @@ struct XCAPivot symbol = NULL; period = NULL; type = XCA_NONE; + + // + Clean(values); } /** @@ -304,13 +316,19 @@ struct XCAPivot // case XCA_SWL: case XCA_VALE: + case XCA_KI_BULL: + case XCA_TKI_BULL: + case XCA_TREND_BULL: case XCA_VALESWLSUP: iDir = X_DIRECTION_BULLISH; break; - // + // case XCA_SWH: case XCA_PEAK: + case XCA_KI_BEAR: + case XCA_TKI_BEAR: + case XCA_TREND_BEAR: case XCA_PEAKSWHRES: iDir = X_DIRECTION_BEARISH; break; @@ -347,7 +365,28 @@ struct XCAPivot box.from = from; box.symbol = symbol; box.period = period; - box.type = ToString(type); + + // + string typeStr = ToString(type); + if (type == XCA_KI_BULL || + type == XCA_KI_BEAR) + { + // + typeStr = "XCA_KI"; + } + else if (type == XCA_TKI_BULL || + type == XCA_TKI_BEAR) + { + // + typeStr = "XCA_TKI"; + } + else if (type == XCA_TREND_BULL || + type == XCA_TREND_BEAR) + { + // + typeStr = "XCA_TREND"; + } + box.type = typeStr; // box.upper = @@ -438,8 +477,14 @@ class XCXCAEAPOIDetector : public XCBase XCAPivot swlPivots[]; XCAPivot peakPivots[]; XCAPivot valePivots[]; + XCAPivot kiBullishPivots[]; + XCAPivot kiBearishPivots[]; + XCAPivot tkiBullishPivots[]; + XCAPivot tkiBearishPivots[]; XCAPivot peakSWHResPivots[]; XCAPivot valeSWLSupPivots[]; + XCAPivot trendBullishPivots[]; + XCAPivot trendBearishPivots[]; // // Constructors ... @@ -491,6 +536,7 @@ class XCXCAEAPOIDetector : public XCBase virtual void Default() { // + maxAllowedPivots = 50; pivotVerifications = 5; } @@ -571,314 +617,720 @@ class XCXCAEAPOIDetector : public XCBase // Checking Pivots ... // - // Peak Pivot ... + bool detectSWHPivot = false; + bool detectSWLPivot = false; + bool detectPeakPivot = false; + bool detectValePivot = false; + bool detectKIBullishPivot = false; + bool detectKIBearishPivot = false; + bool detectTKIBullishPivot = false; + bool detectTKIBearishPivot = false; + bool detectPeakSWHResPivot = false; + bool detectValeSWLSupPivot = false; + bool detectTrendBullishPivot = true; + bool detectTrendBearishPivot = true; // - if (!peakPivot.IsValid()) + // Peak Pivot ... + if (detectPeakPivot) { // - peakPivot.type = XCA_PEAK; - peakPivot.symbol = iConditions.symbol; - peakPivot.period = iConditions.period; + if (!peakPivot.IsValid()) + { + // + peakPivot.type = XCA_PEAK; + peakPivot.symbol = iConditions.symbol; + peakPivot.period = iConditions.period; + + // + if (iConditions.isPeakSameLast) + { + // + peakPivot.to = cBar.time; + peakPivot.from = pBar.time; + peakPivot.value = iConditions.peakBuffer[cIDX]; + } + } // if (iConditions.isPeakSameLast) { // - peakPivot.to = cBar.time; peakPivot.from = pBar.time; - peakPivot.value = iConditions.peakBuffer[cIDX]; + peakPivot.reserve = + peakPivot.reserve == 0 + ? iConditions.peakGoldenBuffer[cIDX] + : MathMax(peakPivot.reserve, iConditions.peakGoldenBuffer[cIDX]); } - } - // - if (iConditions.isPeakSameLast) - { // - peakPivot.from = pBar.time; - peakPivot.reserve = - peakPivot.reserve == 0 - ? iConditions.peakGoldenBuffer[cIDX] - : MathMax(peakPivot.reserve, iConditions.peakGoldenBuffer[cIDX]); - } - - // - if (!iConditions.isPeakSameLast) - { - // - has = - peakPivot.IsValid() && - peakPivot.GetAge() >= pivotVerifications; - if (has) + if (!iConditions.isPeakSameLast) { // - AddPivot( - peakPivot, - peakPivots // - ); - } + has = + peakPivot.IsValid() && + peakPivot.GetAge() >= pivotVerifications; + if (has) + { + // + AddPivot( + peakPivot, + peakPivots // + ); + } - // - peakPivot.Clean(); + // + peakPivot.Clean(); + } } // // Peak SWH Res Pivot ... - - // - if (!peakSWHResPivot.IsValid()) + if (detectPeakSWHResPivot) { // - peakSWHResPivot.type = XCA_PEAKSWHRES; - peakSWHResPivot.symbol = iConditions.symbol; - peakSWHResPivot.period = iConditions.period; + if (!peakSWHResPivot.IsValid()) + { + // + peakSWHResPivot.type = XCA_PEAKSWHRES; + peakSWHResPivot.symbol = iConditions.symbol; + peakSWHResPivot.period = iConditions.period; + + // + if (iConditions.isPeakIsPivot && iConditions.isPeakSameLast) + { + // + peakSWHResPivot.to = cBar.time; + peakSWHResPivot.from = pBar.time; + peakSWHResPivot.value = iConditions.peakBuffer[cIDX]; + } + } // if (iConditions.isPeakIsPivot && iConditions.isPeakSameLast) { // - peakSWHResPivot.to = cBar.time; peakSWHResPivot.from = pBar.time; - peakSWHResPivot.value = iConditions.peakBuffer[cIDX]; + peakSWHResPivot.reserve = + peakSWHResPivot.reserve == 0 + ? iConditions.peakGoldenBuffer[cIDX] + : MathMax(peakSWHResPivot.reserve, iConditions.peakGoldenBuffer[cIDX]); } - } - // - if (iConditions.isPeakIsPivot && iConditions.isPeakSameLast) - { // - peakSWHResPivot.from = pBar.time; - peakSWHResPivot.reserve = - peakSWHResPivot.reserve == 0 - ? iConditions.peakGoldenBuffer[cIDX] - : MathMax(peakSWHResPivot.reserve, iConditions.peakGoldenBuffer[cIDX]); - } - - // - if (!(iConditions.isPeakIsPivot && iConditions.isPeakSameLast)) - { - // - has = peakSWHResPivot.IsValid() && - peakSWHResPivot.GetAge() >= pivotVerifications; - if (has) + if (!(iConditions.isPeakIsPivot && iConditions.isPeakSameLast)) { // - AddPivot( - peakSWHResPivot, - peakSWHResPivots // - ); - } + has = peakSWHResPivot.IsValid() && + peakSWHResPivot.GetAge() >= pivotVerifications; + if (has) + { + // + AddPivot( + peakSWHResPivot, + peakSWHResPivots // + ); + } - // - peakSWHResPivot.Clean(); + // + peakSWHResPivot.Clean(); + } } // // Vale Pivot ... - - // - if (!valePivot.IsValid()) + if (detectValePivot) { // - valePivot.type = XCA_VALE; - valePivot.symbol = iConditions.symbol; - valePivot.period = iConditions.period; + if (!valePivot.IsValid()) + { + // + valePivot.type = XCA_VALE; + valePivot.symbol = iConditions.symbol; + valePivot.period = iConditions.period; + + // + if (iConditions.isValeSameLast) + { + // + valePivot.to = cBar.time; + valePivot.from = pBar.time; + valePivot.value = iConditions.valeBuffer[cIDX]; + } + } // if (iConditions.isValeSameLast) { // - valePivot.to = cBar.time; valePivot.from = pBar.time; - valePivot.value = iConditions.valeBuffer[cIDX]; + valePivot.reserve = + valePivot.reserve == 0 + ? iConditions.valeGoldenBuffer[cIDX] + : MathMin(valePivot.reserve, iConditions.valeGoldenBuffer[cIDX]); } - } - // - if (iConditions.isValeSameLast) - { // - valePivot.from = pBar.time; - valePivot.reserve = - valePivot.reserve == 0 - ? iConditions.valeGoldenBuffer[cIDX] - : MathMin(valePivot.reserve, iConditions.valeGoldenBuffer[cIDX]); - } - - // - if (!iConditions.isValeSameLast) - { - // - has = valePivot.IsValid() && - valePivot.GetAge() >= pivotVerifications; - if (has) + if (!iConditions.isValeSameLast) { // - AddPivot( - valePivot, - valePivots // - ); - } + has = valePivot.IsValid() && + valePivot.GetAge() >= pivotVerifications; + if (has) + { + // + AddPivot( + valePivot, + valePivots // + ); + } - // - valePivot.Clean(); + // + valePivot.Clean(); + } } // // Vale SWL Sup Pivot ... - - // - if (!valeSWLSupPivot.IsValid()) + if (detectValeSWLSupPivot) { // - valeSWLSupPivot.type = XCA_VALESWLSUP; - valeSWLSupPivot.symbol = iConditions.symbol; - valeSWLSupPivot.period = iConditions.period; + if (!valeSWLSupPivot.IsValid()) + { + // + valeSWLSupPivot.type = XCA_VALESWLSUP; + valeSWLSupPivot.symbol = iConditions.symbol; + valeSWLSupPivot.period = iConditions.period; + + // + if (iConditions.isValeIsPivot && iConditions.isValeSameLast) + { + // + valeSWLSupPivot.to = cBar.time; + valeSWLSupPivot.from = pBar.time; + valeSWLSupPivot.value = iConditions.valeBuffer[cIDX]; + } + } // if (iConditions.isValeIsPivot && iConditions.isValeSameLast) { // - valeSWLSupPivot.to = cBar.time; valeSWLSupPivot.from = pBar.time; - valeSWLSupPivot.value = iConditions.valeBuffer[cIDX]; + valeSWLSupPivot.reserve = + valeSWLSupPivot.reserve == 0 + ? iConditions.valeGoldenBuffer[cIDX] + : MathMin(valeSWLSupPivot.reserve, iConditions.valeGoldenBuffer[cIDX]); } - } - // - if (iConditions.isValeIsPivot && iConditions.isValeSameLast) - { // - valeSWLSupPivot.from = pBar.time; - valeSWLSupPivot.reserve = - valeSWLSupPivot.reserve == 0 - ? iConditions.valeGoldenBuffer[cIDX] - : MathMin(valeSWLSupPivot.reserve, iConditions.valeGoldenBuffer[cIDX]); - } - - // - if (!(iConditions.isValeIsPivot && iConditions.isValeSameLast)) - { - // - has = valeSWLSupPivot.IsValid() && - valeSWLSupPivot.GetAge() >= pivotVerifications; - if (has) + if (!(iConditions.isValeIsPivot && iConditions.isValeSameLast)) { // - AddPivot( - valeSWLSupPivot, - valeSWLSupPivots // - ); - } + has = valeSWLSupPivot.IsValid() && + valeSWLSupPivot.GetAge() >= pivotVerifications; + if (has) + { + // + AddPivot( + valeSWLSupPivot, + valeSWLSupPivots // + ); + } - // - valeSWLSupPivot.Clean(); + // + valeSWLSupPivot.Clean(); + } } // // SWH Pivot ... - - // - if (!swhPivot.IsValid()) + if (detectSWHPivot) { // - swhPivot.type = XCA_SWH; - swhPivot.symbol = iConditions.symbol; - swhPivot.period = iConditions.period; + if (!swhPivot.IsValid()) + { + // + swhPivot.type = XCA_SWH; + swhPivot.symbol = iConditions.symbol; + swhPivot.period = iConditions.period; + + // + if (iConditions.isSwingHighSameLast) + { + // + swhPivot.to = cBar.time; + swhPivot.from = pBar.time; + swhPivot.value = iConditions.swingHighBuffer[cIDX]; + } + } // if (iConditions.isSwingHighSameLast) { - // - swhPivot.to = cBar.time; swhPivot.from = pBar.time; - swhPivot.value = iConditions.swingHighBuffer[cIDX]; } - } - // - if (iConditions.isSwingHighSameLast) - { // - swhPivot.from = pBar.time; - } - - // - if (!iConditions.isSwingHighSameLast) - { - // - has = - swhPivot.IsValid() && - cBar.high > cBar.GetUp() && - cBar.high == swhPivot.value && - swhPivot.GetAge() >= pivotVerifications; - if (has) + if (!iConditions.isSwingHighSameLast) { // - swhPivot.reserve = cBar.GetUp(); + has = + swhPivot.IsValid() && + cBar.high > cBar.GetUp() && + cBar.high == swhPivot.value && + swhPivot.GetAge() >= pivotVerifications; + if (has) + { + // + swhPivot.reserve = cBar.GetUp(); + + // + AddPivot( + swhPivot, + swhPivots // + ); + } // - AddPivot( - swhPivot, - swhPivots // - ); + swhPivot.Clean(); } - - // - swhPivot.Clean(); } // // SWL Pivot ... - - // - if (!swlPivot.IsValid()) + if (detectSWLPivot) { // - swlPivot.type = XCA_SWL; - swlPivot.symbol = iConditions.symbol; - swlPivot.period = iConditions.period; + if (!swlPivot.IsValid()) + { + // + swlPivot.type = XCA_SWL; + swlPivot.symbol = iConditions.symbol; + swlPivot.period = iConditions.period; + + // + if (iConditions.isSwingLowSameLast) + { + // + swlPivot.to = cBar.time; + swlPivot.from = pBar.time; + swlPivot.value = iConditions.swingLowBuffer[cIDX]; + } + } // if (iConditions.isSwingLowSameLast) { - // - swlPivot.to = cBar.time; swlPivot.from = pBar.time; - swlPivot.value = iConditions.swingLowBuffer[cIDX]; } - } - // - if (iConditions.isSwingLowSameLast) - { // - swlPivot.from = pBar.time; - } - - // - if (!iConditions.isSwingLowSameLast) - { - // - has = - swlPivot.IsValid() && - cBar.low < cBar.GetDown() && - cBar.low == swlPivot.value && - swlPivot.GetAge() >= pivotVerifications; - if (has) + if (!iConditions.isSwingLowSameLast) { // - swlPivot.reserve = cBar.GetDown(); + has = + swlPivot.IsValid() && + cBar.low < cBar.GetDown() && + cBar.low == swlPivot.value && + swlPivot.GetAge() >= pivotVerifications; + if (has) + { + // + swlPivot.reserve = cBar.GetDown(); + + // + AddPivot( + swlPivot, + swlPivots // + ); + } // - AddPivot( - swlPivot, - swlPivots // - ); + swlPivot.Clean(); + } + } + + // + // KI Bullish ... + if (detectKIBullishPivot) + { + // + if (!kiBullishPivot.IsValid()) + { + // + kiBullishPivot.type = XCA_KI_BULL; + kiBullishPivot.symbol = iConditions.symbol; + kiBullishPivot.period = iConditions.period; + + // + if (iConditions.isKIBullish) + { + // + kiBullishPivot.to = cBar.time; + kiBullishPivot.from = pBar.time; + kiBullishPivot.value = iConditions.kiBuffer[cIDX]; + } } // - swlPivot.Clean(); + if (iConditions.isKIBullish) + { + // + kiBullishPivot.from = pBar.time; + kiBullishPivot.value = + kiBullishPivot.value == 0 + ? iConditions.kiBuffer[cIDX] + : MathMin(iConditions.kiBuffer[cIDX], kiBullishPivot.value); + kiBullishPivot.reserve = + kiBullishPivot.reserve == 0 + ? iConditions.kiBuffer[cIDX] + : MathMax(iConditions.kiBuffer[cIDX], kiBullishPivot.reserve); + } + + // + if (iConditions.isKISwitchedToBullish) + { + // + has = + kiBullishPivot.IsValid() && + kiBullishPivot.GetAge() >= pivotVerifications; + if (has) + { + // + AddPivot( + kiBullishPivot, + kiBullishPivots // + ); + } + + // + kiBullishPivot.Clean(); + } + } + + // + // KI Bearish ... + if (detectKIBearishPivot) + { + // + if (!kiBearishPivot.IsValid()) + { + // + kiBearishPivot.type = XCA_KI_BEAR; + kiBearishPivot.symbol = iConditions.symbol; + kiBearishPivot.period = iConditions.period; + + // + if (iConditions.isKIBearish) + { + // + kiBearishPivot.to = cBar.time; + kiBearishPivot.from = pBar.time; + kiBearishPivot.value = iConditions.kiBuffer[cIDX]; + } + } + + // + if (iConditions.isKIBearish) + { + // + kiBearishPivot.from = pBar.time; + kiBearishPivot.value = + kiBearishPivot.value == 0 + ? iConditions.kiBuffer[cIDX] + : MathMax(iConditions.kiBuffer[cIDX], kiBearishPivot.value); + kiBearishPivot.reserve = + kiBearishPivot.reserve == 0 + ? iConditions.kiBuffer[cIDX] + : MathMin(iConditions.kiBuffer[cIDX], kiBearishPivot.reserve); + } + + // + if (iConditions.isKISwitchedToBearish) + { + // + has = + kiBearishPivot.IsValid() && + kiBearishPivot.GetAge() >= pivotVerifications; + if (has) + { + // + AddPivot( + kiBearishPivot, + kiBearishPivots // + ); + } + + // + kiBearishPivot.Clean(); + } + } + + // + // TKI Bullish ... + if (detectTKIBullishPivot) + { + // + if (!tkiBullishPivot.IsValid()) + { + // + tkiBullishPivot.type = XCA_TKI_BULL; + tkiBullishPivot.symbol = iConditions.symbol; + tkiBullishPivot.period = iConditions.period; + + // + if (iConditions.isTKIBullish) + { + // + tkiBullishPivot.to = cBar.time; + tkiBullishPivot.from = pBar.time; + tkiBullishPivot.value = iConditions.tkiBuffer[cIDX]; + } + } + + // + if (iConditions.isTKIBullish) + { + // + tkiBullishPivot.from = pBar.time; + tkiBullishPivot.value = + tkiBullishPivot.value == 0 + ? iConditions.tkiBuffer[cIDX] + : MathMin(iConditions.tkiBuffer[cIDX], tkiBullishPivot.value); + tkiBullishPivot.reserve = + tkiBullishPivot.reserve == 0 + ? iConditions.tkiBuffer[cIDX] + : MathMax(iConditions.tkiBuffer[cIDX], tkiBullishPivot.reserve); + } + + // + if (iConditions.isTKISwitchedToBullish) + { + // + has = + tkiBullishPivot.IsValid() && + tkiBullishPivot.GetAge() >= pivotVerifications; + if (has) + { + // + AddPivot( + tkiBullishPivot, + tkiBullishPivots // + ); + } + + // + tkiBullishPivot.Clean(); + } + } + + // + // TKI Bearish ... + if (detectTKIBearishPivot) + { + // + if (!tkiBearishPivot.IsValid()) + { + // + tkiBearishPivot.type = XCA_TKI_BEAR; + tkiBearishPivot.symbol = iConditions.symbol; + tkiBearishPivot.period = iConditions.period; + + // + if (iConditions.isTKIBearish) + { + // + tkiBearishPivot.to = cBar.time; + tkiBearishPivot.from = pBar.time; + tkiBearishPivot.value = iConditions.tkiBuffer[cIDX]; + } + } + + // + if (iConditions.isTKIBearish) + { + // + tkiBearishPivot.from = pBar.time; + tkiBearishPivot.value = + tkiBearishPivot.value == 0 + ? iConditions.kiBuffer[cIDX] + : MathMax(iConditions.kiBuffer[cIDX], tkiBearishPivot.value); + tkiBearishPivot.reserve = + tkiBearishPivot.reserve == 0 + ? iConditions.kiBuffer[cIDX] + : MathMin(iConditions.kiBuffer[cIDX], tkiBearishPivot.reserve); + } + + // + if (iConditions.isTKISwitchedToBearish) + { + // + has = + tkiBearishPivot.IsValid() && + tkiBearishPivot.GetAge() >= pivotVerifications; + if (has) + { + // + AddPivot( + tkiBearishPivot, + tkiBearishPivots // + ); + } + + // + tkiBearishPivot.Clean(); + } + } + + // + // TREND Bullish ... + if (detectTrendBullishPivot) + { + // + if (!trendBullishPivot.IsValid()) + { + // + trendBullishPivot.type = XCA_TREND_BULL; + trendBullishPivot.symbol = iConditions.symbol; + trendBullishPivot.period = iConditions.period; + + // + if (iConditions.isTrendBullish) + { + // + trendBullishPivot.to = cBar.time; + trendBullishPivot.from = pBar.time; + trendBullishPivot.value = iConditions.trendBuffer[cIDX]; + trendBullishPivot.reserve = iConditions.trendBuffer[cIDX]; + } + } + + // + if (iConditions.isTrendBullish) + { + // + Add( + iConditions.trendBuffer[cIDX], + trendBullishPivot.values // + ); + + // + trendBullishPivot.from = pBar.time; + + // + trendBullishPivot.value = + trendBullishPivot.value == 0 + ? iConditions.trendBuffer[cIDX] + : MathMin(iConditions.trendBuffer[cIDX], trendBullishPivot.value); + trendBullishPivot.reserve = + trendBullishPivot.reserve == 0 + ? iConditions.trendBuffer[cIDX] + : MathMax(iConditions.trendBuffer[cIDX], trendBullishPivot.reserve); + } + + // + if (iConditions.isTrendSwitchedToBullish) + { + // + has = + trendBullishPivot.IsValid() && + trendBullishPivot.GetAge() >= pivotVerifications; + if (has) + { + // // + // double ivMin = GetMin(trendBullishPivot.values); + // double ivMax = GetMax(trendBullishPivot.values); + + // // + // trendBullishPivot.value = ivMin; + // trendBullishPivot.reserve = ivMax; + + // + AddPivot( + trendBullishPivot, + trendBullishPivots // + ); + } + + // + trendBullishPivot.Clean(); + } + } + + // + // TREND Bearish ... + if (detectTrendBearishPivot) + { + // + if (!trendBearishPivot.IsValid()) + { + // + trendBearishPivot.type = XCA_TREND_BEAR; + trendBearishPivot.symbol = iConditions.symbol; + trendBearishPivot.period = iConditions.period; + + // + if (iConditions.isTrendBearish) + { + // + trendBearishPivot.to = cBar.time; + trendBearishPivot.from = pBar.time; + trendBearishPivot.value = iConditions.trendBuffer[cIDX]; + trendBearishPivot.reserve = iConditions.trendBuffer[cIDX]; + } + } + + // + if (iConditions.isTrendBearish) + { + // + Add( + iConditions.trendBuffer[cIDX], + trendBearishPivot.values // + ); + + // + trendBearishPivot.from = pBar.time; + + // + trendBearishPivot.value = + trendBearishPivot.value == 0 + ? iConditions.trendBuffer[cIDX] + : MathMax(iConditions.trendBuffer[cIDX], trendBearishPivot.value); + trendBearishPivot.reserve = + trendBearishPivot.reserve == 0 + ? iConditions.trendBuffer[cIDX] + : MathMin(iConditions.trendBuffer[cIDX], trendBearishPivot.reserve); + } + + // + if (iConditions.isTrendSwitchedToBearish) + { + // + has = + trendBearishPivot.IsValid() && + trendBearishPivot.GetAge() >= pivotVerifications; + if (has) + { + // // + // double ivMin = GetMin(trendBearishPivot.values); + // double ivMax = GetMax(trendBearishPivot.values); + + // // + // trendBearishPivot.value = ivMax; + // trendBearishPivot.reserve = ivMin; + + // + AddPivot( + trendBearishPivot, + trendBearishPivots // + ); + } + + // + trendBearishPivot.Clean(); + } } // @@ -899,7 +1351,11 @@ class XCXCAEAPOIDetector : public XCBase // POI Handlers ... // - bool HasPeakPivots() + // Peaks ... + + // + bool + HasPeakPivots() { return HasChild(peakPivots); } @@ -910,6 +1366,9 @@ class XCXCAEAPOIDetector : public XCBase return ArraySize(peakPivots); } + // + // Peak SWH Res ... + // bool HasPeakSWHResPivots() { @@ -922,6 +1381,9 @@ class XCXCAEAPOIDetector : public XCBase return ArraySize(peakSWHResPivots); } + // + // Vale ... + // bool HasValePivots() { @@ -934,6 +1396,9 @@ class XCXCAEAPOIDetector : public XCBase return ArraySize(valePivots); } + // + // ValeSWLSup ... + // bool HasValeSWLSupPivots() { @@ -946,6 +1411,9 @@ class XCXCAEAPOIDetector : public XCBase return ArraySize(valeSWLSupPivots); } + // + // Swing High ... + // bool HasSWHPivots() { @@ -958,6 +1426,9 @@ class XCXCAEAPOIDetector : public XCBase return ArraySize(swhPivots); } + // + // Swing Low ... + // bool HasSWLPivots() { @@ -970,6 +1441,87 @@ class XCXCAEAPOIDetector : public XCBase return ArraySize(swlPivots); } + // + // KI ... + + // + bool HasKIBullishPivots() + { + return HasChild(kiBullishPivots); + } + + // + int CountKIBullishPivots() + { + return ArraySize(kiBullishPivots); + } + + // + bool HasKIBearishPivots() + { + return HasChild(kiBearishPivots); + } + + // + int CountKIBearishPivots() + { + return ArraySize(kiBearishPivots); + } + + // + // TKI ... + + // + bool HasTKIBullishPivots() + { + return HasChild(tkiBullishPivots); + } + + // + int CountTKIBullishPivots() + { + return ArraySize(tkiBullishPivots); + } + + // + bool HasTKIBearishPivots() + { + return HasChild(tkiBearishPivots); + } + + // + int CountTKIBearishPivots() + { + return ArraySize(tkiBearishPivots); + } + + // + // TREND ... + + // + bool HasTrendBullishPivots() + { + return HasChild(trendBullishPivots); + } + + // + int CountTrendBullishPivots() + { + return ArraySize(trendBullishPivots); + } + + // + bool HasTrendBearishPivots() + { + return HasChild(trendBearishPivots); + } + + // + int CountTrendBearishPivots() + { + return ArraySize(trendBearishPivots); + } + // // Protected ... protected: @@ -982,14 +1534,21 @@ class XCXCAEAPOIDetector : public XCBase // // Props ... int pivotVerifications; // Pivots Verifications ... + int maxAllowedPivots; // Max Allowed Holding Pibots ... // XCAPivot swhPivot; XCAPivot swlPivot; XCAPivot peakPivot; XCAPivot valePivot; + XCAPivot kiBullishPivot; + XCAPivot kiBearishPivot; + XCAPivot tkiBullishPivot; + XCAPivot tkiBearishPivot; XCAPivot peakSWHResPivot; XCAPivot valeSWLSupPivot; + XCAPivot trendBullishPivot; + XCAPivot trendBearishPivot; // XCPOIDrawer *drawer; @@ -1091,6 +1650,13 @@ class XCXCAEAPOIDetector : public XCBase // pivots[updateIDX].to = pivot.to; } + + // + // Apply Max Allowed ... + CleanupArray( + pivots, + maxAllowedPivots // + ); } // diff --git a/XCAEA/Libraries/xcaea.signaller.lib.mq5 b/XCAEA/Libraries/xcaea.signaller.lib.mq5 index 2f377415..ff0b9128 100644 --- a/XCAEA/Libraries/xcaea.signaller.lib.mq5 +++ b/XCAEA/Libraries/xcaea.signaller.lib.mq5 @@ -752,13 +752,21 @@ bool DetectXCAEAConditions( // bool isCond1Bullish = - conditions.isValeIsPivot && - isTKITRNDSwitchedToBullish; + // conditions.isRSIOS && + // conditions.isValeIsPivot && + // isTKITRNDSwitchedToBullish + conditions.isKISwitchedToBullish + // + ; // bool isCond1Bearish = - conditions.isPeakIsPivot && - isTKITRNDSwitchedToBearish; + // conditions.isRSIOB && + // conditions.isPeakIsPivot && + // isTKITRNDSwitchedToBearish + conditions.isKISwitchedToBearish + // + ; // if (isCond1Bullish || diff --git a/XCAEA/Signals/xcaea.signaller.class.mq5 b/XCAEA/Signals/xcaea.signaller.class.mq5 index fe3ad57b..bcd44d9c 100644 --- a/XCAEA/Signals/xcaea.signaller.class.mq5 +++ b/XCAEA/Signals/xcaea.signaller.class.mq5 @@ -172,174 +172,11 @@ class XCXCAEASignaller : XCBase ); // - bool drawSWHPivots = true; - bool drawSWLPivots = true; - bool drawPeakPivots = false; - bool drawValePivots = false; + DrawPivots(); // - // Draw Peak SWH Res Pivots ... - if (drawPeakPivots) - { - // - has = detector.HasPeakSWHResPivots(); - if (has) - { - // - count = detector.CountPeakSWHResPivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox; - has = detector - .peakSWHResPivots[i] - .AsBox(iBox); - if (has) - { - // - iBox.to = cTime; - - // - XCBoxObject *iObj; - has = helper.poiDrawer.DrawBox( - iBox, - iObj // - ); - if (has) - { - mObjects.Add(iObj); - } - } - - // - iBox.Clean(); - } - - // - Print("Draw Peak SWH Res Pivots ..."); - } - } - // - // Draw Vale SWL Sup Pivots ... - if (drawValePivots) - { - // - has = detector.HasValeSWLSupPivots(); - if (has) - { - // - count = detector.CountValeSWLSupPivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox; - has = detector - .valeSWLSupPivots[i] - .AsBox(iBox); - if (has) - { - // - iBox.to = cTime; - - // - XCBoxObject *iObj; - has = helper.poiDrawer.DrawBox( - iBox, - iObj // - ); - if (has) - { - mObjects.Add(iObj); - } - } - - // - iBox.Clean(); - } - - // - Print("Draw Vale SWL Sup Pivots ..."); - } - } - // - // Draw SWH Pvots ... - if (drawSWHPivots) - { - // - has = detector.HasSWHPivots(); - if (has) - { - // - count = detector.CountSWHPivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox; - has = detector - .swhPivots[i] - .AsBox(iBox); - if (has) - { - // - iBox.to = cTime; - - // - XCBoxObject *iObj; - has = helper - .poiDrawer - .DrawBox( - iBox, - iObj // - ); - if (has) - { - mObjects.Add(iObj); - } - } - } - } - } - - // - // Draw SWL Pvots ... - if (drawSWLPivots) - { - // - has = detector.HasSWLPivots(); - if (has) - { - // - count = detector.CountSWLPivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox; - has = detector - .swlPivots[i] - .AsBox(iBox); - if (has) - { - // - iBox.to = cTime; - - // - XCBoxObject *iObj; - has = helper - .poiDrawer - .DrawBox( - iBox, - iObj // - ); - if (has) - { - mObjects.Add(iObj); - } - } - } - } - } // XCAEAConditions conditions; @@ -678,6 +515,419 @@ class XCXCAEASignaller : XCBase protected: // + // + void DrawPivots() + { + // + int count = 0; + bool has = false; + datetime cTime = TimeCurrent(); + + // + bool drawSWHPivots = false; + bool drawSWLPivots = false; + bool drawPeakPivots = false; + bool drawValePivots = false; + bool drawKIBullishPivots = false; + bool drawKIBearishPivots = false; + bool drawTKIBullishPivots = false; + bool drawTKIBearishPivots = false; + bool drawTrendBullishPivots = true; + bool drawTrendBearishPivots = true; + + // + // Draw Peak SWH Res Pivots ... + if (drawPeakPivots) + { + // + has = detector.HasPeakSWHResPivots(); + if (has) + { + // + count = detector.CountPeakSWHResPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = detector + .peakSWHResPivots[i] + .AsBox(iBox); + if (has) + { + // + iBox.to = cTime; + + // + XCBoxObject *iObj; + has = helper.poiDrawer.DrawBox( + iBox, + iObj // + ); + if (has) + { + mObjects.Add(iObj); + } + } + + // + iBox.Clean(); + } + } + } + + // + // Draw Vale SWL Sup Pivots ... + if (drawValePivots) + { + // + has = detector.HasValeSWLSupPivots(); + if (has) + { + // + count = detector.CountValeSWLSupPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = detector + .valeSWLSupPivots[i] + .AsBox(iBox); + if (has) + { + // + iBox.to = cTime; + + // + XCBoxObject *iObj; + has = helper.poiDrawer.DrawBox( + iBox, + iObj // + ); + if (has) + { + mObjects.Add(iObj); + } + } + + // + iBox.Clean(); + } + } + } + + // + // Draw SWH Pvots ... + if (drawSWHPivots) + { + // + has = detector.HasSWHPivots(); + if (has) + { + // + count = detector.CountSWHPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = detector + .swhPivots[i] + .AsBox(iBox); + if (has) + { + // + iBox.to = cTime; + + // + XCBoxObject *iObj; + has = helper + .poiDrawer + .DrawBox( + iBox, + iObj // + ); + if (has) + { + mObjects.Add(iObj); + } + } + } + } + } + + // + // Draw SWL Pvots ... + if (drawSWLPivots) + { + // + has = detector.HasSWLPivots(); + if (has) + { + // + count = detector.CountSWLPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = detector + .swlPivots[i] + .AsBox(iBox); + if (has) + { + // + iBox.to = cTime; + + // + XCBoxObject *iObj; + has = helper + .poiDrawer + .DrawBox( + iBox, + iObj // + ); + if (has) + { + mObjects.Add(iObj); + } + } + } + } + } + + // + // Draw KI Bullish Pivots ... + if (drawKIBullishPivots) + { + // + has = detector.HasKIBullishPivots(); + if (has) + { + // + count = detector.CountKIBullishPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = detector + .kiBullishPivots[i] + .AsBox(iBox); + if (has) + { + // + iBox.to = cTime; + + // + XCBoxObject *iObj; + has = helper + .poiDrawer + .DrawBox( + iBox, + iObj // + ); + if (has) + { + mObjects.Add(iObj); + } + } + } + } + } + + // + // Draw KI Bearish Pivots ... + if (drawKIBearishPivots) + { + // + has = detector.HasKIBullishPivots(); + if (has) + { + // + count = detector.CountKIBearishPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = detector + .kiBearishPivots[i] + .AsBox(iBox); + if (has) + { + // + iBox.to = cTime; + + // + XCBoxObject *iObj; + has = helper + .poiDrawer + .DrawBox( + iBox, + iObj // + ); + if (has) + { + mObjects.Add(iObj); + } + } + } + } + } + + // + // Draw TKI Bullish Pivots ... + if (drawTKIBullishPivots) + { + // + has = detector.HasTKIBullishPivots(); + if (has) + { + // + count = detector.CountTKIBullishPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = detector + .tkiBullishPivots[i] + .AsBox(iBox); + if (has) + { + // + // iBox.to = cTime; + + // + XCBoxObject *iObj; + has = helper + .poiDrawer + .DrawBox( + iBox, + iObj // + ); + if (has) + { + mObjects.Add(iObj); + } + } + } + } + } + + // + // Draw TKI Bearish Pivots ... + if (drawTKIBearishPivots) + { + // + has = detector.HasTKIBullishPivots(); + if (has) + { + // + count = detector.CountTKIBearishPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = detector + .tkiBearishPivots[i] + .AsBox(iBox); + if (has) + { + // + // iBox.to = cTime; + + // + XCBoxObject *iObj; + has = helper + .poiDrawer + .DrawBox( + iBox, + iObj // + ); + if (has) + { + mObjects.Add(iObj); + } + } + } + } + } + + // + // Draw Trend Bullish Pivots ... + if (drawTrendBullishPivots) + { + // + has = detector.HasTrendBullishPivots(); + if (has) + { + // + count = detector.CountTrendBullishPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = detector + .trendBullishPivots[i] + .AsBox(iBox); + if (has) + { + // + // iBox.to = cTime; + + // + XCBoxObject *iObj; + has = helper + .poiDrawer + .DrawBox( + iBox, + iObj // + ); + if (has) + { + mObjects.Add(iObj); + } + } + } + } + } + + // + // Draw Trend Bearish Pivots ... + if (drawTrendBearishPivots) + { + // + has = detector.HasTrendBullishPivots(); + if (has) + { + // + count = detector.CountTrendBearishPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = detector + .trendBearishPivots[i] + .AsBox(iBox); + if (has) + { + // + // iBox.to = cTime; + + // + XCBoxObject *iObj; + has = helper + .poiDrawer + .DrawBox( + iBox, + iObj // + ); + if (has) + { + mObjects.Add(iObj); + } + } + } + } + } + } + // // Private ... private: