From 4d9307bc3ee6d50f48eeb3874d84fa19584feba1 Mon Sep 17 00:00:00 2001 From: Hadi Khazaee Asl Date: Sat, 19 Apr 2025 00:41:36 +0330 Subject: [PATCH] last ... --- XCAEA/Classes/xcaea.x-poi.detector.class.mq5 | 1214 +++++++++++++++++- XCAEA/Classes/xcaea.x-poi.drawer.class.mq5 | 300 +++++ XCAEA/Signals/xcaea.signaller.class.mq5 | 25 +- 3 files changed, 1510 insertions(+), 29 deletions(-) diff --git a/XCAEA/Classes/xcaea.x-poi.detector.class.mq5 b/XCAEA/Classes/xcaea.x-poi.detector.class.mq5 index 16a03324..1c60c961 100644 --- a/XCAEA/Classes/xcaea.x-poi.detector.class.mq5 +++ b/XCAEA/Classes/xcaea.x-poi.detector.class.mq5 @@ -32,6 +32,9 @@ enum ENUM_XCA_PIVOTS { XCA_NONE, // None + XCA_LL, // LowestLow + XCA_HH, // HighestHigh + XCA_KI, // KI XCA_SWL, // SWL XCA_SWH, // SWH XCA_VALE, // VALE @@ -316,6 +319,7 @@ struct XCAPivot switch (type) { // + case XCA_LL: case XCA_SWL: case XCA_VALE: case XCA_KI_BULL: @@ -327,6 +331,7 @@ struct XCAPivot break; // + case XCA_HH: case XCA_SWH: case XCA_PEAK: case XCA_KI_BEAR: @@ -484,12 +489,43 @@ class XCXCAEAPOIDetector : public XCBase // // Props ... + // + int pivotVerifications; // Pivots Verifications ... + int maxAllowedPivots; // Max Allowed Holding Pibots ... + + // + bool detectSWHPivot; + bool detectSWLPivot; + bool detectPeakPivot; + bool detectValePivot; + bool detectKIBullishPivot; + bool detectKIBearishPivot; + bool detectTKIBullishPivot; + bool detectTKIBearishPivot; + bool detectPeakSWHResPivot; + bool detectValeSWLSupPivot; + bool detectCycleSameLLPivot; + bool detectCycleSameHHPivot; + bool detectTrendBullishPivot; + bool detectTrendBearishPivot; + bool detectTKITRNDBullishPivot; + bool detectTKITRNDBearishPivot; + // // Active Pivots ... XCAPivot swhPivot; XCAPivot swlPivot; XCAPivot peakPivot; XCAPivot valePivot; + XCAPivot kiSamePivot; + XCAPivot sSameHHPivot; + XCAPivot mSameHHPivot; + XCAPivot lSameHHPivot; + XCAPivot hSameHHPivot; + XCAPivot sSameLLPivot; + XCAPivot mSameLLPivot; + XCAPivot lSameLLPivot; + XCAPivot hSameLLPivot; XCAPivot kiBullishPivot; XCAPivot kiBearishPivot; XCAPivot tkiBullishPivot; @@ -507,6 +543,15 @@ class XCXCAEAPOIDetector : public XCBase XCAPivot swlPivots[]; XCAPivot peakPivots[]; XCAPivot valePivots[]; + XCAPivot kiSamePivots[]; + XCAPivot sSameHHPivots[]; + XCAPivot mSameHHPivots[]; + XCAPivot lSameHHPivots[]; + XCAPivot hSameHHPivots[]; + XCAPivot sSameLLPivots[]; + XCAPivot mSameLLPivots[]; + XCAPivot lSameLLPivots[]; + XCAPivot hSameLLPivots[]; XCAPivot kiBullishPivots[]; XCAPivot kiBearishPivots[]; XCAPivot tkiBullishPivots[]; @@ -538,20 +583,54 @@ class XCXCAEAPOIDetector : public XCBase ~XCXCAEAPOIDetector() { // + swhPivot.Clean(); + swlPivot.Clean(); peakPivot.Clean(); - Clean(peakPivots); - - // valePivot.Clean(); - Clean(valePivots); - - // + kiSamePivot.Clean(); + sSameHHPivot.Clean(); + mSameHHPivot.Clean(); + lSameHHPivot.Clean(); + hSameHHPivot.Clean(); + sSameLLPivot.Clean(); + mSameLLPivot.Clean(); + lSameLLPivot.Clean(); + hSameLLPivot.Clean(); + kiBullishPivot.Clean(); + kiBearishPivot.Clean(); + tkiBullishPivot.Clean(); + tkiBearishPivot.Clean(); peakSWHResPivot.Clean(); - Clean(peakSWHResPivots); + valeSWLSupPivot.Clean(); + trendBullishPivot.Clean(); + trendBearishPivot.Clean(); + tkitrndBullishPivot.Clean(); + tkitrndBearishPivot.Clean(); // - valeSWLSupPivot.Clean(); + Clean(swhPivots); + Clean(swlPivots); + Clean(peakPivots); + Clean(valePivots); + Clean(kiSamePivots); + Clean(sSameHHPivots); + Clean(mSameHHPivots); + Clean(lSameHHPivots); + Clean(hSameHHPivots); + Clean(sSameLLPivots); + Clean(mSameLLPivots); + Clean(lSameLLPivots); + Clean(hSameLLPivots); + Clean(kiBullishPivots); + Clean(kiBearishPivots); + Clean(tkiBullishPivots); + Clean(tkiBearishPivots); + Clean(peakSWHResPivots); Clean(valeSWLSupPivots); + Clean(trendBullishPivots); + Clean(trendBearishPivots); + Clean(tkitrndBullishPivots); + Clean(tkitrndBearishPivots); // ZeroMemory(helper); @@ -570,6 +649,24 @@ class XCXCAEAPOIDetector : public XCBase // maxAllowedPivots = 50; pivotVerifications = 5; + + // + detectSWHPivot = true; + detectSWLPivot = true; + detectPeakPivot = true; + detectValePivot = true; + detectCycleSameLLPivot = true; + detectCycleSameHHPivot = true; + detectKIBullishPivot = true; + detectKIBearishPivot = true; + detectTKIBullishPivot = true; + detectTKIBearishPivot = true; + detectPeakSWHResPivot = true; + detectValeSWLSupPivot = true; + detectTrendBullishPivot = true; + detectTrendBearishPivot = true; + detectTKITRNDBullishPivot = true; + detectTKITRNDBearishPivot = true; } // @@ -895,23 +992,251 @@ class XCXCAEAPOIDetector : public XCBase !isPTKITRNDBearish; // - // Checking Pivots ... + // CYCLES ... // - bool detectSWHPivot = true; - bool detectSWLPivot = true; - bool detectPeakPivot = true; - bool detectValePivot = true; - bool detectTKITRNDBullish = true; - bool detectTKITRNDBearish = true; - bool detectKIBullishPivot = true; - bool detectKIBearishPivot = true; - bool detectTKIBullishPivot = true; - bool detectTKIBearishPivot = true; - bool detectPeakSWHResPivot = true; - bool detectValeSWLSupPivot = true; - bool detectTrendBullishPivot = true; - bool detectTrendBearishPivot = true; + double cSLL = iConditions.sLLBuffer[cIDX]; + double pSLL = iConditions.sLLBuffer[pIDX]; + double p2SLL = iConditions.sLLBuffer[p2IDX]; + + // + double cSHH = iConditions.sHHBuffer[cIDX]; + double pSHH = iConditions.sHHBuffer[pIDX]; + double p2SHH = iConditions.sHHBuffer[p2IDX]; + + // + double cMLL = iConditions.mLLBuffer[cIDX]; + double pMLL = iConditions.mLLBuffer[pIDX]; + double p2MLL = iConditions.mLLBuffer[p2IDX]; + + // + double cMHH = iConditions.mHHBuffer[cIDX]; + double pMHH = iConditions.mHHBuffer[pIDX]; + double p2MHH = iConditions.mHHBuffer[p2IDX]; + + // + double cLLL = iConditions.lLLBuffer[cIDX]; + double pLLL = iConditions.lLLBuffer[pIDX]; + double p2LLL = iConditions.lLLBuffer[p2IDX]; + + // + double cLHH = iConditions.lHHBuffer[cIDX]; + double pLHH = iConditions.lHHBuffer[pIDX]; + double p2LHH = iConditions.lHHBuffer[p2IDX]; + + // + double cHLL = iConditions.hLLBuffer[cIDX]; + double pHLL = iConditions.hLLBuffer[pIDX]; + double p2HLL = iConditions.hLLBuffer[p2IDX]; + + // + double cHHH = iConditions.hHHBuffer[cIDX]; + double pHHH = iConditions.hHHBuffer[pIDX]; + double p2HHH = iConditions.hHHBuffer[p2IDX]; + + // + // Short Cycle ... + + // + // LL ... + + // + bool isCSLLSame = + cSLL == pSLL; + + // + bool isPSLLSame = + pSLL == p2SLL; + + // + bool isSLLStartSame = + isCSLLSame && + !isPSLLSame; + + // + bool isSLLFinishedSame = + !isCSLLSame && + isPSLLSame; + + // + // HH ... + + // + bool isCSHHSame = + cSHH == pSHH; + + // + bool isPSHHSame = + pSHH == p2SHH; + + // + bool isSHHStartSame = + isCSHHSame && + !isPSHHSame; + + // + bool isSHHFinishedSame = + !isCSHHSame && + isPSHHSame; + + // + // Mediu Cycle ... + + // + // LL ... + + // + bool isCMLLSame = + cMLL == pMLL; + + // + bool isPMLLSame = + pMLL == p2MLL; + + // + bool isMLLStartSame = + isCMLLSame && + !isPMLLSame; + + // + bool isMLLFinishedSame = + !isCMLLSame && + isPMLLSame; + + // + // HH ... + + // + bool isCMHHSame = + cMHH == pMHH; + + // + bool isPMHHSame = + pMHH == p2MHH; + + // + bool isMHHStartSame = + isCMHHSame && + !isPMHHSame; + + // + bool isMHHFinishedSame = + !isCMHHSame && + isPMHHSame; + + // + // Long Cycle ... + + // + // LL ... + + // + bool isCLLLSame = + cLLL == pLLL; + + // + bool isPLLLSame = + pLLL == p2LLL; + + // + bool isLLLStartSame = + isCLLLSame && + !isPLLLSame; + + // + bool isLLLFinishedSame = + !isCLLLSame && + isPLLLSame; + + // + // HH ... + + // + bool isCLHHSame = + cLHH == pLHH; + + // + bool isPLHHSame = + pLHH == p2LHH; + + // + bool isLHHStartSame = + isCLHHSame && + !isPLHHSame; + + // + bool isLHHFinishedSame = + !isCLHHSame && + isPLHHSame; + + // + // Hind Cycle ... + + // + // LL ... + + // + bool isCHLLSame = + cHLL == pHLL; + + // + bool isPHLLSame = + pHLL == p2HLL; + + // + bool isHLLStartSame = + isCHLLSame && + !isPHLLSame; + + // + bool isHLLFinishedSame = + !isCHLLSame && + isPHLLSame; + + // + // HH ... + + // + bool isCHHHSame = + cHHH == pHHH; + + // + bool isPHHHSame = + pHHH == p2HHH; + + // + bool isHHHStartSame = + isCHHHSame && + !isPHHHSame; + + // + bool isHHHFinishedSame = + !isCHHHSame && + isPHHHSame; + + // + // KI ... + + // + bool isCKISame = + cKI == pKI; + + // + bool isPKISame = + pKI == p2KI; + + // + bool isKIStartSame = + isCKISame && + !isPKISame; + + // + bool isKIFinishedSame = + !isCKISame && + isPKISame; + + // + // Checking Pivots ... // // Peak Pivot ... @@ -1822,7 +2147,7 @@ class XCXCAEAPOIDetector : public XCBase // // TKITRND Bullish ... - if (detectTKITRNDBullish) + if (detectTKITRNDBullishPivot) { // if (!tkitrndBullishPivot.IsValid()) @@ -1905,7 +2230,7 @@ class XCXCAEAPOIDetector : public XCBase // // TKITRND Bearish ... - if (detectTKITRNDBearish) + if (detectTKITRNDBearishPivot) { // if (!tkitrndBearishPivot.IsValid()) @@ -1986,6 +2311,744 @@ class XCXCAEAPOIDetector : public XCBase } } + // + // Cycles LL ... + if (detectCycleSameLLPivot) + { + // + // Short Cycle ... + if (!sSameLLPivot.IsValid()) + { + // + sSameLLPivot.type = XCA_LL; + sSameLLPivot.symbol = iConditions.symbol; + sSameLLPivot.period = iConditions.period; + + // + if (isSLLFinishedSame) + { + // + sSameLLPivot.Clean(); + + // + sSameLLPivot.type = XCA_LL; + sSameLLPivot.symbol = iConditions.symbol; + sSameLLPivot.period = iConditions.period; + + // + sSameLLPivot.to = pBar.time; + sSameLLPivot.from = pBar.time; + sSameLLPivot.value = pSLL; + sSameLLPivot.reserve = pSLL; + } + } + + // + if (isCSLLSame) + { + // + sSameLLPivot.from = pBar.time; + + // + double reserve = sSameLLPivot.reserve; + if (pBar.low == pSLL) + { + // + reserve = + reserve == 0 + ? pBar.GetDown() + : MathMax(reserve, pBar.GetDown()); + } + sSameLLPivot.reserve = reserve; + } + + // + if (isSLLStartSame) + { + // + double reserve = sSameLLPivot.reserve; + if (cBar.low == cSLL) + { + // + reserve = + reserve == 0 + ? cBar.GetDown() + : MathMax(reserve, cBar.GetDown()); + } + if (pBar.low == pSLL) + { + // + reserve = + reserve == 0 + ? pBar.GetDown() + : MathMax(reserve, pBar.GetDown()); + } + if (reserve == 0 || reserve == sSameLLPivot.value) + { + reserve = sSameLLPivot.value + (5 * points); + } + sSameLLPivot.reserve = reserve; + + // + has = + sSameLLPivot.IsValid() && + sSameLLPivot.GetAge() >= pivotVerifications; + if (has) + { + // + AddPivot( + sSameLLPivot, + sSameLLPivots // + ); + } + + // + sSameLLPivot.Clean(); + } + + // + // Medium Cycle ... + if (!mSameLLPivot.IsValid()) + { + // + mSameLLPivot.type = XCA_LL; + mSameLLPivot.symbol = iConditions.symbol; + mSameLLPivot.period = iConditions.period; + + // + if (isMLLFinishedSame) + { + // + mSameLLPivot.Clean(); + + // + mSameLLPivot.type = XCA_LL; + mSameLLPivot.symbol = iConditions.symbol; + mSameLLPivot.period = iConditions.period; + + // + mSameLLPivot.to = pBar.time; + mSameLLPivot.from = pBar.time; + mSameLLPivot.value = pMLL; + mSameLLPivot.reserve = pMLL; + } + } + + // + if (isCMLLSame) + { + // + mSameLLPivot.from = pBar.time; + + // + double reserve = mSameLLPivot.reserve; + if (pBar.low == pMLL) + { + // + reserve = + reserve == 0 + ? pBar.GetDown() + : MathMax(reserve, pBar.GetDown()); + } + mSameLLPivot.reserve = reserve; + } + + // + if (isMLLStartSame) + { + // + double reserve = mSameLLPivot.reserve; + if (cBar.low == cMLL) + { + // + reserve = + reserve == 0 + ? cBar.GetDown() + : MathMax(reserve, cBar.GetDown()); + } + if (pBar.low == pMLL) + { + // + reserve = + reserve == 0 + ? pBar.GetDown() + : MathMax(reserve, pBar.GetDown()); + } + if (reserve == 0 || reserve == mSameLLPivot.value) + { + reserve = mSameLLPivot.value + (5 * points); + } + mSameLLPivot.reserve = reserve; + + // + has = + mSameLLPivot.IsValid() && + mSameLLPivot.GetAge() >= pivotVerifications; + if (has) + { + // + AddPivot( + mSameLLPivot, + mSameLLPivots // + ); + } + + // + mSameLLPivot.Clean(); + } + + // + // Long Cycle ... + if (!lSameLLPivot.IsValid()) + { + // + lSameLLPivot.type = XCA_LL; + lSameLLPivot.symbol = iConditions.symbol; + lSameLLPivot.period = iConditions.period; + + // + if (isLLLFinishedSame) + { + // + lSameLLPivot.Clean(); + + // + lSameLLPivot.type = XCA_LL; + lSameLLPivot.symbol = iConditions.symbol; + lSameLLPivot.period = iConditions.period; + + // + lSameLLPivot.to = pBar.time; + lSameLLPivot.from = pBar.time; + lSameLLPivot.value = pLLL; + lSameLLPivot.reserve = pLLL; + } + } + + // + if (isCLLLSame) + { + // + lSameLLPivot.from = pBar.time; + + // + double reserve = lSameLLPivot.reserve; + if (pBar.low == pLLL) + { + // + reserve = + reserve == 0 + ? pBar.GetDown() + : MathMax(reserve, pBar.GetDown()); + } + lSameLLPivot.reserve = reserve; + } + + // + if (isLLLStartSame) + { + // + double reserve = lSameLLPivot.reserve; + if (cBar.low == cLLL) + { + // + reserve = + reserve == 0 + ? cBar.GetDown() + : MathMax(reserve, cBar.GetDown()); + } + if (pBar.low == pLLL) + { + // + reserve = + reserve == 0 + ? pBar.GetDown() + : MathMax(reserve, pBar.GetDown()); + } + if (reserve == 0 || reserve == lSameLLPivot.value) + { + reserve = lSameLLPivot.value + (5 * points); + } + lSameLLPivot.reserve = reserve; + + // + has = + lSameLLPivot.IsValid() && + lSameLLPivot.GetAge() >= pivotVerifications; + if (has) + { + // + AddPivot( + lSameLLPivot, + lSameLLPivots // + ); + } + + // + lSameLLPivot.Clean(); + } + + // + // Hind Cycle ... + if (!hSameLLPivot.IsValid()) + { + // + hSameLLPivot.type = XCA_LL; + hSameLLPivot.symbol = iConditions.symbol; + hSameLLPivot.period = iConditions.period; + + // + if (isHLLFinishedSame) + { + // + hSameLLPivot.Clean(); + + // + hSameLLPivot.type = XCA_LL; + hSameLLPivot.symbol = iConditions.symbol; + hSameLLPivot.period = iConditions.period; + + // + hSameLLPivot.to = pBar.time; + hSameLLPivot.from = pBar.time; + hSameLLPivot.value = pHLL; + hSameLLPivot.reserve = pHLL; + } + } + + // + if (isCHLLSame) + { + // + hSameLLPivot.from = pBar.time; + + // + double reserve = hSameLLPivot.reserve; + if (pBar.low == pHLL) + { + // + reserve = + reserve == 0 + ? pBar.GetDown() + : MathMax(reserve, pBar.GetDown()); + } + hSameLLPivot.reserve = reserve; + } + + // + if (isHLLStartSame) + { + // + double reserve = hSameLLPivot.reserve; + if (cBar.low == cHLL) + { + // + reserve = + reserve == 0 + ? cBar.GetDown() + : MathMax(reserve, cBar.GetDown()); + } + if (pBar.low == pHLL) + { + // + reserve = + reserve == 0 + ? pBar.GetDown() + : MathMax(reserve, pBar.GetDown()); + } + if (reserve == 0 || reserve == hSameLLPivot.value) + { + reserve = hSameLLPivot.value + (5 * points); + } + hSameLLPivot.reserve = reserve; + + // + has = + hSameLLPivot.IsValid() && + hSameLLPivot.GetAge() >= pivotVerifications; + if (has) + { + // + AddPivot( + hSameLLPivot, + hSameLLPivots // + ); + } + + // + hSameLLPivot.Clean(); + } + } + + // + // Cycles HH ... + if (detectCycleSameHHPivot) + { + // + // Short Cycle ... + if (!sSameHHPivot.IsValid()) + { + // + sSameHHPivot.type = XCA_HH; + sSameHHPivot.symbol = iConditions.symbol; + sSameHHPivot.period = iConditions.period; + + // + if (isSHHFinishedSame) + { + // + sSameHHPivot.Clean(); + + // + sSameHHPivot.type = XCA_HH; + sSameHHPivot.symbol = iConditions.symbol; + sSameHHPivot.period = iConditions.period; + + // + sSameHHPivot.to = pBar.time; + sSameHHPivot.from = pBar.time; + sSameHHPivot.value = pSHH; + sSameHHPivot.reserve = pSHH; + } + } + + // + if (isCSHHSame) + { + // + sSameHHPivot.from = pBar.time; + + // + double reserve = sSameHHPivot.reserve; + if (pBar.high == pSHH) + { + // + reserve = + reserve == 0 + ? pBar.GetUp() + : MathMin(reserve, pBar.GetUp()); + } + sSameHHPivot.reserve = reserve; + } + + // + if (isSHHStartSame) + { + // + double reserve = sSameHHPivot.reserve; + if (cBar.high == cSHH) + { + // + reserve = + reserve == 0 + ? cBar.GetUp() + : MathMin(reserve, cBar.GetUp()); + } + if (pBar.high == pSHH) + { + // + reserve = + reserve == 0 + ? pBar.GetUp() + : MathMin(reserve, pBar.GetUp()); + } + if (reserve == 0 || reserve == sSameHHPivot.value) + { + reserve = sSameHHPivot.value + (5 * points); + } + sSameHHPivot.reserve = reserve; + + // + has = + sSameHHPivot.IsValid() && + sSameHHPivot.GetAge() >= pivotVerifications; + if (has) + { + // + AddPivot( + sSameHHPivot, + sSameHHPivots // + ); + } + + // + sSameHHPivot.Clean(); + } + + // + // Medium Cycle ... + if (!mSameHHPivot.IsValid()) + { + // + mSameHHPivot.type = XCA_HH; + mSameHHPivot.symbol = iConditions.symbol; + mSameHHPivot.period = iConditions.period; + + // + if (isMHHFinishedSame) + { + // + mSameHHPivot.Clean(); + + // + mSameHHPivot.type = XCA_HH; + mSameHHPivot.symbol = iConditions.symbol; + mSameHHPivot.period = iConditions.period; + + // + mSameHHPivot.to = pBar.time; + mSameHHPivot.from = pBar.time; + mSameHHPivot.value = pMHH; + mSameHHPivot.reserve = pMHH; + } + } + + // + if (isCMHHSame) + { + // + mSameHHPivot.from = pBar.time; + + // + double reserve = mSameHHPivot.reserve; + if (pBar.high == pMHH) + { + // + reserve = + reserve == 0 + ? pBar.GetUp() + : MathMin(reserve, pBar.GetUp()); + } + mSameHHPivot.reserve = reserve; + } + + // + if (isMHHStartSame) + { + // + double reserve = mSameHHPivot.reserve; + if (cBar.high == cMHH) + { + // + reserve = + reserve == 0 + ? cBar.GetUp() + : MathMin(reserve, cBar.GetUp()); + } + if (pBar.high == pMHH) + { + // + reserve = + reserve == 0 + ? pBar.GetUp() + : MathMin(reserve, pBar.GetUp()); + } + if (reserve == 0 || reserve == mSameHHPivot.value) + { + reserve = mSameHHPivot.value + (5 * points); + } + mSameHHPivot.reserve = reserve; + + // + has = + mSameHHPivot.IsValid() && + mSameHHPivot.GetAge() >= pivotVerifications; + if (has) + { + // + AddPivot( + mSameHHPivot, + mSameHHPivots // + ); + } + + // + mSameHHPivot.Clean(); + } + + // + // Long Cycle ... + if (!lSameHHPivot.IsValid()) + { + // + lSameHHPivot.type = XCA_HH; + lSameHHPivot.symbol = iConditions.symbol; + lSameHHPivot.period = iConditions.period; + + // + if (isLHHFinishedSame) + { + // + lSameHHPivot.Clean(); + + // + lSameHHPivot.type = XCA_HH; + lSameHHPivot.symbol = iConditions.symbol; + lSameHHPivot.period = iConditions.period; + + // + lSameHHPivot.to = pBar.time; + lSameHHPivot.from = pBar.time; + lSameHHPivot.value = pLHH; + lSameHHPivot.reserve = pLHH; + } + } + + // + if (isCLHHSame) + { + // + lSameHHPivot.from = pBar.time; + + // + double reserve = lSameHHPivot.reserve; + if (pBar.high == pLHH) + { + // + reserve = + reserve == 0 + ? pBar.GetUp() + : MathMin(reserve, pBar.GetUp()); + } + lSameHHPivot.reserve = reserve; + } + + // + if (isLHHStartSame) + { + // + double reserve = lSameHHPivot.reserve; + if (cBar.high == cLHH) + { + // + reserve = + reserve == 0 + ? cBar.GetUp() + : MathMin(reserve, cBar.GetUp()); + } + if (pBar.high == pLHH) + { + // + reserve = + reserve == 0 + ? pBar.GetUp() + : MathMin(reserve, pBar.GetUp()); + } + if (reserve == 0 || reserve == lSameHHPivot.value) + { + reserve = lSameHHPivot.value + (5 * points); + } + lSameHHPivot.reserve = reserve; + + // + has = + lSameHHPivot.IsValid() && + lSameHHPivot.GetAge() >= pivotVerifications; + if (has) + { + // + AddPivot( + lSameHHPivot, + lSameHHPivots // + ); + } + + // + lSameHHPivot.Clean(); + } + + // + // Hind Cycle ... + if (!hSameHHPivot.IsValid()) + { + // + hSameHHPivot.type = XCA_HH; + hSameHHPivot.symbol = iConditions.symbol; + hSameHHPivot.period = iConditions.period; + + // + if (isHHHFinishedSame) + { + // + hSameHHPivot.Clean(); + + // + hSameHHPivot.type = XCA_HH; + hSameHHPivot.symbol = iConditions.symbol; + hSameHHPivot.period = iConditions.period; + + // + hSameHHPivot.to = pBar.time; + hSameHHPivot.from = pBar.time; + hSameHHPivot.value = pHHH; + hSameHHPivot.reserve = pHHH; + } + } + + // + if (isCHHHSame) + { + // + hSameHHPivot.from = pBar.time; + + // + double reserve = hSameHHPivot.reserve; + if (pBar.high == pHHH) + { + // + reserve = + reserve == 0 + ? pBar.GetUp() + : MathMin(reserve, pBar.GetUp()); + } + hSameHHPivot.reserve = reserve; + } + + // + if (isHHHStartSame) + { + // + double reserve = hSameHHPivot.reserve; + if (cBar.high == cHHH) + { + // + reserve = + reserve == 0 + ? cBar.GetUp() + : MathMin(reserve, cBar.GetUp()); + } + if (pBar.high == pHHH) + { + // + reserve = + reserve == 0 + ? pBar.GetUp() + : MathMin(reserve, pBar.GetUp()); + } + if (reserve == 0 || reserve == hSameHHPivot.value) + { + reserve = hSameHHPivot.value + (5 * points); + } + hSameHHPivot.reserve = reserve; + + // + has = + hSameHHPivot.IsValid() && + hSameHHPivot.GetAge() >= pivotVerifications; + if (has) + { + // + AddPivot( + hSameHHPivot, + hSameHHPivots // + ); + } + + // + hSameHHPivot.Clean(); + } + } + // start++; @@ -2201,6 +3264,105 @@ class XCXCAEAPOIDetector : public XCBase return ArraySize(tkitrndBearishPivots); } + // + // Same Cycles ... + + // + bool HasSSameLLPivots() + { + return HasChild(sSameLLPivots); + } + + // + int CountSSameLLPivots() + { + return ArraySize(sSameLLPivots); + } + + // + bool HasMSameLLPivots() + { + return HasChild(mSameLLPivots); + } + + // + int CountMSameLLPivots() + { + return ArraySize(mSameLLPivots); + } + + // + bool HasLSameLLPivots() + { + return HasChild(lSameLLPivots); + } + + // + int CountLSameLLPivots() + { + return ArraySize(lSameLLPivots); + } + + // + bool HasHSameLLPivots() + { + return HasChild(hSameLLPivots); + } + + // + int CountHSameLLPivots() + { + return ArraySize(hSameLLPivots); + } + + // + bool HasSSameHHPivots() + { + return HasChild(sSameHHPivots); + } + + // + int CountSSameHHPivots() + { + return ArraySize(sSameHHPivots); + } + + // + bool HasMSameHHPivots() + { + return HasChild(mSameHHPivots); + } + + // + int CountMSameHHPivots() + { + return ArraySize(mSameHHPivots); + } + + // + bool HasLSameHHPivots() + { + return HasChild(lSameHHPivots); + } + + // + int CountLSameHHPivots() + { + return ArraySize(lSameHHPivots); + } + + // + bool HasHSameHHPivots() + { + return HasChild(hSameHHPivots); + } + + // + int CountHSameHHPivots() + { + return ArraySize(hSameHHPivots); + } + // // Protected ... protected: @@ -2212,8 +3374,6 @@ class XCXCAEAPOIDetector : public XCBase private: // // Props ... - int pivotVerifications; // Pivots Verifications ... - int maxAllowedPivots; // Max Allowed Holding Pibots ... // XCPOIDrawer *drawer; diff --git a/XCAEA/Classes/xcaea.x-poi.drawer.class.mq5 b/XCAEA/Classes/xcaea.x-poi.drawer.class.mq5 index 1dd05976..4ea7aa30 100644 --- a/XCAEA/Classes/xcaea.x-poi.drawer.class.mq5 +++ b/XCAEA/Classes/xcaea.x-poi.drawer.class.mq5 @@ -46,6 +46,8 @@ class XCXCAEAPOIDrawer : public XCBase bool drawValeSWLSupPivots; bool drawTKIBullishPivots; bool drawTKIBearishPivots; + bool drawCycleSameLLPivots; + bool drawCycleSameHHPivots; bool drawTrendBullishPivots; bool drawTrendBearishPivots; bool drawTKITRNDBullishPivots; @@ -98,6 +100,8 @@ class XCXCAEAPOIDrawer : public XCBase mTKIBearishPivotObjects.Clear(); mTrendBullishPivotObjects.Clear(); mTrendBearishPivotObjects.Clear(); + mCycleSameLLPivotObjects.Clear(); + mCycleSameHHPivotObjects.Clear(); mTKITRNDBullishPivotObjects.Clear(); mTKITRNDBearishPivotObjects.Clear(); @@ -196,6 +200,8 @@ class XCXCAEAPOIDrawer : public XCBase drawValeSWLSupPivots = false; drawTKIBullishPivots = false; drawTKIBearishPivots = false; + drawCycleSameLLPivots = false; + drawCycleSameHHPivots = false; drawTrendBullishPivots = false; drawTrendBearishPivots = false; drawTKITRNDBullishPivots = false; @@ -232,6 +238,8 @@ class XCXCAEAPOIDrawer : public XCBase DrawValeSWLSupPivots(); DrawTKIBullishPivots(); DrawTKIBearishPivots(); + DrawCycleSameLLPivots(); + DrawCycleSameHHPivots(); DrawTrendBullishPivots(); DrawTrendBearishPivots(); DrawTKITRNDBullishPivots(); @@ -878,6 +886,296 @@ class XCXCAEAPOIDrawer : public XCBase } } + // + void DrawCycleSameLLPivots() + { + // + if (!drawCycleSameLLPivots) + { + return; + } + + // + int count = 0; + + // + // SHORT ... + bool has = detector.HasSSameLLPivots(); + if (has) + { + // + count = detector.CountSSameLLPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = detector.sSameLLPivots[i].AsBox(iBox); + if (!has) + { + continue; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + iBox, + iObj // + ); + if (has) + { + mCycleSameLLPivotObjects.Add(iObj); + } + + // + iBox.Clean(); + } + } + + // + // MEDIUM ... + has = detector.HasMSameLLPivots(); + if (has) + { + // + count = detector.CountMSameLLPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = detector.mSameLLPivots[i].AsBox(iBox); + if (!has) + { + continue; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + iBox, + iObj // + ); + if (has) + { + mCycleSameLLPivotObjects.Add(iObj); + } + + // + iBox.Clean(); + } + } + + // + // LONG ... + has = detector.HasLSameLLPivots(); + if (has) + { + // + count = detector.CountLSameLLPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = detector.lSameLLPivots[i].AsBox(iBox); + if (!has) + { + continue; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + iBox, + iObj // + ); + if (has) + { + mCycleSameLLPivotObjects.Add(iObj); + } + + // + iBox.Clean(); + } + } + + // + // HIND ... + has = detector.HasHSameLLPivots(); + if (has) + { + // + count = detector.CountHSameLLPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = detector.hSameLLPivots[i].AsBox(iBox); + if (!has) + { + continue; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + iBox, + iObj // + ); + if (has) + { + mCycleSameLLPivotObjects.Add(iObj); + } + + // + iBox.Clean(); + } + } + } + + // + void DrawCycleSameHHPivots() + { + // + if (!drawCycleSameHHPivots) + { + return; + } + + // + int count = 0; + + // + // SHORT ... + bool has = detector.HasSSameHHPivots(); + if (has) + { + // + count = detector.CountSSameHHPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = detector.sSameHHPivots[i].AsBox(iBox); + if (!has) + { + continue; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + iBox, + iObj // + ); + if (has) + { + mCycleSameHHPivotObjects.Add(iObj); + } + + // + iBox.Clean(); + } + } + + // + // MEDIUM ... + has = detector.HasMSameHHPivots(); + if (has) + { + // + count = detector.CountMSameHHPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = detector.mSameHHPivots[i].AsBox(iBox); + if (!has) + { + continue; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + iBox, + iObj // + ); + if (has) + { + mCycleSameHHPivotObjects.Add(iObj); + } + + // + iBox.Clean(); + } + } + + // + // LONG ... + has = detector.HasLSameHHPivots(); + if (has) + { + // + count = detector.CountLSameHHPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = detector.lSameHHPivots[i].AsBox(iBox); + if (!has) + { + continue; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + iBox, + iObj // + ); + if (has) + { + mCycleSameHHPivotObjects.Add(iObj); + } + + // + iBox.Clean(); + } + } + + // + // HIND ... + has = detector.HasHSameHHPivots(); + if (has) + { + // + count = detector.CountHSameHHPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = detector.hSameHHPivots[i].AsBox(iBox); + if (!has) + { + continue; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + iBox, + iObj // + ); + if (has) + { + mCycleSameHHPivotObjects.Add(iObj); + } + + // + iBox.Clean(); + } + } + } + // // // @@ -1413,6 +1711,8 @@ class XCXCAEAPOIDrawer : public XCBase CArrayObj mValeSWLSupPivotObjects; CArrayObj mTKIBullishPivotObjects; CArrayObj mTKIBearishPivotObjects; + CArrayObj mCycleSameLLPivotObjects; + CArrayObj mCycleSameHHPivotObjects; CArrayObj mTrendBullishPivotObjects; CArrayObj mTrendBearishPivotObjects; CArrayObj mTKITRNDBullishPivotObjects; diff --git a/XCAEA/Signals/xcaea.signaller.class.mq5 b/XCAEA/Signals/xcaea.signaller.class.mq5 index f5c9ed1d..36ef9012 100644 --- a/XCAEA/Signals/xcaea.signaller.class.mq5 +++ b/XCAEA/Signals/xcaea.signaller.class.mq5 @@ -611,8 +611,27 @@ class XCXCAEASignaller : XCBase ); // + // Initialize and Configure Detector ... detector = new XCXCAEAPOIDetector(helper); + // + detector.detectSWHPivot = false; + detector.detectSWLPivot = false; + detector.detectPeakPivot = false; + detector.detectValePivot = false; + detector.detectKIBullishPivot = false; + detector.detectKIBearishPivot = false; + detector.detectPeakSWHResPivot = true; + detector.detectValeSWLSupPivot = true; + detector.detectTKIBullishPivot = false; + detector.detectCycleSameLLPivot = true; + detector.detectCycleSameHHPivot = true; + detector.detectTKIBearishPivot = false; + detector.detectTrendBullishPivot = true; + detector.detectTrendBearishPivot = true; + detector.detectTKITRNDBullishPivot = false; + detector.detectTKITRNDBearishPivot = false; + // // Initialize and Configure Drawer ... drawer = new XCXCAEAPOIDrawer(detector); @@ -625,8 +644,10 @@ class XCXCAEASignaller : XCBase drawer.drawValePivots = false; drawer.drawKIBullishPivots = false; drawer.drawKIBearishPivots = false; - drawer.drawPeakSWHResPivots = true; - drawer.drawValeSWLSupPivots = true; + drawer.drawPeakSWHResPivots = false; // true; + drawer.drawValeSWLSupPivots = false; // true; + drawer.drawCycleSameLLPivots = true; + drawer.drawCycleSameHHPivots = true; drawer.drawTKIBullishPivots = false; drawer.drawTKIBearishPivots = false; drawer.drawTrendBullishPivots = false;