diff --git a/Classes/x-saherelm.x-cobject.class.mq5 b/Classes/x-saherelm.x-cobject.class.mq5 index 3ab50daa..a2aff813 100644 --- a/Classes/x-saherelm.x-cobject.class.mq5 +++ b/Classes/x-saherelm.x-cobject.class.mq5 @@ -39,13 +39,13 @@ enum ENUM_XCHARTOBJECTS { // // Global ... - X_BOX_OBJ = 7861, - X_BAR_ARROW_OBJ = 7862, - // - X_SIGNAL_OBJ = 8860, - X_OHCL_OBJ = 8863, - X_RR_OBJ = 8864, - X_PIVOT_OBJ = 8865, + X_EMPTY_OBJ = 7860, // Empty + X_BOX_OBJ = 7861, // XBox + X_BAR_ARROW_OBJ = 7862, // XBarArrow + X_SIGNAL_OBJ = 8860, // XSignal + X_OHCL_OBJ = 8863, // XBar + X_RR_OBJ = 8864, // XRR + X_PIVOT_OBJ = 8865, // XPivot // // 9860 Custom Object ... }; @@ -78,6 +78,12 @@ string ToString(ENUM_X_CHART_IDS value) return result; } +string ToXString(ENUM_XCHARTOBJECTS value) +{ + // + return EnumToString(value); +} + struct XPOIStyle { // @@ -372,9 +378,26 @@ class XCBaseObject : public CChartObject */ void ObjName(string value) { + // + Name(value); mObjName = value; } + virtual string TypeString() + { + return ToXString(X_EMPTY_OBJ); + } + + /** + * Retrieve Object Type ... + * + * @return ( ENUM_XCHARTOBJECTS ) + */ + virtual int Type(void) const + { + return ((int)X_EMPTY_OBJ); + } + /** * Destroy ... */ @@ -481,6 +504,38 @@ class XCBarArrowObject : public XCBaseObject // // Virtual ... + /** + * Destroy ... + */ + void virtual Destroy() + { + // + mArrow.Detach(); + mArrow.Delete(); + + // + Detach(); + Delete(); + } + + /** + * Retrieve Object Type ... + * + * @return ( ENUM_XCHARTOBJECTS ) + */ + virtual int Type(void) + { + return (int)X_BAR_ARROW_OBJ; + } + + /** + * Type as String ... + **/ + string TypeString() override + { + return ToXString(X_BAR_ARROW_OBJ); + } + // // Setter(s) ... @@ -687,6 +742,48 @@ class XCSignalObject : public XCBaseObject return result; } + // + // Virtual ... + + /** + * Destroy ... + */ + void virtual Destroy() + { + // + mTPTrend.Detach(); + mTPTrend.Delete(); + mSLTrend.Detach(); + mSLTrend.Delete(); + mEntryTrend.Detach(); + mEntryTrend.Delete(); + + // + mTargetTrends.Clear(); + + // + Detach(); + Delete(); + } + + /** + * Retrieve Object Type ... + * + * @return ( ENUM_XCHARTOBJECTS ) + */ + virtual int Type(void) + { + return (int)X_SIGNAL_OBJ; + } + + /** + * Type as String ... + **/ + string TypeString() override + { + return ToXString(X_SIGNAL_OBJ); + } + // // Setter(s) ... @@ -867,16 +964,6 @@ class XCSignalObject : public XCBaseObject mEntryTrend.Style(value); } - /** - * Retrieve Object Type ... - * - * @return ( ENUM_XCHARTOBJECTS ) - */ - virtual ENUM_XCHARTOBJECTS Type() - { - return X_SIGNAL_OBJ; - } - // private: // @@ -950,6 +1037,24 @@ class XCRRObject : public XCSignalObject // return result; } + + /** + * Retrieve Object Type ... + * + * @return ( ENUM_XCHARTOBJECTS ) + */ + virtual int Type(void) + { + return (int)X_RR_OBJ; + } + + /** + * Type as String ... + **/ + string TypeString() override + { + return ToXString(X_RR_OBJ); + } }; // @@ -1072,6 +1177,49 @@ class XCOHCLObject : public XCBaseObject return result; } + // + // Virtual ... + + /** + * Destroy ... + */ + void virtual Destroy() + { + // + mBodyRect.Detach(); + mBodyRect.Delete(); + + // + mLowShadowRect.Detach(); + mLowShadowRect.Delete(); + + // + mHighShadowRect.Detach(); + mHighShadowRect.Delete(); + + // + Detach(); + Delete(); + } + + /** + * Retrieve Object Type ... + * + * @return ( ENUM_XCHARTOBJECTS ) + */ + virtual int Type(void) + { + return (int)X_OHCL_OBJ; + } + + /** + * Type as String ... + **/ + string TypeString() override + { + return ToXString(X_OHCL_OBJ); + } + // // Getter(s) / Setter(s) ... @@ -1244,19 +1392,6 @@ class XCOHCLObject : public XCBaseObject HighShadowFill(fill); } - // - // Virtual ... - - /** - * Retrieve Object Type ... - * - * @return ( ENUM_XCHARTOBJECTS ) - */ - virtual ENUM_XCHARTOBJECTS Type() - { - return X_OHCL_OBJ; - } - // private: // @@ -1375,6 +1510,45 @@ class XCBoxObject : public XCBaseObject return result; } + // + // Virtual ... + + /** + * Destroy ... + */ + void virtual Destroy() + { + // + mAt.Detach(); + mAt.Delete(); + + // + mRect.Detach(); + mRect.Delete(); + + // + Detach(); + Delete(); + } + + /** + * Retrieve Object Type ... + * + * @return ( ENUM_XCHARTOBJECTS ) + */ + virtual int Type(void) + { + return (int)X_BOX_OBJ; + } + + /** + * Type as String ... + **/ + string TypeString() override + { + return ToXString(X_BOX_OBJ); + } + // // Getter(s) / Setter(s) ... @@ -1430,19 +1604,6 @@ class XCBoxObject : public XCBaseObject mRect.Fill(value); } - // - // Virtual ... - - /** - * Retrieve Object Type ... - * - * @return ( ENUM_XCHARTOBJECTS ) - */ - virtual ENUM_XCHARTOBJECTS Type() - { - return X_BOX_OBJ; - } - // private: // @@ -1685,10 +1846,24 @@ class XCPivotAnalysisObject : public XCBaseObject // if (model.pivots[i].IsPeak()) { + // + if (mPeaks == NULL) + { + mPeaks = new CArrayObj(); + } + + // mPeaks.Add(iObj); } else { + // + if (mVales == NULL) + { + mVales = new CArrayObj(); + } + + // mVales.Add(iObj); } } @@ -1723,9 +1898,17 @@ class XCPivotAnalysisObject : public XCBaseObject * * @return ( ENUM_XCHARTOBJECTS ) */ - virtual ENUM_XCHARTOBJECTS Type() + virtual int Type(void) { - return X_PIVOT_OBJ; + return (int)X_PIVOT_OBJ; + } + + /** + * Type as String ... + **/ + string TypeString() override + { + return ToXString(X_PIVOT_OBJ); } /** @@ -1734,14 +1917,34 @@ class XCPivotAnalysisObject : public XCBaseObject void virtual Destroy() { // - Detach(); - Delete(); + DestroyObjects(mPeaks); + DestroyObjects(mVales); // DestroyObject(mUpper); DestroyObject(mLower); DestroyObject(mSupportBox); DestroyObject(mResistanceBox); + + // + delete mPeaks; + delete mVales; + delete mUpper; + delete mLower; + delete mSupportBox; + delete mResistanceBox; + + // + ZeroMemory(mPeaks); + ZeroMemory(mVales); + ZeroMemory(mUpper); + ZeroMemory(mLower); + ZeroMemory(mSupportBox); + ZeroMemory(mResistanceBox); + + // + Detach(); + Delete(); } // @@ -2050,6 +2253,12 @@ class XCPivotAnalysisObject : public XCBaseObject */ void PeaksWidth(int value) { + // + if (mPeaks == NULL) + { + return; + } + // // Normalize ... value = NormalizeInt(value, 1); @@ -2081,6 +2290,12 @@ class XCPivotAnalysisObject : public XCBaseObject */ void PeaksColor(color value) { + // + if (mPeaks == NULL) + { + return; + } + // // Validate ... int count = mPeaks.Total(); @@ -2108,6 +2323,12 @@ class XCPivotAnalysisObject : public XCBaseObject */ void PeaksAnchor(ENUM_ARROW_ANCHOR value) { + // + if (mPeaks == NULL) + { + return; + } + // // Validate ... int count = mPeaks.Total(); @@ -2135,6 +2356,12 @@ class XCPivotAnalysisObject : public XCBaseObject */ void ValesWidth(int value) { + // + if (mVales == NULL) + { + return; + } + // // Normalize ... value = NormalizeInt(value, 1); @@ -2166,6 +2393,12 @@ class XCPivotAnalysisObject : public XCBaseObject */ void ValesColor(color value) { + // + if (mVales == NULL) + { + return; + } + // // Validate ... int count = mVales.Total(); @@ -2193,6 +2426,12 @@ class XCPivotAnalysisObject : public XCBaseObject */ void ValesAnchor(ENUM_ARROW_ANCHOR value) { + // + if (mVales == NULL) + { + return; + } + // // Validate ... int count = mVales.Total(); @@ -2216,8 +2455,8 @@ class XCPivotAnalysisObject : public XCBaseObject // private: // - CArrayObj mPeaks; - CArrayObj mVales; + CArrayObj *mPeaks; + CArrayObj *mVales; CChartObjectTrend *mUpper; CChartObjectTrend *mLower; XCBoxObject *mSupportBox; @@ -2331,6 +2570,215 @@ void DestroyObject(CChartObjectTrend *&object) ZeroMemory(object); } +/** + * Completely Destroy all Chart Objects ... + * + * @param objects: CArrayObj, pointer refrence Specified Data Source ... + */ +void DestroyObjects(CArrayObj *&objects) +{ + // + // Validate Exists ... + if (objects == NULL) + { + return; + } + + // + // Count Childs ... + int count = objects.Total(); + if (!IsValidSize(count)) + { + return; + } + + // + // Destroy all Childs ... + for (int i = 0; i < count; i++) + { + // + // Checking Types ... + int iType = ((CChartObject *)objects.At(i)).Type(); + + // + string iTypeStr = NULL; + if (iType == X_EMPTY_OBJ) + { + // + XCBaseObject *iObj = (XCBaseObject *)objects.At(i); + iTypeStr = iObj.TypeString(); + + // + if (iTypeStr == ToXString(X_BOX_OBJ)) + { + iType = X_BOX_OBJ; + } + else if (iTypeStr == ToXString(X_BAR_ARROW_OBJ)) + { + iType = X_BAR_ARROW_OBJ; + } + else if (iTypeStr == ToXString(X_SIGNAL_OBJ)) + { + iType = X_SIGNAL_OBJ; + } + else if (iTypeStr == ToXString(X_OHCL_OBJ)) + { + iType = X_OHCL_OBJ; + } + else if (iTypeStr == ToXString(X_RR_OBJ)) + { + iType = X_RR_OBJ; + } + else if (iTypeStr == ToXString(X_PIVOT_OBJ)) + { + iType = X_PIVOT_OBJ; + } + } + + // + string iName = ((CChartObject *)objects.At(i)).Name(); + if (!IsSpecifiedValid(iName)) + { + iName = ((XCBaseObject *)objects.At(i)).ObjName(); + } + + // + switch (iType) + { + // + case X_RR_OBJ: { + // + XCRRObject *iObj = (XCRRObject *)objects.At(i); + iObj.Destroy(); + + // + delete iObj; + ZeroMemory(iObj); + } + break; + case X_BOX_OBJ: { + // + XCBoxObject *iObj = (XCBoxObject *)objects.At(i); + iObj.Destroy(); + iObj.Detach(); + iObj.Delete(); + + // + delete iObj; + ZeroMemory(iObj); + } + break; + case X_OHCL_OBJ: { + // + XCOHCLObject *iObj = (XCOHCLObject *)objects.At(i); + iObj.Destroy(); + + // + delete iObj; + ZeroMemory(iObj); + } + break; + case X_PIVOT_OBJ: { + // + XCPivotAnalysisObject *iObj = (XCPivotAnalysisObject *)objects.At(i); + iObj.Destroy(); + + // + delete iObj; + ZeroMemory(iObj); + } + break; + case X_SIGNAL_OBJ: { + // + XCSignalObject *iObj = (XCSignalObject *)objects.At(i); + iObj.Destroy(); + + // + delete iObj; + ZeroMemory(iObj); + } + break; + case X_BAR_ARROW_OBJ: { + // + XCBarArrowObject *iObj = (XCBarArrowObject *)objects.At(i); + iObj.Destroy(); + + // + delete iObj; + ZeroMemory(iObj); + } + break; + // + // Default Object Types ... + case OBJ_VLINE: + case OBJ_HLINE: + case OBJ_TREND: + case OBJ_TRENDBYANGLE: + case OBJ_CYCLES: + case OBJ_ARROWED_LINE: + case OBJ_CHANNEL: + case OBJ_STDDEVCHANNEL: + case OBJ_REGRESSION: + case OBJ_PITCHFORK: + case OBJ_GANNLINE: + case OBJ_GANNFAN: + case OBJ_GANNGRID: + case OBJ_FIBO: + case OBJ_FIBOTIMES: + case OBJ_FIBOFAN: + case OBJ_FIBOARC: + case OBJ_FIBOCHANNEL: + case OBJ_EXPANSION: + case OBJ_ELLIOTWAVE5: + case OBJ_ELLIOTWAVE3: + case OBJ_RECTANGLE: + case OBJ_TRIANGLE: + case OBJ_ELLIPSE: + case OBJ_ARROW_THUMB_UP: + case OBJ_ARROW_THUMB_DOWN: + case OBJ_ARROW_UP: + case OBJ_ARROW_DOWN: + case OBJ_ARROW_STOP: + case OBJ_ARROW_CHECK: + case OBJ_ARROW_LEFT_PRICE: + case OBJ_ARROW_RIGHT_PRICE: + case OBJ_ARROW_BUY: + case OBJ_ARROW_SELL: + case OBJ_ARROW: + case OBJ_TEXT: + case OBJ_LABEL: + case OBJ_BUTTON: + case OBJ_CHART: + case OBJ_BITMAP: + case OBJ_BITMAP_LABEL: + case OBJ_EDIT: + case OBJ_EVENT: + case OBJ_RECTANGLE_LABEL: { + // + CChartObject *iObj = (CChartObject *)objects.At(i); + + // + iObj.Detach(); + iObj.Delete(); + + // + delete iObj; + ZeroMemory(iObj); + } + break; + } + + // + RemoveObjects(iName); + } + + // + // Destroy itSelf ... + objects.Clear(); + delete objects; + ZeroMemory(objects); +} + /** * Remove Drawn Objects from Chart ... * diff --git a/Classes/x-saherelm.x-poi.drawer.class.mq5 b/Classes/x-saherelm.x-poi.drawer.class.mq5 index 2ebac09a..42b4ad45 100644 --- a/Classes/x-saherelm.x-poi.drawer.class.mq5 +++ b/Classes/x-saherelm.x-poi.drawer.class.mq5 @@ -430,6 +430,10 @@ class XCPOIDrawer : public XCBase // // Prepare ... + if (draws == NULL) + { + draws = new CArrayObj(); + } draws.Clear(); // @@ -617,6 +621,63 @@ class XCPOIDrawer : public XCBase return result; } + /** + * Draw a Collection of Boxes ... + * + * @param boxes: reference collection to Provide Boxes ... + * @param objects: reference pointer to holds drawn Objects ... + * @param ignoreAt: bool, ignore Box At Drawn ... + * + * @return ( int ) + */ + int DrawBoxes( + XBoxZone &boxes[], + CArrayObj *&objects, + bool ignoreAt = true // + ) + { + // + int result = 0; + + // + // Prepare ... + objects = new CArrayObj(); + + // + // Validate ... + if (!HasChild(boxes)) + { + return result; + } + + // + bool has = false; + XCBoxObject *iObj; + int count = ArraySize(boxes); + for (int i = 0; i < count; i++) + { + // + has = DrawBox( + boxes[i], + iObj, + ignoreAt // + ); + if (has) + { + objects.Add(iObj); + } + + // + ZeroMemory(iObj); + } + + // + result = objects.Total(); + + // + return result; + } + /** * Draw Specified Signal ... * @@ -1073,6 +1134,37 @@ class XCPOIDrawer : public XCBase object.BoxStyle(style.style); } + /** + * Apply Specified Style to a Collection on Drawn Boxes ... + * + * @param objects: pointer reference of Objects ... + * @param style: XPOIStyle, Specifed Style to Apply ... + */ + void ApplyBoxesStyle( + CArrayObj *&objects, + XPOIStyle &style // + ) + { + // + // Validate ... + if (objects == NULL || objects.Total() <= 0) + { + return; + } + + // + for (int i = 0; i < objects.Total(); i++) + { + // + XCBoxObject *iObj = ((XCBoxObject *)objects.At(i)); + ApplyBoxStyle( + iObj, + style // + ); + ZeroMemory(iObj); + } + } + /** * Apply Specified Style to Specified Object ... * diff --git a/Experts/x-saherelm.xfima.backtester.ea.mq5 b/Experts/x-saherelm.xfima.backtester.ea.mq5 index 3451dab0..421d808a 100644 --- a/Experts/x-saherelm.xfima.backtester.ea.mq5 +++ b/Experts/x-saherelm.xfima.backtester.ea.mq5 @@ -154,7 +154,8 @@ XFIMAMarketStructureDrawerConfig marketStructureDrawerConfig; // POI Drawer Conf // // Drawer and eaDraws ... -CArrayObj eaDraws; // Drawn Objects ... +// CArrayObj *eaDraws; // Drawn Objects ... +CArrayObj *marketStructureObjects; // Market Structure Objects ... // XBarTracker eaBarTracker; // EA Bar Traker ... @@ -387,6 +388,7 @@ int OnInit() // // Configure XFIMA POI Detector / Drawer ... detectorConfig.Default(); + // eaDraws = new CArrayObj(); detectorConfig.FullDetect(); marketStructureDrawerConfig.FullDraw(); @@ -457,8 +459,8 @@ void OnTick() fima1Signaller.OnTick(); fima2Signaller.OnTick(); - // // - // AnalyseMarket(0); + // + AnalyseMarket(1); } // @@ -616,40 +618,40 @@ void OnSignalTriggered(XSignal &signal) // Draw Signal Vertical Line ... // - CChartObjectVLine *iObj = new CChartObjectVLine(); + // CChartObjectVLine *iObj = new CChartObjectVLine(); + + // // + // string iName = signal.GetTag(); + // color iColor = IsLong(signal.type) ? clrLime : clrRed; + + // // + // bool has = iObj.Create( + // fima2Signaller.poiDrawer.ChartIdentification(), + // iName, + // fima2Signaller.poiDrawer.SubWindowIdentification(), + // signal.time // + // ); + // if (has) + // { + // // + // iObj.Width(2); + // iObj.Color(iColor); + + // // + // // eaDraws.Add(iObj); + // } + + // // + // // Alert Issued Signal ... + // string message = signal.GetMessage(); // - string iName = signal.GetTag(); - color iColor = IsLong(signal.type) ? clrLime : clrRed; - - // - bool has = iObj.Create( - fima2Signaller.poiDrawer.ChartIdentification(), - iName, - fima2Signaller.poiDrawer.SubWindowIdentification(), - signal.time // - ); - if (has) - { - // - iObj.Width(2); - iObj.Color(iColor); - - // - eaDraws.Add(iObj); - } - - // - // Alert Issued Signal ... - string message = signal.GetMessage(); - - // - int signalBarIndex = GetBarIndex( - signal.symbol, - signal.period, - signal.time // - ); - AnalyseMarket(signalBarIndex); + // int signalBarIndex = GetBarIndex( + // signal.symbol, + // signal.period, + // signal.time // + // ); + // AnalyseMarket(signalBarIndex); } // @@ -843,15 +845,31 @@ void AnalyseMarket(int barIndex = 0) // // Configure Drawer ... + // + marketStructureDrawerConfig.drawOB = false; + marketStructureDrawerConfig.drawFVG = false; + + // + marketStructureDrawerConfig.drawPinned = true; + marketStructureDrawerConfig.drawEngulfed = true; + marketStructureDrawerConfig.drawTrueGaped = false; + marketStructureDrawerConfig.drawMomentum = false; + marketStructureDrawerConfig.drawFlagPattern = false; + marketStructureDrawerConfig.drawStarPattern = false; + marketStructureDrawerConfig.drawRisingPattern = false; + marketStructureDrawerConfig.drawPiercingPattern = false; + marketStructureDrawerConfig.drawSignalKeyBarPattern = true; + // // Recents ... + marketStructureDrawerConfig.drawRecentPatterns = false; marketStructureDrawerConfig.drawFakeBreakedZone = true; - marketStructureDrawerConfig.drawRecentlyTestedZones = true; - marketStructureDrawerConfig.drawRecentlyBreakedZones = true; + marketStructureDrawerConfig.drawRecentlyTestedZones = false; + marketStructureDrawerConfig.drawRecentlyBreakedZones = false; // // XPV ... - marketStructureDrawerConfig.drawFIMAPVPivotsAnalysis = true; + marketStructureDrawerConfig.drawFIMAPVPivotsAnalysis = false; marketStructureDrawerConfig.drawFIMAPVPivotsAnalysisZones = true; marketStructureDrawerConfig.drawFIMAPVPivotsAnalysisTrends = true; marketStructureDrawerConfig.drawFIMAPVPivotsAnalysisPivots = true; @@ -885,41 +903,36 @@ void AnalyseMarket(int barIndex = 0) detectorConfig // ); + // + if (marketStructureObjects == NULL) { + marketStructureObjects = new CArrayObj(); + } + + // + // marketStructureObjects.Clear(); + + // + // Draw Only ... + // // Draw Market Structure ... - CArrayObj *marketStructureObjects; int marketStructureObjectsCount = fima2Signaller.poiDrawer.DrawMarketStructure( marketStructure, marketStructureDrawerConfig, marketStructureObjects // ); - if (IsValidIndex(marketStructureObjectsCount)) - { - // - // Add Drawn Objects if Necessary ... - } - - // - if (HasChild(marketStructure.recentlyTestedZones)) - { - Print("Recently Tested Zones ..."); - } - - // - if (HasChild(marketStructure.recentlyBreakedZones)) - { - Print("Recently Breaked Zones ..."); - } - - // - if (marketStructure.fakeBreakedZone.IsValid()) - { - Print("Fake Breaked Zone ..."); - } + // if (IsValidIndex(marketStructureObjectsCount)) + // { + // // + // // Add Drawn Objects if Necessary ... + // // AddObjects( + // // marketStructureObjects, + // // eaDraws // + // // ); + // } // bar.Clean(); - marketStructureObjects.Clear(); } // \ No newline at end of file diff --git a/Libraries/x-saherelm.common.extensions.lib.mq5 b/Libraries/x-saherelm.common.extensions.lib.mq5 index 305165af..b9d1cf96 100644 --- a/Libraries/x-saherelm.common.extensions.lib.mq5 +++ b/Libraries/x-saherelm.common.extensions.lib.mq5 @@ -1524,6 +1524,11 @@ string GetTypeName(const T &t) { return typename(T); } +template +string GetTypeName(const T *t) +{ + return typename(T); +} /** * Get Specified Types Token ... diff --git a/Libraries/x-saherelm.x-enums.lib.mq5 b/Libraries/x-saherelm.x-enums.lib.mq5 index 68dbd1f9..2e90cf4f 100644 --- a/Libraries/x-saherelm.x-enums.lib.mq5 +++ b/Libraries/x-saherelm.x-enums.lib.mq5 @@ -1282,8 +1282,8 @@ string ToString(ENUM_X_MA_METHOD value) // enum ENUM_X_PIVOT_TYPE { - X_PIVOT_TYPE_NONE = 0, // None - X_PIVOT_TYPE_PEAK = 1, // PEAK + X_PIVOT_TYPE_NONE = 0, // None + X_PIVOT_TYPE_PEAK = 1, // PEAK X_PIVOT_TYPE_VALE = 2, // VALE }; @@ -1355,7 +1355,31 @@ bool IsXVale(ENUM_X_PIVOT_TYPE value) */ string ToXString(ENUM_X_PIVOT_TYPE value) { - return EnumToString(value); + // + string result = NULL; + + // + switch (value) + { + // + case X_PIVOT_TYPE_NONE: + result = "XNONE"; + break; + + // + case X_PIVOT_TYPE_PEAK: + result = "XPEAK"; + break; + + // + case X_PIVOT_TYPE_VALE: + result = "XVALE"; + break; + } + + // + return result; + // return EnumToString(value); } // diff --git a/Libraries/x-saherelm.x-poi.extensions.lib.mq5 b/Libraries/x-saherelm.x-poi.extensions.lib.mq5 index f1790011..0f3a446f 100644 --- a/Libraries/x-saherelm.x-poi.extensions.lib.mq5 +++ b/Libraries/x-saherelm.x-poi.extensions.lib.mq5 @@ -3951,8 +3951,8 @@ bool ToBox( box.dir = forDir; box.type = prefix; box.at = bar.time; + box.to = bar.time; box.from = bar.time; - box.to = TimeCurrent(); box.symbol = bar.symbol; box.period = bar.period; diff --git a/XFIMAEA/Classes/x-saherelm.xfima.x-poi.detector.class.mq5 b/XFIMAEA/Classes/x-saherelm.xfima.x-poi.detector.class.mq5 index 629c776a..8bf20bfc 100644 --- a/XFIMAEA/Classes/x-saherelm.xfima.x-poi.detector.class.mq5 +++ b/XFIMAEA/Classes/x-saherelm.xfima.x-poi.detector.class.mq5 @@ -1227,6 +1227,40 @@ class XCXFIMAPOIDetector : public XCMarketPatternDetector ); } + // + // Supports ... + if (config.detectSupport) + { + // + Copy( + supports, + structure.supports // + ); + Sort( + structure.supports, + iSortBy, + iSortDir, + config.recentlyPatternsMaxAllowedCollecting // + ); + } + + // + // Resistances ... + if (config.detectResistance) + { + // + Copy( + resistances, + structure.resistances // + ); + Sort( + structure.resistances, + iSortBy, + iSortDir, + config.recentlyPatternsMaxAllowedCollecting // + ); + } + // // Loop through Items ... for (int i = start; i < end; i++) @@ -1312,7 +1346,7 @@ class XCXFIMAPOIDetector : public XCMarketPatternDetector // iPrefix = "TruGapedBar"; has = IsTrueGapedBar( - forBar, + iBar, iDir, config.truwGapApprovedPointMultiplier // ); @@ -1341,7 +1375,7 @@ class XCXFIMAPOIDetector : public XCMarketPatternDetector // iPrefix = "PinBar"; has = IsPinnedBar( - forBar, + iBar, iDir, config.pinnedBaarShadowApprovedMultiplier, config.pinnedBarMinimumPinBarRangeMultiplier, @@ -1375,12 +1409,12 @@ class XCXFIMAPOIDetector : public XCMarketPatternDetector // iPrefix = "Star"; has = IsStartPattern( - forBar, + iBar, iDir // ); has = has && ToBox( - forBar, + iBar, iBox, iDir, iPrefix // @@ -1403,12 +1437,12 @@ class XCXFIMAPOIDetector : public XCMarketPatternDetector // iPrefix = "Piercing"; has = IsPiercingPattern( - forBar, + iBar, iDir // ); has = has && ToBox( - forBar, + iBar, iBox, iDir, iPrefix // @@ -1431,12 +1465,12 @@ class XCXFIMAPOIDetector : public XCMarketPatternDetector // iPrefix = "Rising"; has = IsRisingPattern( - forBar, + iBar, iDir // ); has = has && ToBox( - forBar, + iBar, iBox, iDir, iPrefix // @@ -1460,14 +1494,14 @@ class XCXFIMAPOIDetector : public XCMarketPatternDetector iPrefix = "Flag"; XOHCL swingBar; has = IsFlagPattern( - forBar, + iBar, iDir, swingBar, config.flagPatternMinimumPullbackBars // ); has = has && ToBox( - forBar, + iBar, iBox, iDir, iPrefix // @@ -1490,7 +1524,7 @@ class XCXFIMAPOIDetector : public XCMarketPatternDetector // iPrefix = "SignalKeyBar"; has = IsSignalKeyBarPattern( - forBar, + iBar, iDir, config.signalKeyBarShadowApprovedMultiplier, config.signalKeyBarMinimumPinBarRangeMultiplier, @@ -1498,7 +1532,7 @@ class XCXFIMAPOIDetector : public XCMarketPatternDetector ); has = has && ToBox( - forBar, + iBar, iBox, iDir, iPrefix // diff --git a/XFIMAEA/Classes/x-saherelm.xfima.x-poi.drawer.class.mq5 b/XFIMAEA/Classes/x-saherelm.xfima.x-poi.drawer.class.mq5 index 3f28d94d..27a8276c 100644 --- a/XFIMAEA/Classes/x-saherelm.xfima.x-poi.drawer.class.mq5 +++ b/XFIMAEA/Classes/x-saherelm.xfima.x-poi.drawer.class.mq5 @@ -230,6 +230,82 @@ class XCXFIMAPOIDrawer : public XCPOIDrawer return result; } + /** + * Get Patterns Zone Style ... + * + * @param style: reference to hold result ... + * @param zone: Specified Zone ... + * + * @return ( bool ) + */ + bool GetPatternStyle( + XPOIStyle &style, + XBoxZone &zone // + ) + { + // + bool result = false; + + // + style.Clean(); + + // + result = zone.IsValid(); + if (!result) + { + return result; + } + + // + GetPatternStyle( + style, + zone.dir // + ); + + // + return result; + } + + /** + * Get Patterns Zone Style ... + * + * @param style: reference to hold result ... + * @param forDir: Specified Direction ... + * + * @return ( bool ) + */ + bool GetPatternStyle( + XPOIStyle &style, + ENUM_X_DIRECTION forDir // + ) + { + // + bool result = false; + + // + style.Clean(); + + // + result = HasDirection(forDir); + if (!result) + { + return result; + } + + // + GetBoxStyle( + style, + forDir // + ); + + // + style.width = 3; + style.style = STYLE_DASH; + + // + return result; + } + /** * Get Breaked Zone Style ... * @@ -450,6 +526,182 @@ class XCXFIMAPOIDrawer : public XCPOIDrawer ); } + /** + * Apply Pattern Style ... + * + * @param object: reference pointer to Object ... + * @param zone: reference to Zone ... + */ + void ApplyPatternStyle( + XCBoxObject *&object, + XBoxZone &zone // + ) + { + // + if (!zone.IsValid() || + object == NULL) + { + return; + } + + // + XPOIStyle style; + if (!GetPatternStyle(style, zone)) + { + return; + } + + // + ApplyBoxStyle( + object, + style // + ); + } + + /** + * Apply Patterns Style ... + * + * @param object: reference pointer to Object ... + */ + void ApplyPatternsStyle( + CArrayObj *&objects // + ) + { + // + if (objects == NULL || + objects.Total() == 0) + { + return; + } + + // + bool has = false; + XPOIStyle iStyle; + string iName = NULL; + XCBoxObject *iBoxObj = NULL; + ENUM_X_DIRECTION iDir = X_DIRECTION_NONE; + for (int i = 0; i < objects.Total(); i++) + { + // + iBoxObj = (XCBoxObject *)objects.At(i); + iName = iBoxObj.ObjName(); + + // + iDir = + IsSpecifiedValid(iName) && + Contains( + "BULL", + iName // + ) + ? X_DIRECTION_BULLISH + : IsSpecifiedValid(iName) && + Contains( + "BEAR", + iName // + ) + ? X_DIRECTION_BEARISH + : X_DIRECTION_NONE; + + // + has = GetPatternStyle(iStyle, iDir); + if (has) + { + // + ApplyBoxStyle( + iBoxObj, + iStyle // + ); + } + + // + iStyle.Clean(); + ZeroMemory(iBoxObj); + } + } + + /** + * Apply Style to Specified Pivot Object ... + * + * @param object: reference pointer to Object ... + * @param zone: reference to Zone ... + */ + void ApplyPivotStyle( + XCBarArrowObject *&object, + XPOIStyle &style // + ) + { + // + if (object == NULL) + { + return; + } + + // + object.ArrowColor(style.clr); + object.ArrowWidth(style.width); + } + + /** + * Apply Patterns Style ... + * + * @param object: reference pointer to Object ... + */ + void ApplyPivotsStyle( + CArrayObj *&objects // + ) + { + // + if (objects == NULL || + objects.Total() == 0) + { + return; + } + + // + bool has = false; + XPOIStyle iStyle; + string iName = NULL; + XCBarArrowObject *iObj = NULL; + ENUM_X_DIRECTION iDir = X_DIRECTION_NONE; + for (int i = 0; i < objects.Total(); i++) + { + // + iObj = (XCBarArrowObject *)objects.At(i); + iName = iObj.ObjName(); + + // + iDir = + IsSpecifiedValid(iName) && + Contains( + "BULL", + iName // + ) + ? X_DIRECTION_BULLISH + : IsSpecifiedValid(iName) && + Contains( + "BEAR", + iName // + ) + ? X_DIRECTION_BEARISH + : X_DIRECTION_NONE; + + // + has = GetPatternStyle(iStyle, iDir); + if (has) + { + // + ApplyPivotStyle( + iObj, + iStyle // + ); + } + + // + iStyle.Clean(); + ZeroMemory(iObj); + } + } + /** * Draw Specified Market Structure Based on Given Configs ... * @@ -477,7 +729,7 @@ class XCXFIMAPOIDrawer : public XCPOIDrawer // // Prepare ... - objects.Clear(); + // objects.Clear(); // int count = 0; @@ -556,7 +808,7 @@ class XCXFIMAPOIDrawer : public XCPOIDrawer // // Support ... - if (config.drawSupports) + if (config.drawSupport) { // // Validate ... @@ -1173,13 +1425,145 @@ class XCXFIMAPOIDrawer : public XCPOIDrawer // Draw Recent Patterns ... if (config.drawRecentPatterns) { + // + int baseArrowCode = 159; + CArrayObj *patternObjects; + + // + // Order Blocs ... + if (config.drawOB && + HasChild(structure.obs)) + { + // + count = DrawBoxes( + structure.obs, + patternObjects // + ); + has = IsValidSize(count); + if (has) + { + // + ApplyPatternsStyle(patternObjects); + + // + AddObjects( + patternObjects, + objects // + ); + } + + // + ZeroMemory(patternObjects); + } + + // + // Fair Value Gaps ... + if (config.drawFVG && + HasChild(structure.fvgs)) + { + // + count = DrawBoxes( + structure.fvgs, + patternObjects // + ); + has = IsValidSize(count); + if (has) + { + // + ApplyPatternsStyle(patternObjects); + + // + AddObjects( + patternObjects, + objects // + ); + } + + // + ZeroMemory(patternObjects); + } + + // + // Supports ... + if (config.drawSupport && + HasChild(structure.supports)) + { + // + count = DrawBoxes( + structure.supports, + patternObjects // + ); + has = IsValidSize(count); + if (has) + { + // + ApplyPatternsStyle(patternObjects); + + // + AddObjects( + patternObjects, + objects // + ); + } + + // + ZeroMemory(patternObjects); + } + + // + // Resistances ... + if (config.drawResistance && + HasChild(structure.obs)) + { + // + count = DrawBoxes( + structure.resistances, + patternObjects // + ); + has = IsValidSize(count); + if (has) + { + // + ApplyPatternsStyle(patternObjects); + + // + AddObjects( + patternObjects, + objects // + ); + } + + // + ZeroMemory(patternObjects); + } + // // Pin Bars ... if (config.drawPinned && HasChild(structure.pinBars)) { // - // TODO: Complete this ... + count = DrawPivots( + structure.pinBars, + patternObjects, + baseArrowCode, + baseArrowCode // + ); + has = IsValidSize(count); + if (has) + { + // + ApplyPivotsStyle(patternObjects); + + // + AddObjects( + patternObjects, + objects // + ); + } + + // + ZeroMemory(patternObjects); } // @@ -1188,7 +1572,27 @@ class XCXFIMAPOIDrawer : public XCPOIDrawer HasChild(structure.engulfBars)) { // - // TODO: Complete this ... + count = DrawPivots( + structure.engulfBars, + patternObjects, + baseArrowCode, + baseArrowCode // + ); + has = IsValidSize(count); + if (has) + { + // + ApplyPivotsStyle(patternObjects); + + // + AddObjects( + patternObjects, + objects // + ); + } + + // + ZeroMemory(patternObjects); } // @@ -1197,16 +1601,56 @@ class XCXFIMAPOIDrawer : public XCPOIDrawer HasChild(structure.trueGapBars)) { // - // TODO: Complete this ... + count = DrawPivots( + structure.trueGapBars, + patternObjects, + baseArrowCode, + baseArrowCode // + ); + has = IsValidSize(count); + if (has) + { + // + ApplyPivotsStyle(patternObjects); + + // + AddObjects( + patternObjects, + objects // + ); + } + + // + ZeroMemory(patternObjects); } // - // TrueGap Bars ... + // Momentum Bars ... if (config.drawMomentum && HasChild(structure.momentumBars)) { // - // TODO: Complete this ... + count = DrawPivots( + structure.momentumBars, + patternObjects, + baseArrowCode, + baseArrowCode // + ); + has = IsValidSize(count); + if (has) + { + // + ApplyPivotsStyle(patternObjects); + + // + AddObjects( + patternObjects, + objects // + ); + } + + // + ZeroMemory(patternObjects); } // @@ -1215,7 +1659,25 @@ class XCXFIMAPOIDrawer : public XCPOIDrawer HasChild(structure.flagPatterns)) { // - // TODO: Complete this ... + count = DrawBoxes( + structure.flagPatterns, + patternObjects // + ); + has = IsValidSize(count); + if (has) + { + // + ApplyPatternsStyle(patternObjects); + + // + AddObjects( + patternObjects, + objects // + ); + } + + // + ZeroMemory(patternObjects); } // @@ -1224,7 +1686,25 @@ class XCXFIMAPOIDrawer : public XCPOIDrawer HasChild(structure.starPatterns)) { // - // TODO: Complete this ... + count = DrawBoxes( + structure.starPatterns, + patternObjects // + ); + has = IsValidSize(count); + if (has) + { + // + ApplyPatternsStyle(patternObjects); + + // + AddObjects( + patternObjects, + objects // + ); + } + + // + ZeroMemory(patternObjects); } // @@ -1233,7 +1713,25 @@ class XCXFIMAPOIDrawer : public XCPOIDrawer HasChild(structure.risingPatterns)) { // - // TODO: Complete this ... + count = DrawBoxes( + structure.risingPatterns, + patternObjects // + ); + has = IsValidSize(count); + if (has) + { + // + ApplyPatternsStyle(patternObjects); + + // + AddObjects( + patternObjects, + objects // + ); + } + + // + ZeroMemory(patternObjects); } // @@ -1242,7 +1740,25 @@ class XCXFIMAPOIDrawer : public XCPOIDrawer HasChild(structure.piercingPatterns)) { // - // TODO: Complete this ... + count = DrawBoxes( + structure.piercingPatterns, + patternObjects // + ); + has = IsValidSize(count); + if (has) + { + // + ApplyPatternsStyle(patternObjects); + + // + AddObjects( + patternObjects, + objects // + ); + } + + // + ZeroMemory(patternObjects); } // @@ -1251,7 +1767,25 @@ class XCXFIMAPOIDrawer : public XCPOIDrawer HasChild(structure.signalKeyBarPatterns)) { // - // TODO: Complete this ... + count = DrawBoxes( + structure.signalKeyBarPatterns, + patternObjects // + ); + has = IsValidSize(count); + if (has) + { + // + ApplyPatternsStyle(patternObjects); + + // + AddObjects( + patternObjects, + objects // + ); + } + + // + ZeroMemory(patternObjects); } } diff --git a/XFIMAEA/Libraries/x-saherelm.xfima.lib.mq5 b/XFIMAEA/Libraries/x-saherelm.xfima.lib.mq5 index 05f5c55a..d0a16627 100644 --- a/XFIMAEA/Libraries/x-saherelm.xfima.lib.mq5 +++ b/XFIMAEA/Libraries/x-saherelm.xfima.lib.mq5 @@ -383,6 +383,8 @@ struct XFIMAMarketStructure // XBoxZone obs[]; XBoxZone fvgs[]; + XBoxZone supports[]; + XBoxZone resistances[]; // XPivot pinBars[]; @@ -485,7 +487,9 @@ struct XFIMAMarketStructure SpecifiedClean(obs); SpecifiedClean(fvgs); SpecifiedClean(pinBars); + SpecifiedClean(supports); SpecifiedClean(engulfBars); + SpecifiedClean(resistances); SpecifiedClean(trueGapBars); SpecifiedClean(momentumBars); SpecifiedClean(flagPatterns); @@ -518,21 +522,21 @@ struct XFIMAMarketStructureDrawerConfig // Props ... // - bool drawOB; // Current Order Block ... + bool drawOB; // Current Order Block ... bool drawFVG; // Current Fair Value Gap ... // - bool drawSupports; // Detected Supports ... + bool drawSupport; // Detected Supports ... bool drawResistance; // Detected Resistances ... // - bool drawSwingTrend; // Swing Trend ... - bool swingTrendRayLeft; // Ray Left Swing Trend ... + bool drawSwingTrend; // Swing Trend ... + bool swingTrendRayLeft; // Ray Left Swing Trend ... bool swingTrendRayRight; // Ray Right Swing Trend ... // // Draw Current Detected Patterns ... - + // bool drawPinned; bool drawMomentum; @@ -540,11 +544,11 @@ struct XFIMAMarketStructureDrawerConfig bool drawTrueGaped; // - bool drawStarPattern; - bool drawFlagPattern; - bool drawRisingPattern; - bool drawPiercingPattern; - bool drawSignalKeyBarPattern; + bool drawStarPattern; + bool drawFlagPattern; + bool drawRisingPattern; + bool drawPiercingPattern; + bool drawSignalKeyBarPattern; // // Draw Recently Zones ... @@ -604,7 +608,7 @@ struct XFIMAMarketStructureDrawerConfig drawFVG = false; drawPinned = false; drawMomentum = false; - drawSupports = false; + drawSupport = false; drawEngulfed = false; drawTrueGaped = false; drawResistance = false; @@ -660,7 +664,7 @@ struct XFIMAMarketStructureDrawerConfig drawFVG = true; drawPinned = true; drawMomentum = true; - drawSupports = true; + drawSupport = true; drawEngulfed = true; drawTrueGaped = true; drawResistance = true; @@ -717,7 +721,7 @@ struct XFIMAMarketStructureDrawerConfig drawFVG = true; drawPinned = true; drawMomentum = true; - drawSupports = true; + drawSupport = true; drawEngulfed = true; drawTrueGaped = true; drawResistance = true;