From e9a012aa2491cb5a3580b1604edb94a1bf5d18e6 Mon Sep 17 00:00:00 2001 From: Hadi Khazaee Asl Date: Sat, 3 May 2025 22:48:30 +0330 Subject: [PATCH] last ... --- XCAEA/Classes/xcaea.x-poi.detector.class.mq5 | 273 +++++++++++++++++++ XCAEA/Signals/xcaea.signaller.class.mq5 | 4 + 2 files changed, 277 insertions(+) diff --git a/XCAEA/Classes/xcaea.x-poi.detector.class.mq5 b/XCAEA/Classes/xcaea.x-poi.detector.class.mq5 index 46524d71..746e541e 100644 --- a/XCAEA/Classes/xcaea.x-poi.detector.class.mq5 +++ b/XCAEA/Classes/xcaea.x-poi.detector.class.mq5 @@ -628,6 +628,13 @@ class XCXCAEAPOIDetector : public XCBase ticksDividerInPoints = 15; pivotDetectionLoopbac = 100; + // + // PV ... + applySwingsOnPVPivots = false; + selectRejectedPVPivots = false; + selectEngulfedPVPivots = false; + applySupportAndResistanceOnPVPivots = false; + // // PEAK ... detectPeakPivots = false; @@ -950,6 +957,12 @@ class XCXCAEAPOIDetector : public XCBase // // PV ... + // + bool applySwingsOnPVPivots; // Apply Swings on PV Pivots ... + bool selectRejectedPVPivots; // Select Rejected PV Pivots ... + bool selectEngulfedPVPivots; // Select Engulfed PV Pivots ... + bool applySupportAndResistanceOnPVPivots; // Apply Support and Resistance on PV Pivots ... + // void ValidatePeakVales( XBoxZone &unavailables[], @@ -1083,6 +1096,72 @@ class XCXCAEAPOIDetector : public XCBase double pValeGolden = conditions.valeGoldenBuffer[pIDX]; double p2ValeGolden = conditions.valeGoldenBuffer[p2IDX]; + // + // SWING High .. + double zSwingHigh = conditions.swingHighBuffer[zIDX]; + double cSwingHigh = conditions.swingHighBuffer[cIDX]; + double pSwingHigh = conditions.swingHighBuffer[pIDX]; + double p2SwingHigh = conditions.swingHighBuffer[p2IDX]; + + // + // SWING Low ... + double zSwingLow = conditions.swingLowBuffer[zIDX]; + double cSwingLow = conditions.swingLowBuffer[cIDX]; + double pSwingLow = conditions.swingLowBuffer[pIDX]; + double p2SwingLow = conditions.swingLowBuffer[p2IDX]; + + // + // SUPPORT ... + double zSupport = conditions.supportBuffer[zIDX]; + double cSupport = conditions.supportBuffer[cIDX]; + double pSupport = conditions.supportBuffer[pIDX]; + double p2Support = conditions.supportBuffer[p2IDX]; + + // + // RESISTANCE ... + double zResistance = conditions.resistanceBuffer[zIDX]; + double cResistance = conditions.resistanceBuffer[cIDX]; + double pResistance = conditions.resistanceBuffer[pIDX]; + double p2Resistance = conditions.resistanceBuffer[p2IDX]; + + // + // Detecting Bar Conditions ... + + // + ENUM_X_DIRECTION cBarDir; + + // + // Rejected ... + bool isCBarRejected = helper + .barAnalyser + .IsRejected( + cBar, + cBarDir, + false, // Force Type ... + true // Force Fibo Pressure ... + ); + bool isCBarBullishRejected = + isCBarRejected && + IsBullish(cBarDir); + bool isCBarBearishRejected = + isCBarRejected && + IsBearish(cBarDir); + + // + // Engulfed ... + bool isCBarEngulfed = helper + .barAnalyser + .IsEngulfed( + cBar, + cBarDir // + ); + bool isCBarBullishEngulfed = + isCBarEngulfed && + IsBullish(cBarDir); + bool isCBarBearishEngulfed = + isCBarEngulfed && + IsBearish(cBarDir); + // // Prepare Conditinal Conditions ... @@ -1090,6 +1169,38 @@ class XCXCAEAPOIDetector : public XCBase bool isPeakSameLast = cPeak == pPeak; bool isPeakSameLastPrev = pPeak == p2Peak; + // + if (applySwingsOnPVPivots) + { + // + isPeakSameLast = + isPeakSameLast && + cSwingHigh == cPeak && + cSwingHigh == pSwingHigh; + + // + isPeakSameLastPrev = + isPeakSameLastPrev && + pSwingHigh == pPeak && + pSwingHigh == p2SwingHigh; + } + + // + if (applySupportAndResistanceOnPVPivots) + { + // + isPeakSameLast = + isPeakSameLast && + cResistance == cPeak && + cResistance == pResistance; + + // + isPeakSameLastPrev = + isPeakSameLastPrev && + pResistance == pPeak && + pResistance == p2Resistance; + } + // bool isPeakSwitchedToSameLast = isPeakSameLast && !isPeakSameLastPrev; @@ -1102,6 +1213,38 @@ class XCXCAEAPOIDetector : public XCBase bool isTypeZeroStart = isPeakFinishedFromSameLast; bool isTypeZeroContinue = isPeakSameLast; bool isTypeZeroFinished = isPeakSwitchedToSameLast; + if (isTypeZeroFinished) + { + // + bool hasSelectionType = selectRejectedPVPivots || + selectEngulfedPVPivots; + + // + bool isPVRejected = + isCBarBearishRejected && + selectRejectedPVPivots; + + // + bool isPVEngulfed = + isCBarBearishEngulfed && + selectEngulfedPVPivots; + + // + bool isBarPassed = + !hasSelectionType + ? true + : isPVRejected || + isPVEngulfed; + + // + isTypeZeroFinished = + isBarPassed && + isTypeZeroFinished; + if (!isTypeZeroFinished) + { + peakPivot.Clean(); + } + } // // Summarizing Conditions ... @@ -1290,6 +1433,72 @@ class XCXCAEAPOIDetector : public XCBase double pValeGolden = conditions.valeGoldenBuffer[pIDX]; double p2ValeGolden = conditions.valeGoldenBuffer[p2IDX]; + // + // SWING High .. + double zSwingHigh = conditions.swingHighBuffer[zIDX]; + double cSwingHigh = conditions.swingHighBuffer[cIDX]; + double pSwingHigh = conditions.swingHighBuffer[pIDX]; + double p2SwingHigh = conditions.swingHighBuffer[p2IDX]; + + // + // SWING Low ... + double zSwingLow = conditions.swingLowBuffer[zIDX]; + double cSwingLow = conditions.swingLowBuffer[cIDX]; + double pSwingLow = conditions.swingLowBuffer[pIDX]; + double p2SwingLow = conditions.swingLowBuffer[p2IDX]; + + // + // SUPPORT ... + double zSupport = conditions.supportBuffer[zIDX]; + double cSupport = conditions.supportBuffer[cIDX]; + double pSupport = conditions.supportBuffer[pIDX]; + double p2Support = conditions.supportBuffer[p2IDX]; + + // + // RESISTANCE ... + double zResistance = conditions.resistanceBuffer[zIDX]; + double cResistance = conditions.resistanceBuffer[cIDX]; + double pResistance = conditions.resistanceBuffer[pIDX]; + double p2Resistance = conditions.resistanceBuffer[p2IDX]; + + // + // Detecting Bar Conditions ... + + // + ENUM_X_DIRECTION cBarDir; + + // + // Rejected ... + bool isCBarRejected = helper + .barAnalyser + .IsRejected( + cBar, + cBarDir, + false, // Force Type ... + true // Force Fibo Pressure ... + ); + bool isCBarBullishRejected = + isCBarRejected && + IsBullish(cBarDir); + bool isCBarBearishRejected = + isCBarRejected && + IsBearish(cBarDir); + + // + // Engulfed ... + bool isCBarEngulfed = helper + .barAnalyser + .IsEngulfed( + cBar, + cBarDir // + ); + bool isCBarBullishEngulfed = + isCBarEngulfed && + IsBullish(cBarDir); + bool isCBarBearishEngulfed = + isCBarEngulfed && + IsBearish(cBarDir); + // // Prepare Conditinal Conditions ... @@ -1297,6 +1506,38 @@ class XCXCAEAPOIDetector : public XCBase bool isValeSameLast = cVale == pVale; bool isValeSameLastPrev = pVale == p2Vale; + // + if (applySwingsOnPVPivots) + { + // + isValeSameLast = + isValeSameLast && + cSwingLow == cVale && + cSwingLow == pSwingLow; + + // + isValeSameLastPrev = + isValeSameLastPrev && + pSwingLow == pVale && + pSwingLow == p2SwingLow; + } + + // + if (applySupportAndResistanceOnPVPivots) + { + // + isValeSameLast = + isValeSameLast && + cSupport == cVale && + cSupport == pSupport; + + // + isValeSameLastPrev = + isValeSameLastPrev && + pSupport == pVale && + pSupport == p2Support; + } + // bool isValeSwitchedToSameLast = isValeSameLast && !isValeSameLastPrev; @@ -1309,6 +1550,38 @@ class XCXCAEAPOIDetector : public XCBase bool isTypeZeroStart = isValeFinishedFromSameLast; bool isTypeZeroContinue = isValeSameLast; bool isTypeZeroFinished = isValeSwitchedToSameLast; + if (isTypeZeroFinished) + { + // + bool hasSelectionType = selectRejectedPVPivots || + selectEngulfedPVPivots; + + // + bool isPVRejected = + isCBarBullishRejected && + selectRejectedPVPivots; + + // + bool isPVEngulfed = + isCBarBullishEngulfed && + selectEngulfedPVPivots; + + // + bool isBarPassed = + !hasSelectionType + ? true + : isPVRejected || + isPVEngulfed; + + // + isTypeZeroFinished = + isBarPassed && + isTypeZeroFinished; + if (!isTypeZeroFinished) + { + valePivot.Clean(); + } + } // // Summarizing Conditions ... diff --git a/XCAEA/Signals/xcaea.signaller.class.mq5 b/XCAEA/Signals/xcaea.signaller.class.mq5 index be410006..60799647 100644 --- a/XCAEA/Signals/xcaea.signaller.class.mq5 +++ b/XCAEA/Signals/xcaea.signaller.class.mq5 @@ -885,6 +885,10 @@ class XCXCAEASignaller : XCBase // // PV ... + detector.applySwingsOnPVPivots = true; + detector.selectRejectedPVPivots = true; + detector.selectEngulfedPVPivots = true; + detector.applySupportAndResistanceOnPVPivots = true; // // PEAK ...