From 168f2c58d1b8f96aaebeba2fc9bd1f4ab6efbee5 Mon Sep 17 00:00:00 2001 From: Hadi Khazaee Asl Date: Tue, 22 Apr 2025 13:07:47 +0330 Subject: [PATCH] last ... --- Helpers/x-saherelm.x121.helper.mq5 | 12 - Helpers/x-saherelm.x121.xvolume.helper.mq5 | 2 +- Libraries/x-saherelm.x-poi.lib.mq5 | 10 +- XCAEA/Classes/xcaea.x-poi.detector.class.mq5 | 399 +++++++++++++++++-- XCAEA/Classes/xcaea.x-poi.drawer.class.mq5 | 64 ++- XCAEA/Libraries/xcaea.signaller.lib.mq5 | 1 + XCAEA/Signals/xcaea.signaller.class.mq5 | 4 + 7 files changed, 437 insertions(+), 55 deletions(-) diff --git a/Helpers/x-saherelm.x121.helper.mq5 b/Helpers/x-saherelm.x121.helper.mq5 index bbc7514e..a8b644de 100644 --- a/Helpers/x-saherelm.x121.helper.mq5 +++ b/Helpers/x-saherelm.x121.helper.mq5 @@ -2792,12 +2792,6 @@ class XCX121Helper : public XCBase conditions.strBuffer // ); - // - Copy( - xstrConditions.strMidBuffer, - conditions.strMidBuffer // - ); - // Copy( xstrConditions.strUpBuffer, @@ -2834,12 +2828,6 @@ class XCX121Helper : public XCBase conditions.strSMHighBuffer // ); - // - Copy( - xstrConditions.strMidStateBuffer, - conditions.strMidStateBuffer // - ); - // // Conditions ... diff --git a/Helpers/x-saherelm.x121.xvolume.helper.mq5 b/Helpers/x-saherelm.x121.xvolume.helper.mq5 index 582a6e29..4fc0c242 100644 --- a/Helpers/x-saherelm.x121.xvolume.helper.mq5 +++ b/Helpers/x-saherelm.x121.xvolume.helper.mq5 @@ -1077,7 +1077,7 @@ class XCX121XVOLUMEHelper : public XCBaseHelper { // // Buffers ... - if (barInex < 0) { + if (barIndex < 0) { barIndex = 0; } diff --git a/Libraries/x-saherelm.x-poi.lib.mq5 b/Libraries/x-saherelm.x-poi.lib.mq5 index bf8b28f4..d2fc14cb 100644 --- a/Libraries/x-saherelm.x-poi.lib.mq5 +++ b/Libraries/x-saherelm.x-poi.lib.mq5 @@ -4657,8 +4657,8 @@ class XCTicksZone : public XCTwoBarZone // Calculate Start and End Time ... datetime from = startBar.time; datetime to = endBar.time; - ulong fromM = ((ulong)startBar.time * 1000); - ulong toM = ((ulong)endBar.time * 1000); + ulong fromM = ((ulong)to * 1000); + ulong toM = ((ulong)from * 1000); // // Symbol and Period ... @@ -4672,7 +4672,7 @@ class XCTicksZone : public XCTwoBarZone // // Retrieve Ticks between Times ... SpecificClean(mTicks); - CopyTicksRange( + int res = CopyTicksRange( symbol, mTicks, COPY_TICKS_ALL, @@ -4826,8 +4826,8 @@ class XCTicksZone : public XCTwoBarZone mType = X_POI_TICKS_ZONES; mEndBar = endBar; mStartBar = startBar; - From(startBar.time); - To(endBar.time); + From(endBar.time); + To(startBar.time); // result = IsValid(); diff --git a/XCAEA/Classes/xcaea.x-poi.detector.class.mq5 b/XCAEA/Classes/xcaea.x-poi.detector.class.mq5 index 7de5b8e0..17c8b1c7 100644 --- a/XCAEA/Classes/xcaea.x-poi.detector.class.mq5 +++ b/XCAEA/Classes/xcaea.x-poi.detector.class.mq5 @@ -13,6 +13,7 @@ ////////////////////////////////////////////////////// // // Global Properties ... +#property library #property copyright "Copyright 2023, SaherElm IT Center" #property link "https://saherelm.ir" #property version "1.00" @@ -469,17 +470,17 @@ struct XCAPivot }; // -struct XCAPVFVG +struct XCAPVPivot { // // Props ... double value; - XCAPivot fvgs[]; + XCAPivot pivots[]; ENUM_X_DIRECTION dir; // // Constructor ... - XCAPVFVG() + XCAPVPivot() { Clean(); } @@ -492,7 +493,7 @@ struct XCAPVFVG { // value = 0; - Clean(fvgs); + Clean(pivots); dir = X_DIRECTION_NONE; // @@ -514,7 +515,7 @@ struct XCAPVFVG } // - void AddFVG(XCAPivot &pivot) + void AddPivot(XCAPivot &pivot) { // if (!IsValid() || @@ -528,7 +529,7 @@ struct XCAPVFVG bool has = FindPivotIndex( idx, pivot, - fvgs // + pivots // ); if (has) { @@ -538,43 +539,43 @@ struct XCAPVFVG // AddRef( pivot, - fvgs // + pivots // ); } // - int GetFVGs(XBoxZone &fvgBoxes[]) + int GetPivots(XBoxZone &pivotBoxes[]) { // int result = 0; // - Clean(fvgBoxes); + Clean(pivotBoxes); // bool has = false; // has = IsValid() && - HasChild(fvgs); + HasChild(pivots); if (!has) { return result; } // - int count = ArraySize(fvgs); + int count = ArraySize(pivots); for (int i = 0; i < count; i++) { // XBoxZone iBox; - has = fvgs[i].AsBox(iBox); + has = pivots[i].AsBox(iBox); if (has) { // AddRef( iBox, - fvgBoxes // + pivotBoxes // ); } @@ -583,13 +584,159 @@ struct XCAPVFVG } // - result = ArraySize(fvgBoxes); + result = ArraySize(pivotBoxes); // return result; } }; +// +struct XCAPVTick +{ + // + XCAPivot pivot; + XCTicksZone *zone; + + // + XCAPVTick() + { + Clean(); + } + + // + // Tools ... + + // + void Clean() + { + // + pivot.Clean(); + + // + ZeroMemory(zone); + ZeroMemory(this); + } + + // + bool IsValid() + { + // + bool result = false; + + // + result = pivot.IsValid() && + zone != NULL; + + // + return result; + } + + // + bool Init(XCAPivot &_pivot) + { + // + bool result = false; + + // + result = _pivot.IsValid(); + if (!result) + { + return result; + } + + // + int toIDX = _pivot.ToIndex(); + int fromIDX = _pivot.FromIndex(); + int rangeLength = fromIDX - toIDX; + result = IsValidIndex(fromIDX) && + IsValidIndex(toIDX); + if (!result) + { + // + Clean(); + return result; + } + + // + XOHCL toBar; + XOHCL fromBar; + result = toBar.Init( + _pivot.symbol, + _pivot.period, + toIDX // + ); + result = result && + fromBar.Init( + _pivot.symbol, + _pivot.period, + fromIDX // + ); + if (!result) + { + // + toBar.Clean(); + fromBar.Clean(); + + // + Clean(); + + // + return result; + } + + // + double rangeDivider = 10 * GetPoints(_pivot.symbol); + double rangeL = toBar.FindLowest(rangeLength, MODE_LOW); + double rangeH = toBar.FindHighest(rangeLength, MODE_HIGH); + double rangeDiff = (rangeH - rangeL); + int zoneLevels = (int)(rangeDiff / rangeDivider); + + // + XCTicksZone *_zone; + _zone = new XCTicksZone(); + _zone.Levels(zoneLevels); + result = _zone.Init( + fromBar, + toBar // + ); + if (!result) + { + // + toBar.Clean(); + fromBar.Clean(); + ZeroMemory(_zone); + + // + Clean(); + + // + return result; + } + + // + pivot = _pivot; + zone = _zone; + + // + result = IsValid(); + if (!result) + { + Clean(); + } + + // + toBar.Clean(); + fromBar.Clean(); + ZeroMemory(_zone); + + // + return result; + } + + // +}; + /** * Find Specified Pivot Index inside a Collection of Pivots ... * @@ -725,12 +872,12 @@ void AddPivot( * * @param value: double, Peak or Vale Value ... * @param fvg: XCAPivot instance reference, Specified Pivot ... - * @param collection: XCAPVFVG instance Collection ... + * @param collection: XCAPVPivot instance Collection ... */ void AddOrUpdatePVFVG( double value, XCAPivot &fvg, - XCAPVFVG &collection[] // + XCAPVPivot &collection[] // ) { // @@ -761,7 +908,7 @@ void AddOrUpdatePVFVG( for (int i = 0; i < count; i++) { // - XCAPVFVG iTem = collection[i]; + XCAPVPivot iTem = collection[i]; // bool isSameValue = iTem.value == value; @@ -789,7 +936,7 @@ void AddOrUpdatePVFVG( { // // New Item ... - XCAPVFVG iPVFVG; + XCAPVPivot iPVFVG; // iPVFVG.dir = dir; @@ -798,7 +945,7 @@ void AddOrUpdatePVFVG( // AddRef( fvg, - iPVFVG.fvgs // + iPVFVG.pivots // ); // @@ -811,12 +958,56 @@ void AddOrUpdatePVFVG( { // // Add Pivot to Existing Item ... - collection[idx].AddFVG(fvg); + collection[idx].AddPivot(fvg); } // } +/** + * Add Specified PVTick to Collection ... + * + * @param pvTick: XCAPVTick instance Reference ... + * @param pvTicks: XCAPVTickinstance Reference Collection ... + */ +void AddPVTick( + XCAPVTick &pvTick, + XCAPVTick &pvTicks[] // +) +{ + // + bool has = pvTick.IsValid(); + if (!has) + { + return; + } + + // + has = false; + int count = ArraySize(pvTicks); + for (int i = 0; i < count; i++) + { + // + has = pvTicks[i].pivot.IsSameAs(pvTick.pivot); + if (has) + { + break; + } + } + + // + if (has) + { + return; + } + + // + AddRef( + pvTick, + pvTicks // + ); +} + // // Implementations ... class XCXCAEAPOIDetector : public XCBase @@ -958,8 +1149,12 @@ class XCXCAEAPOIDetector : public XCBase XCAPivot cciCrossedUnderOBPivots[]; // - XCAPVFVG pvFVGBullishPivots[]; - XCAPVFVG pvFVGBearishPivots[]; + XCAPVTick peakTicks[]; + XCAPVTick valeTicks[]; + + // + XCAPVPivot pvFVGBullishPivots[]; + XCAPVPivot pvFVGBearishPivots[]; // // Constructors ... @@ -2120,6 +2315,21 @@ class XCXCAEAPOIDetector : public XCBase peakSWHResPivots, maxAllowedPivots // ); + + // + XCAPVTick peakTick; + has = peakTick.Init(peakSWHResPivot); + if (has) + { + // + AddPVTick( + peakTick, + peakTicks // + ); + } + + // + peakTick.Clean(); } // @@ -2185,6 +2395,21 @@ class XCXCAEAPOIDetector : public XCBase valeSWLSupPivots, maxAllowedPivots // ); + + // + XCAPVTick valeTick; + has = valeTick.Init(valeSWLSupPivot); + if (has) + { + // + AddPVTick( + valeTick, + valeTicks // + ); + } + + // + valeTick.Clean(); } // @@ -4664,7 +4889,7 @@ class XCXCAEAPOIDetector : public XCBase // // PVFVG ... - XCAPVFVG tmpPVFVG[]; + XCAPVPivot tmpPVFVG[]; // has = HasPVFVGBullishPivots(); @@ -4679,7 +4904,7 @@ class XCXCAEAPOIDetector : public XCBase while (HasChild(tmpPVFVG)) { // - XCAPVFVG iPVFVG = tmpPVFVG[0]; + XCAPVPivot iPVFVG = tmpPVFVG[0]; ArrayRemove( tmpPVFVG, 0, @@ -4689,10 +4914,10 @@ class XCXCAEAPOIDetector : public XCBase // XCAPivot tmpFVGs[]; Copy( - iPVFVG.fvgs, + iPVFVG.pivots, tmpFVGs // ); - Clean(iPVFVG.fvgs); + Clean(iPVFVG.pivots); while (HasChild(tmpFVGs)) { // @@ -4714,14 +4939,14 @@ class XCXCAEAPOIDetector : public XCBase // AddRef( iPivot, - iPVFVG.fvgs // + iPVFVG.pivots // ); } } Clean(tmpFVGs); // - if (HasChild(iPVFVG.fvgs)) + if (HasChild(iPVFVG.pivots)) { // AddRef( @@ -4747,7 +4972,7 @@ class XCXCAEAPOIDetector : public XCBase while (HasChild(tmpPVFVG)) { // - XCAPVFVG iPVFVG = tmpPVFVG[0]; + XCAPVPivot iPVFVG = tmpPVFVG[0]; ArrayRemove( tmpPVFVG, 0, @@ -4757,10 +4982,10 @@ class XCXCAEAPOIDetector : public XCBase // XCAPivot tmpFVGs[]; Copy( - iPVFVG.fvgs, + iPVFVG.pivots, tmpFVGs // ); - Clean(iPVFVG.fvgs); + Clean(iPVFVG.pivots); while (HasChild(tmpFVGs)) { // @@ -4782,14 +5007,14 @@ class XCXCAEAPOIDetector : public XCBase // AddRef( iPivot, - iPVFVG.fvgs // + iPVFVG.pivots // ); } } Clean(tmpFVGs); // - if (HasChild(iPVFVG.fvgs)) + if (HasChild(iPVFVG.pivots)) { // AddRef( @@ -5580,9 +5805,90 @@ class XCXCAEAPOIDetector : public XCBase Clean(tmp); } + // + // PVTICKS ... + + // + XCAPVTick tmpTicks[]; + + // + has = HasPeakTicks(); + if (has) + { + // + Copy( + peakTicks, + tmpTicks // + ); + Clean(peakTicks); + while (HasChild(tmpTicks)) + { + // + XCAPVTick iPVTick = tmpTicks[0]; + ArrayRemove( + tmpTicks, + 0, + 1); + + // + has = IsPivotBreaked( + iPVTick.pivot, + unAvailableBoxes, + barIndex // + ); + if (!has) + { + // + AddRef( + iPVTick, + peakTicks // + ); + } + } + Clean(tmpTicks); + } + + // + has = HasValeTicks(); + if (has) + { + // + Copy( + valeTicks, + tmpTicks // + ); + Clean(valeTicks); + while (HasChild(tmpTicks)) + { + // + XCAPVTick iPVTick = tmpTicks[0]; + ArrayRemove( + tmpTicks, + 0, + 1); + + // + has = IsPivotBreaked( + iPVTick.pivot, + unAvailableBoxes, + barIndex // + ); + if (!has) + { + // + AddRef( + iPVTick, + valeTicks // + ); + } + } + Clean(tmpTicks); + } + // Clean(tmp); Clean(tmpPVFVG); + Clean(tmpTicks); } // @@ -6888,6 +7194,33 @@ class XCXCAEAPOIDetector : public XCBase return ArraySize(cciCrossedUnderOBPivots); } + // + // PVTICKS ... + + // + bool HasPeakTicks() + { + return HasChild(peakTicks); + } + + // + int CountPeakTicks() + { + return ArraySize(peakTicks); + } + + // + bool HasValeTicks() + { + return HasChild(valeTicks); + } + + // + int CountValeTicks() + { + return ArraySize(valeTicks); + } + // // Protected ... protected: diff --git a/XCAEA/Classes/xcaea.x-poi.drawer.class.mq5 b/XCAEA/Classes/xcaea.x-poi.drawer.class.mq5 index bd37eec5..41adc8b0 100644 --- a/XCAEA/Classes/xcaea.x-poi.drawer.class.mq5 +++ b/XCAEA/Classes/xcaea.x-poi.drawer.class.mq5 @@ -13,6 +13,7 @@ ////////////////////////////////////////////////////// // // Global Properties ... +#property library #property copyright "Copyright 2023, SaherElm IT Center" #property link "https://saherelm.ir" #property version "1.00" @@ -65,6 +66,9 @@ class XCXCAEAPOIDrawer : public XCBase bool drawCCICrossedOverOSPivots; bool drawCCICrossedUnderOBPivots; + // + bool drawTicks; + // // Colorize Props ... @@ -212,6 +216,9 @@ class XCXCAEAPOIDrawer : public XCBase drawCCICrossedOverOSPivots = false; drawCCICrossedUnderOBPivots = false; + // + drawTicks = false; + // // Color ... defBullishPivotColor = clrLime; @@ -274,6 +281,7 @@ class XCXCAEAPOIDrawer : public XCBase void Draw(datetime to = NULL) { // + DrawTicks(); DrawSWHPivots(to); DrawSWLPivots(to); DrawPeakPivots(to); @@ -306,6 +314,54 @@ class XCXCAEAPOIDrawer : public XCBase // // + // + void DrawTicks() + { + // + if (!drawTicks) + { + return; + } + + // + // PEAK TICKS ... + bool has = detector.HasPeakTicks(); + if (has) { + // + int count = detector.CountPeakTicks(); + for (int i = 0; i < count; i++) { + // + XCTicksZoneObject *iObj; + has = drawer.CreateTicksZone( + detector.peakTicks[i].zone, + iObj // + ); + if (has) { + mPeakPivotObjects.Add(iObj); + } + } + } + + // + // VALE TICKS ... + has = detector.HasValeTicks(); + if (has) { + // + int count = detector.CountValeTicks(); + for (int i = 0; i < count; i++) { + // + XCTicksZoneObject *iObj; + has = drawer.CreateTicksZone( + detector.valeTicks[i].zone, + iObj // + ); + if (has) { + mPeakPivotObjects.Add(iObj); + } + } + } + } + // void DrawSWHPivots(datetime to = NULL) { @@ -725,11 +781,11 @@ class XCXCAEAPOIDrawer : public XCBase for (int i = 0; i < count; i++) { // - XCAPVFVG iPVFVG = detector.pvFVGBullishPivots[i]; + XCAPVPivot iPVFVG = detector.pvFVGBullishPivots[i]; // XBoxZone fvgBoxes[]; - int fvgBoxesCount = iPVFVG.GetFVGs(fvgBoxes); + int fvgBoxesCount = iPVFVG.GetPivots(fvgBoxes); has = IsValidSize(fvgBoxesCount); if (has) { @@ -840,11 +896,11 @@ class XCXCAEAPOIDrawer : public XCBase for (int i = 0; i < count; i++) { // - XCAPVFVG iPVFVG = detector.pvFVGBearishPivots[i]; + XCAPVPivot iPVFVG = detector.pvFVGBearishPivots[i]; // XBoxZone fvgBoxes[]; - int fvgBoxesCount = iPVFVG.GetFVGs(fvgBoxes); + int fvgBoxesCount = iPVFVG.GetPivots(fvgBoxes); has = IsValidSize(fvgBoxesCount); if (has) { diff --git a/XCAEA/Libraries/xcaea.signaller.lib.mq5 b/XCAEA/Libraries/xcaea.signaller.lib.mq5 index 43e4592c..f100771d 100644 --- a/XCAEA/Libraries/xcaea.signaller.lib.mq5 +++ b/XCAEA/Libraries/xcaea.signaller.lib.mq5 @@ -13,6 +13,7 @@ ////////////////////////////////////////////////////// // // Global Properties ... +#property library #property copyright "Copyright 2023, SaherElm IT Center" #property link "https://saherelm.ir" #property version "1.00" diff --git a/XCAEA/Signals/xcaea.signaller.class.mq5 b/XCAEA/Signals/xcaea.signaller.class.mq5 index 72fdefdf..026c4458 100644 --- a/XCAEA/Signals/xcaea.signaller.class.mq5 +++ b/XCAEA/Signals/xcaea.signaller.class.mq5 @@ -13,6 +13,7 @@ ////////////////////////////////////////////////////// // // Global Properties ... +#property library #property copyright "Copyright 2023, SaherElm IT Center" #property link "https://saherelm.ir" #property version "1.00" @@ -796,6 +797,9 @@ class XCXCAEASignaller : XCBase drawer.drawCCICrossedOverOSPivots = false; drawer.drawCCICrossedUnderOBPivots = false; + // + drawer.drawTicks = true; + // // Configure Width ... drawer.peakPivotWidth = 1;