From c013e593adffeef0a46440691d86a078dae10013 Mon Sep 17 00:00:00 2001 From: Hadi Khazaee Asl Date: Thu, 8 May 2025 13:07:25 +0330 Subject: [PATCH] last ... --- .vscode/vscode-kanban.json | 9 ++ Classes/x-saherelm.x-bar.analyser.class.mq5 | 163 ++++++++++++++++++++ Experts/x-saherelm.xcaea.ea.mq5 | 24 +-- XCAEA/Libraries/xcaea.signaller.lib.mq5 | 25 ++- XCAEA/Signals/xcaea.signaller.class.mq5 | 45 +++--- 5 files changed, 233 insertions(+), 33 deletions(-) diff --git a/.vscode/vscode-kanban.json b/.vscode/vscode-kanban.json index e401c6ed..d05ea05b 100644 --- a/.vscode/vscode-kanban.json +++ b/.vscode/vscode-kanban.json @@ -34,6 +34,15 @@ "id": "2", "references": [], "title": "Add Support for Daily Max Volume and Ticks Box in XCAEA POI Detector ..." + }, + { + "assignedTo": { + "name": "Hadi Khazaee Asl" + }, + "creation_time": "2025-05-07T22:57:51.059Z", + "id": "3", + "references": [], + "title": "add support for Block Detection in Bar Analyser Class" } ], "done": [] diff --git a/Classes/x-saherelm.x-bar.analyser.class.mq5 b/Classes/x-saherelm.x-bar.analyser.class.mq5 index 60e6d162..20088256 100644 --- a/Classes/x-saherelm.x-bar.analyser.class.mq5 +++ b/Classes/x-saherelm.x-bar.analyser.class.mq5 @@ -1868,6 +1868,169 @@ class XCBarAnalyser : public XCBase return result; } + /** + * Check a Bar is End of an OrderBlock Bar or Not ... + * + * @param bar: XOHCL ... + * @param box: XBoxZone ... + * @param forceFVGBarType: bool, Force all Bars must be Same as Direction ... + * @param forceOBTwoBar: bool, Force Two Bars of OB Start must be InDirection ... + * + * @return ( bool ) + */ + bool IsOrderBlock( + XOHCL &bar, + XBoxZone &box, + bool forceFVGBarType = false, + bool forceOBTwoBar = false // + ) + { + // + bool result = false; + + // + box.Clean(); + + // + result = bar.IsValid(); + if (!result) + { + return result; + } + + // + // Check Bar Must be FVG ... + result = IsFVG( + bar, + box, + forceFVGBarType // + ); + if (!result) + { + // + box.Clean(); + + // + return result; + } + + // + box.type = "XOB"; + + // + bool isBullish = box.IsBullish(); + bool isBearish = box.IsBearish(); + + // + // Order Block Includes an FVG which Starts by atleast One + // or More Indirectional Bars ... + XOHCL fvgLastBar; + XOHCL fvgLastBarPrev; + + // + int barIndex = bar.Index(); + int fvgLastBarIndex = barIndex + 3; + result = fvgLastBar.Init( + bar.symbol, + bar.period, + fvgLastBarIndex // + ); + result = + result && + fvgLastBar.GetPreviousBar(fvgLastBarPrev); + if (!result) + { + // + box.Clean(); + fvgLastBar.Clean(); + fvgLastBarPrev.Clean(); + + // + return result; + } + + // + // Check FVG Last Bar ... + + // + bool isBullishBlock = + isBullish && + fvgLastBar.IsBearish(); + + // + bool isBearishBlock = + isBearish && + fvgLastBar.IsBullish(); + + // + // Update Box ... + + // + if (isBullishBlock || + isBearishBlock) + { + // + box.from = fvgLastBar.time; + + // + box.lower = MathMin(box.lower, fvgLastBar.low); + box.upper = MathMax(box.upper, fvgLastBar.high); + } + + // + // Apply Force Two Bar ... + if (forceOBTwoBar) + { + // + isBullishBlock = + isBullishBlock && + fvgLastBarPrev.IsBearish(); + + // + isBearishBlock = + isBearishBlock && + fvgLastBarPrev.IsBullish(); + + // + // Update Box ... + if (isBullishBlock || + isBearishBlock) + { + // + box.from = fvgLastBarPrev.time; + box.lower = MathMin(box.lower, fvgLastBarPrev.low); + box.upper = MathMax(box.upper, fvgLastBarPrev.high); + } + } + + // + result = isBullishBlock || + isBearishBlock; + if (!result) + { + // + box.Clean(); + fvgLastBar.Clean(); + fvgLastBarPrev.Clean(); + + // + return result; + } + + // + result = box.IsValid(); + + // + // Cleanup Resources ... + + // + fvgLastBar.Clean(); + fvgLastBarPrev.Clean(); + + // + return result; + } + // // Candlestick ... diff --git a/Experts/x-saherelm.xcaea.ea.mq5 b/Experts/x-saherelm.xcaea.ea.mq5 index 15bef723..31da2706 100644 --- a/Experts/x-saherelm.xcaea.ea.mq5 +++ b/Experts/x-saherelm.xcaea.ea.mq5 @@ -63,6 +63,7 @@ input string eaSessionEndTime = ""; // Trade End Time input int eaMaxAllowedPositions = 5; // Max Allowed Same Time Trades input double eaMaxAllowedSpread = 25; // Max Allowed Spread For Trade input double eaMaxAllowedDrawdownFactor = 0.3; // Max Allowed DrawDown for Trade +input string eaCloseAllOpenTradesAt = ""; // Close All Open Trades per Day At Specified Time // // Alert ... @@ -182,12 +183,6 @@ void OnTick() int count = 0; bool has = false; - // - if (eaTimeTracker.IsNewDay()) - { - eaTradeManager.HandleNewDay(); - } - // HandleTimeReport(); @@ -715,14 +710,23 @@ void HandleTimeReport() // // Daily Report .... - if (eaReportNewDays && - eaTimeTracker.IsNewDay()) + bool isNewDay = eaTimeTracker.IsNewDay(); + if (isNewDay) { // - string msg = "New Day ..."; + // Handle New Day on Trade Manager ... + eaTradeManager.HandleNewDay(); // - eaAlert.Alert(msg); + // Reporting New Day if Reuired ... + if (eaReportNewDays) + { + // + string msg = "New Day ..."; + + // + eaAlert.Alert(msg); + } } // diff --git a/XCAEA/Libraries/xcaea.signaller.lib.mq5 b/XCAEA/Libraries/xcaea.signaller.lib.mq5 index b1594009..a398c875 100644 --- a/XCAEA/Libraries/xcaea.signaller.lib.mq5 +++ b/XCAEA/Libraries/xcaea.signaller.lib.mq5 @@ -81,7 +81,7 @@ struct XCAEAStrategyConditions // double partialCloseOnTPLevel; - double partialCloseMultiplier; + double partialCloseMultiplier; // ENUM_X_DIRECTION dir; @@ -124,7 +124,7 @@ struct XCAEAStrategyConditions // partialCloseOnTPLevel = 0; - partialCloseMultiplier = 0; + partialCloseMultiplier = 0; // Clean(targets); @@ -578,6 +578,24 @@ bool DetectDecisionZone( // bool isVolumeNeutural = MathAbs(bullishVolume - bearishVolume) == 0; + // + // Checking OB ... + XBoxZone ob; + bool isOB = helper + .barAnalyser + .IsOrderBlock( + cBar, + ob, + false, // Force FVG Bar Type + true // Force Two Bar Start ... + ); + bool isBullishOB = + isOB && + ob.IsBullish(); + bool isBearishOB = + isOB && + ob.IsBearish(); + // // Reading Values ... @@ -1074,6 +1092,7 @@ bool DetectDecisionZone( // bool isCond1Bullish = + isBullishOB && isCIsValePivot && isRSICrossedOverOS && !isFiboSectionChanged && @@ -1081,6 +1100,7 @@ bool DetectDecisionZone( // bool isCond1Bearish = + isBearishOB && isCIsPeakPivot && isRSICrossedUnderOB && !isFiboSectionChanged && @@ -1234,6 +1254,7 @@ bool DetectDecisionZone( // Cleaning Up ... // + ob.Clean(); zBar.Clean(); cBar.Clean(); pBar.Clean(); diff --git a/XCAEA/Signals/xcaea.signaller.class.mq5 b/XCAEA/Signals/xcaea.signaller.class.mq5 index b7d41ea0..fdb9cb61 100644 --- a/XCAEA/Signals/xcaea.signaller.class.mq5 +++ b/XCAEA/Signals/xcaea.signaller.class.mq5 @@ -121,28 +121,28 @@ class XCXCAEASignaller : XCBase inputs.x3maInputs.fastLength = 5; // - inputs.x3maInputs.showFast = true; - inputs.x3maInputs.showSlow = true; - inputs.x3maInputs.showMedium = true; + inputs.x3maInputs.showFast = false; + inputs.x3maInputs.showSlow = false; + inputs.x3maInputs.showMedium = false; // - inputs.caInputs.showMAH = true; - inputs.caInputs.showMAL = true; - inputs.caInputs.showMAC = true; - inputs.caInputs.showSar = true; + inputs.caInputs.showMAH = false; + inputs.caInputs.showMAL = false; + inputs.caInputs.showMAC = false; + inputs.caInputs.showSar = false; inputs.caInputs.showSwings = true; - inputs.caInputs.showFiboLevel1 = true; - inputs.caInputs.showFiboLevel2 = true; - inputs.caInputs.showFiboLevel3 = true; - inputs.caInputs.showFiboLevel4 = true; - inputs.caInputs.showFiboLevel5 = true; + inputs.caInputs.showFiboLevel1 = false; + inputs.caInputs.showFiboLevel2 = false; + inputs.caInputs.showFiboLevel3 = false; + inputs.caInputs.showFiboLevel4 = false; + inputs.caInputs.showFiboLevel5 = false; inputs.caInputs.showPeaksAndVales = true; // - inputs.caInputs.showKI = true; - inputs.caInputs.showTKI = true; - inputs.caInputs.showVidya = true; - inputs.caInputs.showTrend = true; + inputs.caInputs.showKI = false; + inputs.caInputs.showTKI = false; + inputs.caInputs.showVidya = false; + inputs.caInputs.showTrend = false; inputs.caInputs.showPeakAndValeGolden = false; inputs.caInputs.showSupportAndResistance = false; @@ -159,7 +159,7 @@ class XCXCAEASignaller : XCBase // // Oscillators Views ... - inputs.showRSI = true; + inputs.showRSI = false; inputs.showCCI = false; inputs.showMFI = false; inputs.showRVI = false; @@ -629,7 +629,7 @@ class XCXCAEASignaller : XCBase // // Checking Trigger Cond 2 ... - bool canTriggerCond2 = false; + bool canTriggerCond2 = false; // CanTriggerCond2( // helper, // conditions.decisionZone, @@ -693,7 +693,10 @@ class XCXCAEASignaller : XCBase } // - double risk = MathAbs(entry - sl); + double spred = GetSpread(conditions.symbol); + + // + double risk = MathAbs(entry - sl) + spred; double reward = (risk * conditions.reward); tp = isBullish @@ -725,8 +728,8 @@ class XCXCAEASignaller : XCBase // // Handling Partial Close ... - conditions.partialCloseOnTPLevel = 1; - conditions.partialCloseMultiplier = 0.5; + // conditions.partialCloseOnTPLevel = 1; + // conditions.partialCloseMultiplier = 0.5; // conditions.sl = sl;