From 72430436bbdcd320b988f0cbc156e93cfbc5b44b Mon Sep 17 00:00:00 2001 From: Hadi Khazaee Asl Date: Sun, 22 Dec 2024 00:48:24 +0330 Subject: [PATCH] last ... --- .../x-121.smc.market.cycle.helper.class.mq5 | 98 +++++++++++++++++-- 1 file changed, 91 insertions(+), 7 deletions(-) diff --git a/X121SMCEA/Classes/x-121.smc.market.cycle.helper.class.mq5 b/X121SMCEA/Classes/x-121.smc.market.cycle.helper.class.mq5 index 3daa4b33..9deb1d55 100644 --- a/X121SMCEA/Classes/x-121.smc.market.cycle.helper.class.mq5 +++ b/X121SMCEA/Classes/x-121.smc.market.cycle.helper.class.mq5 @@ -50,7 +50,8 @@ enum ENUM_X_CYCLE_EVENTS VWAP_ORDER_CHANGE_ETECTED, VWAP_STATE_CHANGE_DETCTED, CONSOLIDATION_BREAKED_DETECTED, - PIVOT_DETECTED, + PIVOT_STARTED, + PIVOT_ENDED, }; class XC121SMCCycleHelper : public XCBase @@ -1376,7 +1377,11 @@ class XC121SMCCycleHelper : public XCBase return result; } - // + /** + * Get Current Active Pivot ... + * + * @param pivot: XPVPivot instance reference ... + */ void GetActivePivot(XPVPivot &pivot) { // @@ -1384,6 +1389,44 @@ class XC121SMCCycleHelper : public XCBase pivot = mActivePivot; } + /** + * Count Calculated Pivots ... + * + * @return ( int ) + */ + int CountPivots() + { + return ArraySize(mPivots); + } + + /** + * Fill Pivots ... + * + * @param pivots: XPVPivot instance Reference Array ... + * + * @return ( int ) + */ + int FillPivots(XPVPivot &pivots[]) + { + // + int result = 0; + + // + Clean(pivots); + + // + Copy( + mPivots, + pivots // + ); + + // + result = ArraySize(pivots); + + // + return result; + } + // // Virtuals ... @@ -1485,6 +1528,7 @@ class XC121SMCCycleHelper : public XCBase // bool isNewPeak = conditions.x121Conditions.isNewPeak; + double peak = conditions.x121Conditions.peaksBuffer[0]; bool isNewPeakOverLast = conditions.x121Conditions.isNewPeakOverLast; bool isNewPeakUnderLast = conditions.x121Conditions.isNewPeakUnderLast; @@ -1529,6 +1573,7 @@ class XC121SMCCycleHelper : public XCBase // bool isNewVale = conditions.x121Conditions.isNewVale; + double vale = conditions.x121Conditions.valesBuffer[0]; bool isNewValeOverLast = conditions.x121Conditions.isNewValeOverLast; bool isNewValeUnderLast = conditions.x121Conditions.isNewValeUnderLast; @@ -1907,7 +1952,14 @@ class XC121SMCCycleHelper : public XCBase // if (!IsValid(mActivePivot.from)) { + // mActivePivot.from = cTime; + + // + Add( + PIVOT_STARTED, + events // + ); } mActivePivot.to = cTime; @@ -1975,22 +2027,54 @@ class XC121SMCCycleHelper : public XCBase XCTickZone *iTZ = mActivePivot.state.ticksZone.GetZone(i); // - bool isBarInside = - changeBar.low >= iTZ.low && - changeBar.high <= iTZ.high; - if (isBarInside) + double pivot = + isNewPeak + ? peak + : vale; + bool isPivotInsideZone = + pivot >= iTZ.low && + pivot <= iTZ.high; + if (isPivotInsideZone) { // cTZoneIDX = i; break; } + + // + bool isBarInside = + changeBar.low >= iTZ.low && + changeBar.high <= iTZ.high; + // if (isBarInside) + // { + // // + // cTZoneIDX = i; + // break; + // } } // - if (IsValidIndex(cTZoneIDX)) + // Last Zone ... + // We Can Break Active Zone ... + if (IsValidIndex(cTZoneIDX) && cTZoneIDX == count - 1) { // Print("ZoneIndex: ", cTZoneIDX); + + // + AddRef( + mActivePivot, + mPivots // + ); + + // + Add( + PIVOT_ENDED, + events // + ); + + // + mActivePivot.Clean(); } } }