From cfe873471586cfd4cc0338e1f160703f5eb2646c Mon Sep 17 00:00:00 2001 From: Hadi Khazaee Asl Date: Tue, 14 Oct 2025 12:16:40 +0330 Subject: [PATCH] last ... --- Experts/x-saherelm.xfima.ea.mq5 | 12 +- Helpers/x-saherelm.xfima.helper.mq5 | 217 ++++++++++++++++++ .../x-saherelm.xfima.signaller.class.mq5 | 137 ++++++++++- 3 files changed, 357 insertions(+), 9 deletions(-) diff --git a/Experts/x-saherelm.xfima.ea.mq5 b/Experts/x-saherelm.xfima.ea.mq5 index a455809c..38e1bf2a 100644 --- a/Experts/x-saherelm.xfima.ea.mq5 +++ b/Experts/x-saherelm.xfima.ea.mq5 @@ -59,7 +59,7 @@ input string eaLogSuffix = ""; // Log Suffix // [XFIMA1|EURUSDb|M5||25.0|5|] // [XFIMA1|XAUUSDb|M5|(ST_04:00_08:30),(TL_10:30_12:00),(NY_16:00_20:00)|25.0|5|(XTRADE_RESTRICATION_DAILY,1,0,2,0)] // [XFIMA1|XAUUSDb|M5|(ST_04:00_08:30),(TL_10:30_12:00),(NY_16:00_20:00)|25.0|5|(XTRADE_RESTRICATION_DAILY,3,0,2,0)] -input string eaSymbolConfiguration = "[XFIMA1|EURUSDb|M5||25.0|5|]"; // Symbol Configurations +input string eaSymbolConfiguration = "[XFIMA1|EURUSDb|M15||25.0|5|]"; // Symbol Configurations // // Management ... @@ -418,6 +418,16 @@ void OnSignalTriggered(XSignal &signal) eaExpert.HandleOnSignalTriggered(signal); } +/** + * Trigger OnSignal Executed Event ... + * + * @param signal: XSignal + */ +void OnSignalExecuted(XSignal &signal) +{ + eaExpert.HandleOnSignalExecuted(signal); +} + /** * Handle StopLoss Triggered Positions ... * diff --git a/Helpers/x-saherelm.xfima.helper.mq5 b/Helpers/x-saherelm.xfima.helper.mq5 index ad83452e..84dfe5b3 100644 --- a/Helpers/x-saherelm.xfima.helper.mq5 +++ b/Helpers/x-saherelm.xfima.helper.mq5 @@ -3074,6 +3074,223 @@ class XCXFIMAHelper : public XCBaseHelper return result; } + // + // ZigZag Pivots With Liquidity ... + + /** + * Check ZigZag has Lower Low by Liquidity or Not ... + * + * @param barIndex: int, Specified Bar Index ... + * @param forceBarValidation: bool, Force Bar Price based on Pivot ... + * + * @return ( bool ) + */ + bool HasZigZagLowerLowByLiquidity( + int barIndex = 0, + bool forceBarValidation = false // + ) + { + // + bool result = false; + + // + // Normalize ... + XOHCL bar; + barIndex = NormalizeBarIndex(barIndex); + + // + // Validate ... + result = IsValid() && + bar.Init( + mSymbol, + mPeriod, + barIndex // + ); + if (!result) + { + // + bar.Clean(); + return result; + } + + // + // Extract Pivots ... + XPivot pivots[]; + int count = ExtractZigZagPivots( + pivots, + barIndex, + 10, + 200 // + ); + + // + // Validate Pivots and Nearest Pivot is Low ... + result = IsValidSize(count) && + pivots[0].IsVale(); + if (!result) + { + // + bar.Clean(); + XClean(pivots); + + // + return result; + } + + // + // Extract Directional Pivots ... + XPivot selected[]; + count = ExtractPivots( + selected, + pivots, + X_PIVOT_TYPE_VALE // + ); + result = IsValidSize(count) && + count >= 3; + if (!result) + { + // + bar.Clean(); + XClean(pivots); + XClean(selected); + + // + return result; + } + + // + // Do Calculations ... + result = + // + // Check Pivot ... + selected[0].value < selected[1].value && + // + // Check Liquidity ... + selected[1].value > selected[2].value && + // + // Check Bar Place ... + (!forceBarValidation + ? true + : bar.open > selected[0].value && + bar.close > selected[0].value); + + // + // Cleanup ... + bar.Clean(); + XClean(pivots); + XClean(selected); + + // + return result; + } + + /** + * Check ZigZag has Higher High by Liquidity or Not ... + * + * @param barIndex: int, Specified Bar Index ... + * @param forceBarValidation: bool, Force Bar Price based on Pivot ... + * + * @return ( bool ) + */ + bool HasZigZagHigherHighByLiquidity( + int barIndex = 0, + bool forceBarValidation = false // + ) + { + // + bool result = false; + + // + // Normalize ... + XOHCL bar; + barIndex = NormalizeBarIndex(barIndex); + + // + // Validate ... + result = IsValid() && + bar.Init( + mSymbol, + mPeriod, + barIndex // + ); + if (!result) + { + // + bar.Clean(); + return result; + } + + // + // Extract Pivots ... + XPivot pivots[]; + int count = ExtractZigZagPivots( + pivots, + barIndex, + 10, + 200 // + ); + + // + // Validate Pivots and Nearest Pivot is Low ... + result = IsValidSize(count) && + pivots[0].IsPeak(); + if (!result) + { + // + bar.Clean(); + XClean(pivots); + + // + return result; + } + + // + // Extract Directional Pivots ... + XPivot selected[]; + count = ExtractPivots( + selected, + pivots, + X_PIVOT_TYPE_PEAK // + ); + result = IsValidSize(count) && + count >= 3; + if (!result) + { + // + bar.Clean(); + XClean(pivots); + XClean(selected); + + // + return result; + } + + // + // Do Calculations ... + result = + // + // Check Pivot ... + selected[0].value > selected[1].value && + // + // Check Liquidity ... + selected[1].value < selected[2].value && + // + // Check Bar Place ... + (!forceBarValidation + ? true + : bar.open < selected[0].value && + bar.close < selected[0].value); + + // + // Cleanup ... + bar.Clean(); + XClean(pivots); + XClean(selected); + + // + return result; + } + // // Extractions ... diff --git a/XFIMAEA/Classes/x-saherelm.xfima.signaller.class.mq5 b/XFIMAEA/Classes/x-saherelm.xfima.signaller.class.mq5 index d4179e41..bdf16d64 100644 --- a/XFIMAEA/Classes/x-saherelm.xfima.signaller.class.mq5 +++ b/XFIMAEA/Classes/x-saherelm.xfima.signaller.class.mq5 @@ -372,11 +372,11 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller structureConfig, barIndex // ); - // poiDrawer.drawnObjects.Clear(); - // poiDrawer.DrawMarketStructure( - // structure, - // structureDrawConfig // - // ); + poiDrawer.drawnObjects.Clear(); + poiDrawer.DrawMarketStructure( + structure, + structureDrawConfig // + ); // // Strategy 1 ... @@ -395,7 +395,22 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller if (!has) { // - has = Strategy2HasSignal( + // has = Strategy2HasSignal( + // iBar, + // iZone, + // iTargets, + // iDir, + // iFIMAConditions, + // structure // + // ); + } + + // + // Strategy 3 ... + if (!has) + { + // + has = Strategy3HasSignal( iBar, iZone, iTargets, @@ -406,7 +421,17 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller } // - has = HasDirection(iDir); + has = HasDirection(iDir) && + iZone.IsValid(); + if (has) + { + // + has = false; + iZone.Clean(); + iDir = X_DIRECTION_NONE; + } + + // if (has) { // @@ -848,7 +873,7 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller } /** - * Check Bar Has Signal Based on Strategy 1 ... + * Check Bar Has Signal Based on Strategy 2 ... * * @param bar: XOHCL, reference to Bar ... * @param zone: XBoxZone, reference to holds affected zone ... @@ -1165,6 +1190,102 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller return result; } + /** + * Check Bar Has Signal Based on Strategy 3 ... + * + * @param bar: XOHCL, reference to Bar ... + * @param zone: XBoxZone, reference to holds affected zone ... + * @param targets: XTarget, reference to detected Signal's Targets collections ... + * @param dir: ENUM_X_DIRECTION, detected Signal's direction ... + * @param conditions: XFIMAConditions, reference to Bar Specified XFIMA Conditions ... + * @param structure: XFIMAMarketStructure, refrence to Provides Market Structure ... + * + * @return ( bool ) + */ + bool Strategy3HasSignal( + XOHCL &bar, + XBoxZone &zone, + XTarget &targets[], + ENUM_X_DIRECTION &dir, + XFIMAConditions &conditions, + XFIMAMarketStructure &_structure // + ) + { + // + bool result = false; + + // + // Prepare ... + zone.Clean(); + XClean(targets); + dir = X_DIRECTION_NONE; + + // + // Validate ... + result = bar.IsValid(); + if (!result) + { + return result; + } + + // + // Define Requirements ... + bool isBullish = false; + bool isBearish = false; + int barIndex = bar.Index(); + + // + // Do Conditions Checking ... + + // + result = fimaHelper.HasMACross( + dir, + barIndex, + structureConfig.maCrossValidationDiffMultiplier // + ); + isBullish = + result && + IsXBullish(dir); + isBearish = + result && + IsXBearish(dir); + + // + result = isBullish || + isBearish; + + // + // Prepare Zone ... + if (result) + { + // + // Zone Detection ... + + // + result = zone.IsValid(); + } + + // + // Prepare Targets ... + if (result) + { + // + // Target Handling ... + } + + // + if (!result) + { + // + zone.Clean(); + XClean(targets); + dir = X_DIRECTION_NONE; + } + + // + return result; + } + // };