From fc318b5c193344e0223a5c4f3406e289402c56f1 Mon Sep 17 00:00:00 2001 From: Hadi Khazaee Asl Date: Thu, 9 Oct 2025 04:22:44 +0330 Subject: [PATCH] Add support for Detect and Draw Market Structure ... --- Classes/x-saherelm.x-market.pattern.class.mq5 | 69 +- Classes/x-saherelm.x-poi.drawer.class.mq5 | 4 + ...saherelm.xfima.x-poi.drawer.class copy.mq5 | 1775 +++++++++++++++++ Libraries/x-saherelm.x-pivot.analysis.lib.mq5 | 21 +- .../x-saherelm.xfima.signaller.class.mq5 | 116 +- .../x-saherelm.xfima.x-poi.detector.class.mq5 | 1061 +--------- .../x-saherelm.xfima.x-poi.drawer.class.mq5 | 1096 +--------- XFIMAEA/Libraries/x-saherelm.xfima.lib.mq5 | 231 ++- 8 files changed, 2199 insertions(+), 2174 deletions(-) create mode 100644 Documents/BKP/x-saherelm.xfima.x-poi.drawer.class copy.mq5 diff --git a/Classes/x-saherelm.x-market.pattern.class.mq5 b/Classes/x-saherelm.x-market.pattern.class.mq5 index bba4690e..a5134e8d 100644 --- a/Classes/x-saherelm.x-market.pattern.class.mq5 +++ b/Classes/x-saherelm.x-market.pattern.class.mq5 @@ -1975,20 +1975,7 @@ class XCMarketPatternDetector : public XCBase * * @param bar: XOHCL, reference to Specified Bar ... * @param analysis: XPatternAnalysis, reference to holds Analysis result ... - * @param pvValidationLength: int, Validation Length for Peak and Vale Detection ... - * @param peakPriceType: ENUM_X_PRICE, Specified Price for Peak (High) Detection ... - * @param valePriceType: ENUM_X_PRICE, Specified Price for Vale (Low) Detection ... - * @param momentumBarValidationLength: int, bar range for approve Momentum ... - * @param momentumBarApprovedMultiplier: double, a Multipler for approve Momentum ... - * @param trueGapApprovedStrength: double, Gap Validation Multiplier in Point ... - * @param pinBarShadowApprovedMultiplier: double, PinBar Shadow Size Approve Multiplier ... - * @param pinBarRangeMultiplier: doubble, PinBar Range Size Approve Multiplier in Point ... - * @param pinBarForceDirection: bool, PinBar Apply Force Bar Type ... - * @param flagPatternPullbackLength: int, Minimum Shoulders of FlagPattern's Swing Bar ... - * @param fvgForceType: bool, Force FVG to Have Same type Bars ... - * @param obForceTwoBar: bool, Force OB to has atleast two indirectional Bars ... - * @param supportAndResistanceValidationLength: int, Support and Resistance Validation Length ... - * @param supportAndResistanceLoopbackLength: int, Support and Resistance Detection Loopback ... + * @param config: XPatternAnalysisConfig, reference to Provides Detector Configs ... * * @return ( bool ) */ @@ -1996,37 +1983,6 @@ class XCMarketPatternDetector : public XCBase XOHCL &bar, XPatternAnalysis &analysis, XPatternAnalysisConfig &config // - // // - // // PV ... - // int pvValidationLength = 7, - // ENUM_X_PRICE peakPriceType = X_PRICE_HIGH, - // ENUM_X_PRICE valePriceType = X_PRICE_LOW, - // // - // // Momentum ... - // int momentumBarValidationLength = 3, - // double momentumBarApprovedMultiplier = 3, - // // - // // TrueGap ... - // double trueGapApprovedStrength = 1, - // // - // // Pin ... - // double pinBarShadowApprovedMultiplier = 3, - // double pinBarRangeMultiplier = 4, - // bool pinBarForceDirection = false, - // // - // // Flag ... - // int flagPatternPullbackLength = 3, - // // - // // FVG ... - // bool fvgForceType = false, - // // - // // OB ... - // bool obForceTwoBar = false, - // // - // // Support and Resistance ... - // int supportAndResistanceValidationLength = 21, - // int supportAndResistanceLoopbackLength = 50 // - // ) { // @@ -2036,29 +1992,6 @@ class XCMarketPatternDetector : public XCBase // Prepare ... analysis.Clean(); - // // - // // Normalize ... - // // - // config.pvValidationLength = NormalizeInt(config.pvValidationLength, 2); - - // // - // config.momentumBarValidationLength = NormalizeInt(config.momentumBarValidationLength, 2); - // momentumBarApprovedMultiplier = NormalizeDouble(momentumBarApprovedMultiplier, 1); - - // // - // trueGapApprovedStrength = NormalizeDouble(trueGapApprovedStrength, 1); - - // // - // pinBarRangeMultiplier = NormalizeDouble(pinBarRangeMultiplier, 4); - // pinBarShadowApprovedMultiplier = NormalizeDouble(pinBarShadowApprovedMultiplier, 3); - - // // - // flagPatternPullbackLength = NormalizeInt(flagPatternPullbackLength, 3); - - // // - // supportAndResistanceLoopbackLength = NormalizeInt(supportAndResistanceLoopbackLength, 10); - // supportAndResistanceValidationLength = NormalizeInt(supportAndResistanceValidationLength, 10); - // // Validate ... result = bar.IsValid(); diff --git a/Classes/x-saherelm.x-poi.drawer.class.mq5 b/Classes/x-saherelm.x-poi.drawer.class.mq5 index 6524537b..cf15d566 100644 --- a/Classes/x-saherelm.x-poi.drawer.class.mq5 +++ b/Classes/x-saherelm.x-poi.drawer.class.mq5 @@ -1463,6 +1463,9 @@ class XCPOIDrawer : public XCBase return; } + // + datetime cTime = TimeCurrent(); + // // Handle Draws ... @@ -1475,6 +1478,7 @@ class XCPOIDrawer : public XCBase // // Draw Zone ... + _zone.to = cTime; DrawZone(_zone, config); } diff --git a/Documents/BKP/x-saherelm.xfima.x-poi.drawer.class copy.mq5 b/Documents/BKP/x-saherelm.xfima.x-poi.drawer.class copy.mq5 new file mode 100644 index 00000000..808c889b --- /dev/null +++ b/Documents/BKP/x-saherelm.xfima.x-poi.drawer.class copy.mq5 @@ -0,0 +1,1775 @@ +/////////////////////////////////////////////////////// +// +// SaherElm IT Center MQL5 Class +// ------------------------------------------------- +// Name: XCXFIMAPoiDrawer ... +// Description: XFIMA 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 XFIMA POI Drawer Class" +#property strict + +// +// Imports ... +#include "../../Classes/x-saherelm.x-poi.drawer.class.mq5" +#include "../Libraries/x-saherelm.xfima.lib.mq5" + +// +// Implementation ... +class XCXFIMAPOIDrawer : public XCPOIDrawer +{ + // + public: + // + // Props ... + + // + // Tested Zones ... + color testedBullishColor; + color testedBearishColor; + + // + // Breaked Zones ... + color breakedBullishColor; + color breakedBearishColor; + + // + // FakeBreaked Zones ... + color fakeBreakedBullishColor; + color fakeBreakedBearishColor; + + // + // Constructor ... + XCXFIMAPOIDrawer() : XCPOIDrawer() + { + Default(); + } + + // + // Deconstructor ... + ~XCXFIMAPOIDrawer() + { + } + + // + // Overrides ... + + /** + * Do additional Configurations for Child Classes ... + */ + void virtual Default() override + { + // + // Apply Default Props ... + + // + Prefix(NULL); + ChartIdentification(0); + SubWindowIdentification(0); + + // + defaultBullishStyle.width = 1; + defaultBullishStyle.clr = clrAqua; + defaultBullishStyle.style = STYLE_SOLID; + + // + defaultBearishStyle.width = 1; + defaultBearishStyle.clr = clrMagenta; + defaultBearishStyle.style = STYLE_SOLID; + + // + boxBullishStyle = defaultBullishStyle; + boxBearishStyle = defaultBearishStyle; + + // + testedBullishColor = clrLime; + breakedBullishColor = clrGreen; + fakeBreakedBullishColor = clrYellow; + + // + testedBearishColor = clrRed; + breakedBearishColor = clrDarkRed; + fakeBreakedBearishColor = clrDarkOrange; + } + + // + // Get Specified Directional Arrow Anchor ... + ENUM_ARROW_ANCHOR GetArrowAnchor(ENUM_X_DIRECTION forDir) + { + // + ENUM_ARROW_ANCHOR result = ANCHOR_BOTTOM; + + // + if (HasDirection(forDir)) + { + // + result = + IsSpecifiedBullish(forDir) + ? ANCHOR_TOP + : ANCHOR_BOTTOM; + } + + // + return result; + } + + // + // Get Specified Directional Arrow Code ... + int GetArrowCode(ENUM_X_DIRECTION forDir) + { + // + int result = 159; + + // + if (HasDirection(forDir)) + { + // + result = + IsSpecifiedBullish(forDir) + ? 233 + : 234; + } + + // + return result; + } + + // + // Get Specified Directional Arrow Code ... + color GetArrowColor(ENUM_X_DIRECTION forDir) + { + // + color result = clrYellow; + + // + if (HasDirection(forDir)) + { + // + result = + IsSpecifiedBullish(forDir) + ? clrAqua + : clrMagenta; + } + + // + return result; + } + + // + // Get Specified Directional Arrow Price Type ... + ENUM_X_PRICE GetArrowPriceType(ENUM_X_DIRECTION forDir) + { + // + ENUM_X_PRICE result = X_PRICE_CLOSE; + + // + if (HasDirection(forDir)) + { + // + result = + IsSpecifiedBullish(forDir) + ? X_PRICE_LOW + : X_PRICE_HIGH; + } + + // + return result; + } + + /** + * Get Tested Zone Style ... + * + * @param style: reference to hold result ... + * @param zone: Specified Zone ... + * + * @return ( bool ) + */ + bool GetTestedStyle( + XPOIStyle &style, + XBoxZone &zone // + ) + { + // + bool result = false; + + // + style.Clean(); + + // + result = zone.IsValid(); + if (!result) + { + return result; + } + + // + GetBoxStyle( + style, + zone.dir // + ); + + // + style.width = 3; + style.clr = + zone.IsBullish() + ? testedBullishColor + : testedBearishColor; + + // + 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 = 2; + style.style = STYLE_DASH; + + // + return result; + } + + /** + * Get Breaked Zone Style ... + * + * @param style: reference to hold result ... + * @param zone: Specified Zone ... + * + * @return ( bool ) + */ + bool GetBreakedStyle( + XPOIStyle &style, + XBoxZone &zone // + ) + { + // + bool result = false; + + // + style.Clean(); + + // + result = zone.IsValid(); + if (!result) + { + return result; + } + + // + GetBoxStyle( + style, + zone.dir // + ); + + // + style.width = 3; + style.clr = + zone.IsBullish() + ? breakedBullishColor + : breakedBearishColor; + + // + return result; + } + + /** + * Get Fake Breaked Zone Style ... + * + * @param style: reference to hold result ... + * @param zone: Specified Zone ... + * + * @return ( bool ) + */ + bool GetFakeBreakedStyle( + XPOIStyle &style, + XBoxZone &zone // + ) + { + // + bool result = false; + + // + style.Clean(); + + // + result = zone.IsValid(); + if (!result) + { + return result; + } + + // + GetBoxStyle( + style, + zone.dir // + ); + + // + style.width = 3; + style.clr = + zone.IsBullish() + ? fakeBreakedBullishColor + : fakeBreakedBearishColor; + + // + return result; + } + + /** + * Fill Arrow Based Drawing Specs ... + * + * @param forDir: Specified Direction ... + * @param arrowPriceType: ENUM_X_PRICE, refrence for Arrow Price ... + * @param arrowCode: int, reference for Arrow Code ... + * @param arrowWidth: int, reference for Arrow Width ... + * @param arrowColor: color, reference for Arrow Color ... + * @param arrowAnchor: ENUM_ARROW_ANCHOR, reference for Arrow Anchor ... + */ + void FillArrowSpecs( + ENUM_X_DIRECTION forDir, + ENUM_X_PRICE &arrowPriceType, + int &arrowCode, + int &arrowWidth, + color &arrowColor, + ENUM_ARROW_ANCHOR &arrowAnchor // + ) + { + // + // Prepare ... + arrowCode = 159; + arrowWidth = 2; + arrowColor = CLR_NONE; + arrowAnchor = ANCHOR_BOTTOM; + arrowPriceType = X_PRICE_CLOSE; + + // + if (HasDirection(forDir)) + { + // + arrowCode = GetArrowCode(forDir); + arrowColor = GetArrowColor(forDir); + arrowAnchor = GetArrowAnchor(forDir); + arrowPriceType = GetArrowPriceType(forDir); + } + } + + /** + * Apply Tested Style ... + * + * @param object: reference pointer to Object ... + * @param zone: reference to Zone ... + */ + void ApplyTestedStyle( + XCBoxObject *&object, + XBoxZone &zone // + ) + { + // + if (!zone.IsValid() || + object == NULL) + { + return; + } + + // + XPOIStyle style; + if (!GetTestedStyle(style, zone)) + { + return; + } + + // + ApplyBoxStyle( + object, + style // + ); + } + + /** + * Apply Breaked Style ... + * + * @param object: reference pointer to Object ... + * @param zone: reference to Zone ... + */ + void ApplyBreakedStyle( + XCBoxObject *&object, + XBoxZone &zone // + ) + { + // + if (!zone.IsValid() || + object == NULL) + { + return; + } + + // + XPOIStyle style; + if (!GetBreakedStyle(style, zone)) + { + return; + } + + // + ApplyBoxStyle( + object, + style // + ); + } + + /** + * Apply Tested Style ... + * + * @param object: reference pointer to Object ... + * @param zone: reference to Zone ... + */ + void ApplyFakeBreakStyle( + XCBoxObject *&object, + XBoxZone &zone // + ) + { + // + if (!zone.IsValid() || + object == NULL) + { + return; + } + + // + XPOIStyle style; + if (!GetFakeBreakedStyle(style, zone)) + { + return; + } + + // + ApplyBoxStyle( + object, + style // + ); + } + + /** + * 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 ... + * + * @param structure: XFIMAMarketStructure, reference to Provide Specifid Market Structure ... + * @param config: XFIMAMarketStructureDrawerConfig, reference to Provide Drawing Configurations ... + * @param objects: CArrayObj, pointer reference to Holds drawn Objects instances ... + * + * @return ( int ) + */ + int DrawMarketStructure( + XFIMAMarketStructure &structure, + XFIMAMarketStructureDrawerConfig &config, + CArrayObj *&objects // + ) + { + // + int result = 0; + + // + // Normalize ... + if (objects == NULL) + { + objects = new CArrayObj(); + } + + // + // Prepare ... + // objects.Clear(); + + // + int count = 0; + bool has = false; + int arrowCode = -1; + int arrowWidth = 3; + string arrowName = NULL; + color arrowColor = CLR_NONE; + ENUM_X_PRICE arrowPriceType = X_PRICE_CLOSE; + ENUM_ARROW_ANCHOR arrowAnchor = ANCHOR_BOTTOM; + + // + int bullArrowCode = GetArrowCode(X_DIRECTION_BULLISH); + int bearArrowCode = GetArrowCode(X_DIRECTION_BEARISH); + + // + // Validate ... + has = structure.bar.IsValid(); + if (!has) + { + return result; + } + + // + // Apply Drawing Methods ... + + // // + // // OB ... + // if (config.drawOB) + // { + // // + // // Validate ... + // has = structure.ob.IsValid(); + // if (has) + // { + // // + // XCBoxObject *iObj; + // has = DrawBox( + // structure.ob, + // iObj // + // ); + // if (has) + // { + // objects.Add(iObj); + // } + + // // + // ZeroMemory(iObj); + // } + // } + + // // + // // FVG ... + // if (config.drawFVG) + // { + // // + // // Validate ... + // has = structure.fvg.IsValid(); + // if (has) + // { + // // + // XCBoxObject *iObj; + // has = DrawBox( + // structure.fvg, + // iObj // + // ); + // if (has) + // { + // objects.Add(iObj); + // } + + // // + // ZeroMemory(iObj); + // } + // } + + // // + // // Support ... + // if (config.drawSupport) + // { + // // + // // Validate ... + // has = structure.support.IsValid(); + // if (has) + // { + // // + // XCBoxObject *iObj; + // has = DrawBox( + // structure.support, + // iObj // + // ); + // if (has) + // { + // objects.Add(iObj); + // } + + // // + // ZeroMemory(iObj); + // } + // } + + // // + // // Resistance ... + // if (config.drawResistance) + // { + // // + // // Validate ... + // has = structure.resistance.IsValid(); + // if (has) + // { + // // + // XCBoxObject *iObj; + // has = DrawBox( + // structure.resistance, + // iObj // + // ); + // if (has) + // { + // objects.Add(iObj); + // } + + // // + // ZeroMemory(iObj); + // } + // } + + // // + // // Swing Trend ... + // if (config.drawSwingTrend) + // { + // // + // // Validate ... + // has = HasDirection(structure.trendDir) && + // HasChild(structure.trendSwings); + // if (has) + // { + // // + // CChartObjectTrend *iObj; + // has = DrawSwingTrend( + // structure.trendSwings, + // structure.trendDir, + // iObj, // + // config.swingTrendRayRight, // Ray Right ... + // config.swingTrendRayLeft // Ray Left ... + // ); + // if (has) + // { + // objects.Add(iObj); + // } + + // // + // ZeroMemory(iObj); + // } + // } + + // // + // // Start Pattern ... + // if (config.drawStarPattern) + // { + // // + // // Validate ... + // has = HasDirection(structure.starPatternDir); + // if (has) + // { + // // + // FillArrowSpecs( + // structure.starPatternDir, + // arrowPriceType, + // arrowCode, + // arrowWidth, + // arrowColor, + // arrowAnchor // + // ); + // XCBarArrowObject *iObj; + // arrowName = "XStar_" + ToMD5(structure.bar.time); + // has = DrawBarArrow( + // structure.bar, + // iObj, + // arrowPriceType, + // arrowCode, + // arrowColor, + // arrowWidth, + // arrowAnchor, + // arrowName // + // ); + // if (has) + // { + // objects.Add(iObj); + // } + // } + // } + + // // + // // Flag Pattern ... + // if (config.drawFlagPattern) + // { + // // + // // Validate ... + // has = HasDirection(structure.flagPatternDir) && + // structure.flagSwing.IsValid(); + // if (has) + // { + // // + // FillArrowSpecs( + // structure.flagPatternDir, + // arrowPriceType, + // arrowCode, + // arrowWidth, + // arrowColor, + // arrowAnchor // + // ); + // XCBarArrowObject *iObj; + // arrowName = "XFlag_" + ToMD5(structure.bar.time); + // has = DrawBarArrow( + // structure.bar, + // iObj, + // arrowPriceType, + // arrowCode, + // arrowColor, + // arrowWidth, + // arrowAnchor, + // arrowName // + // ); + // if (has) + // { + // objects.Add(iObj); + // } + // } + // } + + // // + // // Rising Pattern ... + // if (config.drawRisingPattern) + // { + // // + // // Validate ... + // has = HasDirection(structure.risingPatternDir); + // if (has) + // { + // // + // FillArrowSpecs( + // structure.risingPatternDir, + // arrowPriceType, + // arrowCode, + // arrowWidth, + // arrowColor, + // arrowAnchor // + // ); + // XCBarArrowObject *iObj; + // arrowName = "XRise_" + ToMD5(structure.bar.time); + // has = DrawBarArrow( + // structure.bar, + // iObj, + // arrowPriceType, + // arrowCode, + // arrowColor, + // arrowWidth, + // arrowAnchor, + // arrowName // + // ); + // if (has) + // { + // objects.Add(iObj); + // } + // } + // } + + // // + // // Piercing Pattern ... + // if (config.drawPiercingPattern) + // { + // // + // // Validate ... + // has = HasDirection(structure.piercingPatternDir); + // if (has) + // { + // // + // FillArrowSpecs( + // structure.piercingPatternDir, + // arrowPriceType, + // arrowCode, + // arrowWidth, + // arrowColor, + // arrowAnchor // + // ); + // XCBarArrowObject *iObj; + // arrowName = "XPiercing_" + ToMD5(structure.bar.time); + // has = DrawBarArrow( + // structure.bar, + // iObj, + // arrowPriceType, + // arrowCode, + // arrowColor, + // arrowWidth, + // arrowAnchor, + // arrowName // + // ); + // if (has) + // { + // objects.Add(iObj); + // } + // } + // } + + // // + // // Signal Key Bar Pattern ... + // if (config.drawSignalKeyBarPattern) + // { + // // + // // Validate ... + // has = HasDirection(structure.signalKeyBarPatternDir); + // if (has) + // { + // // + // FillArrowSpecs( + // structure.signalKeyBarPatternDir, + // arrowPriceType, + // arrowCode, + // arrowWidth, + // arrowColor, + // arrowAnchor // + // ); + // XCBarArrowObject *iObj; + // arrowName = "XSignalKey_" + ToMD5(structure.bar.time); + // has = DrawBarArrow( + // structure.bar, + // iObj, + // arrowPriceType, + // arrowCode, + // arrowColor, + // arrowWidth, + // arrowAnchor, + // arrowName // + // ); + // if (has) + // { + // objects.Add(iObj); + // } + // } + // } + + // // + // // Pinned Bar ... + // if (config.drawPinned) + // { + // // + // // Validate ... + // has = HasDirection(structure.pinnedDir); + // if (has) + // { + // // + // FillArrowSpecs( + // structure.pinnedDir, + // arrowPriceType, + // arrowCode, + // arrowWidth, + // arrowColor, + // arrowAnchor // + // ); + // XCBarArrowObject *iObj; + // arrowName = "XPin_" + ToMD5(structure.bar.time); + // has = DrawBarArrow( + // structure.bar, + // iObj, + // arrowPriceType, + // arrowCode, + // arrowColor, + // arrowWidth, + // arrowAnchor, + // arrowName // + // ); + // if (has) + // { + // objects.Add(iObj); + // } + // } + // } + + // // + // // Momentum Bar ... + // if (config.drawMomentum) + // { + // // + // // Validate ... + // has = HasDirection(structure.momentumDir); + // if (has) + // { + // // + // FillArrowSpecs( + // structure.momentumDir, + // arrowPriceType, + // arrowCode, + // arrowWidth, + // arrowColor, + // arrowAnchor // + // ); + // XCBarArrowObject *iObj; + // arrowName = "XMomentum_" + ToMD5(structure.bar.time); + // has = DrawBarArrow( + // structure.bar, + // iObj, + // arrowPriceType, + // arrowCode, + // arrowColor, + // arrowWidth, + // arrowAnchor, + // arrowName // + // ); + // if (has) + // { + // objects.Add(iObj); + // } + // } + // } + + // // + // // Engulfed Bar ... + // if (config.drawEngulfed) + // { + // // + // // Validate ... + // has = HasDirection(structure.engulfedDir); + // if (has) + // { + // // + // FillArrowSpecs( + // structure.engulfedDir, + // arrowPriceType, + // arrowCode, + // arrowWidth, + // arrowColor, + // arrowAnchor // + // ); + // XCBarArrowObject *iObj; + // arrowName = "XEngulf_" + ToMD5(structure.bar.time); + // has = DrawBarArrow( + // structure.bar, + // iObj, + // arrowPriceType, + // arrowCode, + // arrowColor, + // arrowWidth, + // arrowAnchor, + // arrowName // + // ); + // if (has) + // { + // objects.Add(iObj); + // } + // } + // } + + // // + // // True Gaped Bar ... + // if (config.drawTrueGaped) + // { + // // + // // Validate ... + // has = HasDirection(structure.trueGapedDir); + // if (has) + // { + // // + // FillArrowSpecs( + // structure.trueGapedDir, + // arrowPriceType, + // arrowCode, + // arrowWidth, + // arrowColor, + // arrowAnchor // + // ); + // XCBarArrowObject *iObj; + // arrowName = "XTrueGap_" + ToMD5(structure.bar.time); + // has = DrawBarArrow( + // structure.bar, + // iObj, + // arrowPriceType, + // arrowCode, + // arrowColor, + // arrowWidth, + // arrowAnchor, + // arrowName // + // ); + // if (has) + // { + // objects.Add(iObj); + // } + // } + // } + + // // + // // XFIMA PV Analysis ... + // if (config.drawFIMAPVPivotsAnalysis) + // { + // // + // // Validate ... + // has = structure.pvAnalysis.IsValid(); + // if (has) + // { + // // + // XCPivotAnalysisObject *iObj; + // has = DrawPivotAnalysis( + // structure.pvAnalysis, + // iObj, + // config.drawFIMAPVPivotsAnalysisTrends, + // config.drawFIMAPVPivotsAnalysisZones, + // config.drawFIMAPVPivotsAnalysisPivots, + // bearArrowCode, + // bullArrowCode // + // ); + // if (has) + // { + // objects.Add(iObj); + // } + // } + // } + + // // + // // XFIMA Sar Analysis ... + // if (config.drawFIMASARPivotsAnalysis) + // { + // // + // // Validate ... + // has = structure.sarAnalysis.IsValid(); + // if (has) + // { + // // + // XCPivotAnalysisObject *iObj; + // has = DrawPivotAnalysis( + // structure.pvAnalysis, + // iObj, + // config.drawFIMASARPivotsAnalysisTrends, + // config.drawFIMASARPivotsAnalysisZones, + // config.drawFIMASARPivotsAnalysisPivots, + // bearArrowCode, + // bullArrowCode // + // ); + // if (has) + // { + // objects.Add(iObj); + // } + // } + // } + + // // + // // XFIMA ZigZag Analysis ... + // if (config.drawFIMAZigZagPivotsAnalysis) + // { + // // + // // Validate ... + // has = structure.zigzagAnalysis.IsValid(); + // if (has) + // { + // // + // XCPivotAnalysisObject *iObj; + // has = DrawPivotAnalysis( + // structure.pvAnalysis, + // iObj, + // config.drawFIMAZigZagPivotsAnalysisTrends, + // config.drawFIMAZigZagPivotsAnalysisZones, + // config.drawFIMAZigZagPivotsAnalysisPivots, + // bearArrowCode, + // bullArrowCode // + // ); + // if (has) + // { + // objects.Add(iObj); + // } + // } + // } + + // // + // // Fake Breaked Zone ... + // if (config.drawFakeBreakedZone && + // structure.fakeBreakedZone.IsValid()) + // { + // // + // XCBoxObject *iObj; + // has = DrawBox( + // structure.fakeBreakedZone, + // iObj // + // ); + // if (has) + // { + // // + // // Apply Style ... + // ApplyFakeBreakStyle( + // iObj, + // structure.fakeBreakedZone // + // ); + + // // + // objects.Add(iObj); + // } + + // // + // ZeroMemory(iObj); + // } + + // // + // // Recently Tested Zones ... + // if (config.drawRecentlyTestedZones && + // HasChild(structure.recentlyTestedZones)) + // { + // // + // XCBoxObject *iObj; + // count = ArraySize(structure.recentlyTestedZones); + // for (int i = 0; i < count; i++) + // { + // // + // // Draw Box ... + // has = DrawBox( + // structure.recentlyTestedZones[i], + // iObj // + // ); + // if (has) + // { + // // + // ApplyTestedStyle( + // iObj, + // structure.recentlyTestedZones[i] // + // ); + + // // + // objects.Add(iObj); + // } + + // // + // ZeroMemory(iObj); + // } + // } + + // // + // // Recently Breaked Zones ... + // if (config.drawRecentlyBreakedZones && + // HasChild(structure.recentlyBreakedZones)) + // { + // // + // XCBoxObject *iObj; + // count = ArraySize(structure.recentlyBreakedZones); + // for (int i = 0; i < count; i++) + // { + // // + // // Draw Box ... + // has = DrawBox( + // structure.recentlyBreakedZones[i], + // iObj // + // ); + // if (has) + // { + // // + // ApplyBreakedStyle( + // iObj, + // structure.recentlyBreakedZones[i] // + // ); + + // // + // objects.Add(iObj); + // } + + // // + // ZeroMemory(iObj); + // } + // } + + // // + // // 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)) + // { + // // + // count = DrawPivots( + // structure.pinBars, + // patternObjects, + // baseArrowCode, + // baseArrowCode // + // ); + // has = IsValidSize(count); + // if (has) + // { + // // + // ApplyPivotsStyle(patternObjects); + + // // + // AddObjects( + // patternObjects, + // objects // + // ); + // } + + // // + // ZeroMemory(patternObjects); + // } + + // // + // // Engulf Bars ... + // if (config.drawEngulfed && + // HasChild(structure.engulfBars)) + // { + // // + // count = DrawPivots( + // structure.engulfBars, + // patternObjects, + // baseArrowCode, + // baseArrowCode // + // ); + // has = IsValidSize(count); + // if (has) + // { + // // + // ApplyPivotsStyle(patternObjects); + + // // + // AddObjects( + // patternObjects, + // objects // + // ); + // } + + // // + // ZeroMemory(patternObjects); + // } + + // // + // // TrueGap Bars ... + // if (config.drawTrueGaped && + // HasChild(structure.trueGapBars)) + // { + // // + // count = DrawPivots( + // structure.trueGapBars, + // patternObjects, + // baseArrowCode, + // baseArrowCode // + // ); + // has = IsValidSize(count); + // if (has) + // { + // // + // ApplyPivotsStyle(patternObjects); + + // // + // AddObjects( + // patternObjects, + // objects // + // ); + // } + + // // + // ZeroMemory(patternObjects); + // } + + // // + // // Momentum Bars ... + // if (config.drawMomentum && + // HasChild(structure.momentumBars)) + // { + // // + // count = DrawPivots( + // structure.momentumBars, + // patternObjects, + // baseArrowCode, + // baseArrowCode // + // ); + // has = IsValidSize(count); + // if (has) + // { + // // + // ApplyPivotsStyle(patternObjects); + + // // + // AddObjects( + // patternObjects, + // objects // + // ); + // } + + // // + // ZeroMemory(patternObjects); + // } + + // // + // // Flag Pattern ... + // if (config.drawFlagPattern && + // HasChild(structure.flagPatterns)) + // { + // // + // count = DrawBoxes( + // structure.flagPatterns, + // patternObjects // + // ); + // has = IsValidSize(count); + // if (has) + // { + // // + // ApplyPatternsStyle(patternObjects); + + // // + // AddObjects( + // patternObjects, + // objects // + // ); + // } + + // // + // ZeroMemory(patternObjects); + // } + + // // + // // Star Pattern ... + // if (config.drawStarPattern && + // HasChild(structure.starPatterns)) + // { + // // + // count = DrawBoxes( + // structure.starPatterns, + // patternObjects // + // ); + // has = IsValidSize(count); + // if (has) + // { + // // + // ApplyPatternsStyle(patternObjects); + + // // + // AddObjects( + // patternObjects, + // objects // + // ); + // } + + // // + // ZeroMemory(patternObjects); + // } + + // // + // // Rising Pattern ... + // if (config.drawRisingPattern && + // HasChild(structure.risingPatterns)) + // { + // // + // count = DrawBoxes( + // structure.risingPatterns, + // patternObjects // + // ); + // has = IsValidSize(count); + // if (has) + // { + // // + // ApplyPatternsStyle(patternObjects); + + // // + // AddObjects( + // patternObjects, + // objects // + // ); + // } + + // // + // ZeroMemory(patternObjects); + // } + + // // + // // Piercing Pattern ... + // if (config.drawPiercingPattern && + // HasChild(structure.piercingPatterns)) + // { + // // + // count = DrawBoxes( + // structure.piercingPatterns, + // patternObjects // + // ); + // has = IsValidSize(count); + // if (has) + // { + // // + // ApplyPatternsStyle(patternObjects); + + // // + // AddObjects( + // patternObjects, + // objects // + // ); + // } + + // // + // ZeroMemory(patternObjects); + // } + + // // + // // SignalKeyBar Pattern ... + // if (config.drawSignalKeyBarPattern && + // HasChild(structure.signalKeyBarPatterns)) + // { + // // + // count = DrawBoxes( + // structure.signalKeyBarPatterns, + // patternObjects // + // ); + // has = IsValidSize(count); + // if (has) + // { + // // + // ApplyPatternsStyle(patternObjects); + + // // + // AddObjects( + // patternObjects, + // objects // + // ); + // } + + // // + // ZeroMemory(patternObjects); + // } + // } + + // + result = objects.Total(); + + // + return result; + } + + // +}; + +// \ No newline at end of file diff --git a/Libraries/x-saherelm.x-pivot.analysis.lib.mq5 b/Libraries/x-saherelm.x-pivot.analysis.lib.mq5 index 10b0b52c..829aa067 100644 --- a/Libraries/x-saherelm.x-pivot.analysis.lib.mq5 +++ b/Libraries/x-saherelm.x-pivot.analysis.lib.mq5 @@ -2418,7 +2418,7 @@ struct XPatternAnalysisConfig { // // PV ... - pvValidationLength = 7; + pvValidationLength = 5; peakPriceType = X_PRICE_HIGH; valePriceType = X_PRICE_LOW; @@ -2594,7 +2594,7 @@ struct XPivotAnalysisDrawConfig // Tools ... /** - * This function fulfills the will of the developer + * This function fulfills the will of the developer */ void Clean() { @@ -2717,7 +2717,7 @@ struct XPatternAnalysisDrawConfig drawConfig.Default(); // - FullDraw(); + Full(); // // Remove Unused From Zones ... @@ -2735,9 +2735,20 @@ struct XPatternAnalysisDrawConfig } /** - * Configure Full Draws ... + * No Draw Abilioty ... */ - void FullDraw() + void Off() + { + // + XClean(allowedDraws); + XClean(allowedDrawZones); + XClean(allowedDrawPivots); + } + + /** + * Full Draw Abilioty ... + */ + void Full() { // GetAllBarPatters(allowedDraws); diff --git a/XFIMAEA/Classes/x-saherelm.xfima.signaller.class.mq5 b/XFIMAEA/Classes/x-saherelm.xfima.signaller.class.mq5 index 19cc4a73..abd41f8d 100644 --- a/XFIMAEA/Classes/x-saherelm.xfima.signaller.class.mq5 +++ b/XFIMAEA/Classes/x-saherelm.xfima.signaller.class.mq5 @@ -41,13 +41,14 @@ class XCXFIMABaseSignaller : public XCBaseSignaller // Props ... // - bool ignoreTargets; // Ignore Signal Targets ... - CArrayObj drawnObjects; // Drawing Objects Holder ... - XFIMAInputs fimaInputs; // XFIMA Inputs ... - XCXFIMAHelper *fimaHelper; // XFIMA Indicator Helper ... - XCXFIMAPOIDrawer *poiDrawer; // XFIMA POI Drawer ... - XCXFIMAPOIDetector *poiDetector; // XFIMA POI Detector ... - XPatternAnalysisConfig patternAnalyserConfig; // Bar Pattern Analyser Config ... + bool ignoreTargets; // Ignore Signal Targets ... + CArrayObj drawnObjects; // Drawing Objects Holder ... + XFIMAInputs fimaInputs; // XFIMA Inputs ... + XCXFIMAHelper *fimaHelper; // XFIMA Indicator Helper ... + XCXFIMAPOIDrawer *poiDrawer; // XFIMA POI Drawer ... + XCXFIMAPOIDetector *poiDetector; // XFIMA POI Detector ... + XFIMAMarketStructureConfig structureConfig; // XFIMA Market Structure Detector Config ... + XFIMAMarketStructureDrawerConfig structureDrawConfig; // XFIMA Market Structure Draw Config ... // // Constructor ... @@ -98,11 +99,8 @@ class XCXFIMABaseSignaller : public XCBaseSignaller // // Configure ... - - // - patternAnalyserConfig.Clean(); - patternAnalyserConfig.Default(); - patternAnalyserConfig.FullPattern(); + structureConfig.Default(); + structureDrawConfig.Default(); } // @@ -142,8 +140,8 @@ class XCXFIMABaseSignaller : public XCBaseSignaller ZeroMemory(poiDetector); // - // analyserConfig.Clean(); - patternAnalyserConfig.Clean(); + structureConfig.Clean(); + structureDrawConfig.Clean(); } // @@ -254,7 +252,7 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller public: // // Props ... - // XFIMAPatternDetectorConfig analyserConfig; + XFIMAMarketStructure structure; // XFIMA Market Structure ... // // Constructor ... @@ -277,12 +275,12 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller ) { // - // Configures ... + // Configure ... + structureConfig.Default(); + structureDrawConfig.Default(); // - patternAnalyserConfig.Clean(); - patternAnalyserConfig.Default(); - patternAnalyserConfig.FullPattern(); + structure.Clean(); // // Ignore Signal Targets ... @@ -293,7 +291,11 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller // Deconstructor ... ~XCXFIMAStrategy1Signaller() { + // Destroy(); + + // + structure.Clean(); } // @@ -366,67 +368,17 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller } // - // Analyse Market ... - // poiDetector.AnalyseMarket( - // iBar, - // iStructure, - // analyserConfig // - // ); - - // - // Bar Pattern Analysis Detection Test ... - // has = poiDetector.AnalyseBarPatterns( - // iBar, - // iBarAnalysis, - // patternAnalyserConfig // - // ); - // DrawBarPatternAnalysis(iBarAnalysis, patternAnalyserDrawConfig); - - // // - // has = fimaHelper.IsBoundaryFakeBreaked( - // iDir, - // iBar.Index() // - // ); - // if (has) - // { - // Print("Hot Place Detected"); - // } - - // // - // XPivot pvPivots[]; - // count = fimaHelper.ExtractPVPivots( - // pvPivots, - // iBar.Index(), - // 25, - // 1500, - // 5 // - // ); - // has = IsValidSize(count); - // if (has) { - // // - // XPivotAnalysis pvAnalysis; - // has = pvAnalysis.Init( - // "XPV", - // symbol, - // period, - // pvPivots // - // ); - // if (has) { - // // - // XPivotAnalysisDrawConfig iC; - // iC.Default(); - // iC.drawPivots = true; - // iC.drawPeakTrend = true; - // iC.drawValeTrend = true; - // poiDrawer.DrawPivotAnalysis( - // pvAnalysis, - // iC // - // ); - - // // - // Print("PV Analysis ..."); - // } - // } + structure.Clean(); + poiDetector.AnalyseMarket( + structure, + structureConfig, + barIndex // + ); + poiDrawer.drawnObjects.Clear(); + poiDrawer.DrawMarketStructure( + structure, + structureDrawConfig // + ); // // Disable Signallers ... @@ -571,7 +523,7 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller XTarget &targets[], ENUM_X_DIRECTION &dir, XFIMAConditions &conditions, - XFIMAMarketStructure &structure // + XFIMAMarketStructure &_structure // ) { // @@ -655,7 +607,7 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller XTarget &targets[], ENUM_X_DIRECTION &dir, XFIMAConditions &conditions, - XFIMAMarketStructure &structure // + XFIMAMarketStructure &_structure // ) { // 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 014b1a6a..28f2c0d2 100644 --- a/XFIMAEA/Classes/x-saherelm.xfima.x-poi.detector.class.mq5 +++ b/XFIMAEA/Classes/x-saherelm.xfima.x-poi.detector.class.mq5 @@ -361,978 +361,127 @@ class XCXFIMAPOIDetector : public XCMarketPatternDetector /** * Analyse Market based on Specified Bar ... * - * @param forBar: XOHCL, reference Specified Bar for Analyse Market ... * @param structure: XFIMAMarketStructure, reference to holds result ... - * @param config: XFIMAPatternDetectorConfig, reference to Configure Detector ... + * @param config: XFIMAMarketStructureConfig, reference to Configure Detector ... + * @param barIndex: int, Bar Index ... */ void AnalyseMarket( - XOHCL &forBar, - XFIMAMarketStructure &structure // , - //XFIMAPatternDetectorConfig &config // + XFIMAMarketStructure &structure, + XFIMAMarketStructureConfig &config, + int barIndex = 0 // ) { - // // - // // Prepare ... - // structure.Clean(); + // + // Prepare ... + structure.Clean(); - // // - // // Validate ... - // if (!forBar.IsValid()) - // { - // return; - // } + // + // Normalize ... + barIndex = NormalizeInt(barIndex, 0); - // // - // // Do Analysis ... + // + bool has = false; - // // - // structure.bar = forBar; + // + string symbol = fimaHelper.GetSymbol(); + ENUM_TIMEFRAMES period = fimaHelper.GetPeriod(); + has = structure.bar.Init( + symbol, + period, + barIndex // + ); + if (!has) + { + // + structure.Clean(); + return; + } - // // - // int idx = -1; - // int count = 0; - // XBoxZone iBox; - // bool has = false; - // ENUM_X_DIRECTION iDir = X_DIRECTION_NONE; + // + // Reading Bar Patterns ... + XOHCL iBar; + XPatternAnalysis iPatternAnalysis; + for (int i = barIndex; i < barIndex + config.loopback; i++) + { + // + // Cleanup ... + iBar.Clean(); + iPatternAnalysis.Clean(); - // // - // // Detecting POI Based on Config ... + // + // Initialize Indexed Bar ... + // + has = structure.bar.BarAt(i, iBar); + if (!has) + { + break; + } - // // - // // Checking Momentum Bar ... - // if (config.detectMomentum) - // { - // // - // bool isMomentum = IsMomentumBar( - // forBar, - // iDir, - // config.momentumBarRangeLength, - // config.momentumBarApprovedMultiplier // - // ); - // bool isBullishMomentum = isMomentum && - // IsSpecifiedBullish(iDir); - // bool isBearishMomentum = isMomentum && - // IsSpecifiedBearish(iDir); - // if (isMomentum) - // { - // structure.momentumDir = iDir; - // } - // } + // + // Analyse Indexed Bar ... + has = AnalyseBarPatterns(iBar, iPatternAnalysis, config.barsAnalysisConfig); + if (has) + { + // + AddRef( + iPatternAnalysis, + structure.barsAnalysis // + ); + } - // // - // // Checking Engulfed Bar ... - // if (config.detectEngulfed) - // { - // // - // bool isEngulfed = IsEngulfedBar( - // forBar, - // iDir // - // ); - // bool isBullishEngulfed = isEngulfed && - // IsSpecifiedBullish(iDir); - // bool isBearishEngulfed = isEngulfed && - // IsSpecifiedBearish(iDir); - // if (isEngulfed) - // { - // structure.engulfedDir = iDir; - // } - // } + // + // Check Satisfied ... + has = ArraySize(structure.barsAnalysis) >= config.requiredPivots; + if (has) + { + break; + } + } - // // - // // Checking TruGaped Bar ... - // if (config.detectTrueGaped) - // { - // // - // bool isTrueGaped = IsTrueGapedBar( - // forBar, - // iDir, - // config.truwGapApprovedPointMultiplier // - // ); - // bool isBullishTrueGaped = isTrueGaped && - // IsSpecifiedBullish(iDir); - // bool isBearishTrueGaped = isTrueGaped && - // IsSpecifiedBearish(iDir); - // if (isTrueGaped) - // { - // structure.trueGapedDir = iDir; - // } - // } + // + // Handle Pivot Analysis ... - // // - // // Checking Pinned Bar ... - // if (config.detectPinned) - // { - // // - // bool isPinned = IsPinnedBar( - // forBar, - // iDir, - // config.pinnedBaarShadowApprovedMultiplier, - // config.pinnedBarMinimumPinBarRangeMultiplier, - // config.pinnedBarForceDirection // - // ); - // bool isBullishPinned = isPinned && - // IsSpecifiedBullish(iDir); - // bool isBearishPinned = isPinned && - // IsSpecifiedBearish(iDir); - // if (isPinned) - // { - // structure.pinnedDir = iDir; - // } - // } + // + // XPV ... + if (config.analysePVPivots) + { + // + // Reading Pivots ... + has = AnalysePVPivots( + structure.pvAnalysis, + barIndex, + config.requiredPivots, + config.loopback, + config.pvPivotsValidationLength // + ); + if (!has) + { + structure.pvAnalysis.Clean(); + } + } - // // - // // Checking Star Pattern ... - // if (config.detectStarPattern) - // { - // // - // bool isStarPattern = IsStarPattern( - // forBar, - // iDir // - // ); - // bool isBullishStarPattern = isStarPattern && - // IsSpecifiedBullish(iDir); - // bool isBearishStarPattern = isStarPattern && - // IsSpecifiedBearish(iDir); - // if (isStarPattern) - // { - // structure.starPatternDir = iDir; - // } - // } + // + // XZG ... + if (config.analyseZGPivots) + { + // + // Reading Pivots ... + has = AnalyseZigZagPivots( + structure.zgAnalysis, + barIndex, + config.requiredPivots, + config.loopback // + ); + if (!has) + { + structure.zgAnalysis.Clean(); + } + } - // // - // // Checking Piercing Pattern ... - // if (config.detectPiercingPattern) - // { - // // - // bool isPiercingPattern = IsPiercingPattern( - // forBar, - // iDir // - // ); - // bool isBullishPiercingPattern = isPiercingPattern && - // IsSpecifiedBullish(iDir); - // bool isBearishPiercingPattern = isPiercingPattern && - // IsSpecifiedBearish(iDir); - // if (isPiercingPattern) - // { - // structure.piercingPatternDir = iDir; - // } - // } - - // // - // // Checking Rising Pattern ... - // if (config.detectRisingPattern) - // { - // // - // bool isRisingPattern = IsRisingPattern( - // forBar, - // iDir // - // ); - // bool isBullishRisingPattern = isRisingPattern && - // IsSpecifiedBullish(iDir); - // bool isBearishRisingPattern = isRisingPattern && - // IsSpecifiedBearish(iDir); - // if (isRisingPattern) - // { - // structure.risingPatternDir = iDir; - // } - // } - - // // - // // Checking Flag Pattern ... - // if (config.detectFlagPattern) - // { - // // - // XOHCL swingBar; - // bool isFlagPattern = IsFlagPattern( - // forBar, - // iDir, - // swingBar, - // config.flagPatternMinimumPullbackBars // - // ); - // bool isBullishFlagPattern = isFlagPattern && - // IsSpecifiedBullish(iDir); - // bool isBearishFlagPattern = isFlagPattern && - // IsSpecifiedBearish(iDir); - // if (isFlagPattern) - // { - // // - // structure.flagSwing = swingBar; - // structure.flagPatternDir = iDir; - // } - // swingBar.Clean(); - // } - - // // - // // Detect SignalKey Bar Pattern ... - // if (config.detectSignalKeyBarPattern) - // { - // // - // bool isSignalKeyBar = IsSignalKeyBarPattern( - // forBar, - // iDir, - // config.signalKeyBarShadowApprovedMultiplier, - // config.signalKeyBarMinimumPinBarRangeMultiplier, - // config.signalKeyBarForceDirection // - // ); - // bool isBullishSignalKeyBar = isSignalKeyBar && - // IsSpecifiedBullish(iDir); - // bool isBearishSignalKeyBar = isSignalKeyBar && - // IsSpecifiedBearish(iDir); - // if (isSignalKeyBar) - // { - // structure.signalKeyBarPatternDir = iDir; - // } - // } - - // // - // // Detect Swing Trend ... - // if (config.detectSwingTrend) - // { - // // - // XOHCL swings[]; - // bool hasSwingTrend = HasSwingTrend( - // forBar, - // iDir, - // swings, - // config.trendingNumberOfSwings, - // config.trendingSwingShoulders // - // ); - // bool hasBullishSwingTrend = hasSwingTrend && - // IsSpecifiedBullish(iDir); - // bool hasBearishSwingTrend = hasSwingTrend && - // IsSpecifiedBearish(iDir); - // if (hasSwingTrend) - // { - // // - // Copy( - // swings, - // structure.trendSwings // - // ); - // structure.trendDir = iDir; - // } - // SpecifiedClean(swings); - // } - - // // - // // Custom Indicator Pivots ... - - // // - // // Detecting MA Crosses ... - // if (config.detectMACrosses) - // { - // // - // idx = forBar.Index(); - // has = fimaHelper.HasMACross( - // structure.maCrossDir, - // idx, - // config.validMACrossDiffMultiplier // - // ); - - // // - // fimaHelper.ExtractMAPivots( - // structure.maCrosses, - // idx, - // config.zonesRequiredNumber, - // config.validMACrossDiffMultiplier, - // config.zonesMaxAllowedLoopbackLength // - // ); - // } - - // // - // // Detecting HK Switches ... - // if (config.detectHKSwitches) - // { - // // - // idx = forBar.Index(); - // has = fimaHelper.HasHKSwitch( - // structure.hkSwitchDir, - // idx // - // ); - - // // - // fimaHelper.ExtractHKPivots( - // structure.hkSwitches, - // idx, - // config.zonesRequiredNumber, - // config.zonesMaxAllowedLoopbackLength // - // ); - // } - - // // - // // Detecting SAR Switches ... - // if (config.detectSARSwitches) - // { - // // - // idx = forBar.Index(); - // has = fimaHelper.HasSARSwitch( - // structure.sarSwitchDir, - // idx // - // ); - - // // - // fimaHelper.ExtractSARPivots( - // structure.sarSwitches, - // idx, - // config.zonesRequiredNumber, - // config.zonesMaxAllowedLoopbackLength // - // ); - // } - - // // - // // Custom Analysers ... - - // // - // // Analyse Based on PV ... - // if (config.analyseFIMAPVPivots) - // { - // // - // XPivotAnalysis analysis; - // has = AnalysePVPivots( - // analysis, // Result ... - // forBar.Index(), // Bar Index ... - // config.numberOfRequiredPivotsForAnalysis, // Required Number of Pivots ... - // config.maxAllowedLoopbackLengthForAnalysis, // Max Allowed Loopback ... - // config.pvPivotsValidationLength // Validation Length ... - // ); - // if (has) - // { - // structure.pvAnalysis = analysis; - // } - // } - - // // - // // Analyse Based on ZigZag ... - // if (config.analyseFIMAZigZagPivots) - // { - // // - // XPivotAnalysis analysis; - // has = AnalyseZigZagPivots( - // analysis, // Result ... - // forBar.Index(), // Bar Index ... - // config.numberOfRequiredPivotsForAnalysis, // Required Number of Pivots ... - // config.maxAllowedLoopbackLengthForAnalysis // Max Allowed Loopback ... - // ); - // if (has) - // { - // structure.zigzagAnalysis = analysis; - // } - // } - - // // - // // Zones and Patterns Recent Actions ... - // if (config.zonesRequiredNumber > 0 && - // config.zonesMaxAllowedLoopbackLength > 0) - // { - // // - // // Detect Recent Patterns ... - - // // - // XOHCL iBar; - // XOHCL tmpBar; - // XPivot iPivot; - // XBoxZone iBox; - // bool has = false; - // string iPrefix = NULL; - // int start = forBar.Index(); - // ENUM_X_SORT_BY iSortBy = X_SORT_BY_DATE; - // ENUM_X_DIRECTION iDir = X_DIRECTION_NONE; - // ENUM_X_DIRECTION iSortDir = X_DIRECTION_BULLISH; - // int end = start + config.zonesMaxAllowedLoopbackLength; - - // // - // // Loop through Items ... - // for (int i = start; i < end; i++) - // { - // // - // iPivot.Clean(); - - // // - // // Initialize Indexed Bar ... - // has = forBar.BarAt(i, iBar); - // if (!has) - // { - // // - // iBar.Clean(); - // continue; - // } - - // // - // // OB ... - // has = HasOB( - // iBar, - // iDir, - // iBox, - // 5 // - // ); - // if (has) - // { - // // - // AddIfNotExists( - // iBox, - // obs // - // ); - // } - - // // - // // FVG ... - // has = HasFVG( - // iBar, - // iDir, - // iBox, - // 5 // - // ); - // if (has) - // { - // // - // AddIfNotExists( - // iBox, - // fvgs // - // ); - // } - - // // - // // SUPPORT ... - // tmpBar.Clean(); - // has = HasSupport( - // iBar, - // tmpBar, - // config.zonesValidationLength, - // config.zonesMaxAllowedLoopbackLength // - // ); - // if (has) - // { - // // - // has = ToSupportBox(tmpBar, iBox, iBar.time); - // if (has) - // { - // // - // // Check Strength ... - // if (config.zonesMinAlloweStrength > 0) - // { - // has = (iBox.upper - iBox.lower) > (config.zonesMinAlloweStrength * GetPoints(iBar.symbol)); - // } - - // // - // if (has) - // { - // // - // AddIfNotExists( - // iBox, - // supports // - // ); - // } - // } - // } - // iBox.Clean(); - // tmpBar.Clean(); - - // // - // // RESISATNCE ... - // tmpBar.Clean(); - // has = HasResistance( - // iBar, - // tmpBar, - // config.zonesValidationLength, - // config.zonesMaxAllowedLoopbackLength // - // ); - // if (has) - // { - // // - // has = ToResistanceBox(tmpBar, iBox, iBar.time); - // if (has) - // { - // // - // // Check Strength ... - // if (config.zonesMinAlloweStrength > 0) - // { - // has = (iBox.upper - iBox.lower) > (config.zonesMinAlloweStrength * GetPoints(iBar.symbol)); - // } - - // // - // if (has) - // { - // // - // AddIfNotExists( - // iBox, - // resistances // - // ); - // } - // } - // } - // iBox.Clean(); - // tmpBar.Clean(); - - // // - // // Bars Detecting ... - - // // - // // Momentum Bars ... - // if (config.detectMomentum) - // { - // // - // iPrefix = "MomentumBar"; - // has = IsMomentumBar( - // iBar, - // iDir, - // config.momentumBarRangeLength, - // config.momentumBarApprovedMultiplier // - // ); - // has = has && - // ToPivot( - // iBar, - // iPivot, - // iDir, - // iPrefix // - // ); - // if (has) - // { - // // - // AddIfNotExists( - // iPivot, - // structure.momentumBars // - // ); - // } - // iPivot.Clean(); - // } - - // // - // // Engulfed Bars ... - // if (config.detectEngulfed) - // { - // // - // iPrefix = "EngulfedBar"; - // has = IsEngulfedBar( - // iBar, - // iDir // - // ); - // has = has && - // ToPivot( - // iBar, - // iPivot, - // iDir, - // iPrefix // - // ); - // if (has) - // { - // // - // AddIfNotExists( - // iPivot, - // structure.engulfBars // - // ); - // } - // iPivot.Clean(); - // } - - // // - // // TruGaped Bars ... - // if (config.detectTrueGaped) - // { - // // - // iPrefix = "TruGapedBar"; - // has = IsTrueGapedBar( - // iBar, - // iDir, - // config.truwGapApprovedPointMultiplier // - // ); - // has = has && - // ToPivot( - // iBar, - // iPivot, - // iDir, - // iPrefix // - // ); - // if (has) - // { - // // - // AddIfNotExists( - // iPivot, - // structure.trueGapBars // - // ); - // } - // iPivot.Clean(); - // } - - // // - // // Pin Bars ... - // if (config.detectTrueGaped) - // { - // // - // iPrefix = "PinBar"; - // has = IsPinnedBar( - // iBar, - // iDir, - // config.pinnedBaarShadowApprovedMultiplier, - // config.pinnedBarMinimumPinBarRangeMultiplier, - // config.pinnedBarForceDirection // - // ); - // has = has && - // ToPivot( - // iBar, - // iPivot, - // iDir, - // iPrefix // - // ); - // if (has) - // { - // // - // AddIfNotExists( - // iPivot, - // structure.pinBars // - // ); - // } - // iPivot.Clean(); - // } - - // // - // // Patterns Detecting ... - - // // - // // Star Pattern ... - // if (config.detectStarPattern) - // { - // // - // iPrefix = "Star"; - // has = IsStarPattern( - // iBar, - // iDir // - // ); - // has = has && - // ToBox( - // iBar, - // iBox, - // iDir, - // iPrefix // - // ); - // if (has) - // { - // // - // AddIfNotExists( - // iBox, - // structure.starPatterns // - // ); - // } - // iBox.Clean(); - // } - - // // - // // Piercing Pattern ... - // if (config.detectPiercingPattern) - // { - // // - // iPrefix = "Piercing"; - // has = IsPiercingPattern( - // iBar, - // iDir // - // ); - // has = has && - // ToBox( - // iBar, - // iBox, - // iDir, - // iPrefix // - // ); - // if (has) - // { - // // - // AddIfNotExists( - // iBox, - // structure.piercingPatterns // - // ); - // } - // iBox.Clean(); - // } - - // // - // // Rising Pattern ... - // if (config.detectRisingPattern) - // { - // // - // iPrefix = "Rising"; - // has = IsRisingPattern( - // iBar, - // iDir // - // ); - // has = has && - // ToBox( - // iBar, - // iBox, - // iDir, - // iPrefix // - // ); - // if (has) - // { - // // - // AddIfNotExists( - // iBox, - // structure.risingPatterns // - // ); - // } - // iBox.Clean(); - // } - - // // - // // Flag Pattern ... - // if (config.detectFlagPattern) - // { - // // - // iPrefix = "Flag"; - // XOHCL swingBar; - // has = IsFlagPattern( - // iBar, - // iDir, - // swingBar, - // config.flagPatternMinimumPullbackBars // - // ); - // has = has && - // ToBox( - // iBar, - // iBox, - // iDir, - // iPrefix // - // ); - // if (has) - // { - // // - // AddIfNotExists( - // iBox, - // structure.flagPatterns // - // ); - // } - // iBox.Clean(); - // } - - // // - // // SignalKey Bar Pattern ... - // if (config.detectSignalKeyBarPattern) - // { - // // - // iPrefix = "SignalKeyBar"; - // has = IsSignalKeyBarPattern( - // iBar, - // iDir, - // config.signalKeyBarShadowApprovedMultiplier, - // config.signalKeyBarMinimumPinBarRangeMultiplier, - // config.signalKeyBarForceDirection // - // ); - // has = has && - // ToBox( - // iBar, - // iBox, - // iDir, - // iPrefix // - // ); - // if (has) - // { - // // - // AddIfNotExists( - // iBox, - // structure.signalKeyBarPatterns // - // ); - // } - // iBox.Clean(); - // } - - // // - // iBar.Clean(); - // iBox.Clean(); - // tmpBar.Clean(); - // iPivot.Clean(); - // } - - // // - // // Zones Extractions ... - - // // - // // XBARZONES ... - // XBoxZone tmpZones[]; - // int tmpZonesCount = fimaHelper.ExtractBarZones( - // tmpZones, - // forBar.Index(), - // config.zonesRequiredNumber, - // config.zonesBreakValidationLength, - // config.zonesBreakValidationLength > 0, - // config.zonesBarShadowMultiplier, - // config.zonesMinAlloweStrength, - // config.zonesValidationLength, - // config.zonesMaxAllowedLoopbackLength // - // ); - // has = IsValidSize(tmpZonesCount); - // if (has) - // { - // // - // for (int i = 0; i < tmpZonesCount; i++) - // { - // // - // if (tmpZones[i].IsBullish()) - // { - // // - // AddIfNotExists( - // tmpZones[i], - // supports // - // ); - // } - // else if (tmpZones[i].IsBearish()) - // { - // // - // AddIfNotExists( - // tmpZones[i], - // resistances // - // ); - // } - // } - // } - - // // - // // XHK ... - // XClean(tmpZones); - // tmpZonesCount = fimaHelper.ExtractHKZones( - // tmpZones, - // forBar.Index(), - // config.zonesRequiredNumber, - // config.zonesBreakValidationLength, - // config.zonesBreakValidationLength > 0, - // config.zonesBarShadowMultiplier, - // config.zonesMinAlloweStrength, - // config.zonesValidationLength, - // config.zonesMaxAllowedLoopbackLength // - // ); - // has = IsValidSize(tmpZonesCount); - // if (has) - // { - // // - // for (int i = 0; i < tmpZonesCount; i++) - // { - // // - // if (tmpZones[i].IsBullish()) - // { - // // - // AddIfNotExists( - // tmpZones[i], - // supports // - // ); - // } - // else if (tmpZones[i].IsBearish()) - // { - // // - // AddIfNotExists( - // tmpZones[i], - // resistances // - // ); - // } - // } - // } - - // // - // // Cleanup Resources ... - // iBar.Clean(); - // iBox.Clean(); - // tmpBar.Clean(); - // iPivot.Clean(); - // } - - // // - // // Analysis Zones ... - - // // - // // XPV ... - - // // - // // Support ... - // has = structure.pvAnalysis.IsValid() && - // structure.pvAnalysis.HasSupportBox(iBox); - // if (has) - // { - // // - // AddIfNotExists( - // iBox, - // supports // - // ); - // } - - // // - // // Resistance ... - // has = structure.pvAnalysis.IsValid() && - // structure.pvAnalysis.HasResistanceBox(iBox); - // if (has) - // { - // // - // AddIfNotExists( - // iBox, - // resistances // - // ); - // } - - // // - // // XZG ... - - // // - // // Support ... - // has = structure.zigzagAnalysis.IsValid() && - // structure.zigzagAnalysis.HasSupportBox(iBox); - // if (has) - // { - // // - // AddIfNotExists( - // iBox, - // supports // - // ); - // } - - // // - // // Resistance ... - // has = structure.zigzagAnalysis.IsValid() && - // structure.zigzagAnalysis.HasResistanceBox(iBox); - // if (has) - // { - // // - // AddIfNotExists( - // iBox, - // resistances // - // ); - // } - - // // - // // ZONES Specified ... - - // // - // // OBS ... - // CheckZones(forBar, obs); - // UpdateToTime(obs, forBar.time); - // Copy( - // obs, - // structure.obs // - // ); - - // // - // // FVGS ... - // CheckZones(forBar, fvgs); - // UpdateToTime(fvgs, forBar.time); - // Copy( - // fvgs, - // structure.fvgs // - // ); - - // // - // // SUPPORTS ... - // CheckZones(forBar, supports); - // UpdateToTime(supports, forBar.time); - // Copy( - // supports, - // structure.supports // - // ); - - // // - // // RESISTANCES ... - // CheckZones(forBar, resistances); - // UpdateToTime(resistances, forBar.time); - // Copy( - // resistances, - // structure.resistances // - // ); - - // // - // // Cleanup Resources ... - // iBox.Clean(); + // + // Cleanup ... + iBar.Clean(); + iPatternAnalysis.Clean(); } // 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 808c889b..c3cfb0d0 100644 --- a/XFIMAEA/Classes/x-saherelm.xfima.x-poi.drawer.class.mq5 +++ b/XFIMAEA/Classes/x-saherelm.xfima.x-poi.drawer.class.mq5 @@ -707,1066 +707,72 @@ class XCXFIMAPOIDrawer : public XCPOIDrawer * * @param structure: XFIMAMarketStructure, reference to Provide Specifid Market Structure ... * @param config: XFIMAMarketStructureDrawerConfig, reference to Provide Drawing Configurations ... - * @param objects: CArrayObj, pointer reference to Holds drawn Objects instances ... - * - * @return ( int ) */ - int DrawMarketStructure( + void DrawMarketStructure( XFIMAMarketStructure &structure, - XFIMAMarketStructureDrawerConfig &config, - CArrayObj *&objects // + XFIMAMarketStructureDrawerConfig &config // ) { - // - int result = 0; - - // - // Normalize ... - if (objects == NULL) - { - objects = new CArrayObj(); - } - - // - // Prepare ... - // objects.Clear(); - - // - int count = 0; - bool has = false; - int arrowCode = -1; - int arrowWidth = 3; - string arrowName = NULL; - color arrowColor = CLR_NONE; - ENUM_X_PRICE arrowPriceType = X_PRICE_CLOSE; - ENUM_ARROW_ANCHOR arrowAnchor = ANCHOR_BOTTOM; - - // - int bullArrowCode = GetArrowCode(X_DIRECTION_BULLISH); - int bearArrowCode = GetArrowCode(X_DIRECTION_BEARISH); - // // Validate ... - has = structure.bar.IsValid(); + bool has = structure.IsValid(); if (!has) { - return result; + return; } // - // Apply Drawing Methods ... - - // // - // // OB ... - // if (config.drawOB) - // { - // // - // // Validate ... - // has = structure.ob.IsValid(); - // if (has) - // { - // // - // XCBoxObject *iObj; - // has = DrawBox( - // structure.ob, - // iObj // - // ); - // if (has) - // { - // objects.Add(iObj); - // } - - // // - // ZeroMemory(iObj); - // } - // } - - // // - // // FVG ... - // if (config.drawFVG) - // { - // // - // // Validate ... - // has = structure.fvg.IsValid(); - // if (has) - // { - // // - // XCBoxObject *iObj; - // has = DrawBox( - // structure.fvg, - // iObj // - // ); - // if (has) - // { - // objects.Add(iObj); - // } - - // // - // ZeroMemory(iObj); - // } - // } - - // // - // // Support ... - // if (config.drawSupport) - // { - // // - // // Validate ... - // has = structure.support.IsValid(); - // if (has) - // { - // // - // XCBoxObject *iObj; - // has = DrawBox( - // structure.support, - // iObj // - // ); - // if (has) - // { - // objects.Add(iObj); - // } - - // // - // ZeroMemory(iObj); - // } - // } - - // // - // // Resistance ... - // if (config.drawResistance) - // { - // // - // // Validate ... - // has = structure.resistance.IsValid(); - // if (has) - // { - // // - // XCBoxObject *iObj; - // has = DrawBox( - // structure.resistance, - // iObj // - // ); - // if (has) - // { - // objects.Add(iObj); - // } - - // // - // ZeroMemory(iObj); - // } - // } - - // // - // // Swing Trend ... - // if (config.drawSwingTrend) - // { - // // - // // Validate ... - // has = HasDirection(structure.trendDir) && - // HasChild(structure.trendSwings); - // if (has) - // { - // // - // CChartObjectTrend *iObj; - // has = DrawSwingTrend( - // structure.trendSwings, - // structure.trendDir, - // iObj, // - // config.swingTrendRayRight, // Ray Right ... - // config.swingTrendRayLeft // Ray Left ... - // ); - // if (has) - // { - // objects.Add(iObj); - // } - - // // - // ZeroMemory(iObj); - // } - // } - - // // - // // Start Pattern ... - // if (config.drawStarPattern) - // { - // // - // // Validate ... - // has = HasDirection(structure.starPatternDir); - // if (has) - // { - // // - // FillArrowSpecs( - // structure.starPatternDir, - // arrowPriceType, - // arrowCode, - // arrowWidth, - // arrowColor, - // arrowAnchor // - // ); - // XCBarArrowObject *iObj; - // arrowName = "XStar_" + ToMD5(structure.bar.time); - // has = DrawBarArrow( - // structure.bar, - // iObj, - // arrowPriceType, - // arrowCode, - // arrowColor, - // arrowWidth, - // arrowAnchor, - // arrowName // - // ); - // if (has) - // { - // objects.Add(iObj); - // } - // } - // } - - // // - // // Flag Pattern ... - // if (config.drawFlagPattern) - // { - // // - // // Validate ... - // has = HasDirection(structure.flagPatternDir) && - // structure.flagSwing.IsValid(); - // if (has) - // { - // // - // FillArrowSpecs( - // structure.flagPatternDir, - // arrowPriceType, - // arrowCode, - // arrowWidth, - // arrowColor, - // arrowAnchor // - // ); - // XCBarArrowObject *iObj; - // arrowName = "XFlag_" + ToMD5(structure.bar.time); - // has = DrawBarArrow( - // structure.bar, - // iObj, - // arrowPriceType, - // arrowCode, - // arrowColor, - // arrowWidth, - // arrowAnchor, - // arrowName // - // ); - // if (has) - // { - // objects.Add(iObj); - // } - // } - // } - - // // - // // Rising Pattern ... - // if (config.drawRisingPattern) - // { - // // - // // Validate ... - // has = HasDirection(structure.risingPatternDir); - // if (has) - // { - // // - // FillArrowSpecs( - // structure.risingPatternDir, - // arrowPriceType, - // arrowCode, - // arrowWidth, - // arrowColor, - // arrowAnchor // - // ); - // XCBarArrowObject *iObj; - // arrowName = "XRise_" + ToMD5(structure.bar.time); - // has = DrawBarArrow( - // structure.bar, - // iObj, - // arrowPriceType, - // arrowCode, - // arrowColor, - // arrowWidth, - // arrowAnchor, - // arrowName // - // ); - // if (has) - // { - // objects.Add(iObj); - // } - // } - // } - - // // - // // Piercing Pattern ... - // if (config.drawPiercingPattern) - // { - // // - // // Validate ... - // has = HasDirection(structure.piercingPatternDir); - // if (has) - // { - // // - // FillArrowSpecs( - // structure.piercingPatternDir, - // arrowPriceType, - // arrowCode, - // arrowWidth, - // arrowColor, - // arrowAnchor // - // ); - // XCBarArrowObject *iObj; - // arrowName = "XPiercing_" + ToMD5(structure.bar.time); - // has = DrawBarArrow( - // structure.bar, - // iObj, - // arrowPriceType, - // arrowCode, - // arrowColor, - // arrowWidth, - // arrowAnchor, - // arrowName // - // ); - // if (has) - // { - // objects.Add(iObj); - // } - // } - // } - - // // - // // Signal Key Bar Pattern ... - // if (config.drawSignalKeyBarPattern) - // { - // // - // // Validate ... - // has = HasDirection(structure.signalKeyBarPatternDir); - // if (has) - // { - // // - // FillArrowSpecs( - // structure.signalKeyBarPatternDir, - // arrowPriceType, - // arrowCode, - // arrowWidth, - // arrowColor, - // arrowAnchor // - // ); - // XCBarArrowObject *iObj; - // arrowName = "XSignalKey_" + ToMD5(structure.bar.time); - // has = DrawBarArrow( - // structure.bar, - // iObj, - // arrowPriceType, - // arrowCode, - // arrowColor, - // arrowWidth, - // arrowAnchor, - // arrowName // - // ); - // if (has) - // { - // objects.Add(iObj); - // } - // } - // } - - // // - // // Pinned Bar ... - // if (config.drawPinned) - // { - // // - // // Validate ... - // has = HasDirection(structure.pinnedDir); - // if (has) - // { - // // - // FillArrowSpecs( - // structure.pinnedDir, - // arrowPriceType, - // arrowCode, - // arrowWidth, - // arrowColor, - // arrowAnchor // - // ); - // XCBarArrowObject *iObj; - // arrowName = "XPin_" + ToMD5(structure.bar.time); - // has = DrawBarArrow( - // structure.bar, - // iObj, - // arrowPriceType, - // arrowCode, - // arrowColor, - // arrowWidth, - // arrowAnchor, - // arrowName // - // ); - // if (has) - // { - // objects.Add(iObj); - // } - // } - // } - - // // - // // Momentum Bar ... - // if (config.drawMomentum) - // { - // // - // // Validate ... - // has = HasDirection(structure.momentumDir); - // if (has) - // { - // // - // FillArrowSpecs( - // structure.momentumDir, - // arrowPriceType, - // arrowCode, - // arrowWidth, - // arrowColor, - // arrowAnchor // - // ); - // XCBarArrowObject *iObj; - // arrowName = "XMomentum_" + ToMD5(structure.bar.time); - // has = DrawBarArrow( - // structure.bar, - // iObj, - // arrowPriceType, - // arrowCode, - // arrowColor, - // arrowWidth, - // arrowAnchor, - // arrowName // - // ); - // if (has) - // { - // objects.Add(iObj); - // } - // } - // } - - // // - // // Engulfed Bar ... - // if (config.drawEngulfed) - // { - // // - // // Validate ... - // has = HasDirection(structure.engulfedDir); - // if (has) - // { - // // - // FillArrowSpecs( - // structure.engulfedDir, - // arrowPriceType, - // arrowCode, - // arrowWidth, - // arrowColor, - // arrowAnchor // - // ); - // XCBarArrowObject *iObj; - // arrowName = "XEngulf_" + ToMD5(structure.bar.time); - // has = DrawBarArrow( - // structure.bar, - // iObj, - // arrowPriceType, - // arrowCode, - // arrowColor, - // arrowWidth, - // arrowAnchor, - // arrowName // - // ); - // if (has) - // { - // objects.Add(iObj); - // } - // } - // } - - // // - // // True Gaped Bar ... - // if (config.drawTrueGaped) - // { - // // - // // Validate ... - // has = HasDirection(structure.trueGapedDir); - // if (has) - // { - // // - // FillArrowSpecs( - // structure.trueGapedDir, - // arrowPriceType, - // arrowCode, - // arrowWidth, - // arrowColor, - // arrowAnchor // - // ); - // XCBarArrowObject *iObj; - // arrowName = "XTrueGap_" + ToMD5(structure.bar.time); - // has = DrawBarArrow( - // structure.bar, - // iObj, - // arrowPriceType, - // arrowCode, - // arrowColor, - // arrowWidth, - // arrowAnchor, - // arrowName // - // ); - // if (has) - // { - // objects.Add(iObj); - // } - // } - // } - - // // - // // XFIMA PV Analysis ... - // if (config.drawFIMAPVPivotsAnalysis) - // { - // // - // // Validate ... - // has = structure.pvAnalysis.IsValid(); - // if (has) - // { - // // - // XCPivotAnalysisObject *iObj; - // has = DrawPivotAnalysis( - // structure.pvAnalysis, - // iObj, - // config.drawFIMAPVPivotsAnalysisTrends, - // config.drawFIMAPVPivotsAnalysisZones, - // config.drawFIMAPVPivotsAnalysisPivots, - // bearArrowCode, - // bullArrowCode // - // ); - // if (has) - // { - // objects.Add(iObj); - // } - // } - // } - - // // - // // XFIMA Sar Analysis ... - // if (config.drawFIMASARPivotsAnalysis) - // { - // // - // // Validate ... - // has = structure.sarAnalysis.IsValid(); - // if (has) - // { - // // - // XCPivotAnalysisObject *iObj; - // has = DrawPivotAnalysis( - // structure.pvAnalysis, - // iObj, - // config.drawFIMASARPivotsAnalysisTrends, - // config.drawFIMASARPivotsAnalysisZones, - // config.drawFIMASARPivotsAnalysisPivots, - // bearArrowCode, - // bullArrowCode // - // ); - // if (has) - // { - // objects.Add(iObj); - // } - // } - // } - - // // - // // XFIMA ZigZag Analysis ... - // if (config.drawFIMAZigZagPivotsAnalysis) - // { - // // - // // Validate ... - // has = structure.zigzagAnalysis.IsValid(); - // if (has) - // { - // // - // XCPivotAnalysisObject *iObj; - // has = DrawPivotAnalysis( - // structure.pvAnalysis, - // iObj, - // config.drawFIMAZigZagPivotsAnalysisTrends, - // config.drawFIMAZigZagPivotsAnalysisZones, - // config.drawFIMAZigZagPivotsAnalysisPivots, - // bearArrowCode, - // bullArrowCode // - // ); - // if (has) - // { - // objects.Add(iObj); - // } - // } - // } - - // // - // // Fake Breaked Zone ... - // if (config.drawFakeBreakedZone && - // structure.fakeBreakedZone.IsValid()) - // { - // // - // XCBoxObject *iObj; - // has = DrawBox( - // structure.fakeBreakedZone, - // iObj // - // ); - // if (has) - // { - // // - // // Apply Style ... - // ApplyFakeBreakStyle( - // iObj, - // structure.fakeBreakedZone // - // ); - - // // - // objects.Add(iObj); - // } - - // // - // ZeroMemory(iObj); - // } - - // // - // // Recently Tested Zones ... - // if (config.drawRecentlyTestedZones && - // HasChild(structure.recentlyTestedZones)) - // { - // // - // XCBoxObject *iObj; - // count = ArraySize(structure.recentlyTestedZones); - // for (int i = 0; i < count; i++) - // { - // // - // // Draw Box ... - // has = DrawBox( - // structure.recentlyTestedZones[i], - // iObj // - // ); - // if (has) - // { - // // - // ApplyTestedStyle( - // iObj, - // structure.recentlyTestedZones[i] // - // ); - - // // - // objects.Add(iObj); - // } - - // // - // ZeroMemory(iObj); - // } - // } - - // // - // // Recently Breaked Zones ... - // if (config.drawRecentlyBreakedZones && - // HasChild(structure.recentlyBreakedZones)) - // { - // // - // XCBoxObject *iObj; - // count = ArraySize(structure.recentlyBreakedZones); - // for (int i = 0; i < count; i++) - // { - // // - // // Draw Box ... - // has = DrawBox( - // structure.recentlyBreakedZones[i], - // iObj // - // ); - // if (has) - // { - // // - // ApplyBreakedStyle( - // iObj, - // structure.recentlyBreakedZones[i] // - // ); - - // // - // objects.Add(iObj); - // } - - // // - // ZeroMemory(iObj); - // } - // } - - // // - // // 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)) - // { - // // - // count = DrawPivots( - // structure.pinBars, - // patternObjects, - // baseArrowCode, - // baseArrowCode // - // ); - // has = IsValidSize(count); - // if (has) - // { - // // - // ApplyPivotsStyle(patternObjects); - - // // - // AddObjects( - // patternObjects, - // objects // - // ); - // } - - // // - // ZeroMemory(patternObjects); - // } - - // // - // // Engulf Bars ... - // if (config.drawEngulfed && - // HasChild(structure.engulfBars)) - // { - // // - // count = DrawPivots( - // structure.engulfBars, - // patternObjects, - // baseArrowCode, - // baseArrowCode // - // ); - // has = IsValidSize(count); - // if (has) - // { - // // - // ApplyPivotsStyle(patternObjects); - - // // - // AddObjects( - // patternObjects, - // objects // - // ); - // } - - // // - // ZeroMemory(patternObjects); - // } - - // // - // // TrueGap Bars ... - // if (config.drawTrueGaped && - // HasChild(structure.trueGapBars)) - // { - // // - // count = DrawPivots( - // structure.trueGapBars, - // patternObjects, - // baseArrowCode, - // baseArrowCode // - // ); - // has = IsValidSize(count); - // if (has) - // { - // // - // ApplyPivotsStyle(patternObjects); - - // // - // AddObjects( - // patternObjects, - // objects // - // ); - // } - - // // - // ZeroMemory(patternObjects); - // } - - // // - // // Momentum Bars ... - // if (config.drawMomentum && - // HasChild(structure.momentumBars)) - // { - // // - // count = DrawPivots( - // structure.momentumBars, - // patternObjects, - // baseArrowCode, - // baseArrowCode // - // ); - // has = IsValidSize(count); - // if (has) - // { - // // - // ApplyPivotsStyle(patternObjects); - - // // - // AddObjects( - // patternObjects, - // objects // - // ); - // } - - // // - // ZeroMemory(patternObjects); - // } - - // // - // // Flag Pattern ... - // if (config.drawFlagPattern && - // HasChild(structure.flagPatterns)) - // { - // // - // count = DrawBoxes( - // structure.flagPatterns, - // patternObjects // - // ); - // has = IsValidSize(count); - // if (has) - // { - // // - // ApplyPatternsStyle(patternObjects); - - // // - // AddObjects( - // patternObjects, - // objects // - // ); - // } - - // // - // ZeroMemory(patternObjects); - // } - - // // - // // Star Pattern ... - // if (config.drawStarPattern && - // HasChild(structure.starPatterns)) - // { - // // - // count = DrawBoxes( - // structure.starPatterns, - // patternObjects // - // ); - // has = IsValidSize(count); - // if (has) - // { - // // - // ApplyPatternsStyle(patternObjects); - - // // - // AddObjects( - // patternObjects, - // objects // - // ); - // } - - // // - // ZeroMemory(patternObjects); - // } - - // // - // // Rising Pattern ... - // if (config.drawRisingPattern && - // HasChild(structure.risingPatterns)) - // { - // // - // count = DrawBoxes( - // structure.risingPatterns, - // patternObjects // - // ); - // has = IsValidSize(count); - // if (has) - // { - // // - // ApplyPatternsStyle(patternObjects); - - // // - // AddObjects( - // patternObjects, - // objects // - // ); - // } - - // // - // ZeroMemory(patternObjects); - // } - - // // - // // Piercing Pattern ... - // if (config.drawPiercingPattern && - // HasChild(structure.piercingPatterns)) - // { - // // - // count = DrawBoxes( - // structure.piercingPatterns, - // patternObjects // - // ); - // has = IsValidSize(count); - // if (has) - // { - // // - // ApplyPatternsStyle(patternObjects); - - // // - // AddObjects( - // patternObjects, - // objects // - // ); - // } - - // // - // ZeroMemory(patternObjects); - // } - - // // - // // SignalKeyBar Pattern ... - // if (config.drawSignalKeyBarPattern && - // HasChild(structure.signalKeyBarPatterns)) - // { - // // - // count = DrawBoxes( - // structure.signalKeyBarPatterns, - // patternObjects // - // ); - // has = IsValidSize(count); - // if (has) - // { - // // - // ApplyPatternsStyle(patternObjects); - - // // - // AddObjects( - // patternObjects, - // objects // - // ); - // } - - // // - // ZeroMemory(patternObjects); - // } - // } + // PV Analysis ... + if (config.drawPVAnalysis) + { + // + has = structure.pvAnalysis.IsValid(); + if (has) + { + // + DrawPivotAnalysis( + structure.pvAnalysis, + config.pivotAnalysisDrawConfig // + ); + } + } // - result = objects.Total(); + // ZG Analysis ... + if (config.drawZGAnalysis) + { + // + has = structure.zgAnalysis.IsValid(); + if (has) + { + // + DrawPivotAnalysis( + structure.zgAnalysis, + config.pivotAnalysisDrawConfig // + ); + } + } // - return result; + // Bars Analysis ... + if (config.drawBarsAnalysis) + { + // + int count = ArraySize(structure.barsAnalysis); + has = IsValidSize(count); + if (has) + { + // + for (int i = 0; i < count; i++) + { + // + DrawPatternAnalysis( + structure.barsAnalysis[i], + config.barAnalysisDrawConfig // + ); + } + } + } } // diff --git a/XFIMAEA/Libraries/x-saherelm.xfima.lib.mq5 b/XFIMAEA/Libraries/x-saherelm.xfima.lib.mq5 index f5fb350d..1650a2f9 100644 --- a/XFIMAEA/Libraries/x-saherelm.xfima.lib.mq5 +++ b/XFIMAEA/Libraries/x-saherelm.xfima.lib.mq5 @@ -36,22 +36,14 @@ struct XFIMAMarketStructure { // - XOHCL bar; // Spacified Start Bar for Analysing ... - int length; // Loopback Length for Analyse Structure ... + XOHCL bar; // Spacified Start Bar for Analysing ... // XPivotAnalysis pvAnalysis; // PV Pivot Analysis Result ... XPivotAnalysis zgAnalysis; // ZG Pivot Analysis Result ... - XPivotAnalysis barsPivotsAnalysis; // Bars Pivot Analysis Result ... // - XPatternAnalysis barsAnalysis[]; // Anaysed Bars ... - XPatternAnalysisConfig barsAnalysisConfig; // Bars Analyser Config ... - - // - // Configure Pivots Detection ... - int requiredPivots; // Required Extracted Pivots for Analysis ... - + XPatternAnalysis barsAnalysis[]; // Anaysed Bars ... // // Constructor ... @@ -70,13 +62,11 @@ struct XFIMAMarketStructure { // bar.Clean(); - length = 0; // pvAnalysis.Clean(); zgAnalysis.Clean(); XClean(barsAnalysis); - barsAnalysisConfig.Clean(); // ZeroMemory(this); @@ -93,8 +83,7 @@ struct XFIMAMarketStructure bool result = false; // - result = bar.IsValid() && - length > 0; + result = bar.IsValid(); // return result; @@ -103,6 +92,120 @@ struct XFIMAMarketStructure // }; +struct XFIMAMarketStructureConfig +{ + // + // Props ... + + // + // Detector Flags ... + + // + bool analysePVPivots; // Analyse PV Pivots ... + bool analyseZGPivots; // Analyse ZG Pivots ... + + // + bool analyseBarPatterns; // Analyse Bar Patterns ... + + // + // Detector Configs ... + + // + int loopback; // Max Allowed Looping Back Length ... + int requiredPivots; // Required Extracted Pivots for Analysis ... + + // + int pvPivotsValidationLength; // PV Pivots Validation Length ... + double maCrossValidationDiffMultiplier; // a Point Distance to Validate MA Crosses ... + + // + XPatternAnalysisConfig barsAnalysisConfig; // Bars Analyser Config ... + + // + // Constructor ... + XFIMAMarketStructureConfig() + { + Clean(); + } + + // + // Tools ... + + /** + * This function fulfills the will of the developer + */ + void Clean() + { + // + // Detector Flags ... + analysePVPivots = false; + analyseZGPivots = false; + analyseBarPatterns = false; + + // + // Configure Detectors ... + loopback = 0; + requiredPivots = 0; + pvPivotsValidationLength = 0; + maCrossValidationDiffMultiplier = 0; + + // + barsAnalysisConfig.Clean(); + + // + ZeroMemory(this); + } + + /** + * Default Configurations ... + */ + void Default() + { + // + // Detector Flags ... + analysePVPivots = true; + analyseZGPivots = true; + analyseBarPatterns = true; + + // + // Configure Detectors ... + loopback = 500; + requiredPivots = 25; + pvPivotsValidationLength = 5; + maCrossValidationDiffMultiplier = 4; + + // + barsAnalysisConfig.Default(); + barsAnalysisConfig.FullPattern(); + } + + /** + * No Draw Abilioty ... + */ + void Off() + { + // + // Detector Flags ... + analysePVPivots = false; + analyseZGPivots = false; + analyseBarPatterns = false; + } + + /** + * Full Draw Abilioty ... + */ + void Full() + { + // + // Detector Flags ... + analysePVPivots = true; + analyseZGPivots = true; + analyseBarPatterns = true; + } + + // +}; + /** * Configure Market Structure Drawer ... **/ @@ -110,6 +213,15 @@ struct XFIMAMarketStructureDrawerConfig { // // Props ... + + // + bool drawPVAnalysis; + bool drawZGAnalysis; + bool drawBarsAnalysis; + + // + XPOIDrawConfig drawConfig; + XPivotAnalysisDrawConfig pivotAnalysisDrawConfig; XPatternAnalysisDrawConfig barAnalysisDrawConfig; // @@ -123,27 +235,110 @@ struct XFIMAMarketStructureDrawerConfig // Tools ... /** - * Cleanup Model ... + * This function fulfills the will of the developer */ void Clean() { + // + // Drawing Flags ... + + // + drawPVAnalysis = false; + drawZGAnalysis = false; + drawBarsAnalysis = false; + + // + // Drawing Configs ... + drawConfig.Clean(); + barAnalysisDrawConfig.Clean(); + pivotAnalysisDrawConfig.Clean(); // ZeroMemory(this); } /** - * Default Model ... + * Default Configurations ... */ void Default() { + // + // Drawing Flags ... + + // + drawPVAnalysis = true; + drawZGAnalysis = true; + drawBarsAnalysis = true; + + // + // Drawing Configs ... + drawConfig.Default(); + pivotAnalysisDrawConfig.Default(); + + // + barAnalysisDrawConfig.Default(); + barAnalysisDrawConfig.Full(); + XClean(barAnalysisDrawConfig.allowedDrawZones); + Add( + X_BAR_PATTERN_SUPPORT, + barAnalysisDrawConfig.allowedDrawZones + ); + Add( + X_BAR_PATTERN_RESISTANCE, + barAnalysisDrawConfig.allowedDrawZones + ); } /** - * Configure for Full Drawing ... + * No Draw Abilioty ... */ - void FullDraw() + void Off() { + // + // Drawing Flags ... + + // + drawPVAnalysis = false; + drawZGAnalysis = false; + drawBarsAnalysis = false; + + // + // Drawing Configs ... + barAnalysisDrawConfig.Off(); + pivotAnalysisDrawConfig.Off(); + } + + /** + * Full Draw Abilioty ... + */ + void Full() + { + // + // Drawing Flags ... + + // + drawPVAnalysis = false; + drawZGAnalysis = false; + drawBarsAnalysis = false; + + // + // Drawing Configs ... + barAnalysisDrawConfig.Full(); + pivotAnalysisDrawConfig.Full(); + } + + void ApplyDrawConfig() + { + // + barAnalysisDrawConfig.drawConfig = drawConfig; + pivotAnalysisDrawConfig.drawConfig = drawConfig; + } + + void ApplyDrawConfig(XPOIDrawConfig &_drawConfig) + { + // + drawConfig = _drawConfig; + ApplyDrawConfig(); } //