diff --git a/Classes/x-saherelm.x-poi.drawer.class.mq5 b/Classes/x-saherelm.x-poi.drawer.class.mq5 index cd3c458c..dfa90237 100644 --- a/Classes/x-saherelm.x-poi.drawer.class.mq5 +++ b/Classes/x-saherelm.x-poi.drawer.class.mq5 @@ -930,6 +930,40 @@ class XCPOIDrawer : public XCBase object.ArrowWidth(style.width); } + /** + * Apply Style to Specified Chart Object ... + * + * @param dir: Argument 2 + */ + void ApplyStyle( + CChartObject *object, + ENUM_X_DIRECTION dir // + ) + { + // + if (!HasDirection(dir)) + { + return; + } + + // + bool isBullish = IsSpecifiedBullish(dir); + if (isBullish) + { + // + object.Color(boxBullishStyle.clr); + object.Style(boxBullishStyle.style); + object.Width(boxBullishStyle.width); + } + else + { + // + object.Color(boxBearishStyle.clr); + object.Style(boxBearishStyle.style); + object.Width(boxBearishStyle.width); + } + } + // protected: // diff --git a/XOM1EA/Classes/xom1ea.expert.class.mq5 b/XOM1EA/Classes/xom1ea.expert.class.mq5 index 8edca790..6e8ae388 100644 --- a/XOM1EA/Classes/xom1ea.expert.class.mq5 +++ b/XOM1EA/Classes/xom1ea.expert.class.mq5 @@ -150,6 +150,9 @@ class XCXOM1EAExpert : public XCBase XOM1Inputs iDZoneOMInputs; iDZoneOMInputs.Default(); iDZoneOMInputs.showFiboZone = false; + + // + iDZoneOMInputs.upperMode = MODE_OPEN // // Configure Signaller ... diff --git a/XOM1EA/Classes/xom1ea.signaller.class.mq5 b/XOM1EA/Classes/xom1ea.signaller.class.mq5 index 0296b3e7..56dd7e67 100644 --- a/XOM1EA/Classes/xom1ea.signaller.class.mq5 +++ b/XOM1EA/Classes/xom1ea.signaller.class.mq5 @@ -22,8 +22,8 @@ // // Imports ... -#include "../../Classes/x-saherelm.x-poi.drawer.class.mq5" #include "../../Helpers/x-saherelm.xom1.helper.mq5" +#include "../Classes/xom1ea.x-poi.drawer.class.mq5" #include "../Libraries/xom1ea.lib.mq5" // @@ -76,7 +76,7 @@ class XCXOM1SignallerBase XOM1Inputs inputs; // Indicator Inputs ... ENUM_TIMEFRAMES period; // Period ... XOM1SignallerConfig config; // Configuration ... - XCPOIDrawer drawer; // POI Drawer ... + XCXOM1POIDrawer drawer; // POI Drawer ... // // Constructor ... @@ -137,9 +137,6 @@ class XCXOM1SignallerBase // inputs.Clean(); - // - mObjects.Clear(); - // SpecifiedClean(zones); @@ -231,6 +228,10 @@ class XCXOM1SignallerBase // Update Indicator Helper ... mHelper.Update(barIndex); + // + // Process Exists Zone ... + ProcessZones(barIndex); + // // Do All Processing Mechanism ... @@ -319,7 +320,7 @@ class XCXOM1SignallerBase iDir, iReason, iConditions.bars[pIdx].time, // From ... - iConditions.bars[cIdx].time // To + iConditions.bars[cIdx].time // To ); if (has) { @@ -350,9 +351,6 @@ class XCXOM1SignallerBase // // Props ... - // - CArrayObj mObjects; // Drawn Objects ... - // XCXOM1Helper *mHelper; // Indicator Helper ... @@ -389,33 +387,39 @@ class XCXOM1SignallerBase // zones[i].UpdateByBarIndex(barIndex); // - // COnverts to Box ... - XBoxZone iBox; - has = zones[i].ToBox(iBox); - if (has) - { - // - XCBoxObject *iBoxObj; - has = drawer.DrawBox( - iBox, - iBoxObj, - true // Ignore At ... - ); - if (has) - { - mObjects.Add(iBoxObj); - } - } - - // - iBox.Clean(); + drawer.DrawZone(zones[i], true, true); } } // // Check XOMZones Validations ... - } + + /** + * Process Exists Zones ... + * Detect a Zone for trigger ... + * + * @param barIndex: int + */ + void ProcessZones(int barIndex = 0) + { + // + // Check Zones Exists ... + int count = ArraySize(zones); + bool has = IsValidSize(count); + if (!has) + { + return; + } + + // + // Loop Through Zones ... + for (int i = 0; i < count; i++) + { + // + } + } + }; // \ No newline at end of file diff --git a/XOM1EA/Classes/xom1ea.x-poi.drawer.class.mq5 b/XOM1EA/Classes/xom1ea.x-poi.drawer.class.mq5 new file mode 100644 index 00000000..a2d16537 --- /dev/null +++ b/XOM1EA/Classes/xom1ea.x-poi.drawer.class.mq5 @@ -0,0 +1,191 @@ +/////////////////////////////////////////////////////// +// +// SaherElm IT Center MQL5 Class +// ------------------------------------------------- +// Name: XCXOM1POIDrawer ... +// Description: XOM1EA POI Drawer Class ... +// +// +// Maintainer: +// ------------ +// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com) +// +////////////////////////////////////////////////////// +// +// Global Properties ... +#property library +#property copyright "Copyright 2023, SaherElm IT Center" +#property link "https://saherelm.ir" +#property version "1.00" +#property description "SaherElm XOM1EA POI Drawer Class" +#property strict + +// +// Imports ... +#include "../../Classes/x-saherelm.x-poi.drawer.class.mq5" +#include "../Libraries/xom1ea.lib.mq5" + +// +// Definitions ... + +// +// Implementation ... +class XCXOM1POIDrawer : public XCBase +{ + // + // Public ... + public: + // + // Props ... + + // + // Constructor ... + XCXOM1POIDrawer() + { + } + + // + // Deconstructor ... + ~XCXOM1POIDrawer() + { + mObjects.Clear(); + } + + // + // Actions ... + + /** + * Draw Specified Zone ... + * + * @param zone: XOM1Zone + * @param drawPrice: bool + * @param drawMiddle: bool + */ + void DrawZone( + XOM1Zone &zone, + bool drawPrice = false, + bool drawMiddle = false // + ) + { + // + bool has = false; + + // + // Validate ... + has = zone.IsValid(); + if (!has) + { + return; + } + + // + // Converts to Box ... + XBoxZone box; + has = zone.ToBox(box); + if (!has) + { + // + box.Clean(); + return; + } + + // + // Draw Box ... + XCBoxObject *object; + has = mDrawer.DrawBox( + box, + object, + true // Ignore At ... + ); + if (has) + { + mObjects.Add(object); + } + + // + // Draw Price ... + if (drawPrice) + { + // + CChartObjectTrend *mLineObj; + string mLineName = "pl_" + ToMD5(zone.GetTag()); + mLineObj = new CChartObjectTrend(); + has = mLineObj.Create( + mDrawer.ChartIdentification(), + mLineName, + mDrawer.SubWindowIdentification(), + zone.from, + zone.price, + zone.to, + zone.price // + ); + if (has) + { + // + mDrawer.ApplyStyle( + mLineObj, + zone.dir // + ); + + // + mObjects.Add(mLineObj); + } + } + + // + // Draw Middle ... + if (drawMiddle) + { + // + CChartObjectTrend *mLineObj; + double mlPrice = zone.lower + ((zone.upper - zone.lower) / 2); + string mLineName = "ml_" + ToMD5(zone.GetTag()); + mLineObj = new CChartObjectTrend(); + has = mLineObj.Create( + mDrawer.ChartIdentification(), + mLineName, + mDrawer.SubWindowIdentification(), + zone.from, + mlPrice, + zone.to, + mlPrice // + ); + if (has) + { + // + mDrawer.ApplyStyle( + mLineObj, + zone.dir // + ); + + // + mObjects.Add(mLineObj); + } + } + + // + // Clean Resources ... + box.Clean(); + } + + /** + * Clear Drawn Objects ... + */ + void Clear() + { + mObjects.Clear(); + } + + // + // Protected ... + protected: + // + // Private ... + private: + // + // Props ... + CArrayObj mObjects; // Drawn Objects ... + XCPOIDrawer mDrawer; // Base POI Drawer ... +}; + +// \ No newline at end of file diff --git a/XOM1EA/Libraries/xom1ea.lib.mq5 b/XOM1EA/Libraries/xom1ea.lib.mq5 index 217cabfc..e1a29a16 100644 --- a/XOM1EA/Libraries/xom1ea.lib.mq5 +++ b/XOM1EA/Libraries/xom1ea.lib.mq5 @@ -201,7 +201,8 @@ struct XOM1Zone signaller = _signaller; // - if (IsSpecifiedValid(_to)) { + if (IsSpecifiedValid(_to)) + { to = _to; } @@ -354,6 +355,26 @@ struct XOM1Zone return result; } + /** + * Check Zone is Bullish ... + * + * @return ( bool ) + */ + bool IsBullish() + { + return IsValid() && IsSpecifiedBullish(dir); + } + + /** + * Check Zone is Bearish ... + * + * @return ( bool ) + */ + bool IsBearish() + { + return IsValid() && IsSpecifiedBearish(dir); + } + /** * Converts to Box ... *