From 48c78e12562515a811388e316c8594185d1cbbba Mon Sep 17 00:00:00 2001 From: Hadi Khazaee Asl Date: Mon, 17 Mar 2025 21:42:38 +0330 Subject: [PATCH] complete support and resistance zones ... --- Classes/x-saherelm.x-bar.analyser.class.mq5 | 147 +++++++++++--------- Classes/x-saherelm.x-poi.class.mq5 | 32 ++--- Experts/x-saherelm.xpoi.test.ea.mq5 | 13 +- 3 files changed, 104 insertions(+), 88 deletions(-) diff --git a/Classes/x-saherelm.x-bar.analyser.class.mq5 b/Classes/x-saherelm.x-bar.analyser.class.mq5 index cf0f78ef..6a00c2b2 100644 --- a/Classes/x-saherelm.x-bar.analyser.class.mq5 +++ b/Classes/x-saherelm.x-bar.analyser.class.mq5 @@ -229,7 +229,7 @@ class XCBarAnalyser : public XCBase // bool has = IsValid(type) && - bar.IsValid(); + bar.IsValid(); if (!has) { return result; @@ -1033,22 +1033,12 @@ class XCBarAnalyser : public XCBase } // - int barIndex = bar.Index() + range; - result = IsValidIndex(barIndex); - if (!result) - { - // - supportBar.Clean(); - return result; - } + int supportIDX = bar.Index() + range; result = supportBar.Init( bar.symbol, bar.period, - barIndex // + supportIDX // ); - - // - result = supportBar.low < supportBar.GetDown(); if (!result) { // @@ -1057,11 +1047,7 @@ class XCBarAnalyser : public XCBase } // - double selectedValue = supportBar.GetDown(); - - // - int llIDX = bar.FindLowestIndex(range - 1, MODE_LOW); - result = IsValidIndex(llIDX); + result = bar.low > supportBar.low; if (!result) { // @@ -1070,23 +1056,46 @@ class XCBarAnalyser : public XCBase } // - double llValue = iLow( - bar.symbol, - bar.period, - llIDX // - ); - - // - result = llValue >= selectedValue; - if (!result) + // Validate Point ... + for (int i = 1; i < range; i++) { // - supportBar.Clean(); - return result; - } + XOHCL iPBar; + XOHCL iNBar; + bool iHas = false; - // - result = supportBar.IsValid(); + // + iHas = iPBar.Init( + bar.symbol, + bar.period, + supportIDX + i // + ); + result = iHas; + if (!result) + { + break; + } + + // + iHas = iNBar.Init( + bar.symbol, + bar.period, + supportIDX - i // + ); + result = iHas; + if (!result) + { + break; + } + + // + result = supportBar.low < iPBar.low && + supportBar.low < iNBar.low; + if (!result) + { + break; + } + } // return result; @@ -1110,9 +1119,6 @@ class XCBarAnalyser : public XCBase // bool result = false; - // - resistanceBar.Clean(); - // result = bar.IsValid(); if (!result) @@ -1121,22 +1127,12 @@ class XCBarAnalyser : public XCBase } // - int barIndex = bar.Index() + range; - result = IsValidIndex(barIndex); - if (!result) - { - // - resistanceBar.Clean(); - return result; - } + int resistanceIDX = bar.Index() + range; result = resistanceBar.Init( bar.symbol, bar.period, - barIndex // + resistanceIDX // ); - - // - result = resistanceBar.low < resistanceBar.GetDown(); if (!result) { // @@ -1145,11 +1141,7 @@ class XCBarAnalyser : public XCBase } // - double selectedValue = resistanceBar.GetUp(); - - // - int hhIDX = bar.FindHighestIndex(range - 1, MODE_HIGH); - result = IsValidIndex(hhIDX); + result = bar.high < resistanceBar.high; if (!result) { // @@ -1158,23 +1150,46 @@ class XCBarAnalyser : public XCBase } // - double hhValue = iHigh( - bar.symbol, - bar.period, - hhIDX // - ); - - // - result = hhValue >= selectedValue; - if (!result) + // Validate Point ... + for (int i = 1; i < range; i++) { // - resistanceBar.Clean(); - return result; - } + XOHCL iPBar; + XOHCL iNBar; + bool iHas = false; - // - result = resistanceBar.IsValid(); + // + iHas = iPBar.Init( + bar.symbol, + bar.period, + resistanceIDX + i // + ); + result = iHas; + if (!result) + { + break; + } + + // + iHas = iNBar.Init( + bar.symbol, + bar.period, + resistanceIDX - i // + ); + result = iHas; + if (!result) + { + break; + } + + // + result = resistanceBar.high > iPBar.high && + resistanceBar.high > iNBar.high; + if (!result) + { + break; + } + } // return result; diff --git a/Classes/x-saherelm.x-poi.class.mq5 b/Classes/x-saherelm.x-poi.class.mq5 index c9a79133..70937831 100644 --- a/Classes/x-saherelm.x-poi.class.mq5 +++ b/Classes/x-saherelm.x-poi.class.mq5 @@ -832,17 +832,17 @@ class XCPOIDetector : public XCBaseAlert // // Support ... - // DetectSupportZone( - // iBar, - // iEvent // - // ); + DetectSupportZone( + iBar, + iEvent // + ); // // Resistance ... - // DetectResistanceZone( - // iBar, - // iEvent // - // ); + DetectResistanceZone( + iBar, + iEvent // + ); // // Supply ... @@ -1051,10 +1051,10 @@ class XCPOIDetector : public XCBaseAlert // // Support ... - // has = DetectSupportZone( - // iBar, - // iEvent // - // ); + has = DetectSupportZone( + iBar, + iEvent // + ); if (has) { // @@ -1066,10 +1066,10 @@ class XCPOIDetector : public XCBaseAlert // // Resistance ... - // has = DetectResistanceZone( - // iBar, - // iEvent // - // ); + has = DetectResistanceZone( + iBar, + iEvent // + ); if (has) { // diff --git a/Experts/x-saherelm.xpoi.test.ea.mq5 b/Experts/x-saherelm.xpoi.test.ea.mq5 index e158a2c1..ef4ee3fb 100644 --- a/Experts/x-saherelm.xpoi.test.ea.mq5 +++ b/Experts/x-saherelm.xpoi.test.ea.mq5 @@ -344,10 +344,10 @@ void DetectPOIState() // Bullish ... showBullishPOIs && true, // SwingLows showBullishPOIs && true, // DemandZones - showBullishPOIs && true, // SupportZones + showBullishPOIs && false, // SupportZones showBullishPOIs && true, // BullishSharps showBullishPOIs && true, // BullishSpikes - showBullishPOIs && false, // BullishPullbacks + showBullishPOIs && true, // BullishPullbacks showBullishPOIs && true, // BullishMomentums showBullishPOIs && true, // BullishRejections showBullishPOIs && true, // BullishOrderBlocks @@ -357,10 +357,10 @@ void DetectPOIState() // Bearish ... showBearishPOIs && true, // SwingHighs showBearishPOIs && true, // SupplyZones - showBearishPOIs && true, // ResistanceZones + showBearishPOIs && false, // ResistanceZones showBearishPOIs && true, // BearishSharps showBearishPOIs && true, // BearishSpikes - showBearishPOIs && false, // BearishPullbacks + showBearishPOIs && true, // BearishPullbacks showBearishPOIs && true, // BearishMomentums showBearishPOIs && true, // BearishRejections showBearishPOIs && true, // BearishOrderBlocks @@ -369,9 +369,10 @@ void DetectPOIState() ); // - if (poiEventNotifier.hasNewPullback) + if (poiEventNotifier.hasNewSupportZone || + poiEventNotifier.hasNewResistanceZone) { - Print("Pullback ..."); + Print("Support/Resistance ..."); } //