From 727344d27a9bd57902d2d540f894161db40cd518 Mon Sep 17 00:00:00 2001 From: Hadi Khazaee Asl Date: Tue, 23 Sep 2025 21:34:15 +0330 Subject: [PATCH] last works on Fix and Resolve XPivotAnalysis Calculations and Drawn ... --- Classes/x-saherelm.x-cobject.class.mq5 | 42 ++++---- Libraries/x-saherelm.x-pivot.analysis.lib.mq5 | 96 ++++++++++++++++++- 2 files changed, 119 insertions(+), 19 deletions(-) diff --git a/Classes/x-saherelm.x-cobject.class.mq5 b/Classes/x-saherelm.x-cobject.class.mq5 index 0a1d1e87..71c0d279 100644 --- a/Classes/x-saherelm.x-cobject.class.mq5 +++ b/Classes/x-saherelm.x-cobject.class.mq5 @@ -1478,6 +1478,9 @@ class XCPivotAnalysisObject : public XCBaseObject // bool result = false; + // + bool has = false; + // // Validate ... result = model.IsValid(); @@ -1489,8 +1492,8 @@ class XCPivotAnalysisObject : public XCBaseObject // // Generate Object ID ... string objID = model.GetObjectID(); - string upperName = "Upper_" + objID; - string lowerName = "Lower_" + objID; + string upperName = model.GetUpperObjectID(); + string lowerName = model.GetLowerObjectID(); // // Extract Recent Pivots ... @@ -1536,18 +1539,21 @@ class XCPivotAnalysisObject : public XCBaseObject // Support ... XBoxZone tmpBox; mSupportBox = NULL; - if (model.HasSupportBox(tmpBox)) + has = model.HasSupportBox(tmpBox); + if (has) { // + datetime to = TimeCurrent(); + string name = model.GetSupportBoxObjectID(); mSupportBox = new XCBoxObject(); - mSupportBox.Create( + has = mSupportBox.Create( chart_id, window, - tmpBox.GetTag(), + name, tmpBox.upper, tmpBox.lower, tmpBox.from, - tmpBox.to // + to // ); } @@ -1555,18 +1561,21 @@ class XCPivotAnalysisObject : public XCBaseObject // Resistance ... tmpBox.Clean(); mResistanceBox = NULL; - if (model.HasResistanceBox(tmpBox)) + has = model.HasResistanceBox(tmpBox); + if (has) { // + datetime to = TimeCurrent(); + string name = model.GetResistanceBoxObjectID(); mResistanceBox = new XCBoxObject(); - mResistanceBox.Create( + has = mResistanceBox.Create( chart_id, window, - tmpBox.GetTag(), + name, tmpBox.upper, tmpBox.lower, tmpBox.from, - tmpBox.to // + to // ); } @@ -1578,7 +1587,6 @@ class XCPivotAnalysisObject : public XCBaseObject // XOHCL iBar; int arrow = 0; - bool has = false; string name = NULL; XCBarArrowObject *iObj; ENUM_X_PRICE type = X_PRICE_NONE; @@ -1799,7 +1807,7 @@ class XCPivotAnalysisObject : public XCBaseObject } // - mSupportBox.Width(value); + mSupportBox.BoxWidth(value); } /** @@ -1816,7 +1824,7 @@ class XCPivotAnalysisObject : public XCBaseObject } // - mSupportBox.Color(value); + mSupportBox.BoxColor(value); } /** @@ -1833,7 +1841,7 @@ class XCPivotAnalysisObject : public XCBaseObject } // - mSupportBox.Style(value); + mSupportBox.BoxStyle(value); } /** @@ -1856,7 +1864,7 @@ class XCPivotAnalysisObject : public XCBaseObject } // - mResistanceBox.Width(value); + mResistanceBox.BoxWidth(value); } /** @@ -1873,7 +1881,7 @@ class XCPivotAnalysisObject : public XCBaseObject } // - mResistanceBox.Color(value); + mResistanceBox.BoxColor(value); } /** @@ -1890,7 +1898,7 @@ class XCPivotAnalysisObject : public XCBaseObject } // - mResistanceBox.Style(value); + mResistanceBox.BoxStyle(value); } /** diff --git a/Libraries/x-saherelm.x-pivot.analysis.lib.mq5 b/Libraries/x-saherelm.x-pivot.analysis.lib.mq5 index 9a8bb6ac..772986fb 100644 --- a/Libraries/x-saherelm.x-pivot.analysis.lib.mq5 +++ b/Libraries/x-saherelm.x-pivot.analysis.lib.mq5 @@ -1004,8 +1004,8 @@ struct XPivotAnalysis box.from = fromTime; // - box.upper = minorResistance; - box.lower = majorResistance; + box.upper = majorResistance; + box.lower = minorResistance; box.dir = X_DIRECTION_BEARISH; box.type = GetTag() + "_Resistance"; @@ -1146,6 +1146,98 @@ struct XPivotAnalysis return result; } + /** + * Represent an String Unique Identifier for Upper Trend Chart Objects ... + * + * @return ( string ) + */ + string GetUpperObjectID() + { + // + string result = ""; + + // + if (!IsValid()) + { + return result; + } + + // + result = GetTag() + "_" + symbol + "_" + ToXString(period) + "_UPPER_" + ToXString(TimeToSeconds(time)); + + // + return result; + } + + /** + * Represent an String Unique Identifier for Lower Trend Chart Objects ... + * + * @return ( string ) + */ + string GetLowerObjectID() + { + // + string result = ""; + + // + if (!IsValid()) + { + return result; + } + + // + result = GetTag() + "_" + symbol + "_" + ToXString(period) + "_LOWER_" + ToXString(TimeToSeconds(time)); + + // + return result; + } + + /** + * Represent an String Unique Identifier for Support Box Chart Objects ... + * + * @return ( string ) + */ + string GetSupportBoxObjectID() + { + // + string result = ""; + + // + if (!IsValid()) + { + return result; + } + + // + result = GetTag() + "_" + symbol + "_" + ToXString(period) + "_SUPPORT_" + ToXString(TimeToSeconds(time)); + + // + return result; + } + + /** + * Represent an String Unique Identifier for Resistance BOX Chart Objects ... + * + * @return ( string ) + */ + string GetResistanceBoxObjectID() + { + // + string result = ""; + + // + if (!IsValid()) + { + return result; + } + + // + result = GetTag() + "_" + symbol + "_" + ToXString(period) + "_RESISTANCE_" + ToXString(TimeToSeconds(time)); + + // + return result; + } + /** * Represent as String ... *