From ad945b90b2a2601db2889ef746ebf09c4e9174a9 Mon Sep 17 00:00:00 2001 From: Hadi Khazaee Asl Date: Wed, 31 Dec 2025 13:49:57 +0330 Subject: [PATCH] last ... --- Classes/x-saherelm.x-market.pattern.class.mq5 | 4 +- .../BKP/X121XKI}/x-saherelm.x121.xki.ea.mq5 | 0 .../x-saherelm.x121xki.expert.class.mq5 | 0 Libraries/x-saherelm.x-poi.lib.mq5 | 53 ++++++ .../x-saherelm.x121.xki.signaller.class.mq5 | 159 +++++++++++++++++- ...saherelm.x121.xki.x-poi.detector.class.mq5 | 2 +- compile.cmd | 3 +- package.json | 3 +- prepareX121XKIEA.js | 29 ++++ 9 files changed, 246 insertions(+), 7 deletions(-) rename {Experts => Documents/BKP/X121XKI}/x-saherelm.x121.xki.ea.mq5 (100%) rename {X121XKIEA/Classes => Documents/BKP/X121XKI}/x-saherelm.x121xki.expert.class.mq5 (100%) create mode 100644 prepareX121XKIEA.js diff --git a/Classes/x-saherelm.x-market.pattern.class.mq5 b/Classes/x-saherelm.x-market.pattern.class.mq5 index 321b2975..07cf9999 100644 --- a/Classes/x-saherelm.x-market.pattern.class.mq5 +++ b/Classes/x-saherelm.x-market.pattern.class.mq5 @@ -4332,14 +4332,14 @@ class XCMarketPatternDetector : public XCBase bool containsFVGs = true, bool containsSupports = true, bool containsResistancess = true, + int loopback = 500, ENUM_X_DIRECTION forDir = X_DIRECTION_NONE, ENUM_X_SORT_BY sortBy = X_SORT_BY_DATE, ENUM_X_DIRECTION sortDir = X_DIRECTION_BEARISH, double zonesRangeValidationFactor = 10, int zonesLoopback = 5, int zonesValidationLength = 5, - int count = 0, - int loopback = 500 // + int count = 0 // ) { // diff --git a/Experts/x-saherelm.x121.xki.ea.mq5 b/Documents/BKP/X121XKI/x-saherelm.x121.xki.ea.mq5 similarity index 100% rename from Experts/x-saherelm.x121.xki.ea.mq5 rename to Documents/BKP/X121XKI/x-saherelm.x121.xki.ea.mq5 diff --git a/X121XKIEA/Classes/x-saherelm.x121xki.expert.class.mq5 b/Documents/BKP/X121XKI/x-saherelm.x121xki.expert.class.mq5 similarity index 100% rename from X121XKIEA/Classes/x-saherelm.x121xki.expert.class.mq5 rename to Documents/BKP/X121XKI/x-saherelm.x121xki.expert.class.mq5 diff --git a/Libraries/x-saherelm.x-poi.lib.mq5 b/Libraries/x-saherelm.x-poi.lib.mq5 index 7034401c..080fae90 100644 --- a/Libraries/x-saherelm.x-poi.lib.mq5 +++ b/Libraries/x-saherelm.x-poi.lib.mq5 @@ -1104,6 +1104,59 @@ struct XBoxZone ZeroMemory(this); } + bool Init( + string _symbol, + ENUM_TIMEFRAMES _period, + double _upper, + double _lower, + datetime _from, + datetime _to, + ENUM_X_DIRECTION _dir, + string _type = "", + datetime _at = NULL // + ) + { + // + bool result = false; + + // + // Validate ... + result = IsXValid(_symbol) && + IsXValid(_period) && + _upper > 0 && + _lower > 0 && + _upper > _lower && + IsXValid(_from) && + IsXValid(_to) && + _from < _to && + HasDirection(_dir); + if (!result) + { + return result; + } + + // + this.to = _to; + this.at = _at; + this.dir = _dir; + this.from = _from; + this.type = _type; + this.lower = _lower; + this.upper = _upper; + this.symbol = _symbol; + this.period = _period; + + // + result = IsValid(); + if (!result) + { + Clean(); + } + + // + return result; + } + /** * Clean Special Props ... */ diff --git a/X121XKIEA/Classes/x-saherelm.x121.xki.signaller.class.mq5 b/X121XKIEA/Classes/x-saherelm.x121.xki.signaller.class.mq5 index 3089ca8b..d0684b19 100644 --- a/X121XKIEA/Classes/x-saherelm.x121.xki.signaller.class.mq5 +++ b/X121XKIEA/Classes/x-saherelm.x121.xki.signaller.class.mq5 @@ -923,10 +923,165 @@ class XCX121XKIStrategy1Signaller : public XCX121XKIBaseSignaller } // - DebugBreak(); + // Detect Nearest Directional ... + int nearestDirectionalSwitchIndex = -1; + if (isBullish) + { + // + isBullish = poiDetector.NearestKIFastSwitchedToBullish( + nearestDirectionalSwitchIndex, + bar.Index() + 2 // + ); + } + else + { + // + isBearish = poiDetector.NearestKIFastSwitchedToBearish( + nearestDirectionalSwitchIndex, + bar.Index() + 2 // + ); + } + result = + IsValidIndex(nearestDirectionalSwitchIndex) && + (isBullish || + isBearish); + if (!result) + { + // + bar.Clean(); + return result; + } + + // + // Preparing Zone ... + double upper = bar.FindHighest(nearestDirectionalSwitchIndex - bar.Index(), MODE_HIGH); + double lower = bar.FindLowest(nearestDirectionalSwitchIndex - bar.Index(), MODE_LOW); + + // + result = zone.Init( + symbol, + period, + upper, + lower, + GetBarTime(symbol, period, nearestDirectionalSwitchIndex), + bar.time, + dir, + "XKI1" // + ); + + // + // Support and Resistance ... + XBoxZone support; + XBoxZone resistance; + if (result) + { + // + XOHCL tmpBar; + int tmpIDX = -1; + bool has = false; + double upper = 0; + double lower = 0; + int length = zone.GetAge(); + + // + // Support ... + tmpIDX = bar.FindLowestIndex(length, MODE_LOW); + if (IsValidIndex(tmpIDX)) + { + // + if (tmpBar.Init(symbol, period, tmpIDX)) + { + // + lower = iLow(symbol, period, tmpIDX); + upper = bar.FindLowest(length, MODE_CLOSE); + if (upper <= lower) + { + upper = tmpBar.GetDown(); + } + + // + has = support.Init( + symbol, + period, + upper, + lower, + tmpBar.time, + bar.time, + X_DIRECTION_BULLISH, + X_BAR_PATTERN_SUPPORT // + ); + + // + tmpBar.Clean(); + } + } + + // + // Resistance ... + tmpIDX = bar.FindHighestIndex(length, MODE_HIGH); + if (IsValidIndex(tmpIDX)) + { + // + if (tmpBar.Init(symbol, period, tmpIDX)) + { + // + upper = iHigh(symbol, period, tmpIDX); + lower = bar.FindHighest(length, MODE_CLOSE); + if (upper <= lower) + { + upper = tmpBar.GetUp(); + } + + // + has = resistance.Init( + symbol, + period, + upper, + lower, + tmpBar.time, + bar.time, + X_DIRECTION_BEARISH, + X_BAR_PATTERN_RESISTANCE // + ); + + // + tmpBar.Clean(); + } + } + } + + // + // TODO: Rempve ... + if (result) + { + // + // Other Drawing Materials ... + XPOIDrawConfig drawConfig; + drawConfig.Default(); + + // + poiDrawer.DrawZone(zone, drawConfig); + + // + if (support.IsValid()) + { + poiDrawer.DrawZone(support, drawConfig); + } + + // + if (resistance.IsValid()) + { + poiDrawer.DrawZone(resistance, drawConfig); + } + + // + drawConfig.Clean(); + + // + // DebugBreak(); + } // - result = ToBox(bar, zone, dir, X_BAR_PATTERN_SIGNALKEY); result = result && zone.IsValid() && diff --git a/X121XKIEA/Classes/x-saherelm.x121.xki.x-poi.detector.class.mq5 b/X121XKIEA/Classes/x-saherelm.x121.xki.x-poi.detector.class.mq5 index 819cd9e6..35d2ae84 100644 --- a/X121XKIEA/Classes/x-saherelm.x121.xki.x-poi.detector.class.mq5 +++ b/X121XKIEA/Classes/x-saherelm.x121.xki.x-poi.detector.class.mq5 @@ -380,7 +380,7 @@ class XCX121XKIPOIDetector : public XCMarketPatternDetector // return result; - } + } // #endregion // #region Detectors ... diff --git a/compile.cmd b/compile.cmd index 9ccec06c..54ad7371 100644 --- a/compile.cmd +++ b/compile.cmd @@ -1,7 +1,8 @@ @echo off + set METAEDITOR="C:\Program Files\MetaTrader 5\MetaEditor64.exe" @REM set METAEDITOR="C:\Program Files\MetaTrader 5 General\MetaEditor64.exe" - set METAEDITOR="C:\Program Files\MetaTrader 5 Main\MetaEditor64.exe" + @REM set METAEDITOR="C:\Program Files\MetaTrader 5 Main\MetaEditor64.exe" @REM set METAEDITOR="C:\Program Files\MetaTrader 5 General\MetaEditor64.exe" set "LOGFILE=%~dpn1.log" diff --git a/package.json b/package.json index 59448092..259f90d6 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,8 @@ "compileIndicators": "npm run mqlHelper indicators", "repackXFIMAEA": "node prepareXFIMAEA.js", "repackXCATBEA": "node prepareXCATBEA.js", - "repackXOM1EA": "node prepareXOM1EA.js" + "repackXOM1EA": "node prepareXOM1EA.js", + "repackX121XKIEA": "node prepareX121XKIEA.js" }, "repository": { "type": "git", diff --git a/prepareX121XKIEA.js b/prepareX121XKIEA.js new file mode 100644 index 00000000..a147dd58 --- /dev/null +++ b/prepareX121XKIEA.js @@ -0,0 +1,29 @@ +// +// Import Requirements ... +const XProjectTools = require("./x-mql-project.tools"); + +// +// define constants ... +const projectName = "X121XKIEA"; + +// +// Projects Resources ... +const projectResources = [ + "Libraries/*", // Required Libraries + "Classes/*", // Required Classes + "X121XKIEA/*", // X121XKIEA Projects ... + "Indicators/x-saherelm.x121.xki", // Required Indicators + "Helpers/x-saherelm.x121.xki.helper", // Indicator's Helpers Classes + "Experts/x-saherelm.x121.xki.backtester.ea", // Expert Advisers +]; + +// +run(); + +/** + * Main Project Function ... + */ +async function run() { + // + await XProjectTools.prepareProject(projectName, projectResources); +}