From 03d6630d25fa8762a9d87ce4ed2793d368690170 Mon Sep 17 00:00:00 2001 From: Hadi Khazaee Asl Date: Fri, 20 Jun 2025 20:29:31 +0330 Subject: [PATCH] last ... --- Indicators/x-saherelm.x121.xcatb.v1.mq5 | 238 +++++++++++++++++- Libraries/x-saherelm.x-poi.extensions.lib.mq5 | 8 + 2 files changed, 240 insertions(+), 6 deletions(-) diff --git a/Indicators/x-saherelm.x121.xcatb.v1.mq5 b/Indicators/x-saherelm.x121.xcatb.v1.mq5 index 8744f9ab..42f3977f 100644 --- a/Indicators/x-saherelm.x121.xcatb.v1.mq5 +++ b/Indicators/x-saherelm.x121.xcatb.v1.mq5 @@ -646,6 +646,7 @@ XCBarAnalyser *mBarAnalyser; // // Temparory ... +int mCount = 0; bool mHas = false; ENUM_X_DIRECTION mDir; bool mHasSignal = false; @@ -654,6 +655,24 @@ bool mIsBearish = false; XDirectionShift mDirShift; string mTriggerBarConditions; +// +// POI(s) ... + +// +XBoxZone tmpBoxes[]; + +// +bool mDrawLiquidities = true; +bool mDetectLiquidities = true; + +// +XBoxZone mBullishLiquidities[]; +XBoxZone mBearishLiquidities[]; + +// // +// XBoxZone mBullishLiquidities[]; +// XBoxZone mBearishLiquidities[]; + // // Counters ... @@ -1052,6 +1071,23 @@ void OnDeinit(const int reason) IndicatorRelease(rsiHandler); IndicatorRelease(adxHandler); IndicatorRelease(trendHandler); + + // + mDirShift.Clean(); + + // + Clean(mBullishKIChanges); + Clean(mBearishKIChanges); + Clean(mBullishSBChanges); + Clean(mBearishSBChanges); + Clean(mBullishHKSChanges); + Clean(mBearishHKSChanges); + Clean(mBullishSarChanges); + Clean(mBearishSarChanges); + Clean(mBullishTrendChanges); + Clean(mBearishTrendChanges); + + // } /** @@ -3259,16 +3295,16 @@ void PrepareMarketConditions( // Recieve Bar ... XOHCL iBar; XOHCL iPBar; - bool has = iBar.Init( + mHas = iBar.Init( _Symbol, _Period, barIndex // ); - has = - has && + mHas = + mHas && iBar.GetPreviousBar(iPBar); - if (!has) + if (!mHas) { return; } @@ -3281,8 +3317,8 @@ void PrepareMarketConditions( // // Check Required Bars Passed ... - has = p3Index <= maxBarIndex; - if (!has) + mHas = p3Index <= maxBarIndex; + if (!mHas) { return; } @@ -4474,6 +4510,103 @@ void DetectPOIs( const long &tickVolume[] // ) { + // + // Check Some Requirements ... + int lastBarIndex = barIndex + 1; + int maxBarIndex = startCalculationForLastBars > 0 + ? startCalculationForLastBars + : ratesTotal; + bool isFirstBar = + startCalculationForLastBars > 0 + ? barIndex == startCalculationForLastBars + : barIndex == firstBarIndex; + + // + // Recieve Bar ... + XOHCL iBar; + XOHCL iPBar; + mHas = iBar.Init( + _Symbol, + _Period, + barIndex + // + ); + mHas = + mHas && + iBar.GetPreviousBar(iPBar); + if (!mHas) + { + return; + } + + // + // Liquidities ... + if (mDetectLiquidities) + { + // + if (isLiquidity) + { + // + XBoxZone iLiq; + + // + iLiq.type = "XLIQ"; + iLiq.symbol = _Symbol; + iLiq.period = _Period; + + // + if (isBullishLiquidity) + { + // + iLiq.from = iBar.time; + iLiq.lower = iBar.low; + iLiq.to = iBar.NextAt(); + iLiq.upper = iBar.GetDown(); + iLiq.dir = X_DIRECTION_BULLISH; + + // + if (iLiq.IsValid()) + { + // + AddIfNotExists( + iLiq, + mBullishLiquidities // + ); + } + } + + // + if (isBearishLiquidity) + { + // + iLiq.from = iBar.time; + iLiq.upper = iBar.high; + iLiq.to = iBar.NextAt(); + iLiq.lower = iBar.GetUp(); + iLiq.dir = X_DIRECTION_BEARISH; + + // + if (iLiq.IsValid()) + { + // + AddIfNotExists( + iLiq, + mBearishLiquidities // + ); + } + } + + // + iLiq.Clean(); + } + } + + // + // Cleanup Resources ... + + // + iBar.Clean(); + iPBar.Clean(); } /** @@ -4499,6 +4632,39 @@ void ValidatePOIs( const long &tickVolume[] // ) { + // + int barsLength = 3; + + // + // Liquidities ... + + // + // Bullish ... + mHas = HasChild(mBullishLiquidities); + if (mHas) + { + // + ValidateBoxes( + mBullishLiquidities, + barIndex, + barsLength // + ); + } + + // + // Bearish ... + mHas = HasChild(mBearishLiquidities); + if (mHas) + { + // + ValidateBoxes( + mBearishLiquidities, + barIndex, + barsLength // + ); + } + + // } /** @@ -4524,6 +4690,66 @@ void DrawPOIs( const long &tickVolume[] // ) { + // + // Liquidities ... + if (mDrawLiquidities) + { + // + // Bullish ... + mCount = ArraySize(mBullishLiquidities); + mHas = IsValidSize(mCount); + if (mHas) + { + // + for (int i = 0; i < mCount; i++) + { + // + XBoxZone iBox = mBullishLiquidities[i]; + + // + XCBoxObject *iBObj; + mHas = mDrawer.DrawBox( + iBox, + iBObj // + ); + if (mHas) + { + mObjects.Add(iBObj); + } + + // + iBox.Clean(); + } + } + + // + // Bearish ... + mCount = ArraySize(mBearishLiquidities); + mHas = IsValidSize(mCount); + if (mHas) + { + // + for (int i = 0; i < mCount; i++) + { + // + XBoxZone iBox = mBearishLiquidities[i]; + + // + XCBoxObject *iBObj; + mHas = mDrawer.DrawBox( + iBox, + iBObj // + ); + if (mHas) + { + mObjects.Add(iBObj); + } + + // + iBox.Clean(); + } + } + } } /** diff --git a/Libraries/x-saherelm.x-poi.extensions.lib.mq5 b/Libraries/x-saherelm.x-poi.extensions.lib.mq5 index bb6eadb2..7d974066 100644 --- a/Libraries/x-saherelm.x-poi.extensions.lib.mq5 +++ b/Libraries/x-saherelm.x-poi.extensions.lib.mq5 @@ -1212,6 +1212,11 @@ void ValidateBoxes( // // Select Indexed Box ... XBoxZone iBox = tmp[0]; + datetime to = GetBarTime( + iBox.symbol, + iBox.period, + barIndex // + ); // // Remove Indexed Box ... @@ -1230,6 +1235,9 @@ void ValidateBoxes( ); if (has) { + // + iBox.to = to; + // AddRef( iBox,