/////////////////////////////////////////////////////// // // SaherElm IT Center MQL5 Indicator // ------------------------------------------------- // Name: XCXCAEAPOIDrawer ... // Description: Class for XCAEA POI Drawer ... // // // 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 Class for XCAEA POI Drawer" #property strict // // Imports ... #include "../../Classes/x-saherelm.x-poi.drawer.class.mq5" #include "../Classes/xcaea.x-poi.detector.class.mq5" // // Definitions ... struct XCAPivotStyle { // // Properties ... int width; color clr; ENUM_LINE_STYLE style; // // Constructor ... XCAPivotStyle() { Default(); } // // Tools ... // // Cleanup Model ... void Clean() { // width = 1; clr = CLR_NONE; style = STYLE_SOLID; // ZeroMemory(this); } // // Default Props ... void Default() { // width = 1; clr = CLR_NONE; style = STYLE_SOLID; } }; // // Implementations ... class XCXCAEAPOIDrawer : public XCBase { // // Public ... public: // // Props ... // bool ignoreUpdateOSCTos; // // Drawers ... bool drawSWHPivots; bool drawSWLPivots; bool drawPeakPivots; bool drawValePivots; bool drawOBBullishPivots; bool drawOBBearishPivots; bool drawFVGBullishPivots; bool drawFVGBearishPivots; bool drawTrendBullishPivots; bool drawTrendBearishPivots; // // Styling ... // XCAPivotStyle defaultBullishStyle; XCAPivotStyle defaultBearishStyle; // XCAPivotStyle swhPivotStyle; XCAPivotStyle swlPivotStyle; // XCAPivotStyle peakPivotStyle; XCAPivotStyle valePivotStyle; // XCAPivotStyle obBullishPivotStyle; XCAPivotStyle obBearishPivotStyle; // XCAPivotStyle fvgBullishPivotStyle; XCAPivotStyle fvgBearishPivotStyle; // XCAPivotStyle trendBullishPivotStyle; XCAPivotStyle trendBearishPivotStyle; // // Constructors ... XCXCAEAPOIDrawer( XCXCAEAPOIDetector *_detector // ) { // detector = _detector; drawer = new XCPOIDrawer(); // Default(); } // // De Constructors ... ~XCXCAEAPOIDrawer() { // Clear(); // ZeroMemory(drawer); ZeroMemory(detector); } // // Properties ... // // Tools ... // virtual void Default() { // // Drawing ... drawSWHPivots = false; drawSWLPivots = false; drawPeakPivots = false; drawValePivots = false; drawOBBullishPivots = false; drawOBBearishPivots = false; drawFVGBullishPivots = false; drawFVGBearishPivots = false; drawTrendBullishPivots = false; drawTrendBearishPivots = false; // // Styling ... // // Bullish ... defaultBullishStyle.width = 1; defaultBullishStyle.clr = clrLime; defaultBullishStyle.style = STYLE_SOLID; // // Bearish ... defaultBearishStyle.width = 1; defaultBearishStyle.clr = clrRed; defaultBearishStyle.style = STYLE_SOLID; // // Pivots ... // // SWING ... swhPivotStyle = defaultBearishStyle; swlPivotStyle = defaultBullishStyle; // // PV ... peakPivotStyle = defaultBearishStyle; valePivotStyle = defaultBullishStyle; // // OB ... obBullishPivotStyle = defaultBullishStyle; obBearishPivotStyle = defaultBearishStyle; // // FVG ... fvgBullishPivotStyle = defaultBullishStyle; fvgBearishPivotStyle = defaultBearishStyle; // // TREND ... trendBullishPivotStyle = defaultBullishStyle; trendBearishPivotStyle = defaultBearishStyle; } // void Draw(datetime to = NULL) { // // SWING ... DrawSWHPivots(to); DrawSWLPivots(to); // // PV ... DrawPeakPivots(to); DrawValePivots(to); // // OB ... DrawOBBullishPivots(to); DrawOBBearishPivots(to); // // FVG ... DrawFVGBullishPivots(to); DrawFVGBearishPivots(to); // // TREND ... DrawTrendBullishPivots(to); DrawTrendBearishPivots(to); } // void DrawBox( XBoxZone &box, datetime to = NULL, bool drawMiddle = false, bool ignoreType = false // ) { // bool has = box.IsValid(); if (!has) { return; } // bool canUpdateTo = IsValid(to); if (canUpdateTo) { box.to = to; } // // Draw Box as POI ... if (!ignoreType) { // // Detect Pivot Type ... ENUM_XCA_PIVOTS iType = GetPivotType(box); has = IsValid(iType); if (!has) { return; } // switch (iType) { // case XCA_SWH: // DrawSWHPivot( box, to // ); break; // case XCA_SWL: // DrawSWLPivot( box, to // ); break; // case XCA_PEAK: // DrawPeakPivot( box, to // ); break; // case XCA_VALE: // DrawValePivot( box, to // ); break; // case XCA_OB_BULL: // DrawOBBullishPivot( box, to // ); break; // case XCA_OB_BEAR: // DrawOBBearishPivot( box, to // ); break; // case XCA_FVG_BULL: // DrawFVGBullishPivot( box, to // ); break; // case XCA_FVG_BEAR: // DrawFVGBearishPivot( box, to // ); break; // case XCA_TREND_BULL: // DrawTrendBullishPivot( box, to // ); break; // case XCA_TREND_BEAR: // DrawTrendBearishPivot( box, to // ); break; } } // // Draw Regular Box ... else { // // Select Styling Config ... XCAPivotStyle style; // if (box.IsBullish()) { style = defaultBullishStyle; } else { style = defaultBearishStyle; } // // Draw Box itself ... XCBoxObject *iBoxObj; has = drawer.DrawBox( box, iBoxObj // ); if (has) { // // Style Object ... ApplyPivotStyle( iBoxObj, style // ); // // Store Object ... mObjects.Add(iBoxObj); } // // Draw Box Middle Range ... if (drawMiddle) { // double middle = box.GetMid(); string middleName = box.GetMiddleTag(); // CChartObjectTrend *iMidObj; iMidObj = new CChartObjectTrend(); has = iMidObj.Create( drawer.ChartIdentification(), middleName, drawer.SubWindowIdentification(), box.from, middle, box.to, middle // ); if (has) { // // Styling Object ... iMidObj.Color(style.clr); iMidObj.Width(style.width); iMidObj.Style(style.style); // // Store Object ... mObjects.Add(iMidObj); } } // style.Clean(); } } // void DrawBoxes( XBoxZone &boxes[], datetime to = NULL, bool drawMiddle = false, bool ignoreType = false // ) { // bool has = HasChild(boxes); if (!has) { return; } // int count = ArraySize(boxes); for (int i = 0; i < count; i++) { // XBoxZone iBox = boxes[i]; // // Detect Pivot Type ... DrawBox( iBox, to, drawMiddle, ignoreType // ); // iBox.Clean(); } } // void Clear() { // // Cleanup Models ... defaultBullishStyle.Clean(); defaultBearishStyle.Clean(); // // Cleanup Styles ... swhPivotStyle.Clean(); swlPivotStyle.Clean(); peakPivotStyle.Clean(); valePivotStyle.Clean(); obBullishPivotStyle.Clean(); obBearishPivotStyle.Clean(); fvgBullishPivotStyle.Clean(); fvgBearishPivotStyle.Clean(); trendBullishPivotStyle.Clean(); trendBearishPivotStyle.Clean(); // // Cleanup Pivot Objects Holder ... mObjects.Clear(); mSWHPivotObjects.Clear(); mSWLPivotObjects.Clear(); mPeakPivotObjects.Clear(); mValePivotObjects.Clear(); mOBBullishPivotObjects.Clear(); mOBBearishPivotObjects.Clear(); mFVGBullishPivotObjects.Clear(); mFVGBearishPivotObjects.Clear(); mTrendBullishPivotObjects.Clear(); mTrendBearishPivotObjects.Clear(); } // // Collection Drawers ... // void DrawSWHPivots(datetime to = NULL) { // bool has = drawSWHPivots; if (!has) { return; } // has = detector.HasSWHPivots(); if (!has) { return; } // int count = detector.CountSWHPivots(); for (int i = 0; i < count; i++) { // XBoxZone iBox = detector.swhPivots[i]; // DrawSWHPivot( iBox, to // ); // iBox.Clean(); } } // void DrawSWLPivots(datetime to = NULL) { // bool has = drawSWLPivots; if (!has) { return; } // has = detector.HasSWLPivots(); if (!has) { return; } // int count = detector.CountSWLPivots(); for (int i = 0; i < count; i++) { // XBoxZone iBox = detector.swlPivots[i]; // DrawSWLPivot( iBox, to // ); // iBox.Clean(); } } // void DrawPeakPivots(datetime to = NULL) { // bool has = drawPeakPivots; if (!has) { return; } // has = detector.HasPeakPivots(); if (!has) { return; } // int count = detector.CountPeakPivots(); for (int i = 0; i < count; i++) { // XBoxZone iBox = detector.peakPivots[i]; // DrawPeakPivot( iBox, to // ); // iBox.Clean(); } } // void DrawValePivots(datetime to = NULL) { // bool has = drawValePivots; if (!has) { return; } // has = detector.HasValePivots(); if (!has) { return; } // int count = detector.CountValePivots(); for (int i = 0; i < count; i++) { // XBoxZone iBox = detector.valePivots[i]; // DrawValePivot( iBox, to // ); // iBox.Clean(); } } // void DrawOBBullishPivots(datetime to = NULL) { // bool has = drawOBBullishPivots; if (!has) { return; } // has = detector.HasOBBullishPivots(); if (!has) { return; } // int count = detector.CountOBBullishPivots(); for (int i = 0; i < count; i++) { // XBoxZone iBox = detector.obBullishPivots[i]; // DrawOBBullishPivot( iBox, to // ); // iBox.Clean(); } } // void DrawOBBearishPivots(datetime to = NULL) { // bool has = drawOBBearishPivots; if (!has) { return; } // has = detector.HasOBBearishPivots(); if (!has) { return; } // int count = detector.CountOBBearishPivots(); for (int i = 0; i < count; i++) { // XBoxZone iBox = detector.obBearishPivots[i]; // DrawOBBearishPivot( iBox, to // ); // iBox.Clean(); } } // void DrawFVGBullishPivots(datetime to = NULL) { // bool has = drawFVGBullishPivots; if (!has) { return; } // has = detector.HasFVGBullishPivots(); if (!has) { return; } // int count = detector.CountFVGBullishPivots(); for (int i = 0; i < count; i++) { // XBoxZone iBox = detector.fvgBullishPivots[i]; // DrawFVGBullishPivot( iBox, to // ); // iBox.Clean(); } } // void DrawFVGBearishPivots(datetime to = NULL) { // bool has = drawFVGBearishPivots; if (!has) { return; } // has = detector.HasFVGBearishPivots(); if (!has) { return; } // int count = detector.CountFVGBearishPivots(); for (int i = 0; i < count; i++) { // XBoxZone iBox = detector.fvgBearishPivots[i]; // DrawFVGBearishPivot( iBox, to // ); // iBox.Clean(); } } // void DrawTrendBullishPivots(datetime to = NULL) { // bool has = drawTrendBullishPivots; if (!has) { return; } // has = detector.HasTrendBullishPivots(); if (!has) { return; } // int count = detector.CountTrendBullishPivots(); for (int i = 0; i < count; i++) { // XBoxZone iBox = detector.trendBullishPivots[i]; // DrawTrendBullishPivot( iBox, to // ); // iBox.Clean(); } } // void DrawTrendBearishPivots(datetime to = NULL) { // bool has = drawTrendBearishPivots; if (!has) { return; } // has = detector.HasTrendBearishPivots(); if (!has) { return; } // int count = detector.CountTrendBearishPivots(); for (int i = 0; i < count; i++) { // XBoxZone iBox = detector.trendBearishPivots[i]; // DrawTrendBearishPivot( iBox, to // ); // iBox.Clean(); } } // // One Item Drawers ... // void DrawSWHPivot( XBoxZone &item, datetime to = NULL // ) { // bool has = drawSWHPivots; if (!has) { return; } // has = item.IsValid() && item.type == GetBoxType(XCA_SWH) && item.dir == GetDirection(XCA_SWH); if (!has) { return; } // bool canUpdateTo = IsValid(to); if (canUpdateTo) { item.to = to; } // XCBoxObject *iObj; has = drawer.DrawBox( item, iObj // ); if (has) { // // Style Object ... ApplyPivotStyle( iObj, swhPivotStyle // ); // // Store Object ... mSWHPivotObjects.Add(iObj); } // ZeroMemory(iObj); } // void DrawSWLPivot( XBoxZone &item, datetime to = NULL // ) { // bool has = drawSWLPivots; if (!has) { return; } // has = item.IsValid() && item.type == GetBoxType(XCA_SWL) && item.dir == GetDirection(XCA_SWL); if (!has) { return; } // bool canUpdateTo = IsValid(to); if (canUpdateTo) { item.to = to; } // XCBoxObject *iObj; has = drawer.DrawBox( item, iObj // ); if (has) { // // Style Object ... ApplyPivotStyle( iObj, swlPivotStyle // ); // // Store Object ... mSWLPivotObjects.Add(iObj); } // ZeroMemory(iObj); } // void DrawPeakPivot( XBoxZone &item, datetime to = NULL // ) { // bool has = drawPeakPivots; if (!has) { return; } // has = item.IsValid() && item.type == GetBoxType(XCA_PEAK) && item.dir == GetDirection(XCA_PEAK); if (!has) { return; } // bool canUpdateTo = IsValid(to); if (canUpdateTo) { item.to = to; } // XCBoxObject *iObj; has = drawer.DrawBox( item, iObj // ); if (has) { // // Style Object ... ApplyPivotStyle( iObj, peakPivotStyle // ); // // Store Object ... mPeakPivotObjects.Add(iObj); } // ZeroMemory(iObj); } // void DrawValePivot( XBoxZone &item, datetime to = NULL // ) { // bool has = drawValePivots; if (!has) { return; } // has = item.IsValid() && item.type == GetBoxType(XCA_VALE) && item.dir == GetDirection(XCA_VALE); if (!has) { return; } // bool canUpdateTo = IsValid(to); if (canUpdateTo) { item.to = to; } // XCBoxObject *iObj; has = drawer.DrawBox( item, iObj // ); if (has) { // // Style Object ... ApplyPivotStyle( iObj, valePivotStyle // ); // // Store Object ... mValePivotObjects.Add(iObj); } // ZeroMemory(iObj); } // void DrawOBBullishPivot( XBoxZone &item, datetime to = NULL // ) { // bool has = drawOBBullishPivots; if (!has) { return; } // has = item.IsValid() && item.type == GetBoxType(XCA_OB_BULL) && item.dir == GetDirection(XCA_OB_BULL); if (!has) { return; } // bool canUpdateTo = IsValid(to); if (canUpdateTo) { item.to = to; } // XCBoxObject *iObj; has = drawer.DrawBox( item, iObj // ); if (has) { // // Style Object ... ApplyPivotStyle( iObj, obBullishPivotStyle // ); // // Store Object ... mOBBullishPivotObjects.Add(iObj); } // ZeroMemory(iObj); } // void DrawOBBearishPivot( XBoxZone &item, datetime to = NULL // ) { // bool has = drawOBBearishPivots; if (!has) { return; } // has = item.IsValid() && item.type == GetBoxType(XCA_OB_BEAR) && item.dir == GetDirection(XCA_OB_BEAR); if (!has) { return; } // bool canUpdateTo = IsValid(to); if (canUpdateTo) { item.to = to; } // XCBoxObject *iObj; has = drawer.DrawBox( item, iObj // ); if (has) { // // Style Object ... ApplyPivotStyle( iObj, obBearishPivotStyle // ); // // Store Object ... mOBBearishPivotObjects.Add(iObj); } // ZeroMemory(iObj); } // void DrawFVGBullishPivot( XBoxZone &item, datetime to = NULL // ) { // bool has = drawFVGBullishPivots; if (!has) { return; } // has = item.IsValid() && item.type == GetBoxType(XCA_FVG_BULL) && item.dir == GetDirection(XCA_FVG_BULL); if (!has) { return; } // bool canUpdateTo = IsValid(to); if (canUpdateTo) { item.to = to; } // XCBoxObject *iObj; has = drawer.DrawBox( item, iObj // ); if (has) { // // Style Object ... ApplyPivotStyle( iObj, fvgBullishPivotStyle // ); // // Store Object ... mFVGBullishPivotObjects.Add(iObj); } // ZeroMemory(iObj); } // void DrawFVGBearishPivot( XBoxZone &item, datetime to = NULL // ) { // bool has = drawFVGBearishPivots; if (!has) { return; } // has = item.IsValid() && item.type == GetBoxType(XCA_FVG_BEAR) && item.dir == GetDirection(XCA_FVG_BEAR); if (!has) { return; } // bool canUpdateTo = IsValid(to); if (canUpdateTo) { item.to = to; } // XCBoxObject *iObj; has = drawer.DrawBox( item, iObj // ); if (has) { // // Style Object ... ApplyPivotStyle( iObj, fvgBearishPivotStyle // ); // // Store Object ... mFVGBearishPivotObjects.Add(iObj); } // ZeroMemory(iObj); } // void DrawTrendBullishPivot( XBoxZone &item, datetime to = NULL // ) { // bool has = drawTrendBullishPivots; if (!has) { return; } // has = item.IsValid() && item.type == GetBoxType(XCA_TREND_BULL) && item.dir == GetDirection(XCA_TREND_BULL); if (!has) { return; } // bool canUpdateTo = IsValid(to); if (canUpdateTo) { item.to = to; } // XCBoxObject *iObj; has = drawer.DrawBox( item, iObj // ); if (has) { // // Style Object ... ApplyPivotStyle( iObj, trendBullishPivotStyle // ); // // Store Object ... mTrendBullishPivotObjects.Add(iObj); } // ZeroMemory(iObj); } // void DrawTrendBearishPivot( XBoxZone &item, datetime to = NULL // ) { // bool has = drawTrendBearishPivots; if (!has) { return; } // has = item.IsValid() && item.type == GetBoxType(XCA_TREND_BEAR) && item.dir == GetDirection(XCA_TREND_BEAR); if (!has) { return; } // bool canUpdateTo = IsValid(to); if (canUpdateTo) { item.to = to; } // XCBoxObject *iObj; has = drawer.DrawBox( item, iObj // ); if (has) { // // Style Object ... ApplyPivotStyle( iObj, trendBearishPivotStyle // ); // // Store Object ... mTrendBearishPivotObjects.Add(iObj); } // ZeroMemory(iObj); } // // Protected ... protected: // // Props ... // void ApplyPivotStyle( XCBoxObject *&object, XCAPivotStyle &style // ) { // if (object == NULL) { return; } // object.BoxColor(style.clr); object.BoxWidth(style.width); object.BoxStyle(style.style); } // // Prrivate ... private: // // Props ... // XCPOIDrawer *drawer; XCXCAEAPOIDetector *detector; // CArrayObj mObjects; // CArrayObj mSWHPivotObjects; CArrayObj mSWLPivotObjects; // CArrayObj mPeakPivotObjects; CArrayObj mValePivotObjects; // CArrayObj mOBBullishPivotObjects; CArrayObj mOBBearishPivotObjects; // CArrayObj mFVGBullishPivotObjects; CArrayObj mFVGBearishPivotObjects; // CArrayObj mTrendBullishPivotObjects; CArrayObj mTrendBearishPivotObjects; // }; //