From 38573265e8ace19801a49136603379c6d7e1da47 Mon Sep 17 00:00:00 2001 From: Hadi Khazaee Asl Date: Sun, 4 May 2025 11:29:00 +0330 Subject: [PATCH] last ... --- Libraries/x-saherelm.x-poi.lib.mq5 | 74 ++++++++++- XCAEA/Classes/xcaea.x-poi.detector.class.mq5 | 89 +++++++++++++ XCAEA/Libraries/xcaea.signaller.lib.mq5 | 127 +++++++++++++++++++ 3 files changed, 289 insertions(+), 1 deletion(-) diff --git a/Libraries/x-saherelm.x-poi.lib.mq5 b/Libraries/x-saherelm.x-poi.lib.mq5 index 07fd176d..070c3e0a 100644 --- a/Libraries/x-saherelm.x-poi.lib.mq5 +++ b/Libraries/x-saherelm.x-poi.lib.mq5 @@ -5595,7 +5595,7 @@ struct XBoxZone /** * Extract Rejection Price based on Box Direction ... - * + * * @return ( double ) */ double GetRejection() @@ -5654,6 +5654,42 @@ struct XBoxZone return result; } + /** + * Retrieve To Bar ... + * + * @return ( bool ) + */ + bool ToBar(XOHCL &bar) + { + // + bool result = false; + + // + bar.Clean(); + + // + int idx = ToIndex(); + + // + result = + IsValid() && + IsValidIndex(idx); + if (!result) + { + return result; + } + + // + result = bar.Init( + symbol, + period, + idx // + ); + + // + return result; + } + /** * From Bar Index ... * @@ -5689,6 +5725,42 @@ struct XBoxZone return result; } + /** + * Retrieve From Bar ... + * + * @return ( bool ) + */ + bool FromBar(XOHCL &bar) + { + // + bool result = false; + + // + bar.Clean(); + + // + int idx = FromIndex(); + + // + result = + IsValid() && + IsValidIndex(idx); + if (!result) + { + return result; + } + + // + result = bar.Init( + symbol, + period, + idx // + ); + + // + return result; + } + /** * Retrieve Unique Identifier ... * diff --git a/XCAEA/Classes/xcaea.x-poi.detector.class.mq5 b/XCAEA/Classes/xcaea.x-poi.detector.class.mq5 index 83e205cc..b0606933 100644 --- a/XCAEA/Classes/xcaea.x-poi.detector.class.mq5 +++ b/XCAEA/Classes/xcaea.x-poi.detector.class.mq5 @@ -255,6 +255,95 @@ int ExtractPivots( return result; } +// +bool IsFakeBreakeout( + XBoxZone &pivot, + int barIndex = 0 // +) +{ + // + bool result = false; + + // + barIndex = NormalizeInt(barIndex, 0); + + // + result = pivot.IsValid(); + if (!result) + { + return result; + } + + // + int fromIDX = pivot.FromIndex(); + result = barIndex > fromIDX; + if (!result) + { + return result; + } + + // + bool isBullish = pivot.IsBullish(); + + // + // Retrieve Required Bars ... + XOHCL cBar; + XOHCL pBar; + XOHCL p2Bar; + XOHCL p3Bar; + result = cBar.Init( + pivot.symbol, + pivot.period, + barIndex // + ); + result = result && + cBar.GetPreviousBar(pBar); + result = result && + pBar.GetPreviousBar(p2Bar); + result = result && + p2Bar.GetPreviousBar(p3Bar); + if (!result) + { + // + cBar.Clean(); + pBar.Clean(); + p2Bar.Clean(); + p3Bar.Clean(); + + // + return result; + } + + // + double breakPrice = + isBullish + ? pivot.lower + : pivot.upper; + + // + bool isBarInside = + cBar.GetDirection() == pivot.dir && + cBar.GetUp() > breakPrice && + cBar.GetDown() < breakPrice; + + // + result = + // + // Bar Must Inside Pivot ... + isBarInside + // + ; + + // + cBar.Clean(); + pBar.Clean(); + p2Bar.Clean(); + p3Bar.Clean(); + + // + return result; +} + // struct XCAPivot { diff --git a/XCAEA/Libraries/xcaea.signaller.lib.mq5 b/XCAEA/Libraries/xcaea.signaller.lib.mq5 index f10e2c0c..18c08149 100644 --- a/XCAEA/Libraries/xcaea.signaller.lib.mq5 +++ b/XCAEA/Libraries/xcaea.signaller.lib.mq5 @@ -1080,6 +1080,7 @@ bool DetectXCAEAConditions( XBoxZone rejectedPivot; XBoxZone insidePivots[]; int insidePivotsCount = 0; + XBoxZone fakeBreakedPivot; bool isRejectedOnMid = false; bool hasInsidePivots = false; bool hasPivots = HasChild(pivots); @@ -1123,6 +1124,28 @@ bool DetectXCAEAConditions( true // ); Clean(allowedRejectedPivots); + + // + // Select Fake Breakout Box ... + ENUM_XCA_PIVOTS allowedFakeBreakedPivots[] = { + XCA_PEAK, + XCA_VALE, + }; + has = SelectFakeBreakedBox( + allowedFakeBreakedPivots, + fakeBreakedPivot, + pivots, + zBar, + cBar, + pBar, + p2Bar // + ); + Clean(allowedFakeBreakedPivots); + if (has) + { + // + Print("Faked Breaked Box Detected ..."); + } } // @@ -1413,6 +1436,7 @@ bool DetectXCAEAConditions( Clean(insidePivots); pConditions.Clean(); rejectedPivot.Clean(); + fakeBreakedPivot.Clean(); // return result; @@ -1673,6 +1697,109 @@ bool SelectRejectedBox( return result; } +// +bool SelectFakeBreakedBox( + ENUM_XCA_PIVOTS &allowedTypes[], + XBoxZone &box, + XBoxZone &boxes[], + XOHCL &zBar, + XOHCL &cBar, + XOHCL &pBar, + XOHCL &p2Bar // +) +{ + // + bool result = false; + + // + box.Clean(); + + // + // Validate ... + result = + zBar.IsValid() && + cBar.IsValid() && + pBar.IsValid() && + p2Bar.IsValid() && + HasChild(boxes); + if (!result) + { + return result; + } + + // + XBoxZone tmp[]; + Copy( + boxes, + tmp // + ); + + // + int idx = -1; + XBoxZone iBox; + while (HasChild(tmp)) + { + // + idx = GetYoungest(tmp); + result = IsValidIndex(idx); + if (!result) + { + break; + } + + // + iBox = tmp[idx]; + ArrayRemove( + tmp, + idx, + 1 // + ); + + // + // Checking Box Type Allowed ... + ENUM_XCA_PIVOTS iType = GetPivotType(iBox); + result = IsValid(iType) && + (!HasChild(allowedTypes) + ? true + : Contains( + iType, + allowedTypes // + )); + if (!result) + { + // + iBox.Clean(); + continue; + } + + // + // Check Box Fake Breakeout ... + result = IsFakeBreakeout( + iBox, + cBar.Index() // + ); + if (result) + { + // + box = iBox; + break; + } + + // + iBox.Clean(); + } + + // + Clean(tmp); + iBox.Clean(); + + // + result = box.IsValid(); + + // + return result; +} + // int ExtractValues( double &values[],