From eb48aebac8d8713f8a305bcaf4b73b78aadd0e1a Mon Sep 17 00:00:00 2001 From: Hadi Khazaee Asl Date: Tue, 29 Oct 2024 16:25:47 +0330 Subject: [PATCH] Last ... --- Classes/x-saherelm.x-chart-objects.class.mq5 | 580 +- Classes/x-saherelm.x-poi.class.mq5 | 1823 +--- Classes/x-saherelm.x-poi.drawer.class.mq5 | 965 +- Documents/BKP/121.smc.strategy.tmp.mq5 | 321 + .../x-saherelm.x-poi.Draw.Abillity.class.mq5 | 9109 +++++++++++++++++ X121SMCEA/Libraries/x-121.smc.lib.mq5 | 24 +- .../Strategy/x-121.smc.strategy.class.mq5 | 1746 ++-- 7 files changed, 12009 insertions(+), 2559 deletions(-) create mode 100644 Documents/BKP/x-saherelm.x-poi.Draw.Abillity.class.mq5 diff --git a/Classes/x-saherelm.x-chart-objects.class.mq5 b/Classes/x-saherelm.x-chart-objects.class.mq5 index a6c6dc1c..4c1fbeb1 100644 --- a/Classes/x-saherelm.x-chart-objects.class.mq5 +++ b/Classes/x-saherelm.x-chart-objects.class.mq5 @@ -25,6 +25,7 @@ // #include +#include #include #include @@ -35,23 +36,29 @@ enum ENUM_XCHARTOBJECTS { // // Global ... - X_ZONE = 7860, - X_FROM_TO = 7861, - X_BAR_ARROW = 7862, + X_ZONE_OBJ = 7860, + X_FROM_TO_OBJ = 7861, + X_BAR_ARROW_OBJ = 7862, // - X_SIGNAL = 8860 - // - // Structured ... - X_TRADE_DAY = 9860, - X_MARKET_SESSION = 9861, - X_SUPPORT_ZONE = 9862, - X_RESISTANCE_ZONE = 9863, - X_SUPPLY_ZONE = 9864, - X_DEMAND_ZONE = 9865, - X_BULLISH_ORDERBLOCK = 9866, - X_BEARISH_ORDERBLOCK = 9867, - X_BULLISH_FVG = 9868, - X_BEARISH_FVG = 9869, + X_SIGNAL_OBJ = 8860, + // + // Structured ... + X_TRADE_DAY_OBJ = 9860, + X_MARKET_SESSION_OBJ = 9861, + X_SWING_HIGH_OBJ = 9862, + X_SWING_LOW_OBJ = 9863, + X_BULLISH_MOMENTUM_BAR_OBJ = 9864, + X_BEARISH_MOMENTUM_BAR_OBJ = 9865, + X_BULLISH_REJECTION_BAR_OBJ = 9866, + X_BEARISH_REJECTION_BAR_OBJ = 9867, + X_SUPPORT_ZONE_OBJ = 9868, + X_RESISTANCE_ZONE_OBJ = 9869, + X_SUPPLY_ZONE_OBJ = 9870, + X_DEMAND_ZONE_OBJ = 9871, + X_BULLISH_ORDERBLOCK_OBJ = 9872, + X_BEARISH_ORDERBLOCK_OBJ = 9873, + X_BULLISH_FVG_OBJ = 9874, + X_BEARISH_FVG_OBJ = 9875, }; enum ENUM_X_CHART_IDS @@ -197,6 +204,9 @@ class XCBarArrow : public XCBaseObject * @param chart_id: Long ... * @param name: String ... * @param window: Integer ... + * @param bar: XOHCL instance ... + * @param priceType: ENUM_X_PRICE member ... + * @param arrow: Integer ... * * @return ( bool ) */ @@ -221,7 +231,7 @@ class XCBarArrow : public XCBaseObject } // - double time = bar.time; + datetime time = bar.time; double price = bar.GetPrice(priceType); // @@ -253,7 +263,7 @@ class XCBarArrow : public XCBaseObject */ virtual ENUM_XCHARTOBJECTS Type() { - return X_BAR_ARROW; + return X_BAR_ARROW_OBJ; } /** @@ -276,6 +286,16 @@ class XCBarArrow : public XCBaseObject mArrow.Color(value); } + /** + * Set Arrow Width ... + * + * @param value: Integer ... + */ + void ArrowWidth(int value) + { + mArrow.Width(value); + } + // protected: // @@ -363,7 +383,7 @@ class XCFromToObject : public XCBaseObject */ virtual ENUM_XCHARTOBJECTS Type() { - return X_FROM_TO; + return X_FROM_TO_OBJ; } /** @@ -648,7 +668,24 @@ class XCZoneObject : public XCBaseObject */ virtual ENUM_XCHARTOBJECTS Type() { - return X_ZONE; + return X_ZONE_OBJ; + } + + /** + * Fill Zone ... + * + * @param value: Boolean ... + */ + void ZoneFill(bool value) + { + // + if (!IsValid(mRect.Name())) + { + return; + } + + // + mRect.Fill(value); } /** @@ -823,6 +860,10 @@ class XCSignalObject : public XCBaseObject return result; } + // + // Set Object Name ... + ObjName(name); + // return result; } @@ -957,7 +998,7 @@ class XCSignalObject : public XCBaseObject */ virtual ENUM_XCHARTOBJECTS Type() { - return X_SIGNAL; + return X_SIGNAL_OBJ; } // @@ -1030,17 +1071,8 @@ class XCTardeDayObject : public XCFromToObject */ virtual ENUM_XCHARTOBJECTS Type() { - return X_TRADE_DAY; + return X_TRADE_DAY_OBJ; } - - // - protected: - // - - // - private: - // - // }; // @@ -1103,25 +1135,451 @@ class XCMarketSessionObject : public XCFromToObject */ virtual ENUM_XCHARTOBJECTS Type() { - return X_MARKET_SESSION; + return X_MARKET_SESSION_OBJ; } - - // - protected: - // - - // - private: - // - // }; // -class XCSwingHighObject : public +// Swing High Object ... +class XCSwingHighObject : public XCBarArrow +{ + // + public: + // - // - // Support Zone ... - class XCSupportZoneObject : public XCZoneObject + // + // Constructor ... + void XCSwingHighObject() + { + } + + // + // Deconstructor ... + void ~XCSwingHighObject() + { + } + + // + // Actions ... + + /** + * Create XCSwingHighObject ... + * + * @param chart_id: Long ... + * @param name: String ... + * @param window: Integer ... + * @param bar: XOHCL instance ... + * @param arrow: Integer ... + * + * @return ( bool ) + */ + bool CreateBySwing( + long chart_id, + const string name, + const int window, + XOHCL &swing, + int arrow // + ) + { + // + bool result = false; + + // + result = Create( + chart_id, + name, + window, + swing, + X_PRICE_HIGH, + (char)arrow // + ); + + // + return result; + } + + // + // Virtual Actions ... + + /** + * Retrieve Object Type ... + * + * @return ( ENUM_XCHARTOBJECTS ) + */ + virtual ENUM_XCHARTOBJECTS Type() + { + return X_SWING_HIGH_OBJ; + } +}; + +// +// Swing Low Object ... +class XCSwingLowObject : public XCBarArrow +{ + // + public: + // + + // + // Constructor ... + void XCSwingLowObject() + { + } + + // + // Deconstructor ... + void ~XCSwingLowObject() + { + } + + // + // Actions ... + + /** + * Create XCSwingHighObject ... + * + * @param chart_id: Long ... + * @param name: String ... + * @param window: Integer ... + * @param bar: XOHCL instance ... + * @param arrow: Integer ... + * + * @return ( bool ) + */ + bool CreateBySwing( + long chart_id, + const string name, + const int window, + XOHCL &swing, + int arrow // + ) + { + // + bool result = false; + + // + result = Create( + chart_id, + name, + window, + swing, + X_PRICE_LOW, + (char)arrow // + ); + + // + return result; + } + + // + // Virtual Actions ... + + /** + * Retrieve Object Type ... + * + * @return ( ENUM_XCHARTOBJECTS ) + */ + virtual ENUM_XCHARTOBJECTS Type() + { + return X_SWING_LOW_OBJ; + } +}; + +// +// Bullish Momentum Bar Object ... +class XCBullishMomentumBarObject : public XCBarArrow +{ + // + public: + // + + // + // Constructor ... + void XCBullishMomentumBarObject() + { + } + + // + // Deconstructor ... + void ~XCBullishMomentumBarObject() + { + } + + // + // Actions ... + + /** + * Create XCBullishMomentumBarObject ... + * + * @param chart_id: Long ... + * @param name: String ... + * @param window: Integer ... + * @param bar: XOHCL instance ... + * @param arrow: Integer ... + * + * @return ( bool ) + */ + bool CreateByBar( + long chart_id, + const string name, + const int window, + XOHCL &bar, + int arrow // + ) + { + // + bool result = false; + + // + result = Create( + chart_id, + name, + window, + bar, + X_PRICE_LOW, + (char)arrow // + ); + + // + return result; + } + + // + // Virtual Actions ... + + /** + * Retrieve Object Type ... + * + * @return ( ENUM_XCHARTOBJECTS ) + */ + virtual ENUM_XCHARTOBJECTS Type() + { + return X_BULLISH_MOMENTUM_BAR_OBJ; + } +}; + +// +// Bearish Momentum Bar Object ... +class XCBearishMomentumBarObject : public XCBarArrow +{ + // + public: + // + + // + // Constructor ... + void XCBearishMomentumBarObject() + { + } + + // + // Deconstructor ... + void ~XCBearishMomentumBarObject() + { + } + + // + // Actions ... + + /** + * Create XCBearishMomentumBarObject ... + * + * @param chart_id: Long ... + * @param name: String ... + * @param window: Integer ... + * @param bar: XOHCL instance ... + * @param arrow: Integer ... + * + * @return ( bool ) + */ + bool CreateByBar( + long chart_id, + const string name, + const int window, + XOHCL &bar, + int arrow // + ) + { + // + bool result = false; + + // + result = Create( + chart_id, + name, + window, + bar, + X_PRICE_HIGH, + (char)arrow // + ); + + // + return result; + } + + // + // Virtual Actions ... + + /** + * Retrieve Object Type ... + * + * @return ( ENUM_XCHARTOBJECTS ) + */ + virtual ENUM_XCHARTOBJECTS Type() + { + return X_BEARISH_MOMENTUM_BAR_OBJ; + } +}; + +// +// Bullish Rejection Bar Object ... +class XCBullishRejectionBarObject : public XCBarArrow +{ + // + public: + // + + // + // Constructor ... + void XCBullishRejectionBarObject() + { + } + + // + // Deconstructor ... + void ~XCBullishRejectionBarObject() + { + } + + // + // Actions ... + + /** + * Create XCBullishRejectionBarObject ... + * + * @param chart_id: Long ... + * @param name: String ... + * @param window: Integer ... + * @param bar: XOHCL instance ... + * @param arrow: Integer ... + * + * @return ( bool ) + */ + bool CreateByBar( + long chart_id, + const string name, + const int window, + XOHCL &bar, + int arrow // + ) + { + // + bool result = false; + + // + result = Create( + chart_id, + name, + window, + bar, + X_PRICE_LOW, + (char)arrow // + ); + + // + return result; + } + + // + // Virtual Actions ... + + /** + * Retrieve Object Type ... + * + * @return ( ENUM_XCHARTOBJECTS ) + */ + virtual ENUM_XCHARTOBJECTS Type() + { + return X_BULLISH_REJECTION_BAR_OBJ; + } +}; + +// +// Bearish Rejection Bar Object ... +class XCBearishRejectionBarObject : public XCBarArrow +{ + // + public: + // + + // + // Constructor ... + void XCBearishRejectionBarObject() + { + } + + // + // Deconstructor ... + void ~XCBearishRejectionBarObject() + { + } + + // + // Actions ... + + /** + * Create XCBearishRejectionBarObject ... + * + * @param chart_id: Long ... + * @param name: String ... + * @param window: Integer ... + * @param bar: XOHCL instance ... + * @param arrow: Integer ... + * + * @return ( bool ) + */ + bool CreateByBar( + long chart_id, + const string name, + const int window, + XOHCL &bar, + int arrow // + ) + { + // + bool result = false; + + // + result = Create( + chart_id, + name, + window, + bar, + X_PRICE_HIGH, + (char)arrow // + ); + + // + return result; + } + + // + // Virtual Actions ... + + /** + * Retrieve Object Type ... + * + * @return ( ENUM_XCHARTOBJECTS ) + */ + virtual ENUM_XCHARTOBJECTS Type() + { + return X_BEARISH_REJECTION_BAR_OBJ; + } +}; + +// +// Support Zone ... +class XCSupportZoneObject : public XCZoneObject { // public: @@ -1200,10 +1658,8 @@ class XCSwingHighObject : public */ virtual ENUM_XCHARTOBJECTS Type() { - return X_SUPPORT_ZONE; + return X_SUPPORT_ZONE_OBJ; } - - // }; // @@ -1287,10 +1743,8 @@ class XCResistanceZoneObject : public XCZoneObject */ virtual ENUM_XCHARTOBJECTS Type() { - return X_RESISTANCE_ZONE; + return X_RESISTANCE_ZONE_OBJ; } - - // }; // @@ -1320,10 +1774,8 @@ class XCSupplyZoneObject : public XCZoneObject */ virtual ENUM_XCHARTOBJECTS Type() { - return X_SUPPLY_ZONE; + return X_SUPPLY_ZONE_OBJ; } - - // }; // @@ -1353,10 +1805,8 @@ class XCDemandZoneObject : public XCZoneObject */ virtual ENUM_XCHARTOBJECTS Type() { - return X_DEMAND_ZONE; + return X_DEMAND_ZONE_OBJ; } - - // }; // @@ -1387,10 +1837,8 @@ class XCBullishOrderBlockObject : public XCZoneObject */ virtual ENUM_XCHARTOBJECTS Type() { - return X_BULLISH_ORDERBLOCK; + return X_BULLISH_ORDERBLOCK_OBJ; } - - // }; // @@ -1421,10 +1869,8 @@ class XCBearishOrderBlockObject : public XCZoneObject */ virtual ENUM_XCHARTOBJECTS Type() { - return X_BEARISH_ORDERBLOCK; + return X_BEARISH_ORDERBLOCK_OBJ; } - - // }; // @@ -1455,10 +1901,8 @@ class XCBullishFVGObject : public XCZoneObject */ virtual ENUM_XCHARTOBJECTS Type() { - return X_BULLISH_FVG; + return X_BULLISH_FVG_OBJ; } - - // }; // @@ -1489,10 +1933,8 @@ class XCBearishFVGObject : public XCZoneObject */ virtual ENUM_XCHARTOBJECTS Type() { - return X_BEARISH_FVG; + return X_BEARISH_FVG_OBJ; } - - // }; // diff --git a/Classes/x-saherelm.x-poi.class.mq5 b/Classes/x-saherelm.x-poi.class.mq5 index 0e9fcd6c..13928bb8 100644 --- a/Classes/x-saherelm.x-poi.class.mq5 +++ b/Classes/x-saherelm.x-poi.class.mq5 @@ -24,14 +24,11 @@ // Imports ... // -#include "../Classes/x-saherelm.x-chart-objects.class.mq5" +#include "../Classes/x-saherelm.x-poi.drawer.class.mq5" #include "../Classes/x-saherelm.xalert.class.mq5" // #include -#include -#include -#include // // Implementation ... @@ -68,6 +65,9 @@ class XCPOI : public XSCBaseAlert mPeriod // ); + // + mDrawer = new XCPOIDrawer(); + // // Apply Default Configurations ... ApplyDefaultConfig(); @@ -82,6 +82,9 @@ class XCPOI : public XSCBaseAlert DestroyObjects(); DestroySessions(); DestroyEventListeners(); + + // + delete mDrawer; } // @@ -92,9 +95,9 @@ class XCPOI : public XSCBaseAlert * * @return ( long ) */ - long ChartID() + long ChartIdentification() { - return mChartID; + return mChartIdentification; } /** @@ -102,7 +105,7 @@ class XCPOI : public XSCBaseAlert * * @param value: Long */ - void ChartID(long value) + void ChartIdentification(long value) { // if (value < 0) @@ -111,25 +114,29 @@ class XCPOI : public XSCBaseAlert } // - mChartID = value; + mChartIdentification = value; + if (mDrawer != NULL) + { + mDrawer.ChartIdentification(value); + } } /** - * Get Sub Window Number ... + * Get Sub SubWindowIdentification Number ... * * @return ( int ) */ - int Window() + int SubWindowIdentification() { - return mWindow; + return mSubWindowIdentification; } /** - * Get Sub Window Number ... + * Get Sub SubWindowIdentification Number ... * * @param value: Integer ... */ - void Window(int value) + void SubWindowIdentification(int value) { // if (value < 0) @@ -138,7 +145,11 @@ class XCPOI : public XSCBaseAlert } // - mWindow = value; + mSubWindowIdentification = value; + if (mDrawer != NULL) + { + mDrawer.SubWindowIdentification(value); + } } /** @@ -473,73 +484,6 @@ class XCPOI : public XSCBaseAlert mSwingHighThreshold = value; } - /** - * Get Swing High Arrow Code ... - * - * @return ( char ) - */ - char SwingHighArrowCode() - { - return mSwingHighArrowCode; - } - - /** - * Set Swing High Arrow Code ... - * - * @param value: Char ... - */ - void SwingHighArrowCode(char value) - { - mSwingHighArrowCode = value; - } - - /** - * Get Swing High Color ... - * - * @return ( color ) - */ - color SwingHighColor() - { - return mSwingHighColor; - } - - /** - * Get Swing High Color ... - * - * @param value: Color - */ - void SwingHighColor(color value) - { - mSwingHighColor = value; - } - - /** - * Get Swing High Width ... - * - * @return ( int ) - */ - int SwingHighWidth() - { - return mSwingHighWidth; - } - - /** - * Set Swing High Width ... - * - * @param value: Integer ... - */ - void SwingHighWidth(int value) - { - // - if (value < 1) - { - value = 1; - } - - // - mSwingHighWidth = value; - } - // // Swing Low ... @@ -610,73 +554,6 @@ class XCPOI : public XSCBaseAlert mSwingLowThreshold = value; } - /** - * Get Swing Low Arrow Code ... - * - * @return ( char ) - */ - char SwingLowArrowCode() - { - return mSwingLowArrowCode; - } - - /** - * Set Swing Low Arrow Code ... - * - * @param value: Char ... - */ - void SwingLowArrowCode(char value) - { - mSwingLowArrowCode = value; - } - - /** - * Get Swing Low Color ... - * - * @return ( color ) - */ - color SwingLowColor() - { - return mSwingLowColor; - } - - /** - * Get Swing Low Color ... - * - * @param value: Color - */ - void SwingLowColor(color value) - { - mSwingLowColor = value; - } - - /** - * Get Swing Low Width ... - * - * @return ( int ) - */ - int SwingLowWidth() - { - return mSwingLowWidth; - } - - /** - * Set Swing Low Width ... - * - * @param value: Integer ... - */ - void SwingLowWidth(int value) - { - // - if (value < 1) - { - value = 1; - } - - // - mSwingLowWidth = value; - } - // // Momentum Bars ... @@ -801,106 +678,6 @@ class XCPOI : public XSCBaseAlert mMomentumBarLoopBack = value; } - /** - * Get Momentum Bar Width ... - * - * @return ( int ) - */ - int MomentumBarWidth() - { - return mMomentumBarWidth; - } - - /** - * Set Momentum Bar Width ... - * - * @param value: Integer ... - */ - void MomentumBarWidth(int value) - { - mMomentumBarWidth = value; - } - - /** - * Get Bullish Momentum Bar Arrow Code ... - * - * @return ( char ) - */ - char MomentumBarBullishArrowCode() - { - return mMomentumBarBullishArrowCode; - } - - /** - * Set Bullish Momentum Bar Arrow Code ... - * - * @param value: Char ... - */ - void MomentumBarBullishArrowCode(char value) - { - mMomentumBarBullishArrowCode = value; - } - - /** - * Get Bullish Momentum Bar Color ... - * - * @return ( char ) - */ - char MomentumBarBearishArrowCode() - { - return mMomentumBarBearishArrowCode; - } - - /** - * Set Bullish Momentum Bar Color ... - * - * @param value: Color ... - */ - void MomentumBarBearishArrowCode(char value) - { - mMomentumBarBearishArrowCode = value; - } - - /** - * Get Bearish Momentum Bar Arrow Code ... - * - * @return ( color ) - */ - color MomentumBarBullishColor() - { - return mMomentumBarBullishColor; - } - - /** - * Set Bearish Momentum Bar Arrow Code ... - * - * @param value: Color ... - */ - void MomentumBarBullishColor(color value) - { - mMomentumBarBullishColor = value; - } - - /** - * Get Bearish Momentum Bar Color ... - * - * @return ( color ) - */ - color MomentumBarBearishColor() - { - return mMomentumBarBearishColor; - } - - /** - * Set Bearish Momentum Bar Color ... - * - * @param value: Color ... - */ - void MomentumBarBearishColor(color value) - { - mMomentumBarBearishColor = value; - } - // // Rejection Bars ... @@ -1004,106 +781,6 @@ class XCPOI : public XSCBaseAlert mRejectionBarLoopBack = value; } - /** - * Get Rejection Bar Width ... - * - * @return ( int ) - */ - int RejectionBarWidth() - { - return mRejectionBarWidth; - } - - /** - * Set Rejection Bar Width ... - * - * @param value: Integer ... - */ - void RejectionBarWidth(int value) - { - mRejectionBarWidth = value; - } - - /** - * Get Bullish Rejection Bar Arrow Code ... - * - * @return ( char ) - */ - char RejectionBarBullishArrowCode() - { - return mRejectionBarBullishArrowCode; - } - - /** - * Set Bullish Rejection Bar Arrow Code ... - * - * @param value: Char ... - */ - void RejectionBarBullishArrowCode(char value) - { - mRejectionBarBullishArrowCode = value; - } - - /** - * Get Bullish Rejection Bar Color ... - * - * @return ( char ) - */ - char RejectionBarBearishArrowCode() - { - return mRejectionBarBearishArrowCode; - } - - /** - * Set Bullish Rejection Bar Color ... - * - * @param value: Color ... - */ - void RejectionBarBearishArrowCode(char value) - { - mRejectionBarBearishArrowCode = value; - } - - /** - * Get Bearish Rejection Bar Arrow Code ... - * - * @return ( color ) - */ - color RejectionBarBullishColor() - { - return mRejectionBarBullishColor; - } - - /** - * Set Bearish Rejection Bar Arrow Code ... - * - * @param value: Color ... - */ - void RejectionBarBullishColor(color value) - { - mRejectionBarBullishColor = value; - } - - /** - * Get Bearish Rejection Bar Color ... - * - * @return ( color ) - */ - color RejectionBarBearishColor() - { - return mRejectionBarBearishColor; - } - - /** - * Set Bearish Rejection Bar Color ... - * - * @param value: Color ... - */ - void RejectionBarBearishColor(color value) - { - mRejectionBarBearishColor = value; - } - // // Support Zone ... @@ -1174,73 +851,6 @@ class XCPOI : public XSCBaseAlert mSupportZoneLoopBack = value; } - /** - * Get Support Zone Width ... - * - * @return ( int ) - */ - int SupportZoneWidth() - { - return mSupportZoneWidth; - } - - /** - * Set Support Zone Width ... - * - * @param value: Integer ... - */ - void SupportZoneWidth(int value) - { - // - if (value < 1) - { - value = 1; - } - - // - mSupportZoneWidth = value; - } - - /** - * Get Support Zone Color ... - * - * @return ( color ) - */ - color SupportZoneColor() - { - return mSupportZoneColor; - } - - /** - * Set Support Zone Color ... - * - * @param value: Color ... - */ - void SupportZoneColor(color value) - { - mSupportZoneColor = value; - } - - /** - * Get Support Zone Style ... - * - * @return ( ENUM_LINE_STYLE ) - */ - ENUM_LINE_STYLE SupportZoneStyle() - { - return mSupportZoneStyle; - } - - /** - * Set Support Zone Style ... - * - * @param value: ENUM_LINE_STYLE member ... - */ - void SupportZoneStyle(ENUM_LINE_STYLE value) - { - mSupportZoneStyle = value; - } - /** * Get Support Zone Price Type ... * @@ -1331,73 +941,6 @@ class XCPOI : public XSCBaseAlert mResistanceZoneLoopBack = value; } - /** - * Get Resistance Zone Width ... - * - * @return ( int ) - */ - int ResistanceZoneWidth() - { - return mResistanceZoneWidth; - } - - /** - * Set Resistance Zone Width ... - * - * @param value: Integer ... - */ - void ResistanceZoneWidth(int value) - { - // - if (value < 1) - { - value = 1; - } - - // - mResistanceZoneWidth = value; - } - - /** - * Get Resistance Zone Color ... - * - * @return ( color ) - */ - color ResistanceZoneColor() - { - return mResistanceZoneColor; - } - - /** - * Set Resistance Zone Color ... - * - * @param value: Color ... - */ - void ResistanceZoneColor(color value) - { - mResistanceZoneColor = value; - } - - /** - * Get Resistance Zone Style ... - * - * @return ( ENUM_LINE_STYLE ) - */ - ENUM_LINE_STYLE ResistanceZoneStyle() - { - return mResistanceZoneStyle; - } - - /** - * Set Resistance Zone Style ... - * - * @param value: ENUM_LINE_STYLE member ... - */ - void ResistanceZoneStyle(ENUM_LINE_STYLE value) - { - mResistanceZoneStyle = value; - } - /** * Get Resistance Zone Price Type ... * @@ -1461,73 +1004,6 @@ class XCPOI : public XSCBaseAlert mAllowDrawSupplyZones = value; } - /** - * Get Supply Zone Width ... - * - * @return ( int ) - */ - int SupplyZoneWidth() - { - return mSupplyZoneWidth; - } - - /** - * Set Supply Zone Width ... - * - * @param value: Integer ... - */ - void SupplyZoneWidth(int value) - { - // - if (value < 1) - { - value = 1; - } - - // - mSupplyZoneWidth = value; - } - - /** - * Get Supply Zone Color ... - * - * @return ( color ) - */ - color SupplyZoneColor() - { - return mSupplyZoneColor; - } - - /** - * Set Supply Zone Color ... - * - * @param value: Color ... - */ - void SupplyZoneColor(color value) - { - mSupplyZoneColor = value; - } - - /** - * Get Supply Zone Style ... - * - * @return ( ENUM_LINE_STYLE ) - */ - ENUM_LINE_STYLE SupplyZoneStyle() - { - return mSupplyZoneStyle; - } - - /** - * Set Supply Zone Style ... - * - * @param value: ENUM_LINE_STYLE member ... - */ - void SupplyZoneStyle(ENUM_LINE_STYLE value) - { - mSupplyZoneStyle = value; - } - /** * Get Supply Zone Detecting Period ... * @@ -1591,73 +1067,6 @@ class XCPOI : public XSCBaseAlert mAllowDrawDemandZones = value; } - /** - * Get Demand Zone Width ... - * - * @return ( int ) - */ - int DemandZoneWidth() - { - return mDemandZoneWidth; - } - - /** - * Set Demand Zone Width ... - * - * @param value: Integer ... - */ - void DemandZoneWidth(int value) - { - // - if (value < 1) - { - value = 1; - } - - // - mDemandZoneWidth = value; - } - - /** - * Get Demand Zone Color ... - * - * @return ( color ) - */ - color DemandZoneColor() - { - return mDemandZoneColor; - } - - /** - * Set Demand Zone Color ... - * - * @param value: Color ... - */ - void DemandZoneColor(color value) - { - mDemandZoneColor = value; - } - - /** - * Get Demand Zone Style ... - * - * @return ( ENUM_LINE_STYLE ) - */ - ENUM_LINE_STYLE DemandZoneStyle() - { - return mDemandZoneStyle; - } - - /** - * Set Demand Zone Style ... - * - * @param value: ENUM_LINE_STYLE member ... - */ - void DemandZoneStyle(ENUM_LINE_STYLE value) - { - mDemandZoneStyle = value; - } - /** * Get Demand Zone Detecting Period ... * @@ -1724,73 +1133,6 @@ class XCPOI : public XSCBaseAlert mAllowDrawBullishOrderBlocks = value; } - /** - * Get Bullish Order Block Width ... - * - * @return ( int ) - */ - int BullishOrderBlockWidth() - { - return mBullishOrderBlockWidth; - } - - /** - * Set Bullish Order Block Width ... - * - * @param value: Integer ... - */ - void BullishOrderBlockWidth(int value) - { - // - if (value < 1) - { - value = 1; - } - - // - mBullishOrderBlockWidth = value; - } - - /** - * Get Bullish Order Block Color ... - * - * @return ( color ) - */ - color BullishOrderBlockColor() - { - return mBullishOrderBlockColor; - } - - /** - * Set Bullish Order Block Color ... - * - * @param value: Color ... - */ - void BullishOrderBlockColor(color value) - { - mBullishOrderBlockColor = value; - } - - /** - * Get Bullish Order Block Style ... - * - * @return ( ENUM_LINE_STYLE ) - */ - ENUM_LINE_STYLE BullishOrderBlockStyle() - { - return mBullishOrderBlockStyle; - } - - /** - * Set Bullish Order Block Style ... - * - * @param value: ENUM_LINE_STYLE member ... - */ - void BullishOrderBlockStyle(ENUM_LINE_STYLE value) - { - mBullishOrderBlockStyle = value; - } - /** * Get Minimum Required Same Bars for Bullish Order Blocks ... * @@ -1861,73 +1203,6 @@ class XCPOI : public XSCBaseAlert mAllowDrawBearishOrderBlocks = value; } - /** - * Get Bearish Order Block Width ... - * - * @return ( int ) - */ - int BearishOrderBlockWidth() - { - return mBearishOrderBlockWidth; - } - - /** - * Set Bearish Order Block Width ... - * - * @param value: Integer ... - */ - void BearishOrderBlockWidth(int value) - { - // - if (value < 1) - { - value = 1; - } - - // - mBearishOrderBlockWidth = value; - } - - /** - * Get Bearish Order Block Color ... - * - * @return ( color ) - */ - color BearishOrderBlockColor() - { - return mBearishOrderBlockColor; - } - - /** - * Set Bearish Order Block Color ... - * - * @param value: Color ... - */ - void BearishOrderBlockColor(color value) - { - mBearishOrderBlockColor = value; - } - - /** - * Get Bearish Order Block Style ... - * - * @return ( ENUM_LINE_STYLE ) - */ - ENUM_LINE_STYLE BearishOrderBlockStyle() - { - return mBearishOrderBlockStyle; - } - - /** - * Set Bearish Order Block Style ... - * - * @param value: ENUM_LINE_STYLE member ... - */ - void BearishOrderBlockStyle(ENUM_LINE_STYLE value) - { - mBearishOrderBlockStyle = value; - } - /** * Get Minimum Required Same Bars for Bearish Order Blocks ... * @@ -2041,75 +1316,8 @@ class XCPOI : public XSCBaseAlert mBullishFVGForceCheckLastBarDirection = value; } - /** - * Get Bullish FVG Width ... - * - * @return ( int ) - */ - int BullishFVGWidth() - { - return mBullishFVGWidth; - } - - /** - * Set Bullish FVG Width ... - * - * @param value: Integer ... - */ - void BullishFVGWidth(int value) - { - // - if (value < 1) - { - value = 1; - } - - // - mBullishFVGWidth = value; - } - - /** - * Get Bullish FVG Color ... - * - * @return ( color ) - */ - color BullishFVGColor() - { - return mBullishFVGColor; - } - - /** - * Set Bullish FVG Color ... - * - * @param value: Color ... - */ - void BullishFVGColor(color value) - { - mBullishFVGColor = value; - } - - /** - * Get Bullish FVG Style ... - * - * @return ( ENUM_LINE_STYLE ) - */ - ENUM_LINE_STYLE BullishFVGStyle() - { - return mBullishFVGStyle; - } - - /** - * Set Bullish FVG Style ... - * - * @param value: ENUM_LINE_STYLE member ... - */ - void BullishFVGStyle(ENUM_LINE_STYLE value) - { - mBullishFVGStyle = value; - } - // - // Bullis FVGs ... + // Bearish FVGs ... /** * Get Detect Bearish Fair Value Gaps State ... @@ -2191,73 +1399,6 @@ class XCPOI : public XSCBaseAlert mBearishFVGForceCheckLastBarDirection = value; } - /** - * Get Bearish FVG Width ... - * - * @return ( int ) - */ - int BearishFVGWidth() - { - return mBearishFVGWidth; - } - - /** - * Set Bearish FVG Width ... - * - * @param value: Integer ... - */ - void BearishFVGWidth(int value) - { - // - if (value < 1) - { - value = 1; - } - - // - mBearishFVGWidth = value; - } - - /** - * Get Bearish FVG Color ... - * - * @return ( color ) - */ - color BearishFVGColor() - { - return mBearishFVGColor; - } - - /** - * Set Bearish FVG Color ... - * - * @param value: Color ... - */ - void BearishFVGColor(color value) - { - mBearishFVGColor = value; - } - - /** - * Get Bearish FVG Style ... - * - * @return ( ENUM_LINE_STYLE ) - */ - ENUM_LINE_STYLE BearishFVGStyle() - { - return mBearishFVGStyle; - } - - /** - * Set Bearish FVG Style ... - * - * @param value: ENUM_LINE_STYLE member ... - */ - void BearishFVGStyle(ENUM_LINE_STYLE value) - { - mBearishFVGStyle = value; - } - // // Actions ... @@ -3364,7 +2505,8 @@ class XCPOI : public XSCBaseAlert * @param state: XPOIState instance ... */ void GetState( - XPOIState &state) + XPOIState &state // + ) { // state.Clean(); @@ -3415,8 +2557,10 @@ class XCPOI : public XSCBaseAlert // Common ... // - ChartID(0); - Window(0); + ChartIdentification(0); + SubWindowIdentification(0); + mDrawer.ChartIdentification(0); + mDrawer.SubWindowIdentification(0); // MaxNumberOfPOIs(10); @@ -3504,39 +2648,41 @@ class XCPOI : public XSCBaseAlert // // Swing Highs ... - SwingHighWidth(5); SwingHighThreshold(3); - SwingHighArrowCode(108); - SwingHighColor(clrMagenta); + mDrawer.SwingHighWidth(5); + mDrawer.SwingHighArrow(108); + mDrawer.SwingHighColor(clrMagenta); // // Swing Lows ... - SwingLowWidth(5); SwingLowThreshold(3); - SwingLowArrowCode(108); - SwingLowColor(clrAqua); + mDrawer.SwingLowWidth(5); + mDrawer.SwingLowArrow(108); + mDrawer.SwingLowColor(clrAqua); // // Momentum Bars ... MomentumBarPercent(55); MomentumBarLoopBack(3); MomentumBarSharpRatio(1.2); - MomentumBarWidth(5); - MomentumBarBullishArrowCode((char)225); - MomentumBarBearishArrowCode((char)226); - MomentumBarBullishColor(clrAqua); - MomentumBarBearishColor(clrMagenta); + mDrawer.BullishMomentumBarWidth(5); + mDrawer.BearishMomentumBarWidth(5); + mDrawer.BullishMomentumBarArrow(225); + mDrawer.BearishMomentumBarArrow(226); + mDrawer.BullishMomentumBarColor(clrAqua); + mDrawer.BearishMomentumBarColor(clrMagenta); // // Rejection Bars ... RejectionBarPercent(55); RejectionBarLoopBack(5); RejectionBarSharpRatio(1.5); - RejectionBarWidth(5); - RejectionBarBullishArrowCode((char)217); - RejectionBarBearishArrowCode((char)218); - RejectionBarBullishColor(clrAqua); - RejectionBarBearishColor(clrMagenta); + mDrawer.BullishRejectionBarWidth(5); + mDrawer.BearishRejectionBarWidth(5); + mDrawer.BullishRejectionBarArrow(217); + mDrawer.BearishRejectionBarArrow(218); + mDrawer.BullishRejectionBarColor(clrAqua); + mDrawer.BearishRejectionBarColor(clrMagenta); // // Support and Resistance Zones ... @@ -3544,71 +2690,71 @@ class XCPOI : public XSCBaseAlert // // Support Zones ... SupportZoneLoopBack(52); - SupportZoneWidth(1); - SupportZoneColor(clrLime); - SupportZoneStyle(STYLE_DOT); SupportZonePriceType(X_PRICE_CLOSE); + mDrawer.SupportZoneWidth(1); + mDrawer.SupportZoneColor(clrLime); + mDrawer.SupportZoneStyle(STYLE_DOT); // // Resistance Zones ... ResistanceZoneLoopBack(52); - ResistanceZoneWidth(1); - ResistanceZoneColor(clrRed); - ResistanceZoneStyle(STYLE_DOT); ResistanceZonePriceType(X_PRICE_CLOSE); + mDrawer.ResistanceZoneWidth(1); + mDrawer.ResistanceZoneColor(clrRed); + mDrawer.ResistanceZoneStyle(STYLE_DOT); // // Supply and Deman Zones ... // // Supply Zones ... - SupplyZoneWidth(1); - SupplyZoneColor(clrDarkRed); - SupplyZoneStyle(STYLE_DASH); SupplyZonePeriod(GetHindMostPeriod(mPeriod)); + mDrawer.SupplyZoneWidth(1); + mDrawer.SupplyZoneColor(clrDarkRed); + mDrawer.SupplyZoneStyle(STYLE_DASH); // // Demand Zones ... - DemandZoneWidth(1); - DemandZoneColor(clrDarkGreen); - DemandZoneStyle(STYLE_DASH); DemandZonePeriod(GetHindMostPeriod(mPeriod)); + mDrawer.DemandZoneWidth(1); + mDrawer.DemandZoneColor(clrDarkGreen); + mDrawer.DemandZoneStyle(STYLE_DASH); // // Order Blocks ... // // Bullish Order Block ... - BullishOrderBlockWidth(1); - BullishOrderBlockColor(clrAqua); - BullishOrderBlockStyle(STYLE_DASHDOT); RequiredBarsForBullishOrderBlock(3); + mDrawer.BullishOrderBlockWidth(1); + mDrawer.BullishOrderBlockColor(clrAqua); + mDrawer.BullishOrderBlockStyle(STYLE_DASHDOT); // // Bearish Order Block ... - BearishOrderBlockWidth(1); - BearishOrderBlockColor(clrMagenta); - BearishOrderBlockStyle(STYLE_DASHDOT); RequiredBarsForBearishOrderBlock(3); + mDrawer.BearishOrderBlockWidth(1); + mDrawer.BearishOrderBlockColor(clrMagenta); + mDrawer.BearishOrderBlockStyle(STYLE_DASHDOT); // // Fair Value Gaps ... // // Bullish FVGs ... - BullishFVGWidth(1); - BullishFVGColor(clrAqua); - BullishFVGStyle(STYLE_DASHDOTDOT); BullishFVGForceMiddleBarCheck(true); BullishFVGForceCheckLastBarDirection(true); + mDrawer.BullishFVGWidth(1); + mDrawer.BullishFVGColor(clrAqua); + mDrawer.BullishFVGStyle(STYLE_DASHDOTDOT); // // Bearish FVGs ... - BearishFVGWidth(1); - BearishFVGColor(clrMagenta); - BearishFVGStyle(STYLE_DASHDOTDOT); BearishFVGForceMiddleBarCheck(true); BearishFVGForceCheckLastBarDirection(true); + mDrawer.BearishFVGWidth(1); + mDrawer.BearishFVGColor(clrMagenta); + mDrawer.BearishFVGStyle(STYLE_DASHDOTDOT); // } @@ -5453,7 +4599,17 @@ class XCPOI : public XSCBaseAlert } // - CreateSwingHighObject(iSwing, iName); + bool allow = AllowDrawSwingHighs(); + if (allow) + { + // + XCSwingHighObject *iObj; + bool isCreated = mDrawer.CreateSwingHigh(iSwing, iObj); + if (isCreated) + { + mSwingHighObjects.Add(iObj); + } + } } } @@ -5537,7 +4693,17 @@ class XCPOI : public XSCBaseAlert } // - CreateSwingLowObject(iSwing, iName); + bool allow = AllowDrawSwingLows(); + if (allow) + { + // + XCSwingLowObject *iObj; + bool isCreated = mDrawer.CreateSwingLow(iSwing, iObj); + if (isCreated) + { + mSwingLowObjects.Add(iObj); + } + } } } @@ -5621,7 +4787,32 @@ class XCPOI : public XSCBaseAlert } // - CreateMomentumBarObject(iBar, iName); + bool allow = AllowDrawMomentumBars(); + if (allow) + { + // + bool isBullish = iBar.IsBullish(); + if (isBullish) + { + // + XCBullishMomentumBarObject *iObj; + bool isCreated = mDrawer.CreateBullishMomentumBar(iBar, iObj); + if (isCreated) + { + mMomentumBarObjects.Add(iObj); + } + } + else + { + // + XCBearishMomentumBarObject *iObj; + bool isCreated = mDrawer.CreateBearishMomentumBar(iBar, iObj); + if (isCreated) + { + mMomentumBarObjects.Add(iObj); + } + } + } } } @@ -5705,7 +4896,32 @@ class XCPOI : public XSCBaseAlert } // - CreateRejectionBarObject(iBar, iName); + bool allow = AllowDrawRejectionBars(); + if (allow) + { + // + bool isBullish = iBar.GetLowShadow() > iBar.GetHighShadow(); + if (isBullish) + { + // + XCBullishRejectionBarObject *iObj; + bool isCreated = mDrawer.CreateBullishRejectionBar(iBar, iObj); + if (isCreated) + { + mRejectionBarObjects.Add(iObj); + } + } + else + { + // + XCBearishRejectionBarObject *iObj; + bool isCreated = mDrawer.CreateBearishRejectionBar(iBar, iObj); + if (isCreated) + { + mRejectionBarObjects.Add(iObj); + } + } + } } } @@ -5789,7 +5005,7 @@ class XCPOI : public XSCBaseAlert } // - CreateMarketSessionObject(iMarketSession, iName); + // CreateMarketSessionObject(iMarketSession, iName); } } @@ -5873,7 +5089,17 @@ class XCPOI : public XSCBaseAlert } // - CreateSupportZoneObject(iSupportZone, iName); + bool allow = AllowDrawSupportZones(); + if (allow) + { + // + XCSupportZoneObject *iObj; + bool isCreated = mDrawer.CreateSupportZone(iSupportZone, iObj); + if (isCreated) + { + mSupportZoneObjects.Add(iObj); + } + } } } @@ -5957,7 +5183,17 @@ class XCPOI : public XSCBaseAlert } // - CreateResistanceZoneObject(iResistanceZone, iName); + bool allow = AllowDrawResistanceZones(); + if (allow) + { + // + XCResistanceZoneObject *iObj; + bool isCreated = mDrawer.CreateResistanceZone(iResistanceZone, iObj); + if (isCreated) + { + mResistanceZoneObjects.Add(iObj); + } + } } } @@ -6041,7 +5277,17 @@ class XCPOI : public XSCBaseAlert } // - CreateSupplyZoneObject(iSupplyZone, iName); + bool allow = AllowDrawSupplyZones(); + if (allow) + { + // + XCSupplyZoneObject *iObj; + bool isCreated = mDrawer.CreateSupplyZone(iSupplyZone, iObj); + if (isCreated) + { + mSupplyZoneObjects.Add(iObj); + } + } } } @@ -6125,7 +5371,17 @@ class XCPOI : public XSCBaseAlert } // - CreateDemandZoneObject(iDemandZone, iName); + bool allow = AllowDrawDemandZones(); + if (allow) + { + // + XCDemandZoneObject *iObj; + bool isCreated = mDrawer.CreateDemandZone(iDemandZone, iObj); + if (isCreated) + { + mDemandZoneObjects.Add(iObj); + } + } } } @@ -6209,7 +5465,17 @@ class XCPOI : public XSCBaseAlert } // - CreateBullishOrderBlockObject(iBullishOB, iName); + bool allow = AllowDrawBullishOrderBlocks(); + if (allow) + { + // + XCBullishOrderBlockObject *iObj; + bool isCreated = mDrawer.CreateBullishOrderBlock(iBullishOB, iObj); + if (isCreated) + { + mBullishOrderBlockObjects.Add(iObj); + } + } } } @@ -6293,7 +5559,17 @@ class XCPOI : public XSCBaseAlert } // - CreateBearishOrderBlockObject(iBearishOB, iName); + bool allow = AllowDrawBearishOrderBlocks(); + if (allow) + { + // + XCBearishOrderBlockObject *iObj; + bool isCreated = mDrawer.CreateBearishOrderBlock(iBearishOB, iObj); + if (isCreated) + { + mBearishOrderBlockObjects.Add(iObj); + } + } } } @@ -6377,7 +5653,17 @@ class XCPOI : public XSCBaseAlert } // - CreateBullishFVGObject(iFVG, iName); + bool allow = AllowDrawBullishFVGs(); + if (allow) + { + // + XCBullishFVGObject *iObj; + bool isCreated = mDrawer.CreateBullishFVG(iFVG, iObj); + if (isCreated) + { + mBullishFVGObjects.Add(iObj); + } + } } } @@ -6461,7 +5747,17 @@ class XCPOI : public XSCBaseAlert } // - CreateBearishFVGObject(iFVG, iName); + bool allow = AllowDrawBearishFVGs(); + if (allow) + { + // + XCBearishFVGObject *iObj; + bool isCreated = mDrawer.CreateBearishFVG(iFVG, iObj); + if (isCreated) + { + mBearishFVGObjects.Add(iObj); + } + } } } @@ -8184,14 +7480,17 @@ class XCPOI : public XSCBaseAlert bool mLock; // Lock State ... string mSymbol; // Market Symbol ... ENUM_TIMEFRAMES mPeriod; // Market Period ... - long mChartID; // Chart ID ... - int mWindow; // Window ID ... + long mChartIdentification; // Chart ID ... + int mSubWindowIdentification; // SubWindowIdentification ID ... int mMaxNumberOfPOIs; // Max Allowed Number of POI(s) which Can Holds ... int mMaxNumberOfRequiredPOIs; // Max Allowed Number of POI(s) which Must Find at Initializion Time ... // XBarTracker mBarTracker; // Market Bar Tracker ... + // + XCPOIDrawer *mDrawer; // POI Drawer ... + // // POI Props ... @@ -8231,9 +7530,9 @@ class XCPOI : public XSCBaseAlert XCTardeDayObject *iObj; iObj = new XCTardeDayObject(); bool isCreated = iObj.CreateByDay( - ChartID(), + ChartIdentification(), name, - Window(), + SubWindowIdentification(), day // ); if (!isCreated) @@ -8296,9 +7595,9 @@ class XCPOI : public XSCBaseAlert XCMarketSessionObject *iObj; iObj = new XCMarketSessionObject(); bool isCreated = iObj.CreateByMarketSession( - ChartID(), + ChartIdentification(), name, - Window(), + SubWindowIdentification(), session // ); if (!isCreated) @@ -8327,116 +7626,22 @@ class XCPOI : public XSCBaseAlert // bool mAllowSwingHighs; // Detect Swing Highs ... bool mAllowDrawSwingHighs; // Draw Swing Highs ... - char mSwingHighArrowCode; // Swing High Arrow Code ... - color mSwingHighColor; // Swing High Color ... - int mSwingHighWidth; // Swing High Width ... double mSwingHighThreshold; // Threshold Required for Swing High Detection ... XOHCL mSwingHighs[]; // Swing Highs ... CArrayObj mSwingHighObjects; // Swing High Chart Objects ... TXOHCLEventHandler mSwingHighEventListeners[]; // Swing High Event Listeners ... - /** - * Create an Object to Represent Swing High on Chart ... - * - * @param bar: XOHCL instance ... - * @param name: String ... - */ - void CreateSwingHighObject( - XOHCL &bar, - string name // - ) - { - // - if (!bar.IsValid() || - !IsValid(name)) - { - return; - } - - // - CChartObjectArrow *iObj; - iObj = new CChartObjectArrow(); - bool isCreated = iObj.Create( - ChartID(), - name, - Window(), - bar.time, - bar.high, - SwingHighArrowCode() // - ); - if (!isCreated) - { - return; - } - - // - // Configure Object ... - iObj.Width(SwingHighWidth()); - iObj.Color(SwingHighColor()); - iObj.Anchor(ANCHOR_BOTTOM); - - // - mSwingHighObjects.Add(iObj); - } - // // Swing Lows ... // bool mAllowSwingLows; // Detect Swing Lows ... bool mAllowDrawSwingLows; // Draw Swing Lows ... - char mSwingLowArrowCode; // Swing Low Arrow Code ... - color mSwingLowColor; // Swing Low Color ... - int mSwingLowWidth; // Swing Low Width ... double mSwingLowThreshold; // Threshold Required for Swing Low Detection ... XOHCL mSwingLows[]; // Swing Lows ... CArrayObj mSwingLowObjects; // Swing Low Chart Objects ... TXOHCLEventHandler mSwingLowEventListeners[]; // Swing Low Event Listeners ... - /** - * Create an Object to Represent Swing Low on Chart ... - * - * @param bar: XOHCL instance ... - * @param name: String ... - */ - void CreateSwingLowObject( - XOHCL &bar, - string name // - ) - { - // - if (!bar.IsValid() || - !IsValid(name)) - { - return; - } - - // - CChartObjectArrow *iObj; - iObj = new CChartObjectArrow(); - bool isCreated = iObj.Create( - ChartID(), - name, - Window(), - bar.time, - bar.low, - SwingLowArrowCode() // - ); - if (!isCreated) - { - return; - } - - // - // Configure Object ... - iObj.Width(SwingLowWidth()); - iObj.Color(SwingLowColor()); - iObj.Anchor(ANCHOR_TOP); - - // - mSwingLowObjects.Add(iObj); - } - // // Momentum Bars ... @@ -8446,78 +7651,10 @@ class XCPOI : public XSCBaseAlert int mMomentumBarPercent; // Momentum Bar Percent ... double mMomentumBarSharpRatio; // Momentum Bar Sharp Ratio ... int mMomentumBarLoopBack; // Momentum Bar Loopback ... - int mMomentumBarWidth; // Momentum Bar Width ... - char mMomentumBarBullishArrowCode; // Bullish Momentum Bar Arrow Code ... - char mMomentumBarBearishArrowCode; // Bullish Momentum Bar Color ... - color mMomentumBarBullishColor; // Bearish Momentum Bar Arrow Code ... - color mMomentumBarBearishColor; // Bearish Momentum Bar Color ... XOHCL mMomentumBars[]; // Momentum Bars ... CArrayObj mMomentumBarObjects; // Momentm Bar Chart Objects ... TXOHCLEventHandler mMomentumBarEventListeners[]; // Momentum Bars Event Listeners ... - /** - * Create an Object to Represent Momentum Bar on Chart ... - * - * @param bar: XOHCL instance ... - * @param name: String ... - */ - void CreateMomentumBarObject( - XOHCL &bar, - string name // - ) - { - // - if (!bar.IsValid() || - !IsValid(name)) - { - return; - } - - // - bool isBullish = bar.IsBullish(); - double price = - isBullish - ? bar.low - : bar.high; - char arrowCode = - isBullish - ? MomentumBarBullishArrowCode() - : MomentumBarBearishArrowCode(); - color clr = - isBullish - ? MomentumBarBullishColor() - : MomentumBarBearishColor(); - ENUM_ARROW_ANCHOR anchor = - isBullish - ? ANCHOR_TOP - : ANCHOR_BOTTOM; - - // - CChartObjectArrow *iObj; - iObj = new CChartObjectArrow(); - bool isCreated = iObj.Create( - ChartID(), - name, - Window(), - bar.time, - price, - arrowCode // - ); - if (!isCreated) - { - return; - } - - // - // Configure Object ... - iObj.Width(MomentumBarWidth()); - iObj.Color(clr); - iObj.Anchor(anchor); - - // - mMomentumBarObjects.Add(iObj); - } - // // Rejection Bars .... @@ -8527,78 +7664,10 @@ class XCPOI : public XSCBaseAlert int mRejectionBarPercent; // Rejection Bar Percent ... double mRejectionBarSharpRatio; // Rejection Bar Sharp Ratio ... int mRejectionBarLoopBack; // Rejection Bar Loopback ... - int mRejectionBarWidth; // Rejection Bar Width ... - char mRejectionBarBullishArrowCode; // Bullish Rejection Bar Arrow Code ... - char mRejectionBarBearishArrowCode; // Bullish Rejection Bar Color ... - color mRejectionBarBullishColor; // Bearish Rejection Bar Arrow Code ... - color mRejectionBarBearishColor; // Bearish Rejection Bar Color ... XOHCL mRejectionBars[]; // Rejection Bars ... CArrayObj mRejectionBarObjects; // Rejection Bar Chart Objects ... TXOHCLEventHandler mRejectionBarEventListeners[]; // Rejection Bars Event Listeners ... - /** - * Create an Object to Represent Rejection Bar on Chart ... - * - * @param bar: XOHCL instance ... - * @param name: String ... - */ - void CreateRejectionBarObject( - XOHCL &bar, - string name // - ) - { - // - if (!bar.IsValid() || - !IsValid(name)) - { - return; - } - - // - bool isBullish = bar.GetLowShadow() > bar.GetHighShadow(); - double price = - isBullish - ? bar.low - : bar.high; - char arrowCode = - isBullish - ? RejectionBarBullishArrowCode() - : RejectionBarBearishArrowCode(); - color clr = - isBullish - ? RejectionBarBullishColor() - : RejectionBarBearishColor(); - ENUM_ARROW_ANCHOR anchor = - isBullish - ? ANCHOR_TOP - : ANCHOR_BOTTOM; - - // - CChartObjectArrow *iObj; - iObj = new CChartObjectArrow(); - bool isCreated = iObj.Create( - ChartID(), - name, - Window(), - bar.time, - price, - arrowCode // - ); - if (!isCreated) - { - return; - } - - // - // Configure Object ... - iObj.Width(RejectionBarWidth()); - iObj.Color(clr); - iObj.Anchor(anchor); - - // - mRejectionBarObjects.Add(iObj); - } - // // Support and Resistance Zones ... @@ -8609,70 +7678,11 @@ class XCPOI : public XSCBaseAlert bool mAllowSupportZones; // Detect Support Zone ... bool mAllowDrawSupportZones; // Draw Support Zone ... int mSupportZoneLoopBack; // Support Zone Loopback ... - int mSupportZoneWidth; // Support Zone Width ... - color mSupportZoneColor; // Support Zone Color ... - ENUM_LINE_STYLE mSupportZoneStyle; // Support Zone Style ... ENUM_X_PRICE mSupportZonePriceType; // Support Zone Price Type ... XOHCL mSupportZones[]; // Support Zones ... CArrayObj mSupportZoneObjects; // Support Zone Chart Objects ... TXOHCLEventHandler mSupportZoneEventListeners[]; // Support Zone Event Listeners ... - /** - * Create an Object to Represent Support Zones on Chart ... - - * @param bar: XOHCL instance ... - * @param name: String ... - */ - void CreateSupportZoneObject( - XOHCL &bar, - string name // - ) - { - // - if (!bar.IsValid() || - !IsValid(name)) - { - return; - } - - // - datetime cBarTime = TimeCurrent(); - if (bar.Index() > 0) - { - // - cBarTime = iTime( - mSymbol, - mPeriod, - bar.Index() - 10 // - ); - } - - // - XCSupportZoneObject *iObj; - iObj = new XCSupportZoneObject(); - bool isCreated = iObj.CreateBySupport( - ChartID(), - name, - Window(), - bar, - cBarTime, - true // Force Draw Rect ... - ); - if (!isCreated) - { - return; - } - - // - // Configure Object ... - iObj.ZoneColor(SupportZoneColor()); - iObj.ZoneStyle(SupportZoneStyle()); - iObj.ZoneWidth(SupportZoneWidth()); - - // - mSupportZoneObjects.Add(iObj); - } - // // Resistance Zones ... @@ -8680,70 +7690,11 @@ class XCPOI : public XSCBaseAlert bool mAllowResistanceZones; // Detect Resistance Zone ... bool mAllowDrawResistanceZones; // Draw Resistance Zone ... int mResistanceZoneLoopBack; // Resistance Zone Loopback ... - int mResistanceZoneWidth; // Resistance Zone Width ... - color mResistanceZoneColor; // Resistance Zone Color ... - ENUM_LINE_STYLE mResistanceZoneStyle; // Resistance Zone Style ... ENUM_X_PRICE mResistanceZonePriceType; // Resistance Zone Price Type ... XOHCL mResistanceZones[]; // Resistance Zones ... CArrayObj mResistanceZoneObjects; // Resistance Zone Chart Objects ... TXOHCLEventHandler mResistanceZoneEventListeners[]; // Resistance Zone Event Listeners ... - /** - * Create an Object to Represent Resistance Zones on Chart ... - - * @param bar: XOHCL instance ... - * @param name: String ... - */ - void CreateResistanceZoneObject( - XOHCL &bar, - string name // - ) - { - // - if (!bar.IsValid() || - !IsValid(name)) - { - return; - } - - // - datetime cBarTime = TimeCurrent(); - if (bar.Index() > 0) - { - // - cBarTime = iTime( - mSymbol, - mPeriod, - bar.Index() - 10 // - ); - } - - // - XCResistanceZoneObject *iObj; - iObj = new XCResistanceZoneObject(); - bool isCreated = iObj.CreateByResistance( - ChartID(), - name, - Window(), - bar, - cBarTime, - true // Force Draw Rect ... - ); - if (!isCreated) - { - return; - } - - // - // Configure Object ... - iObj.ZoneColor(ResistanceZoneColor()); - iObj.ZoneStyle(ResistanceZoneStyle()); - iObj.ZoneWidth(ResistanceZoneWidth()); - - // - mResistanceZoneObjects.Add(iObj); - } - // // Supply and Demand Zones ... @@ -8753,116 +7704,22 @@ class XCPOI : public XSCBaseAlert // bool mAllowSupplyZones; // Detect Supply Zone ... bool mAllowDrawSupplyZones; // Draw Supply Zone ... - int mSupplyZoneWidth; // Supply Zone Width ... - color mSupplyZoneColor; // Supply Zone Color ... - ENUM_LINE_STYLE mSupplyZoneStyle; // Supply Zone Style ... ENUM_TIMEFRAMES mSupplyZonePeriod; // Supply Zone Detection Period ... XZone mSupplyZones[]; // Supply Zones ... CArrayObj mSupplyZoneObjects; // Supply Zone Chart Objects ... TXZoneEventHandler mSupplyZoneEventListeners[]; // Supply Zone Event Listeners ... - /** - * Create an Object to Represent Supply Zones on Chart ... - - * @param bar: XZone instance ... - * @param name: String ... - */ - void CreateSupplyZoneObject( - XZone &zone, - string name // - ) - { - // - if (!zone.IsValid() || - !IsValid(name)) - { - return; - } - - // - XCSupplyZoneObject *iObj; - iObj = new XCSupplyZoneObject(); - bool isCreated = iObj.CreateByZone( - ChartID(), - name, - Window(), - zone, - NULL, // Object Prefix ... - true // Force Draw Rect ... - ); - if (!isCreated) - { - return; - } - - // - // Configure Object ... - iObj.ZoneColor(SupplyZoneColor()); - iObj.ZoneStyle(SupplyZoneStyle()); - iObj.ZoneWidth(SupplyZoneWidth()); - - // - mSupplyZoneObjects.Add(iObj); - } - // // Demand Zones ... // bool mAllowDemandZones; // Detect Demand Zone ... bool mAllowDrawDemandZones; // Draw Demand Zone ... - int mDemandZoneWidth; // Demand Zone Width ... - color mDemandZoneColor; // Demand Zone Color ... - ENUM_LINE_STYLE mDemandZoneStyle; // Demand Zone Style ... ENUM_TIMEFRAMES mDemandZonePeriod; // Demand Zone Detection Period ... XZone mDemandZones[]; // Demand Zones ... CArrayObj mDemandZoneObjects; // Demand Zone Chart Objects ... TXZoneEventHandler mDemandZoneEventListeners[]; // Demand Zone Event Listeners ... - /** - * Create an Object to Represent Demand Zones on Chart ... - - * @param bar: XZone instance ... - * @param name: String ... - */ - void CreateDemandZoneObject( - XZone &zone, - string name // - ) - { - // - if (!zone.IsValid() || - !IsValid(name)) - { - return; - } - - // - XCDemandZoneObject *iObj; - iObj = new XCDemandZoneObject(); - bool isCreated = iObj.CreateByZone( - ChartID(), - name, - Window(), - zone, - NULL, // Object Prefix ... - true // Force Draw Rect ... - ); - if (!isCreated) - { - return; - } - - // - // Configure Object ... - iObj.ZoneColor(DemandZoneColor()); - iObj.ZoneStyle(DemandZoneStyle()); - iObj.ZoneWidth(DemandZoneWidth()); - - // - mDemandZoneObjects.Add(iObj); - } - // // Order Blocks ... @@ -8872,116 +7729,22 @@ class XCPOI : public XSCBaseAlert // bool mAllowBullishOrderBlocks; // Detect Bullish Order Blocks ... bool mAllowDrawBullishOrderBlocks; // Draw Bullish Order Blocks ... - int mBullishOrderBlockWidth; // Bullish Order Block Width ... - color mBullishOrderBlockColor; // Bullish Order Block Color ... - ENUM_LINE_STYLE mBullishOrderBlockStyle; // Bullish Order Block Style ... int mRequiredBarsForBullishOrderBlock; // Minimum Required Same Bars for Bullish Order Blocks ... XZone mBullishOrderBlocks[]; // Bullish Order Blocks ... CArrayObj mBullishOrderBlockObjects; // Bullish Order Block Objects ... TXZoneEventHandler mBullishOrderBlockEventListeners[]; // Bullish Order Block Event Listeners ... - /** - * Create an Object to Represent Bullish Order Block on Chart ... - - * @param bar: XZone instance ... - * @param name: String ... - */ - void CreateBullishOrderBlockObject( - XZone &zone, - string name // - ) - { - // - if (!zone.IsValid() || - !IsValid(name)) - { - return; - } - - // - XCBullishOrderBlockObject *iObj; - iObj = new XCBullishOrderBlockObject(); - bool isCreated = iObj.CreateByZone( - ChartID(), - name, - Window(), - zone, - NULL, // Object Prefix ... - true // Force Draw Rect ... - ); - if (!isCreated) - { - return; - } - - // - // Configure Object ... - iObj.ZoneColor(BullishOrderBlockColor()); - iObj.ZoneStyle(BullishOrderBlockStyle()); - iObj.ZoneWidth(BullishOrderBlockWidth()); - - // - mBullishOrderBlockObjects.Add(iObj); - } - // // Bearish Order Blocks ... // bool mAllowBearishOrderBlocks; // Detect Bearish Order Blocks ... bool mAllowDrawBearishOrderBlocks; // Draw Bearish Order Blocks ... - int mBearishOrderBlockWidth; // Bearish Order Block Width ... - color mBearishOrderBlockColor; // Bearish Order Block Color ... - ENUM_LINE_STYLE mBearishOrderBlockStyle; // Bearish Order Block Style ... int mRequiredBarsForBearishOrderBlock; // Minimum Required Same Bars for Bearish Order Blocks ... XZone mBearishOrderBlocks[]; // Bearish Order Blocks ... CArrayObj mBearishOrderBlockObjects; // Bearish Order Block Objects ... TXZoneEventHandler mBearishOrderBlockEventListeners[]; // Bearish Order Block Event Listeners ... - /** - * Create an Object to Represent Bearish Order Block on Chart ... - - * @param bar: XZone instance ... - * @param name: String ... - */ - void CreateBearishOrderBlockObject( - XZone &zone, - string name // - ) - { - // - if (!zone.IsValid() || - !IsValid(name)) - { - return; - } - - // - XCBearishOrderBlockObject *iObj; - iObj = new XCBearishOrderBlockObject(); - bool isCreated = iObj.CreateByZone( - ChartID(), - name, - Window(), - zone, - NULL, // Object Prefix ... - true // Force Draw Rect ... - ); - if (!isCreated) - { - return; - } - - // - // Configure Object ... - iObj.ZoneColor(BearishOrderBlockColor()); - iObj.ZoneStyle(BearishOrderBlockStyle()); - iObj.ZoneWidth(BearishOrderBlockWidth()); - - // - mBearishOrderBlockObjects.Add(iObj); - } - // // Fair Value Gaps ... @@ -8993,57 +7756,10 @@ class XCPOI : public XSCBaseAlert bool mAllowDrawBullishFVGs; // Draw Bullish Fair Value Gaps ... bool mBullishFVGForceMiddleBarCheck; // Bullish FVG Force Middle Bar Check ... bool mBullishFVGForceCheckLastBarDirection; // Bullish FVG Check Last Bar Direction ... - int mBullishFVGWidth; // Bullish FVG Width ... - color mBullishFVGColor; // Bullish FVG Color ... - ENUM_LINE_STYLE mBullishFVGStyle; // Bullish FVG Style ... XZone mBullishFVGs[]; // Bullish FVGs ... CArrayObj mBullishFVGObjects; // Bullish FVG Objects ... TXZoneEventHandler mBullishFVGEventListeners[]; // Bullish FVG Event Listeners ... - /** - * Create an Object to Represent Bullish FVG on Chart ... - - * @param bar: XZone instance ... - * @param name: String ... - */ - void CreateBullishFVGObject( - XZone &zone, - string name // - ) - { - // - if (!zone.IsValid() || - !IsValid(name)) - { - return; - } - - // - XCBullishFVGObject *iObj; - iObj = new XCBullishFVGObject(); - bool isCreated = iObj.CreateByZone( - ChartID(), - name, - Window(), - zone, - NULL, // Object Prefix ... - true // Force Draw Rect ... - ); - if (!isCreated) - { - return; - } - - // - // Configure Object ... - iObj.ZoneColor(BullishFVGColor()); - iObj.ZoneStyle(BullishFVGStyle()); - iObj.ZoneWidth(BullishFVGWidth()); - - // - mBullishFVGObjects.Add(iObj); - } - // // Bearish Fair Value Gaps ... @@ -9052,57 +7768,10 @@ class XCPOI : public XSCBaseAlert bool mAllowDrawBearishFVGs; // Draw Bearish Fair Value Gaps ... bool mBearishFVGForceMiddleBarCheck; // Bearish FVG Force Middle Bar Check ... bool mBearishFVGForceCheckLastBarDirection; // Bearish FVG Check Last Bar Direction ... - int mBearishFVGWidth; // Bearish FVG Width ... - color mBearishFVGColor; // Bearish FVG Color ... - ENUM_LINE_STYLE mBearishFVGStyle; // Bearish FVG Style ... XZone mBearishFVGs[]; // Bearish FVGs ... CArrayObj mBearishFVGObjects; // Bearish FVG Objects ... TXZoneEventHandler mBearishFVGEventListeners[]; // Bearish FVG Event Listeners ... - /** - * Create an Object to Represent Bearish FVG on Chart ... - - * @param bar: XZone instance ... - * @param name: String ... - */ - void CreateBearishFVGObject( - XZone &zone, - string name // - ) - { - // - if (!zone.IsValid() || - !IsValid(name)) - { - return; - } - - // - XCBearishFVGObject *iObj; - iObj = new XCBearishFVGObject(); - bool isCreated = iObj.CreateByZone( - ChartID(), - name, - Window(), - zone, - NULL, // Object Prefix ... - true // Force Draw Rect ... - ); - if (!isCreated) - { - return; - } - - // - // Configure Object ... - iObj.ZoneColor(BearishFVGColor()); - iObj.ZoneStyle(BearishFVGStyle()); - iObj.ZoneWidth(BearishFVGWidth()); - - // - mBearishFVGObjects.Add(iObj); - } - // }; diff --git a/Classes/x-saherelm.x-poi.drawer.class.mq5 b/Classes/x-saherelm.x-poi.drawer.class.mq5 index 32d5d19d..c4a31318 100644 --- a/Classes/x-saherelm.x-poi.drawer.class.mq5 +++ b/Classes/x-saherelm.x-poi.drawer.class.mq5 @@ -26,7 +26,7 @@ // // Definitions ... -class XPOIDrawer : public XSCBase +class XCPOIDrawer : public XSCBase { // public: @@ -34,7 +34,7 @@ class XPOIDrawer : public XSCBase // // Constructor ... - void XPOIDrawer() + void XCPOIDrawer() { // Default(); @@ -42,7 +42,7 @@ class XPOIDrawer : public XSCBase // // Deconstructor ... - void ~XPOIDrawer() + void ~XCPOIDrawer() { } @@ -1273,11 +1273,970 @@ class XPOIDrawer : public XSCBase // Object Creators ... // + // Swings ... + + /** + * Create Swing High Object ... + * + * @param swing: XOHCL instance ... + * + * @return ( bool ) + */ bool CreateSwingHigh( XOHCL &swing, XCSwingHighObject *&object // ) { + // + bool result = false; + + // + object = NULL; + + // + result = swing.IsValid(); + if (!result) + { + return result; + } + + // + long chartID = ChartIdentification(); + int window = SubWindowIdentification(); + + // + string name = swing.GetTag(ToString(X_POI_SWING_HIGH)); + + // + int arrow = SwingHighArrow(); + int width = SwingHighWidth(); + color crl = SwingHighColor(); + + // + object = new XCSwingHighObject(); + result = object.CreateBySwing( + chartID, + name, + window, + swing, + (char)arrow // + ); + + // + if (!result) + { + return result; + } + + // + object.ArrowColor(crl); + object.ArrowWidth(width); + object.ArrowAnchor(ANCHOR_BOTTOM); + + // + return result; + } + + /** + * Create Swing Low Object ... + * + * @param swing: XOHCL instance ... + * + * @return ( bool ) + */ + bool CreateSwingLow( + XOHCL &swing, + XCSwingLowObject *&object // + ) + { + // + bool result = false; + + // + object = NULL; + + // + result = swing.IsValid(); + if (!result) + { + return result; + } + + // + long chartID = ChartIdentification(); + int window = SubWindowIdentification(); + + // + string name = swing.GetTag(ToString(X_POI_SWING_LOW)); + + // + int arrow = SwingLowArrow(); + int width = SwingLowWidth(); + color crl = SwingLowColor(); + + // + object = new XCSwingLowObject(); + result = object.CreateBySwing( + chartID, + name, + window, + swing, + (char)arrow // + ); + + // + if (!result) + { + return result; + } + + // + object.ArrowColor(crl); + object.ArrowWidth(width); + object.ArrowAnchor(ANCHOR_TOP); + + // + return result; + } + + // + // Momentum Bars ... + + /** + * Create Bullish Momentum Bar Object ... + * + * @param bar: XOHCL instance ... + * + * @return ( bool ) + */ + bool CreateBullishMomentumBar( + XOHCL &bar, + XCBullishMomentumBarObject *&object // + ) + { + // + bool result = false; + + // + object = NULL; + + // + result = bar.IsValid(); + if (!result) + { + return result; + } + + // + long chartID = ChartIdentification(); + int window = SubWindowIdentification(); + + // + string name = bar.GetTag(ToString(X_POI_MOMENTUM_BAR)); + + // + int arrow = BullishMomentumBarArrow(); + int width = BullishMomentumBarWidth(); + color crl = BullishMomentumBarColor(); + + // + object = new XCBullishMomentumBarObject(); + result = object.CreateByBar( + chartID, + name, + window, + bar, + (char)arrow // + ); + + // + if (!result) + { + return result; + } + + // + object.ArrowColor(crl); + object.ArrowWidth(width); + object.ArrowAnchor(ANCHOR_TOP); + + // + return result; + } + + /** + * Create Bearish Momentum Bar Object ... + * + * @param bar: XOHCL instance ... + * + * @return ( bool ) + */ + bool CreateBearishMomentumBar( + XOHCL &bar, + XCBearishMomentumBarObject *&object // + ) + { + // + bool result = false; + + // + object = NULL; + + // + result = bar.IsValid(); + if (!result) + { + return result; + } + + // + long chartID = ChartIdentification(); + int window = SubWindowIdentification(); + + // + string name = bar.GetTag(ToString(X_POI_MOMENTUM_BAR)); + + // + int arrow = BearishMomentumBarArrow(); + int width = BearishMomentumBarWidth(); + color crl = BearishMomentumBarColor(); + + // + object = new XCBearishMomentumBarObject(); + result = object.CreateByBar( + chartID, + name, + window, + bar, + (char)arrow // + ); + + // + if (!result) + { + return result; + } + + // + object.ArrowColor(crl); + object.ArrowWidth(width); + object.ArrowAnchor(ANCHOR_TOP); + + // + return result; + } + + // + // Rejection Bars ... + + /** + * Create Bullish Rejection Bar Object ... + * + * @param bar: XOHCL instance ... + * + * @return ( bool ) + */ + bool CreateBullishRejectionBar( + XOHCL &bar, + XCBullishRejectionBarObject *&object // + ) + { + // + bool result = false; + + // + object = NULL; + + // + result = bar.IsValid(); + if (!result) + { + return result; + } + + // + long chartID = ChartIdentification(); + int window = SubWindowIdentification(); + + // + string name = bar.GetTag(ToString(X_POI_REJECTION_BAR)); + + // + int arrow = BullishRejectionBarArrow(); + int width = BullishRejectionBarWidth(); + color crl = BullishRejectionBarColor(); + + // + object = new XCBullishRejectionBarObject(); + result = object.CreateByBar( + chartID, + name, + window, + bar, + (char)arrow // + ); + + // + if (!result) + { + return result; + } + + // + object.ArrowColor(crl); + object.ArrowWidth(width); + object.ArrowAnchor(ANCHOR_TOP); + + // + return result; + } + + /** + * Create Bearish Rejection Bar Object ... + * + * @param bar: XOHCL instance ... + * + * @return ( bool ) + */ + bool CreateBearishRejectionBar( + XOHCL &bar, + XCBearishRejectionBarObject *&object // + ) + { + // + bool result = false; + + // + object = NULL; + + // + result = bar.IsValid(); + if (!result) + { + return result; + } + + // + long chartID = ChartIdentification(); + int window = SubWindowIdentification(); + + // + string name = bar.GetTag(ToString(X_POI_REJECTION_BAR)); + + // + int arrow = BearishRejectionBarArrow(); + int width = BearishRejectionBarWidth(); + color crl = BearishRejectionBarColor(); + + // + object = new XCBearishRejectionBarObject(); + result = object.CreateByBar( + chartID, + name, + window, + bar, + (char)arrow // + ); + + // + if (!result) + { + return result; + } + + // + object.ArrowColor(crl); + object.ArrowWidth(width); + object.ArrowAnchor(ANCHOR_TOP); + + // + return result; + } + + // + // Support and Resistance Zones ... + + /** + * Create Support Zone Object ... + * + * @param bar: XOHCL instance ... + * + * @return ( bool ) + */ + bool CreateSupportZone( + XOHCL &bar, + XCSupportZoneObject *&object // + ) + { + // + bool result = false; + + // + object = NULL; + + // + result = bar.IsValid(); + if (!result) + { + return result; + } + + // + long chartID = ChartIdentification(); + int window = SubWindowIdentification(); + + // + string name = bar.GetTag(ToString(X_POI_SUPPORT_ZONE)); + + // + datetime time2 = (datetime)((int)bar.time + (PeriodSeconds(bar.period) * 5)); + + // + bool fill = SupportZoneFill(); + int width = SupportZoneWidth(); + color crl = SupportZoneColor(); + ENUM_LINE_STYLE style = SupportZoneStyle(); + + // + object = new XCSupportZoneObject(); + result = object.CreateBySupport( + chartID, + name, + window, + bar, + time2, + true // + ); + + // + if (!result) + { + return result; + } + + // + object.ZoneFill(fill); + object.ZoneColor(crl); + object.ZoneWidth(width); + object.ZoneStyle(style); + + // + return result; + } + + /** + * Create Resistance Zone Object ... + * + * @param bar: XOHCL instance ... + * + * @return ( bool ) + */ + bool CreateResistanceZone( + XOHCL &bar, + XCResistanceZoneObject *&object // + ) + { + // + bool result = false; + + // + object = NULL; + + // + result = bar.IsValid(); + if (!result) + { + return result; + } + + // + long chartID = ChartIdentification(); + int window = SubWindowIdentification(); + + // + string name = bar.GetTag(ToString(X_POI_RESISTANCE_ZONE)); + + // + datetime time2 = (datetime)((int)bar.time + (PeriodSeconds(bar.period) * 5)); + + // + bool fill = ResistanceZoneFill(); + int width = ResistanceZoneWidth(); + color crl = ResistanceZoneColor(); + ENUM_LINE_STYLE style = ResistanceZoneStyle(); + + // + object = new XCResistanceZoneObject(); + result = object.CreateByResistance( + chartID, + name, + window, + bar, + time2, + true // + ); + + // + if (!result) + { + return result; + } + + // + object.ZoneFill(fill); + object.ZoneColor(crl); + object.ZoneWidth(width); + object.ZoneStyle(style); + + // + return result; + } + + // + // Supply and Demand Zones ... + + /** + * Create Supply Zone Object ... + * + * @param zone: XZone instance ... + * + * @return ( bool ) + */ + bool CreateSupplyZone( + XZone &zone, + XCSupplyZoneObject *&object // + ) + { + // + bool result = false; + + // + object = NULL; + + // + result = zone.IsValid(); + if (!result) + { + return result; + } + + // + long chartID = ChartIdentification(); + int window = SubWindowIdentification(); + + // + string name = zone.GetTag(); + result = Contains( + ToString(X_POI_SUPPLY_ZONE), + name // + ); + if (!result) + { + return result; + } + + // + bool fill = SupplyZoneFill(); + int width = SupplyZoneWidth(); + color crl = SupplyZoneColor(); + ENUM_LINE_STYLE style = SupplyZoneStyle(); + + // + object = new XCSupplyZoneObject(); + result = object.CreateByZone( + chartID, + name, + window, + zone, + NULL, + true // + ); + + // + if (!result) + { + return result; + } + + // + object.ZoneFill(fill); + object.ZoneColor(crl); + object.ZoneWidth(width); + object.ZoneStyle(style); + + // + return result; + } + + /** + * Create Demand Zone Object ... + * + * @param zone: XZone instance ... + * + * @return ( bool ) + */ + bool CreateDemandZone( + XZone &zone, + XCDemandZoneObject *&object // + ) + { + // + bool result = false; + + // + object = NULL; + + // + result = zone.IsValid(); + if (!result) + { + return result; + } + + // + long chartID = ChartIdentification(); + int window = SubWindowIdentification(); + + // + string name = zone.GetTag(); + result = Contains( + ToString(X_POI_DEMAND_ZONE), + name // + ); + if (!result) + { + return result; + } + + // + bool fill = DemandZoneFill(); + int width = DemandZoneWidth(); + color crl = DemandZoneColor(); + ENUM_LINE_STYLE style = DemandZoneStyle(); + + // + object = new XCDemandZoneObject(); + result = object.CreateByZone( + chartID, + name, + window, + zone, + NULL, + true // + ); + + // + if (!result) + { + return result; + } + + // + object.ZoneFill(fill); + object.ZoneColor(crl); + object.ZoneWidth(width); + object.ZoneStyle(style); + + // + return result; + } + + // + // Order Blocks ... + + /** + * Create Bullish Order Block Object ... + * + * @param zone: XZone instance ... + * + * @return ( bool ) + */ + bool CreateBullishOrderBlock( + XZone &zone, + XCBullishOrderBlockObject *&object // + ) + { + // + bool result = false; + + // + object = NULL; + + // + result = zone.IsValid(); + if (!result) + { + return result; + } + + // + long chartID = ChartIdentification(); + int window = SubWindowIdentification(); + + // + string name = zone.GetTag(); + result = Contains( + ToString(X_POI_BULLISH_ORDERBLOCK), + name // + ); + if (!result) + { + return result; + } + + // + bool fill = BullishOrderBlockFill(); + int width = BullishOrderBlockWidth(); + color crl = BullishOrderBlockColor(); + ENUM_LINE_STYLE style = BullishOrderBlockStyle(); + + // + object = new XCBullishOrderBlockObject(); + result = object.CreateByZone( + chartID, + name, + window, + zone, + NULL, + true // + ); + + // + if (!result) + { + return result; + } + + // + object.ZoneFill(fill); + object.ZoneColor(crl); + object.ZoneWidth(width); + object.ZoneStyle(style); + + // + return result; + } + + /** + * Create Bearish Order Block Object ... + * + * @param zone: XZone instance ... + * + * @return ( bool ) + */ + bool CreateBearishOrderBlock( + XZone &zone, + XCBearishOrderBlockObject *&object // + ) + { + // + bool result = false; + + // + object = NULL; + + // + result = zone.IsValid(); + if (!result) + { + return result; + } + + // + long chartID = ChartIdentification(); + int window = SubWindowIdentification(); + + // + string name = zone.GetTag(); + result = Contains( + ToString(X_POI_BEARISH_ORDERBLOCK), + name // + ); + if (!result) + { + return result; + } + + // + bool fill = BearishOrderBlockFill(); + int width = BearishOrderBlockWidth(); + color crl = BearishOrderBlockColor(); + ENUM_LINE_STYLE style = BearishOrderBlockStyle(); + + // + object = new XCBearishOrderBlockObject(); + result = object.CreateByZone( + chartID, + name, + window, + zone, + NULL, + true // + ); + + // + if (!result) + { + return result; + } + + // + object.ZoneFill(fill); + object.ZoneColor(crl); + object.ZoneWidth(width); + object.ZoneStyle(style); + + // + return result; + } + + // + // Order Blocks ... + + /** + * Create Bullish FVG Object ... + * + * @param zone: XZone instance ... + * + * @return ( bool ) + */ + bool CreateBullishFVG( + XZone &zone, + XCBullishFVGObject *&object // + ) + { + // + bool result = false; + + // + object = NULL; + + // + result = zone.IsValid(); + if (!result) + { + return result; + } + + // + long chartID = ChartIdentification(); + int window = SubWindowIdentification(); + + // + string name = zone.GetTag(); + result = Contains( + ToString(X_POI_BULLISH_FVG), + name // + ); + if (!result) + { + return result; + } + + // + bool fill = BullishFVGFill(); + int width = BullishFVGWidth(); + color crl = BullishFVGColor(); + ENUM_LINE_STYLE style = BullishFVGStyle(); + + // + object = new XCBullishFVGObject(); + result = object.CreateByZone( + chartID, + name, + window, + zone, + NULL, + true // + ); + + // + if (!result) + { + return result; + } + + // + object.ZoneFill(fill); + object.ZoneColor(crl); + object.ZoneWidth(width); + object.ZoneStyle(style); + + // + return result; + } + + /** + * Create Bearish FVG Object ... + * + * @param zone: XZone instance ... + * + * @return ( bool ) + */ + bool CreateBearishFVG( + XZone &zone, + XCBearishFVGObject *&object // + ) + { + // + bool result = false; + + // + object = NULL; + + // + result = zone.IsValid(); + if (!result) + { + return result; + } + + // + long chartID = ChartIdentification(); + int window = SubWindowIdentification(); + + // + string name = zone.GetTag(); + result = Contains( + ToString(X_POI_BEARISH_ORDERBLOCK), + name // + ); + if (!result) + { + return result; + } + + // + bool fill = BearishFVGFill(); + int width = BearishFVGWidth(); + color crl = BearishFVGColor(); + ENUM_LINE_STYLE style = BearishFVGStyle(); + + // + object = new XCBearishFVGObject(); + result = object.CreateByZone( + chartID, + name, + window, + zone, + NULL, + true // + ); + + // + if (!result) + { + return result; + } + + // + object.ZoneFill(fill); + object.ZoneColor(crl); + object.ZoneWidth(width); + object.ZoneStyle(style); + + // + return result; } // diff --git a/Documents/BKP/121.smc.strategy.tmp.mq5 b/Documents/BKP/121.smc.strategy.tmp.mq5 index 531ec2c3..7aefd587 100644 --- a/Documents/BKP/121.smc.strategy.tmp.mq5 +++ b/Documents/BKP/121.smc.strategy.tmp.mq5 @@ -226,3 +226,324 @@ // Print("hasShortConditions"); break; } + + + ////////////////////////////////////////////////////////////////////////////// + + // + XZone iBearishOrderBlock; + XZone iBearishFVG; + + // + bool isPassed = false; + int orderBlocksCount = ArraySize(orderBlocksState.bearishOrderBlocks); + isPassed = IsValidSize(orderBlocksCount); + if (!isPassed) + { + continue; + } + + // + // Find Related Order Block ... + isPassed = false; + for (int j = 0; j < orderBlocksCount; j++) + { + // + XZone jOrderBlock = orderBlocksState.bearishOrderBlocks[j]; + + // + bool isOrderBlockInsideZone = IsSupplyZoneOrderBlock( + iSupplyZone, + jOrderBlock // + ); + if (isOrderBlockInsideZone) + { + // + isPassed = true; + iBearishOrderBlock = jOrderBlock; + conditions.bearishOrderBlock = jOrderBlock; + break; + } + } + if (!isPassed) + { + continue; + } + + // + isPassed = false; + int fairValueGapsCount = ArraySize(fvgsState.bearishFVGs); + isPassed = IsValidSize(fairValueGapsCount); + if (!isPassed) + { + continue; + } + + // + // Find Related Fair Value Gaps ... + isPassed = false; + for (int j = 0; j < fairValueGapsCount; j++) + { + // + XZone jFVG = fvgsState.bearishFVGs[j]; + + // + bool isBelongs = IsBearishOrderBlockFVG( + iBearishOrderBlock, + jFVG // + ); + if (isBelongs) + { + // + iBearishFVG = jFVG; + conditions.bearishFVG = jFVG; + + // + isPassed = true; + break; + } + } + // if (!isPassed) + // { + // continue; + // } + + // // + // if (isPassed) + // { + // // + // DrawSupplyZone(iSupplyZone); + // DrawBearishOrderBlock(iBearishOrderBlock); + // DrawBearishFVG(iBearishFVG); + // } + + + +////////////////////////////////////////////// + + + + // + XZone iBullishOrderBlock; + XZone iBullishFVG; + + // + bool isPassed = false; + int orderBlocksCount = ArraySize(orderBlocksState.bullishOrderBlocks); + isPassed = IsValidSize(orderBlocksCount); + if (!isPassed) + { + continue; + } + + // + // Find Related Order Block ... + isPassed = false; + for (int j = 0; j < orderBlocksCount; j++) + { + // + XZone jOrderBlock = orderBlocksState.bullishOrderBlocks[j]; + + // + bool isOrderBlockInsideZone = IsDemandZoneOrderBlock( + iDemandZone, + jOrderBlock // + ); + if (isOrderBlockInsideZone) + { + // + isPassed = true; + iBullishOrderBlock = jOrderBlock; + conditions.bullishOrderBlock = jOrderBlock; + break; + } + } + if (!isPassed) + { + continue; + } + + // + isPassed = false; + int fairValueGapsCount = ArraySize(fvgsState.bullishFVGs); + isPassed = IsValidSize(fairValueGapsCount); + if (!isPassed) + { + continue; + } + + // + // Find Related Fair Value Gaps ... + isPassed = false; + for (int j = 0; j < fairValueGapsCount; j++) + { + // + XZone jFVG = fvgsState.bullishFVGs[j]; + + // + bool isBelongs = IsBullishOrderBlockFVG( + iBullishOrderBlock, + jFVG // + ); + if (isBelongs) + { + // + iBullishFVG = jFVG; + conditions.bullishFVG = jFVG; + + // + isPassed = true; + break; + } + } + // if (!isPassed) + // { + // continue; + // } + + // // + // if (isPassed) + // { + // // + // DrawDemandZone(iDemandZone); + // DrawBullishOrderBlock(iBullishOrderBlock); + // DrawBullishFVG(iBullishFVG); + // } + + +////////////////////////////////////////////// + + + + // + // Tools Functions ... + + /** + * Check an Order Block belongs to a Supply Zone ... + * + * @param supply: XZone instance ... + * @param orderBlock: XZone instance ... + * + * @return ( bool ) + */ + bool IsSupplyZoneOrderBlock( + XZone &supply, + XZone &orderBlock // + ) + { + // + bool result = false; + + // + result = supply.IsValid() && + orderBlock.IsValid(); + if (!result) + { + return result; + } + + // + result = + orderBlock.upper <= supply.upper; + + // + return result; + } + + /** + * Check an Order Block belongs to a Demand Zone ... + * + * @param demand: XZone instance ... + * @param orderBlock: XZone instance ... + * + * @return ( bool ) + */ + bool IsDemandZoneOrderBlock( + XZone &demand, + XZone &orderBlock // + ) + { + // + bool result = false; + + // + result = demand.IsValid() && + orderBlock.IsValid(); + if (!result) + { + return result; + } + + // + result = + orderBlock.lower >= demand.lower; + + // + return result; + } + + /** + * Check a Bearish FVG belongs to a Bearish Order Block ... + * + * @param orderBlock: XZone instance ... + * @param fvg: XZone instance ... + * + * @return ( bool ) + */ + bool IsBearishOrderBlockFVG( + XZone &orderBlock, + XZone &fvg // + ) + { + // + bool result = false; + + // + result = fvg.IsValid() && + orderBlock.IsValid(); + if (!result) + { + return result; + } + + // + result = + fvg.upper <= orderBlock.upper && + fvg.upper > orderBlock.lower; + + // + return result; + } + + /** + * Check a Bullish FVG belongs to a Bullish Order Block ... + * + * @param orderBlock: XZone instance ... + * @param fvg: XZone instance ... + * + * @return ( bool ) + */ + bool IsBullishOrderBlockFVG( + XZone &orderBlock, + XZone &fvg // + ) + { + // + bool result = false; + + // + result = fvg.IsValid() && + orderBlock.IsValid(); + if (!result) + { + return result; + } + + // + result = + fvg.lower >= orderBlock.lower && + fvg.lower < orderBlock.upper; + + // + return result; + } diff --git a/Documents/BKP/x-saherelm.x-poi.Draw.Abillity.class.mq5 b/Documents/BKP/x-saherelm.x-poi.Draw.Abillity.class.mq5 new file mode 100644 index 00000000..0e9fcd6c --- /dev/null +++ b/Documents/BKP/x-saherelm.x-poi.Draw.Abillity.class.mq5 @@ -0,0 +1,9109 @@ +/////////////////////////////////////////////////////// +// +// SaherElm IT Center MQL5 Class Library +// -------------------------------------- +// Name: XPOI +// Description: Provides Point of Interests ... +// - Swing Highs; +// - Swing Lows; +// +// Maintainer: +// ------------ +// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com) +// +////////////////////////////////////////////////////// +// +// Global Properties ... +#property library +#property copyright "Copyright 2023, SaherElm IT Center" +#property link "https://www.saherelm.ir" +#property version "1.00" +#property strict + +// +// Imports ... + +// +#include "../Classes/x-saherelm.x-chart-objects.class.mq5" +#include "../Classes/x-saherelm.xalert.class.mq5" + +// +#include +#include +#include +#include + +// +// Implementation ... + +// +class XCPOI : public XSCBaseAlert +{ + // + public: + // + + // + // Constructors ... + /** + * Create an Instance ... + * + * @param symbol: String ... + * @param period: ENUM_TIMEFRAMES member ... + */ + void XCPOI( + string symbol, + ENUM_TIMEFRAMES period // + ) + { + // + // Attach Required Properties ... + mSymbol = symbol; + mPeriod = period; + + // + // Initialize Bar Tracker ... + mBarTracker.Init( + mSymbol, + mPeriod // + ); + + // + // Apply Default Configurations ... + ApplyDefaultConfig(); + } + + // + // Deconstructor ... + void ~XCPOI() + { + // + DestroyPOIs(); + DestroyObjects(); + DestroySessions(); + DestroyEventListeners(); + } + + // + // Getter(s) / Setter(s) ... + + /** + * Get Chart ID ... + * + * @return ( long ) + */ + long ChartID() + { + return mChartID; + } + + /** + * Set Chart ID ... + * + * @param value: Long + */ + void ChartID(long value) + { + // + if (value < 0) + { + value = 0; + } + + // + mChartID = value; + } + + /** + * Get Sub Window Number ... + * + * @return ( int ) + */ + int Window() + { + return mWindow; + } + + /** + * Get Sub Window Number ... + * + * @param value: Integer ... + */ + void Window(int value) + { + // + if (value < 0) + { + value = 0; + } + + // + mWindow = value; + } + + /** + * Get Max Number of POIs which holds ... + * + * @return ( int ) + */ + int MaxNumberOfPOIs() + { + return mMaxNumberOfPOIs; + } + + /** + * Set Max Number of POIs which holds ... + * 0 => Infinity ... + * + * @param value: Integer ... + */ + void MaxNumberOfPOIs(int value) + { + // + if (value < 0) + { + value = 0; + } + + // + mMaxNumberOfPOIs = value; + } + + /** + * Get Number of POI(s) which must Find at Initializations ... + * + * @return ( int ) + */ + int MaxNumberOfRequiredPOIs() + { + return mMaxNumberOfRequiredPOIs; + } + + /** + * Set Number of POI(s) which must Find at Initializations ... + * 2 is Default ... + * + * @param value: Integer ... + */ + void MaxNumberOfRequiredPOIs(int value) + { + // + if (value < 2) + { + value = 2; + } + + // + mMaxNumberOfRequiredPOIs = value; + } + + /** + * Check Is Locked or not ... + * + * @return ( bool ) + */ + bool IsLocked() + { + return mLock; + } + + // + // POI(s) Configs ... + + // + // Trading Days ... + + /** + * Get Detect Trading Days State ... + * + * @return ( bool ) + */ + bool AllowTradingDays() + { + return mAllowTradingDays; + } + + /** + * Set Detect Trading Days State ... + * + * @param value: Boolean ... + */ + void AllowTradingDays(bool value) + { + mAllowTradingDays = value; + } + + /** + * Get Draw Trading Days State ... + * + * @return ( bool ) + */ + bool AllowDrawTradingDays() + { + return mAllowDrawTradingDays; + } + + /** + * Set Draw Trading Days State ... + * + * @param value: Boolean ... + */ + void AllowDrawTradingDays(bool value) + { + mAllowDrawTradingDays = value; + } + + /** + * Get Trading Days Start Color ... + * + * @return ( color ) + */ + color TradingDaysStartColor() + { + return mTradingDaysStartColor; + } + + /** + * Set Trading Days Start Color ... + * + * @param value: Argument 1 + */ + void TradingDaysStartColor(color value) + { + mTradingDaysStartColor = value; + } + + /** + * Get Trading Days Start Style ... + * + * @return ( ENUM_LINE_STYLE ) + */ + ENUM_LINE_STYLE TradingDaysStartStyle() + { + return mTradingDaysStartStyle; + } + + /** + * Set Trading Days Start Style ... + * + * @param value: ENUM_LINE_STYLE member ... + */ + void TradingDaysStartStyle(ENUM_LINE_STYLE value) + { + mTradingDaysStartStyle = value; + } + + /** + * Get Trading Days End Color ... + * + * @return ( color ) + */ + color TradingDaysEndColor() + { + return mTradingDaysEndColor; + } + + /** + * Set Trading Days End Color ... + * + * @param value: Argument 1 + */ + void TradingDaysEndColor(color value) + { + mTradingDaysEndColor = value; + } + + /** + * Get Trading Days End Style ... + * + * @return ( ENUM_LINE_STYLE ) + */ + ENUM_LINE_STYLE TradingDaysEndStyle() + { + return mTradingDaysEndStyle; + } + + /** + * Set Trading Days End Style ... + * + * @param value: ENUM_LINE_STYLE member ... + */ + void TradingDaysEndStyle(ENUM_LINE_STYLE value) + { + mTradingDaysEndStyle = value; + } + + // + // Sessions ... + + /** + * Get Detect Market Sessions State ... + * + * @return ( bool ) + */ + bool AllowMarketSessions() + { + return mAllowMarketSessions; + } + + /** + * Set Detect Market Sessions State ... + * + * @param value: Boolean ... + */ + void AllowMarketSessions(bool value) + { + mAllowMarketSessions = value; + } + + /** + * Get Draw Market Sessions State ... + * + * @return ( bool ) + */ + bool AllowDrawMarketSessions() + { + return mAllowDrawMarketSessions; + } + + /** + * Set Draw Market Sessions State ... + * + * @param value: Boolean ... + */ + void AllowDrawMarketSessions(bool value) + { + mAllowDrawMarketSessions = value; + } + + /** + * Get Session Working Hors ... + * + * @return ( int ) + */ + int SessionOpenHours() + { + return mSessionOpenHours; + } + + /** + * Set Session Working Hors ... + * + * @param value: Integer ... + */ + void SessionOpenHours(int value) + { + // + if (value <= 0) + { + value = 9; + } + + // + mSessionOpenHours = value; + } + + // + // Swing High ... + + /** + * Get Detect Swing Highs State ... + * + * @return ( bool ) + */ + bool AllowSwingHighs() + { + return mAllowSwingHighs; + } + + /** + * Set Detect Swing Highs State ... + * + * @param value: Boolean + */ + void AllowSwingHighs(bool value) + { + mAllowSwingHighs = value; + } + + /** + * Get Draw Swing Highs State ... + * + * @return ( bool ) + */ + bool AllowDrawSwingHighs() + { + return mAllowDrawSwingHighs; + } + + /** + * Set Draw Swing Highs State ... + * + * @param value: Boolean + */ + void AllowDrawSwingHighs(bool value) + { + mAllowDrawSwingHighs = value; + } + + /** + * Get Threshold Required for Swing High Detection ... + * + * @return ( double ) + */ + double SwingHighThreshold() + { + return mSwingHighThreshold; + } + + /** + * Set Threshold Required for Swing High Detection ... + * + * @param value: Double ... + */ + void SwingHighThreshold(double value) + { + // + if (value < 0) + { + value = 0; + } + + // + mSwingHighThreshold = value; + } + + /** + * Get Swing High Arrow Code ... + * + * @return ( char ) + */ + char SwingHighArrowCode() + { + return mSwingHighArrowCode; + } + + /** + * Set Swing High Arrow Code ... + * + * @param value: Char ... + */ + void SwingHighArrowCode(char value) + { + mSwingHighArrowCode = value; + } + + /** + * Get Swing High Color ... + * + * @return ( color ) + */ + color SwingHighColor() + { + return mSwingHighColor; + } + + /** + * Get Swing High Color ... + * + * @param value: Color + */ + void SwingHighColor(color value) + { + mSwingHighColor = value; + } + + /** + * Get Swing High Width ... + * + * @return ( int ) + */ + int SwingHighWidth() + { + return mSwingHighWidth; + } + + /** + * Set Swing High Width ... + * + * @param value: Integer ... + */ + void SwingHighWidth(int value) + { + // + if (value < 1) + { + value = 1; + } + + // + mSwingHighWidth = value; + } + + // + // Swing Low ... + + /** + * Get Detect Swing Lows State ... + * + * @return ( bool ) + */ + bool AllowSwingLows() + { + return mAllowSwingLows; + } + + /** + * Set Detect Swing Lows State ... + * + * @param value: Boolean ... + */ + void AllowSwingLows(bool value) + { + mAllowSwingLows = value; + } + + /** + * Get Draw Swing Lows State ... + * + * @return ( bool ) + */ + bool AllowDrawSwingLows() + { + return mAllowDrawSwingLows; + } + + /** + * Set Draw Swing Lows State ... + * + * @param value: Boolean + */ + void AllowDrawSwingLows(bool value) + { + mAllowDrawSwingLows = value; + } + + /** + * Get Threshold Required for Swing Low Detection ... + * + * @return ( double ) + */ + double SwingLowThreshold() + { + return mSwingLowThreshold; + } + + /** + * Set Threshold Required for Swing Low Detection ... + * + * @param value: Double ... + */ + void SwingLowThreshold(double value) + { + // + if (value < 0) + { + value = 0; + } + + // + mSwingLowThreshold = value; + } + + /** + * Get Swing Low Arrow Code ... + * + * @return ( char ) + */ + char SwingLowArrowCode() + { + return mSwingLowArrowCode; + } + + /** + * Set Swing Low Arrow Code ... + * + * @param value: Char ... + */ + void SwingLowArrowCode(char value) + { + mSwingLowArrowCode = value; + } + + /** + * Get Swing Low Color ... + * + * @return ( color ) + */ + color SwingLowColor() + { + return mSwingLowColor; + } + + /** + * Get Swing Low Color ... + * + * @param value: Color + */ + void SwingLowColor(color value) + { + mSwingLowColor = value; + } + + /** + * Get Swing Low Width ... + * + * @return ( int ) + */ + int SwingLowWidth() + { + return mSwingLowWidth; + } + + /** + * Set Swing Low Width ... + * + * @param value: Integer ... + */ + void SwingLowWidth(int value) + { + // + if (value < 1) + { + value = 1; + } + + // + mSwingLowWidth = value; + } + + // + // Momentum Bars ... + + /** + * Get Detect Momentum Bars State ... + * + * @return ( bool ) + */ + bool AllowMomentumBars() + { + return mAllowMomentumBars; + } + + /** + * Set Detect Momentum Bars State ... + * + * @param value: Boolean ... + */ + void AllowMomentumBars(bool value) + { + mAllowMomentumBars = value; + } + + /** + * Get Draw Momentum Bars State ... + * + * @return ( bool ) + */ + bool AllowDrawMomentumBars() + { + return mAllowDrawMomentumBars; + } + + /** + * Set Draw Momentum Bars State ... + * + * @param value: Boolean + */ + void AllowDrawMomentumBars(bool value) + { + mAllowDrawMomentumBars = value; + } + + /** + * Get Momentum Bar Percent ... + * + * @return ( int ) + */ + int MomentumBarPercent() + { + return mMomentumBarPercent; + } + + /** + * Set Momentum Bar Percent ... + * + * @param value: Integer + */ + void MomentumBarPercent(int value) + { + // + if (value < 0) + { + value = 0; + } + + // + mMomentumBarPercent = value; + } + + /** + * Get Momentum Bar Sharp Ratio ... + * + * @return ( double ) + */ + double MomentumBarSharpRatio() + { + return mMomentumBarSharpRatio; + } + + /** + * Set Momentum Bar Sharp Ratio ... + * + * @param value: Double ... + */ + void MomentumBarSharpRatio(double value) + { + // + if (value < 0) + { + value = 0; + } + + // + mMomentumBarSharpRatio = value; + } + + /** + * Get Momentum Bar Loopback ... + * + * @return ( int ) + */ + int MomentumBarLoopBack() + { + return mMomentumBarLoopBack; + } + + /** + * Set Momentum Bar Loopback ... + * + * @param value: Integer ... + */ + void MomentumBarLoopBack(int value) + { + // + if (value < 0) + { + value = 0; + } + + // + mMomentumBarLoopBack = value; + } + + /** + * Get Momentum Bar Width ... + * + * @return ( int ) + */ + int MomentumBarWidth() + { + return mMomentumBarWidth; + } + + /** + * Set Momentum Bar Width ... + * + * @param value: Integer ... + */ + void MomentumBarWidth(int value) + { + mMomentumBarWidth = value; + } + + /** + * Get Bullish Momentum Bar Arrow Code ... + * + * @return ( char ) + */ + char MomentumBarBullishArrowCode() + { + return mMomentumBarBullishArrowCode; + } + + /** + * Set Bullish Momentum Bar Arrow Code ... + * + * @param value: Char ... + */ + void MomentumBarBullishArrowCode(char value) + { + mMomentumBarBullishArrowCode = value; + } + + /** + * Get Bullish Momentum Bar Color ... + * + * @return ( char ) + */ + char MomentumBarBearishArrowCode() + { + return mMomentumBarBearishArrowCode; + } + + /** + * Set Bullish Momentum Bar Color ... + * + * @param value: Color ... + */ + void MomentumBarBearishArrowCode(char value) + { + mMomentumBarBearishArrowCode = value; + } + + /** + * Get Bearish Momentum Bar Arrow Code ... + * + * @return ( color ) + */ + color MomentumBarBullishColor() + { + return mMomentumBarBullishColor; + } + + /** + * Set Bearish Momentum Bar Arrow Code ... + * + * @param value: Color ... + */ + void MomentumBarBullishColor(color value) + { + mMomentumBarBullishColor = value; + } + + /** + * Get Bearish Momentum Bar Color ... + * + * @return ( color ) + */ + color MomentumBarBearishColor() + { + return mMomentumBarBearishColor; + } + + /** + * Set Bearish Momentum Bar Color ... + * + * @param value: Color ... + */ + void MomentumBarBearishColor(color value) + { + mMomentumBarBearishColor = value; + } + + // + // Rejection Bars ... + + /** + * Get Detect Rejection Bars State ... + * + * @return ( bool ) + */ + bool AllowRejectionBars() + { + return mAllowRejectionBars; + } + + /** + * Set Detect Rejection Bars State ... + * + * @param value: Boolean ... + */ + void AllowRejectionBars(bool value) + { + mAllowRejectionBars = value; + } + + /** + * Get Draw Rejection Bars State ... + * + * @return ( bool ) + */ + bool AllowDrawRejectionBars() + { + return mAllowDrawRejectionBars; + } + + /** + * Set Draw Rejection Bars State ... + * + * @param value: Boolean ... + */ + void AllowDrawRejectionBars(bool value) + { + mAllowDrawRejectionBars = value; + } + + /** + * Get Rejection Bar Percent ... + * + * @return ( int ) + */ + int RejectionBarPercent() + { + return mRejectionBarPercent; + } + + /** + * Set Rejection Bar Percent ... + * + * @param value: Integer + */ + void RejectionBarPercent(int value) + { + mRejectionBarPercent = value; + } + + /** + * Get Rejection Bar Sharp Ratio ... + * + * @return ( double ) + */ + double RejectionBarSharpRatio() + { + return mRejectionBarSharpRatio; + } + + /** + * Set Rejection Bar Sharp Ratio ... + * + * @param value: Double ... + */ + void RejectionBarSharpRatio(double value) + { + mRejectionBarSharpRatio = value; + } + + /** + * Get Rejection Bar Loopback ... + * + * @return ( int ) + */ + int RejectionBarLoopBack() + { + return mRejectionBarLoopBack; + } + + /** + * Set Rejection Bar Loopback ... + * + * @param value: Integer ... + */ + void RejectionBarLoopBack(int value) + { + mRejectionBarLoopBack = value; + } + + /** + * Get Rejection Bar Width ... + * + * @return ( int ) + */ + int RejectionBarWidth() + { + return mRejectionBarWidth; + } + + /** + * Set Rejection Bar Width ... + * + * @param value: Integer ... + */ + void RejectionBarWidth(int value) + { + mRejectionBarWidth = value; + } + + /** + * Get Bullish Rejection Bar Arrow Code ... + * + * @return ( char ) + */ + char RejectionBarBullishArrowCode() + { + return mRejectionBarBullishArrowCode; + } + + /** + * Set Bullish Rejection Bar Arrow Code ... + * + * @param value: Char ... + */ + void RejectionBarBullishArrowCode(char value) + { + mRejectionBarBullishArrowCode = value; + } + + /** + * Get Bullish Rejection Bar Color ... + * + * @return ( char ) + */ + char RejectionBarBearishArrowCode() + { + return mRejectionBarBearishArrowCode; + } + + /** + * Set Bullish Rejection Bar Color ... + * + * @param value: Color ... + */ + void RejectionBarBearishArrowCode(char value) + { + mRejectionBarBearishArrowCode = value; + } + + /** + * Get Bearish Rejection Bar Arrow Code ... + * + * @return ( color ) + */ + color RejectionBarBullishColor() + { + return mRejectionBarBullishColor; + } + + /** + * Set Bearish Rejection Bar Arrow Code ... + * + * @param value: Color ... + */ + void RejectionBarBullishColor(color value) + { + mRejectionBarBullishColor = value; + } + + /** + * Get Bearish Rejection Bar Color ... + * + * @return ( color ) + */ + color RejectionBarBearishColor() + { + return mRejectionBarBearishColor; + } + + /** + * Set Bearish Rejection Bar Color ... + * + * @param value: Color ... + */ + void RejectionBarBearishColor(color value) + { + mRejectionBarBearishColor = value; + } + + // + // Support Zone ... + + /** + * Get Detect Support Zone State ... + * + * @return ( bool ) + */ + bool AllowSupportZones() + { + return mAllowSupportZones; + } + + /** + * Set Detect Support Zone State ... + * + * @param value: Boolean ... + */ + void AllowSupportZones(bool value) + { + mAllowSupportZones = value; + } + + /** + * Get Draw Support Zone State ... + * + * @return ( bool ) + */ + bool AllowDrawSupportZones() + { + return mAllowDrawSupportZones; + } + + /** + * Set Draw Support Zone State ... + * + * @param value: Boolean ... + */ + void AllowDrawSupportZones(bool value) + { + mAllowDrawSupportZones = value; + } + + /** + * Get Support Zone Loopback ... + * + * @return ( int ) + */ + int SupportZoneLoopBack() + { + return mSupportZoneLoopBack; + } + + /** + * Set Support Zone Loopback ... + * + * @param value: Integer ... + */ + void SupportZoneLoopBack(int value) + { + // + if (value < 10) + { + value = 10; + } + + // + mSupportZoneLoopBack = value; + } + + /** + * Get Support Zone Width ... + * + * @return ( int ) + */ + int SupportZoneWidth() + { + return mSupportZoneWidth; + } + + /** + * Set Support Zone Width ... + * + * @param value: Integer ... + */ + void SupportZoneWidth(int value) + { + // + if (value < 1) + { + value = 1; + } + + // + mSupportZoneWidth = value; + } + + /** + * Get Support Zone Color ... + * + * @return ( color ) + */ + color SupportZoneColor() + { + return mSupportZoneColor; + } + + /** + * Set Support Zone Color ... + * + * @param value: Color ... + */ + void SupportZoneColor(color value) + { + mSupportZoneColor = value; + } + + /** + * Get Support Zone Style ... + * + * @return ( ENUM_LINE_STYLE ) + */ + ENUM_LINE_STYLE SupportZoneStyle() + { + return mSupportZoneStyle; + } + + /** + * Set Support Zone Style ... + * + * @param value: ENUM_LINE_STYLE member ... + */ + void SupportZoneStyle(ENUM_LINE_STYLE value) + { + mSupportZoneStyle = value; + } + + /** + * Get Support Zone Price Type ... + * + * @return ( ENUM_LINE_STYLE ) + */ + ENUM_X_PRICE SupportZonePriceType() + { + return mSupportZonePriceType; + } + + /** + * Set Support Zone Price Type ... + * + * @param value: ENUM_X_PRICE member ... + */ + void SupportZonePriceType(ENUM_X_PRICE value) + { + mSupportZonePriceType = value; + } + + // + // Resistance Zone ... + + /** + * Get Detect Resistance Zone State ... + * + * @return ( bool ) + */ + bool AllowResistanceZones() + { + return mAllowResistanceZones; + } + + /** + * Set Detect Resistance Zone State ... + * + * @param value: Boolean ... + */ + void AllowResistanceZones(bool value) + { + mAllowResistanceZones = value; + } + + /** + * Get Draw Resistance Zone State ... + * + * @return ( bool ) + */ + bool AllowDrawResistanceZones() + { + return mAllowDrawResistanceZones; + } + + /** + * Set Draw Resistance Zone State ... + * + * @param value: Boolean ... + */ + void AllowDrawResistanceZones(bool value) + { + mAllowDrawResistanceZones = value; + } + + /** + * Get Resistance Zone Loopback ... + * + * @return ( int ) + */ + int ResistanceZoneLoopBack() + { + return mResistanceZoneLoopBack; + } + + /** + * Set Resistance Zone Loopback ... + * + * @param value: Integer ... + */ + void ResistanceZoneLoopBack(int value) + { + // + if (value < 10) + { + value = 10; + } + + // + mResistanceZoneLoopBack = value; + } + + /** + * Get Resistance Zone Width ... + * + * @return ( int ) + */ + int ResistanceZoneWidth() + { + return mResistanceZoneWidth; + } + + /** + * Set Resistance Zone Width ... + * + * @param value: Integer ... + */ + void ResistanceZoneWidth(int value) + { + // + if (value < 1) + { + value = 1; + } + + // + mResistanceZoneWidth = value; + } + + /** + * Get Resistance Zone Color ... + * + * @return ( color ) + */ + color ResistanceZoneColor() + { + return mResistanceZoneColor; + } + + /** + * Set Resistance Zone Color ... + * + * @param value: Color ... + */ + void ResistanceZoneColor(color value) + { + mResistanceZoneColor = value; + } + + /** + * Get Resistance Zone Style ... + * + * @return ( ENUM_LINE_STYLE ) + */ + ENUM_LINE_STYLE ResistanceZoneStyle() + { + return mResistanceZoneStyle; + } + + /** + * Set Resistance Zone Style ... + * + * @param value: ENUM_LINE_STYLE member ... + */ + void ResistanceZoneStyle(ENUM_LINE_STYLE value) + { + mResistanceZoneStyle = value; + } + + /** + * Get Resistance Zone Price Type ... + * + * @return ( ENUM_LINE_STYLE ) + */ + ENUM_X_PRICE ResistanceZonePriceType() + { + return mResistanceZonePriceType; + } + + /** + * Set Resistance Zone Price Type ... + * + * @param value: ENUM_X_PRICE member ... + */ + void ResistanceZonePriceType(ENUM_X_PRICE value) + { + mResistanceZonePriceType = value; + } + + // + // Supply Zone ... + + /** + * Get Detect Supply Zone State ... + * + * @return ( bool ) + */ + bool AllowSupplyZones() + { + return mAllowSupplyZones; + } + + /** + * Set Detect Supply Zone State ... + * + * @param value: Boolean ... + */ + void AllowSupplyZones(bool value) + { + mAllowSupplyZones = value; + } + + /** + * Get Draw Supply Zone State ... + * + * @return ( bool ) + */ + bool AllowDrawSupplyZones() + { + return mAllowDrawSupplyZones; + } + + /** + * Set Draw Supply Zone State ... + * + * @param value: Boolean ... + */ + void AllowDrawSupplyZones(bool value) + { + mAllowDrawSupplyZones = value; + } + + /** + * Get Supply Zone Width ... + * + * @return ( int ) + */ + int SupplyZoneWidth() + { + return mSupplyZoneWidth; + } + + /** + * Set Supply Zone Width ... + * + * @param value: Integer ... + */ + void SupplyZoneWidth(int value) + { + // + if (value < 1) + { + value = 1; + } + + // + mSupplyZoneWidth = value; + } + + /** + * Get Supply Zone Color ... + * + * @return ( color ) + */ + color SupplyZoneColor() + { + return mSupplyZoneColor; + } + + /** + * Set Supply Zone Color ... + * + * @param value: Color ... + */ + void SupplyZoneColor(color value) + { + mSupplyZoneColor = value; + } + + /** + * Get Supply Zone Style ... + * + * @return ( ENUM_LINE_STYLE ) + */ + ENUM_LINE_STYLE SupplyZoneStyle() + { + return mSupplyZoneStyle; + } + + /** + * Set Supply Zone Style ... + * + * @param value: ENUM_LINE_STYLE member ... + */ + void SupplyZoneStyle(ENUM_LINE_STYLE value) + { + mSupplyZoneStyle = value; + } + + /** + * Get Supply Zone Detecting Period ... + * + * @return ( ENUM_TIMEFRAMES ) ... + */ + ENUM_TIMEFRAMES SupplyZonePeriod() + { + return mSupplyZonePeriod; + } + + /** + * Set Supply Zone Detecting Period ... + * + * @param value: ENUM_TIMEFRAMES member ... + */ + void SupplyZonePeriod(ENUM_TIMEFRAMES value) + { + mSupplyZonePeriod = value; + } + + // + // Demand Zone ... + + /** + * Get Detect Demand Zone State ... + * + * @return ( bool ) + */ + bool AllowDemandZones() + { + return mAllowDemandZones; + } + + /** + * Set Detect Demand Zone State ... + * + * @param value: Boolean ... + */ + void AllowDemandZones(bool value) + { + mAllowDemandZones = value; + } + + /** + * Get Draw Demand Zone State ... + * + * @return ( bool ) + */ + bool AllowDrawDemandZones() + { + return mAllowDrawDemandZones; + } + + /** + * Set Draw Demand Zone State ... + * + * @param value: Boolean ... + */ + void AllowDrawDemandZones(bool value) + { + mAllowDrawDemandZones = value; + } + + /** + * Get Demand Zone Width ... + * + * @return ( int ) + */ + int DemandZoneWidth() + { + return mDemandZoneWidth; + } + + /** + * Set Demand Zone Width ... + * + * @param value: Integer ... + */ + void DemandZoneWidth(int value) + { + // + if (value < 1) + { + value = 1; + } + + // + mDemandZoneWidth = value; + } + + /** + * Get Demand Zone Color ... + * + * @return ( color ) + */ + color DemandZoneColor() + { + return mDemandZoneColor; + } + + /** + * Set Demand Zone Color ... + * + * @param value: Color ... + */ + void DemandZoneColor(color value) + { + mDemandZoneColor = value; + } + + /** + * Get Demand Zone Style ... + * + * @return ( ENUM_LINE_STYLE ) + */ + ENUM_LINE_STYLE DemandZoneStyle() + { + return mDemandZoneStyle; + } + + /** + * Set Demand Zone Style ... + * + * @param value: ENUM_LINE_STYLE member ... + */ + void DemandZoneStyle(ENUM_LINE_STYLE value) + { + mDemandZoneStyle = value; + } + + /** + * Get Demand Zone Detecting Period ... + * + * @return ( ENUM_TIMEFRAMES ) ... + */ + ENUM_TIMEFRAMES DemandZonePeriod() + { + return mDemandZonePeriod; + } + + /** + * Set Demand Zone Detecting Period ... + * + * @param value: ENUM_TIMEFRAMES member ... + */ + void DemandZonePeriod(ENUM_TIMEFRAMES value) + { + mDemandZonePeriod = value; + } + + // + // Order Blocks ... + + // + // Bullish Order Blocks ... + + /** + * Get Detect Bullish Order Blocks State ... + * + * @return ( bool ) + */ + bool AllowBullishOrderBlocks() + { + return mAllowBullishOrderBlocks; + } + + /** + * Set Detect Bullish Order Blocks State ... + * + * @param value: Boolean ... + */ + void AllowBullishOrderBlocks(bool value) + { + mAllowBullishOrderBlocks = value; + } + + /** + * Get Draw Bullish Order Blocks State ... + * + * @return ( bool ) + */ + bool AllowDrawBullishOrderBlocks() + { + return mAllowDrawBullishOrderBlocks; + } + + /** + * Set Draw Bullish Order Blocks State ... + * + * @param value: Boolean ... + */ + void AllowDrawBullishOrderBlocks(bool value) + { + mAllowDrawBullishOrderBlocks = value; + } + + /** + * Get Bullish Order Block Width ... + * + * @return ( int ) + */ + int BullishOrderBlockWidth() + { + return mBullishOrderBlockWidth; + } + + /** + * Set Bullish Order Block Width ... + * + * @param value: Integer ... + */ + void BullishOrderBlockWidth(int value) + { + // + if (value < 1) + { + value = 1; + } + + // + mBullishOrderBlockWidth = value; + } + + /** + * Get Bullish Order Block Color ... + * + * @return ( color ) + */ + color BullishOrderBlockColor() + { + return mBullishOrderBlockColor; + } + + /** + * Set Bullish Order Block Color ... + * + * @param value: Color ... + */ + void BullishOrderBlockColor(color value) + { + mBullishOrderBlockColor = value; + } + + /** + * Get Bullish Order Block Style ... + * + * @return ( ENUM_LINE_STYLE ) + */ + ENUM_LINE_STYLE BullishOrderBlockStyle() + { + return mBullishOrderBlockStyle; + } + + /** + * Set Bullish Order Block Style ... + * + * @param value: ENUM_LINE_STYLE member ... + */ + void BullishOrderBlockStyle(ENUM_LINE_STYLE value) + { + mBullishOrderBlockStyle = value; + } + + /** + * Get Minimum Required Same Bars for Bullish Order Blocks ... + * + * @return ( int ) + */ + int RequiredBarsForBullishOrderBlock() + { + return mRequiredBarsForBullishOrderBlock; + } + + /** + * Set Minimum Required Same Bars for Bullish Order Blocks ... + * + * @param value: Integer ... + */ + void RequiredBarsForBullishOrderBlock(int value) + { + // + if (value < 3) + { + value = 3; + } + + // + mRequiredBarsForBullishOrderBlock = value; + } + + // + // Bearish Order Blocks ... + + /** + * Get Detect Bearish Order Blocks State ... + * + * @return ( bool ) + */ + bool AllowBearishOrderBlocks() + { + return mAllowBearishOrderBlocks; + } + + /** + * Set Detect Bearish Order Blocks State ... + * + * @param value: Boolean ... + */ + void AllowBearishOrderBlocks(bool value) + { + mAllowBearishOrderBlocks = value; + } + + /** + * Get Draw Bearish Order Blocks State ... + * + * @return ( bool ) + */ + bool AllowDrawBearishOrderBlocks() + { + return mAllowDrawBearishOrderBlocks; + } + + /** + * Set Draw Bearish Order Blocks State ... + * + * @param value: Boolean ... + */ + void AllowDrawBearishOrderBlocks(bool value) + { + mAllowDrawBearishOrderBlocks = value; + } + + /** + * Get Bearish Order Block Width ... + * + * @return ( int ) + */ + int BearishOrderBlockWidth() + { + return mBearishOrderBlockWidth; + } + + /** + * Set Bearish Order Block Width ... + * + * @param value: Integer ... + */ + void BearishOrderBlockWidth(int value) + { + // + if (value < 1) + { + value = 1; + } + + // + mBearishOrderBlockWidth = value; + } + + /** + * Get Bearish Order Block Color ... + * + * @return ( color ) + */ + color BearishOrderBlockColor() + { + return mBearishOrderBlockColor; + } + + /** + * Set Bearish Order Block Color ... + * + * @param value: Color ... + */ + void BearishOrderBlockColor(color value) + { + mBearishOrderBlockColor = value; + } + + /** + * Get Bearish Order Block Style ... + * + * @return ( ENUM_LINE_STYLE ) + */ + ENUM_LINE_STYLE BearishOrderBlockStyle() + { + return mBearishOrderBlockStyle; + } + + /** + * Set Bearish Order Block Style ... + * + * @param value: ENUM_LINE_STYLE member ... + */ + void BearishOrderBlockStyle(ENUM_LINE_STYLE value) + { + mBearishOrderBlockStyle = value; + } + + /** + * Get Minimum Required Same Bars for Bearish Order Blocks ... + * + * @return ( int ) + */ + int RequiredBarsForBearishOrderBlock() + { + return mRequiredBarsForBearishOrderBlock; + } + + /** + * Set Minimum Required Same Bars for Bearish Order Blocks ... + * + * @param value: Integer ... + */ + void RequiredBarsForBearishOrderBlock(int value) + { + // + if (value < 3) + { + value = 3; + } + + // + mRequiredBarsForBearishOrderBlock = value; + } + + // + // Fair Value Gaps ... + + // + // Bullis FVGs ... + + /** + * Get Detect Bullish Fair Value Gaps State ... + * + * @return ( bool ) + */ + bool AllowBullishFVGs() + { + return mAllowBullishFVGs; + } + + /** + * Set Detect Bullish Fair Value Gaps State ... + * + * @param value: Boolean ... + */ + void AllowBullishFVGs(bool value) + { + mAllowBullishFVGs = value; + } + + /** + * Get Draw Bullish Fair Value Gaps ... + * + * @return ( bool ) + */ + bool AllowDrawBullishFVGs() + { + return mAllowDrawBullishFVGs; + } + + /** + * Set Draw Bullish Fair Value Gaps ... + * + * @param value: Boolean ... + */ + void AllowDrawBullishFVGs(bool value) + { + mAllowDrawBullishFVGs = value; + } + + /** + * Get Bullish FVG Force Middle Bar Check ... + * + * @return ( bool ) + */ + bool BullishFVGForceMiddleBarCheck() + { + return mBullishFVGForceMiddleBarCheck; + } + + /** + * Set Bullish FVG Force Middle Bar Check ... + * + * @param value: Boolean ... + */ + void BullishFVGForceMiddleBarCheck(bool value) + { + mBullishFVGForceMiddleBarCheck = value; + } + + /** + * Get Bullish FVG Force Check Last Bar Direction ... + * + * @return ( bool ) + */ + bool BullishFVGForceCheckLastBarDirection() + { + return mBullishFVGForceCheckLastBarDirection; + } + + /** + * Set Bullish FVG Force Check Last Bar Direction ... + * + * @param value: Boolean ... + */ + void BullishFVGForceCheckLastBarDirection(bool value) + { + mBullishFVGForceCheckLastBarDirection = value; + } + + /** + * Get Bullish FVG Width ... + * + * @return ( int ) + */ + int BullishFVGWidth() + { + return mBullishFVGWidth; + } + + /** + * Set Bullish FVG Width ... + * + * @param value: Integer ... + */ + void BullishFVGWidth(int value) + { + // + if (value < 1) + { + value = 1; + } + + // + mBullishFVGWidth = value; + } + + /** + * Get Bullish FVG Color ... + * + * @return ( color ) + */ + color BullishFVGColor() + { + return mBullishFVGColor; + } + + /** + * Set Bullish FVG Color ... + * + * @param value: Color ... + */ + void BullishFVGColor(color value) + { + mBullishFVGColor = value; + } + + /** + * Get Bullish FVG Style ... + * + * @return ( ENUM_LINE_STYLE ) + */ + ENUM_LINE_STYLE BullishFVGStyle() + { + return mBullishFVGStyle; + } + + /** + * Set Bullish FVG Style ... + * + * @param value: ENUM_LINE_STYLE member ... + */ + void BullishFVGStyle(ENUM_LINE_STYLE value) + { + mBullishFVGStyle = value; + } + + // + // Bullis FVGs ... + + /** + * Get Detect Bearish Fair Value Gaps State ... + * + * @return ( bool ) + */ + bool AllowBearishFVGs() + { + return mAllowBearishFVGs; + } + + /** + * Set Detect Bearish Fair Value Gaps State ... + * + * @param value: Boolean ... + */ + void AllowBearishFVGs(bool value) + { + mAllowBearishFVGs = value; + } + + /** + * Get Draw Bearish Fair Value Gaps ... + * + * @return ( bool ) + */ + bool AllowDrawBearishFVGs() + { + return mAllowDrawBearishFVGs; + } + + /** + * Set Draw Bearish Fair Value Gaps ... + * + * @param value: Boolean ... + */ + void AllowDrawBearishFVGs(bool value) + { + mAllowDrawBearishFVGs = value; + } + + /** + * Get Bearish FVG Force Middle Bar Check ... + * + * @return ( bool ) + */ + bool BearishFVGForceMiddleBarCheck() + { + return mBearishFVGForceMiddleBarCheck; + } + + /** + * Set Bearish FVG Force Middle Bar Check ... + * + * @param value: Boolean ... + */ + void BearishFVGForceMiddleBarCheck(bool value) + { + mBearishFVGForceMiddleBarCheck = value; + } + + /** + * Get Bearish FVG Force Check Last Bar Direction ... + * + * @return ( bool ) + */ + bool BearishFVGForceCheckLastBarDirection() + { + return mBearishFVGForceCheckLastBarDirection; + } + + /** + * Set Bearish FVG Force Check Last Bar Direction ... + * + * @param value: Boolean ... + */ + void BearishFVGForceCheckLastBarDirection(bool value) + { + mBearishFVGForceCheckLastBarDirection = value; + } + + /** + * Get Bearish FVG Width ... + * + * @return ( int ) + */ + int BearishFVGWidth() + { + return mBearishFVGWidth; + } + + /** + * Set Bearish FVG Width ... + * + * @param value: Integer ... + */ + void BearishFVGWidth(int value) + { + // + if (value < 1) + { + value = 1; + } + + // + mBearishFVGWidth = value; + } + + /** + * Get Bearish FVG Color ... + * + * @return ( color ) + */ + color BearishFVGColor() + { + return mBearishFVGColor; + } + + /** + * Set Bearish FVG Color ... + * + * @param value: Color ... + */ + void BearishFVGColor(color value) + { + mBearishFVGColor = value; + } + + /** + * Get Bearish FVG Style ... + * + * @return ( ENUM_LINE_STYLE ) + */ + ENUM_LINE_STYLE BearishFVGStyle() + { + return mBearishFVGStyle; + } + + /** + * Set Bearish FVG Style ... + * + * @param value: ENUM_LINE_STYLE member ... + */ + void BearishFVGStyle(ENUM_LINE_STYLE value) + { + mBearishFVGStyle = value; + } + + // + // Actions ... + + /** + * Initialize POI Detector ... + */ + void Init() + { + // + // Detect Previous POI(s) ... + DetectRequiredPOIs(); + } + + /** + * Update POI(s) ... + * + * @param state: an Array Refrence of ENUM_XPOI_EVENTS members ... + */ + int Update( + ENUM_XPOI_EVENTS &state[] // + ) + { + // + int result = 0; + + // + Clean(state); + + // + // Check Bar Tracker if Waits ... + if (!mBarTracker.IsNewBar()) + { + return result; + } + + // + int zIndex = 0; + int cIndex = zIndex + 1; + int pIndex = cIndex + 1; + + // + datetime cTime = TimeCurrent(); + + // + XOHCL zBar; + bool isInited = zBar.Init( + mSymbol, + mPeriod, + zIndex // + ); + if (!isInited) + { + return result; + } + + // + XOHCL cBar; + isInited = cBar.Init( + mSymbol, + mPeriod, + cIndex // + ); + if (!isInited) + { + return result; + } + + // + XOHCL pBar; + isInited = pBar.Init( + mSymbol, + mPeriod, + pIndex // + ); + if (!isInited) + { + return result; + } + + // + XOHCL zDayBar; + isInited = zDayBar.Init( + mSymbol, + PERIOD_D1, + zIndex // + ); + if (!isInited) + { + return result; + } + + // + // Trading Days ... + + // + bool allowTradingDays = AllowTradingDays(); + int tradingDaysCount = ArraySize(mTradingDays); + if (allowTradingDays) + { + // + int tradingDayIDX = HasTradeDay(zDayBar.time); + if (IsValidIndex(tradingDayIDX)) + { + // + if (zBar.time == mTradingDays[tradingDayIDX].to) + { + // + ENUM_XPOI_EVENTS event = X_TRADE_DAY_LAST_BAR; + Add( + event, + state // + ); + OnTradingDayEvent(event); + NotifyTradingDayEventListeners(event); + } + } + else + { + // + // there isn't any Trading Day ... + // create one ... + + // + XTradeDay tradeDay; + tradeDay.from = zDayBar.time; + tradeDay.to = zDayBar.GetLastBarTimeOfPeriod(mPeriod); + + // + AddRef( + tradeDay, + mTradingDays // + ); + + // + DrawTradingDays(); + + // + // Notfy Day Started ... + if (zBar.time == zDayBar.time) + { + // + Add( + X_TRADE_DAY_FIRST_BAR, + state // + ); + OnTradingDayEvent(X_TRADE_DAY_FIRST_BAR); + NotifyTradingDayEventListeners(X_TRADE_DAY_FIRST_BAR); + } + } + } + + // + // Market Session ... + + // + bool allowMarketSessions = AllowMarketSessions(); + int marketSessionsCount = ArraySize(mMarketSessions); + if (allowMarketSessions) + { + // + int sessionsCount = ArraySize(mSessions); + bool isSessionFound = false; + if (IsValidSize(sessionsCount)) + { + // + for (int i = 0; i < sessionsCount; i++) + { + // + XSession iSession = mSessions[i]; + int marketSessionIDX = HasMarketSessionByStartTime( + iSession.session, + zBar.time // + ); + + // + if (!IsValidIndex(marketSessionIDX)) + { + // + datetime zTimeGMT = GetUTCTime(zBar.time); + string zTimeString = GetTimeString(zTimeGMT); + + // + bool isStarted = iSession.start == zTimeString; + + // + if (isStarted) + { + // + XMarketSession iMarketSession; + iMarketSession.session = iSession.session; + iMarketSession.from = zBar.time; + + // + int iSessionWorkingHoure = SessionOpenHours(); + int iSessionWorkingSeconds = iSessionWorkingHoure * 60 * 60; + iMarketSession.to = (datetime)((int)zBar.time + iSessionWorkingSeconds); + + // + isSessionFound = AddRef( + iMarketSession, + mMarketSessions // + ); + + // + marketSessionsCount = ArraySize(mMarketSessions); + + // + DrawMarketSessions(); + + // + Add( + X_SESSION_FIRST_BAR, + state // + ); + OnMarketSessionEvent( + iMarketSession.session, + X_SESSION_FIRST_BAR // + ); + NotifyMarketSessionEventListeners( + iMarketSession.session, + X_SESSION_FIRST_BAR // + ); + } + } + + // + // Check End Time for Last Bar ... + for (int i = 0; i < marketSessionsCount; i++) + { + // + XMarketSession iMarketSession = mMarketSessions[i]; + + // + // Calculate Last Bar Time ... + datetime endTime = iMarketSession.to; + datetime lastBarTime = (datetime)((int)endTime - PeriodSeconds(mPeriod)); + if (zBar.time == lastBarTime) + { + // + ENUM_XPOI_EVENTS event = X_SESSION_LAST_BAR; + Add( + event, + state // + ); + OnMarketSessionEvent( + iMarketSession.session, + event // + ); + NotifyMarketSessionEventListeners( + iMarketSession.session, + event // + ); + } + } + } + } + } + + // + // Swing Highs and Lows ... + + // + // Swing Highs ... + + // + bool allowSwingHighs = AllowSwingHighs(); + int swingHighsCount = ArraySize(mSwingHighs); + if (allowSwingHighs) + { + // + bool isSingHigh = pBar.IsSimpleSwingHigh(SwingHighThreshold()); + if (isSingHigh) + { + // + bool isAdded = AddBar( + X_POI_SWING_HIGH, + pBar, + mSwingHighs // + ); + + // + if (isAdded) + { + // + swingHighsCount = ArraySize(mSwingHighs); + DrawSwingHighs(); + + // + ENUM_XPOI_EVENTS event = X_SWING_HIGH_DETECTED; + Add( + event, + state // + ); + OnSwingHighEvent(event, pBar); + NotifySwingHighEventListeners(event, pBar); + } + } + } + + // + // Swing Lows ... + + // + bool allowSwingLows = AllowSwingLows(); + int swingLowsCount = ArraySize(mSwingLows); + if (allowSwingLows) + { + // + bool isSingLow = pBar.IsSimpleSwingLow(SwingLowThreshold()); + if (isSingLow) + { + // + bool isAdded = AddBar( + X_POI_SWING_LOW, + pBar, + mSwingLows // + ); + + // + if (isAdded) + { + // + swingLowsCount = ArraySize(mSwingLows); + DrawSwingLows(); + + // + ENUM_XPOI_EVENTS event = X_SWING_LOW_DETECTED; + Add( + event, + state // + ); + OnSwingLowEvent(event, pBar); + NotifySwingLowEventListeners(event, pBar); + } + } + } + + // + // Momentum Bars ... + + // + bool allowMomentumBars = AllowMomentumBars(); + int momentumBarsCount = ArraySize(mMomentumBars); + if (allowMomentumBars) + { + // + bool isStrongBar = cBar.IsStrong(MomentumBarPercent()); + bool isSharpBullish = cBar.IsSharpBullish( + MomentumBarLoopBack(), + MomentumBarSharpRatio() // + ); + bool isSharpBearish = cBar.IsSharpBearish( + MomentumBarLoopBack(), + MomentumBarSharpRatio() // + ); + bool isMomentumBar = + isStrongBar && + (isSharpBearish || + isSharpBullish); + if (isMomentumBar) + { + // + bool isAdded = AddBar( + X_POI_MOMENTUM_BAR, + cBar, + mMomentumBars // + ); + + // + if (isAdded) + { + // + momentumBarsCount = ArraySize(mMomentumBars); + DrawMomentumBars(); + + // + ENUM_XPOI_EVENTS event = X_MOMENTUM_BAR_DETECTED; + Add( + event, + state // + ); + OnMomentumBarEvent(event, cBar); + NotifyMomentumBarEventListeners(event, cBar); + } + } + } + + // + // Rejection Bars ... + + // + bool allowRejectionBars = AllowRejectionBars(); + int rejectionBarsCount = ArraySize(mRejectionBars); + if (allowRejectionBars) + { + // + int rejectionBarLoopBackBarIndex = RejectionBarLoopBack() + 1; + XOHCL iRBar; + bool isIRBarInited = iRBar.Init( + mSymbol, + mPeriod, + rejectionBarLoopBackBarIndex // + ); + if (isIRBarInited) + { + // + bool isRejectionBar = + iRBar.HasStrongLowShadow( + RejectionBarPercent(), + RejectionBarLoopBack(), + RejectionBarSharpRatio() // + ) || + iRBar.HasStrongHighShadow( + RejectionBarPercent(), + RejectionBarLoopBack(), + RejectionBarSharpRatio() // + ); + if (isRejectionBar) + { + // + bool isAdded = AddBar( + X_POI_REJECTION_BAR, + iRBar, + mRejectionBars // + ); + + // + if (isAdded) + { + // + rejectionBarsCount = ArraySize(mRejectionBars); + DrawRejectionBars(); + + // + ENUM_XPOI_EVENTS event = X_REJECTION_BAR_DETECTED; + Add( + event, + state // + ); + OnRejectionBarEvent(event, iRBar); + NotifyRejectionBarEventListeners(event, iRBar); + } + } + } + } + + // + // Support and Resistance Zones ... + + // + // Support Zones ... + + // + bool allowSupportZones = AllowSupportZones(); + int supportZonesCount = ArraySize(mSupportZones); + if (allowSupportZones) + { + // + XOHCL support; + bool hasSupport = cBar.HasSupport( + support, + SupportZonePriceType(), + SupportZoneLoopBack() // + ); + if (hasSupport) + { + // + bool isAdded = AddBar( + X_POI_SUPPORT_ZONE, + support, + mSupportZones // + ); + + // + if (isAdded) + { + // + supportZonesCount = ArraySize(mSupportZones); + DrawSupportZones(); + + // + ENUM_XPOI_EVENTS event = X_SUPPORT_ZONE_DETECTED; + Add( + event, + state // + ); + OnSupportZoneEvent(event, support); + NotifySupportZoneEventListeners(event, support); + } + } + } + + // + // Resistance Zone ... + + // + bool allowResistanceZones = AllowResistanceZones(); + int resistanceZonesCount = ArraySize(mResistanceZones); + if (allowResistanceZones) + { + // + XOHCL resistance; + bool hasResistance = cBar.HasResistance( + resistance, + ResistanceZonePriceType(), + ResistanceZoneLoopBack() // + ); + if (hasResistance) + { + // + bool isAdded = AddBar( + X_POI_RESISTANCE_ZONE, + resistance, + mResistanceZones // + ); + + // + if (isAdded) + { + // + resistanceZonesCount = ArraySize(mResistanceZones); + DrawResistanceZones(); + + // + ENUM_XPOI_EVENTS event = X_RESISTANCE_ZONE_DETECTED; + Add( + event, + state // + ); + OnResistanceZoneEvent(event, resistance); + NotifyResistanceZoneEventListeners(event, resistance); + } + } + } + + // + // Supply and Demand Zones ... + + // + // Supply Zones ... + + // + bool allowSupplyZones = AllowSupplyZones(); + int supplyZonesCount = ArraySize(mSupplyZones); + if (allowSupplyZones) + { + // + datetime endTime = cBar.time; + XOHCL cSupplyBar; + bool isSupplyBarInited = cSupplyBar.Init( + mSymbol, + SupplyZonePeriod(), + 0 // + ); + if (isSupplyBarInited) + { + // + datetime lastSupplyBarTime = cSupplyBar + .GetLastBarTimeOfPeriod(mPeriod); + if (zBar.time == lastSupplyBarTime) + { + // + datetime startTime = cSupplyBar.time; + int cSupplyZonePeriodIndex = iBarShift( + mSymbol, + mPeriod, + cSupplyBar.time // + ); + + // + // Find Swings ... + XOHCL swings[]; + for (int i = 0; i < cSupplyZonePeriodIndex; i++) + { + // + XOHCL iBar; + bool isIBarInited = iBar.Init( + mSymbol, + mPeriod, + i // + ); + if (!isIBarInited) + { + continue; + } + + // + // Check is Bar Swing or not ... + bool isSwing = iBar.IsSimpleSwingHigh(); + if (!isSwing) + { + continue; + } + + // + AddRef( + iBar, + swings // + ); + } + + // + // Select Max Swing for Supply Zone ... + XOHCL selectedSwing; + int swingsCount = ArraySize(swings); + if (IsValidSize(swingsCount)) + { + // + for (int i = 0; i < swingsCount; i++) + { + // + XOHCL iSwing = swings[i]; + if (!selectedSwing.IsValid() || + selectedSwing.high < iSwing.high) + { + selectedSwing = iSwing; + } + } + } + + // + // Check Swing ... + if (selectedSwing.IsValid()) + { + // + XZone zone; + bool isInited = zone.Init( + selectedSwing.high, + selectedSwing.low, + ToString(X_POI_SUPPLY_ZONE) + "_" + ToString(SupplyZonePeriod()), + startTime, + endTime // + ); + if (isInited) + { + // + int zoneIDX = FindZoneIndex( + zone, + mSupplyZones // + ); + + // + if (!IsValidIndex(zoneIDX)) + { + // + AddRef( + zone, + mSupplyZones // + ); + + // + supplyZonesCount = ArraySize(mSupplyZones); + DrawSupplyZones(); + + // + ENUM_XPOI_EVENTS event = X_SUPPLY_ZONE_DETECTED; + Add( + event, + state // + ); + OnSupplyZoneEvent(event, zone); + NotifySupplyZoneEventListeners(event, zone); + } + } + } + } + } + } + + // + // Demand Zones ... + + // + bool allowDemandZones = AllowDemandZones(); + int demandZonesCount = ArraySize(mDemandZones); + if (allowDemandZones) + { + // + datetime endTime = cBar.time; + XOHCL cDemandBar; + bool isDemandBarInited = cDemandBar.Init( + mSymbol, + DemandZonePeriod(), + 0 // + ); + if (isDemandBarInited) + { + // + datetime lastDemandBarTime = cDemandBar + .GetLastBarTimeOfPeriod(mPeriod); + if (zBar.time == lastDemandBarTime) + { + // + datetime startTime = cDemandBar.time; + int cDemandZonePeriodIndex = iBarShift( + mSymbol, + mPeriod, + cDemandBar.time // + ); + + // + // Find Swings ... + XOHCL swings[]; + for (int i = 0; i < cDemandZonePeriodIndex; i++) + { + // + XOHCL iBar; + bool isIBarInited = iBar.Init( + mSymbol, + mPeriod, + i // + ); + if (!isIBarInited) + { + continue; + } + + // + // Check is Bar Swing or not ... + bool isSwing = iBar.IsSimpleSwingLow(); + if (!isSwing) + { + continue; + } + + // + AddRef( + iBar, + swings // + ); + } + + // + // Select Max Swing for Supply Zone ... + XOHCL selectedSwing; + int swingsCount = ArraySize(swings); + if (IsValidSize(swingsCount)) + { + // + for (int i = 0; i < swingsCount; i++) + { + // + XOHCL iSwing = swings[i]; + if (!selectedSwing.IsValid() || + selectedSwing.low > iSwing.low) + { + selectedSwing = iSwing; + } + } + } + + // + // Check Swing ... + if (selectedSwing.IsValid()) + { + // + XZone zone; + bool isInited = zone.Init( + selectedSwing.high, + selectedSwing.low, + ToString(X_POI_DEMAND_ZONE) + "_" + ToString(SupplyZonePeriod()), + startTime, + endTime // + ); + if (isInited) + { + // + int zoneIDX = FindZoneIndex( + zone, + mDemandZones // + ); + + // + if (!IsValidIndex(zoneIDX)) + { + // + AddRef( + zone, + mDemandZones // + ); + + // + demandZonesCount = ArraySize(mDemandZones); + DrawDemandZones(); + + // + ENUM_XPOI_EVENTS event = X_DEMAND_ZONE_DETECTED; + Add( + event, + state // + ); + OnDemandZoneEvent(event, zone); + NotifyDemandZoneEventListeners(event, zone); + } + } + } + } + } + } + + // + // Order Blocks ... + + // + // Bullish Order Blocks ... + + // + bool allowBullishOrderBlocks = AllowBullishOrderBlocks(); + int bullishOrderBlocksCount = ArraySize(mBullishOrderBlocks); + if (allowBullishOrderBlocks) + { + // + XOHCL bullOB; + bool hasBullOB = cBar.HasBullishOrderBlock( + bullOB, + RequiredBarsForBullishOrderBlock() // + ); + if (hasBullOB) + { + // + XZone obZone; + bool isAdded = AddZone( + obZone, // Dest ... + bullOB, + cBar.time, + X_POI_BULLISH_ORDERBLOCK, + mBullishOrderBlocks // + ); + if (isAdded) + { + // + bullishOrderBlocksCount = ArraySize(mBullishOrderBlocks); + DrawBullishOrderBlocks(); + + // + ENUM_XPOI_EVENTS event = X_BULLISH_ORDERBLOCK_DETECTED; + Add( + event, + state // + ); + OnBullishOrderBlockEvent(event, obZone); + NotifyBullishOrderBlockEventListeners(event, obZone); + } + } + } + + // + // Bearish Order Blocks ... + + // + bool allowBearishOrderBlocks = AllowBearishOrderBlocks(); + int bearishOrderBlocksCount = ArraySize(mBearishOrderBlocks); + if (allowBearishOrderBlocks) + { + // + XOHCL bearOB; + bool hasBearOB = cBar.HasBearishOrderBlock( + bearOB, + RequiredBarsForBearishOrderBlock() // + ); + if (hasBearOB) + { + // + XZone zone; + bool isAdded = AddZone( + zone, // + bearOB, + cBar.time, + X_POI_BEARISH_ORDERBLOCK, + mBearishOrderBlocks // + ); + if (isAdded) + { + // + bullishOrderBlocksCount = ArraySize(mBearishOrderBlocks); + DrawBearishOrderBlocks(); + + // + ENUM_XPOI_EVENTS event = X_BEARISH_ORDERBLOCK_DETECTED; + Add( + event, + state // + ); + OnBullishOrderBlockEvent(event, zone); + NotifyBullishOrderBlockEventListeners(event, zone); + } + } + } + + // + // Fair Value Gaps ... + double upper; + double lower; + datetime start; + datetime end; + + // + // Bullish FVGs ... + bool allowBullishFVGs = AllowBullishFVGs(); + int bullishFVGsCount = ArraySize(mBullishFVGs); + if (allowBullishFVGs) + { + // + bool hasBullishFVG = cBar.HasBullishFVG( + upper, + lower, + start, + end, + BullishFVGForceMiddleBarCheck(), + BullishFVGForceCheckLastBarDirection() // + ); + if (hasBullishFVG) + { + // + XZone zone; + bool isAdded = AddZone( + zone, + upper, + lower, + start, + end, + X_POI_BULLISH_FVG, + mBullishFVGs // + ); + if (isAdded) + { + // + bullishFVGsCount = ArraySize(mBullishFVGs); + DrawBullishFVGs(); + + // + ENUM_XPOI_EVENTS event = X_BULLISH_FVG_DETECTED; + Add( + event, + state // + ); + OnBullishFVGEvent(event, zone); + NotifyBullishFVGEventListeners(event, zone); + } + } + } + + // + // Bearish FVGs ... + bool allowBearishFVGs = AllowBearishFVGs(); + int bearishFVGsCount = ArraySize(mBearishFVGs); + if (allowBearishFVGs) + { + // + bool hasBearishFVG = cBar.HasBearishFVG( + upper, + lower, + start, + end, + BearishFVGForceMiddleBarCheck(), + BearishFVGForceCheckLastBarDirection() // + ); + if (hasBearishFVG) + { + // + XZone zone; + bool isAdded = AddZone( + zone, + upper, + lower, + start, + end, + X_POI_BEARISH_FVG, + mBearishFVGs // + ); + if (isAdded) + { + // + bearishFVGsCount = ArraySize(mBearishFVGs); + DrawBearishFVGs(); + + // + ENUM_XPOI_EVENTS event = X_BEARISH_FVG_DETECTED; + Add( + event, + state // + ); + OnBearishFVGEvent(event, zone); + NotifyBearishFVGEventListeners(event, zone); + } + } + } + + // + // ... + + // + CleanupUnusedPOIs(); + + // + mBarTracker.Waits(); + + // + result = ArraySize(state); + + // + return result; + } + + /** + * Enable All POIs Detection ... + */ + void EnablePOIs() + { + ChangePOIsState(true); + } + + /** + * Disable All POIs Detection ... + */ + void DisablePOIs() + { + ChangePOIsState(false); + } + + /** + * Set All POIs Detection States ... + * + * @param state: Argument 1 + */ + void ChangePOIsState(bool state) + { + // + AllowSwingLows(state); + AllowSwingHighs(state); + AllowTradingDays(state); + AllowSupplyZones(state); + AllowDemandZones(state); + AllowBullishFVGs(state); + AllowBearishFVGs(state); + AllowMomentumBars(state); + AllowSupportZones(state); + AllowRejectionBars(state); + AllowMarketSessions(state); + AllowResistanceZones(state); + AllowBullishOrderBlocks(state); + AllowBearishOrderBlocks(state); + } + + /** + * Enable Draw All POI(s) ... + */ + void EnableDrawPOIs() + { + ChangePOIsDrawState(true); + } + + /** + * Disable Draw All POI(s) ... + */ + void DisableDrawPOIs() + { + ChangePOIsDrawState(false); + } + + /** + * Set Drawing State of all POIs ... + * + * @param state: Boolean ... + */ + void ChangePOIsDrawState(bool state) + { + // + AllowDrawSwingLows(state); + AllowDrawSwingHighs(state); + AllowDrawTradingDays(state); + AllowDrawSupplyZones(state); + AllowDrawBullishFVGs(state); + AllowDrawBearishFVGs(state); + AllowDrawDemandZones(state); + AllowDrawSupportZones(state); + AllowDrawMomentumBars(state); + AllowDrawRejectionBars(state); + AllowDrawMarketSessions(state); + AllowDrawResistanceZones(state); + AllowDrawBullishOrderBlocks(state); + AllowDrawBearishOrderBlocks(state); + + // + // Sessions ... + int sessionsCount = ArraySize(mSessions); + if (IsValidSize(sessionsCount)) + { + // + for (int i = 0; i < sessionsCount; i++) + { + // + mSessions[i].allowDraw = state; + } + } + } + + // + // Retrievers ... + + /** + * Get Current State of POIs ... + * + * @param state: XPOIState instance ... + */ + void GetState( + XPOIState &state) + { + // + state.Clean(); + + // + state.symbol = mSymbol; + state.period = mPeriod; + state.reportedAt = TimeCurrent(); + + // + state.FillTradingDays(mTradingDays); + state.FillMarketSessions(mMarketSessions); + + // + state.FillMomentumBars(mMomentumBars); + state.FillRejectionBars(mRejectionBars); + + // + state.FillSwingHighs(mSwingHighs); + state.FillSwingLows(mSwingLows); + + // + state.FillSupportZones(mSupportZones); + state.FillResistanceZones(mResistanceZones); + + // + state.FillSupplyZones(mSupplyZones); + state.FillDemandZones(mDemandZones); + + // + state.FillBullishOrderBlocks(mBullishOrderBlocks); + state.FillBearishOrderBlocks(mBearishOrderBlocks); + + // + state.FillBullishFVGs(mBullishFVGs); + state.FillBearishFVGs(mBearishFVGs); + } + + // + // Virtual Actions ... + + /** + * Apply Default Configurations ... + */ + virtual void ApplyDefaultConfig() + { + // + // Common ... + + // + ChartID(0); + Window(0); + + // + MaxNumberOfPOIs(10); + MaxNumberOfRequiredPOIs(2); + + // + EnablePOIs(); + EnableDrawPOIs(); + + // + // Trading Days ... + TradingDaysStartColor(clrYellow); + TradingDaysStartStyle(STYLE_DASHDOT); + TradingDaysEndColor(clrGray); + TradingDaysEndStyle(STYLE_DASHDOT); + + // + // Sessions ... + + // + // SYDNEY ... + // Start: (UTC) 21:00 + // End: (UTC) 06:00 + XSession mSyndeySession; + mSyndeySession.Init( + X_SYDNEY, + "20:00", // Start ... + "05:00" // End Next Day ... + ); + mSyndeySession.startColor = clrFireBrick; + mSyndeySession.endColor = clrFireBrick; + mSyndeySession.allowDraw = true; + AddSession(mSyndeySession); + + // + // TOKYO ... + // Start: (UTC) 12:00 + // End: (UTC) 09:00 + XSession mTokyoSession; + mTokyoSession.Init( + X_TOKYO, + "00:00", // Start ... + "09:00" // End Next Day ... + ); + mTokyoSession.startColor = clrBlueViolet; + mTokyoSession.endColor = clrBlueViolet; + mTokyoSession.allowDraw = true; + AddSession(mTokyoSession); + + // + // LONDON ... + // Start: (UTC) 07:00 + // End: (UTC) 16:00 + XSession mLondonSession; + mLondonSession.Init( + X_LONDON, + "07:00", // Start ... + "16:00" // End ... + ); + mLondonSession.startColor = clrLime; + mLondonSession.endColor = clrLime; + mLondonSession.allowDraw = true; + AddSession(mLondonSession); + + // + // NEWYORK ... + // Start: (UTC) 13:00 + // End: (UTC) 22:00 + XSession mNewYorkSession; + mNewYorkSession.Init( + X_NEW_YORK, + "12:00", // Start ... + "21:00" // End ... + ); + mNewYorkSession.startColor = clrAqua; + mNewYorkSession.endColor = clrAqua; + mNewYorkSession.allowDraw = true; + AddSession(mNewYorkSession); + + // + SessionOpenHours(9); + + // + // Swing High and Low (s) ... + + // + // Swing Highs ... + SwingHighWidth(5); + SwingHighThreshold(3); + SwingHighArrowCode(108); + SwingHighColor(clrMagenta); + + // + // Swing Lows ... + SwingLowWidth(5); + SwingLowThreshold(3); + SwingLowArrowCode(108); + SwingLowColor(clrAqua); + + // + // Momentum Bars ... + MomentumBarPercent(55); + MomentumBarLoopBack(3); + MomentumBarSharpRatio(1.2); + MomentumBarWidth(5); + MomentumBarBullishArrowCode((char)225); + MomentumBarBearishArrowCode((char)226); + MomentumBarBullishColor(clrAqua); + MomentumBarBearishColor(clrMagenta); + + // + // Rejection Bars ... + RejectionBarPercent(55); + RejectionBarLoopBack(5); + RejectionBarSharpRatio(1.5); + RejectionBarWidth(5); + RejectionBarBullishArrowCode((char)217); + RejectionBarBearishArrowCode((char)218); + RejectionBarBullishColor(clrAqua); + RejectionBarBearishColor(clrMagenta); + + // + // Support and Resistance Zones ... + + // + // Support Zones ... + SupportZoneLoopBack(52); + SupportZoneWidth(1); + SupportZoneColor(clrLime); + SupportZoneStyle(STYLE_DOT); + SupportZonePriceType(X_PRICE_CLOSE); + + // + // Resistance Zones ... + ResistanceZoneLoopBack(52); + ResistanceZoneWidth(1); + ResistanceZoneColor(clrRed); + ResistanceZoneStyle(STYLE_DOT); + ResistanceZonePriceType(X_PRICE_CLOSE); + + // + // Supply and Deman Zones ... + + // + // Supply Zones ... + SupplyZoneWidth(1); + SupplyZoneColor(clrDarkRed); + SupplyZoneStyle(STYLE_DASH); + SupplyZonePeriod(GetHindMostPeriod(mPeriod)); + + // + // Demand Zones ... + DemandZoneWidth(1); + DemandZoneColor(clrDarkGreen); + DemandZoneStyle(STYLE_DASH); + DemandZonePeriod(GetHindMostPeriod(mPeriod)); + + // + // Order Blocks ... + + // + // Bullish Order Block ... + BullishOrderBlockWidth(1); + BullishOrderBlockColor(clrAqua); + BullishOrderBlockStyle(STYLE_DASHDOT); + RequiredBarsForBullishOrderBlock(3); + + // + // Bearish Order Block ... + BearishOrderBlockWidth(1); + BearishOrderBlockColor(clrMagenta); + BearishOrderBlockStyle(STYLE_DASHDOT); + RequiredBarsForBearishOrderBlock(3); + + // + // Fair Value Gaps ... + + // + // Bullish FVGs ... + BullishFVGWidth(1); + BullishFVGColor(clrAqua); + BullishFVGStyle(STYLE_DASHDOTDOT); + BullishFVGForceMiddleBarCheck(true); + BullishFVGForceCheckLastBarDirection(true); + + // + // Bearish FVGs ... + BearishFVGWidth(1); + BearishFVGColor(clrMagenta); + BearishFVGStyle(STYLE_DASHDOTDOT); + BearishFVGForceMiddleBarCheck(true); + BearishFVGForceCheckLastBarDirection(true); + + // + } + + // + // Session Configurations ... + + /** + * Add Sepcific Session to Supported Sessions ... + * + * @param session: XSession instance ... + */ + void AddSession(XSession &session) + { + // + if (!session.IsValid()) + { + return; + } + + // + AddRef( + session, + mSessions // + ); + } + + // + // Event Listeners ... + + // + // Trading Days ... + + /** + * Calls When new Trading Day Event Happens ... + * + * @param event: ENUM_XPOI_EVENTS member ... + */ + virtual void OnTradingDayEvent( + ENUM_XPOI_EVENTS event // + ) + { + } + + /** + * Register an Event Listener for New Trading Day Events ... + * + * @param listener: TXPOIEventHandler instance ... + */ + void AddTradingDayEventListener(TXPOIEventHandler listener) + { + // + Add( + listener, + mTradingDayEventListeners // + ); + } + + // + // Market Sessions ... + + /** + * Calls When new Market Session Event Happens ... + * + * @param session: ENUM_XSESSION member ... + * @param event: ENUM_XPOI_EVENTS member ... + */ + virtual void OnMarketSessionEvent( + ENUM_XSESSION session, + ENUM_XPOI_EVENTS event // + ) + { + } + + /** + * Register an Event Listener for New Market Session Events ... + * + * @param listener: TXSessionEventHandler instance ... + */ + void AddMarketSessionEventListener(TXSessionEventHandler listener) + { + // + Add( + listener, + mMarketSessionEventListeners // + ); + } + + // + // Swings ... + + // + // Swing Highs ... + + /** + * Calls When new Swing High Event ... + * + * @param event: ENUM_XPOI_EVENTS member ... + * @param bar: XOHCL instance ... + */ + virtual void OnSwingHighEvent( + ENUM_XPOI_EVENTS event, + XOHCL &bar // + ) + { + } + + /** + * Register an Event Listener for New Swing High Event ... + * + * @param listener: TXOHCLEventHandler instance ... + */ + void AddSwingHighEventListener(TXOHCLEventHandler listener) + { + // + Add( + listener, + mSwingHighEventListeners // + ); + } + + // + // Swing Lows ... + + /** + * Calls When new Swing Low Detected ... + * + * @param event: ENUM_XPOI_EVENTS member ... + * @param bar: XOHCL instance ... + */ + virtual void OnSwingLowEvent( + ENUM_XPOI_EVENTS event, + XOHCL &bar // + ) + { + } + + /** + * Register an Event Listener for New Swing Low Event ... + * + * @param listener: TXOHCLEventHandler instance ... + */ + void AddSwingLowEventListener(TXOHCLEventHandler listener) + { + // + Add( + listener, + mSwingLowEventListeners // + ); + } + + // + // Momentum Bar ... + + /** + * Calls When new Momentum Bar Event ... + * + * @param event: ENUM_XPOI_EVENTS member ... + * @param bar: XOHCL instance ... + */ + virtual void OnMomentumBarEvent( + ENUM_XPOI_EVENTS event, + XOHCL &bar // + ) + { + } + + /** + * Register an Event Listener for New Momentum Bar Event ... + * + * @param listener: TXOHCLEventHandler instance ... + */ + void AddMomentumBarEventListener(TXOHCLEventHandler listener) + { + // + Add( + listener, + mMomentumBarEventListeners // + ); + } + + // + // Rejection Bar ... + + /** + * Calls When new Rejection Bar Event ... + * + * @param event: ENUM_XPOI_EVENTS member ... + * @param bar: XOHCL instance ... + */ + virtual void OnRejectionBarEvent( + ENUM_XPOI_EVENTS event, + XOHCL &bar // + ) + { + } + + /** + * Register an Event Listener for New Rejection Bar Event ... + * + * @param listener: TXOHCLEventHandler instance ... + */ + void AddRejectionBarEventListener(TXOHCLEventHandler listener) + { + // + Add( + listener, + mRejectionBarEventListeners // + ); + } + + // + // Support and Resistance Zones ... + + // + // Support Zones ... + + /** + * Calls When new Support Zone Event ... + * + * @param event: ENUM_XPOI_EVENTS member ... + * @param bar: XOHCL instance ... + */ + virtual void OnSupportZoneEvent( + ENUM_XPOI_EVENTS event, + XOHCL &bar // + ) + { + } + + /** + * Register an Event Listener for New Support Zone Event ... + * + * @param listener: TXOHCLEventHandler instance ... + */ + void AddSupportZoneEventListener(TXOHCLEventHandler listener) + { + // + Add( + listener, + mSupportZoneEventListeners // + ); + } + + // + // Resistance Zones ... + + /** + * Calls When new Resistance Zone Event ... + * + * @param event: ENUM_XPOI_EVENTS member ... + * @param bar: XOHCL instance ... + */ + virtual void OnResistanceZoneEvent( + ENUM_XPOI_EVENTS event, + XOHCL &bar // + ) + { + } + + /** + * Register an Event Listener for New Resistance Zone Event ... + * + * @param listener: TXOHCLEventHandler instance ... + */ + void AddResistanceZoneEventListener(TXOHCLEventHandler listener) + { + // + Add( + listener, + mResistanceZoneEventListeners // + ); + } + + // + // Supply and Demand Zones ... + + // + // Supply Zones ... + + /** + * Calls When new Supply Zone Event ... + * + * @param event: ENUM_XPOI_EVENTS member ... + * @param zone: XZone instance ... + */ + virtual void OnSupplyZoneEvent( + ENUM_XPOI_EVENTS event, + XZone &zone // + ) + { + } + + /** + * Register an Event Listener for New Supply Zone Event ... + * + * @param listener: TXZoneEventHandler instance ... + */ + void AddSupplyZoneEventListener(TXZoneEventHandler listener) + { + // + Add( + listener, + mSupplyZoneEventListeners // + ); + } + + // + // Demand Zones ... + + /** + * Calls When new Demand Zone Event ... + * + * @param event: ENUM_XPOI_EVENTS member ... + * @param zone: XZone instance ... + */ + virtual void OnDemandZoneEvent( + ENUM_XPOI_EVENTS event, + XZone &zone // + ) + { + } + + /** + * Register an Event Listener for New Demand Zone Event ... + * + * @param listener: TXZoneEventHandler instance ... + */ + void AddDemandZoneEventListener(TXZoneEventHandler listener) + { + // + Add( + listener, + mDemandZoneEventListeners // + ); + } + + // + // Order Blocks ... + + // + // Bullish Order Blocks ... + + /** + * Calls When new Bullish Order Block Event ... + * + * @param event: ENUM_XPOI_EVENTS member ... + * @param zone: XZone instance ... + */ + virtual void OnBullishOrderBlockEvent( + ENUM_XPOI_EVENTS event, + XZone &zone // + ) + { + } + + /** + * Register an Event Listener for New Bullish Order Block Event ... + * + * @param listener: TXZoneEventHandler instance ... + */ + void AddBullishOrderBlockEventListener(TXZoneEventHandler listener) + { + // + Add( + listener, + mBullishOrderBlockEventListeners // + ); + } + + // + // Bearish Order Blocks ... + + /** + * Calls When new Bearish Order Block Event ... + * + * @param event: ENUM_XPOI_EVENTS member ... + * @param zone: XZone instance ... + */ + virtual void OnBearishOrderBlockEvent( + ENUM_XPOI_EVENTS event, + XZone &zone // + ) + { + } + + /** + * Register an Event Listener for New Bearish Order Block Event ... + * + * @param listener: TXZoneEventHandler instance ... + */ + void AddBearishOrderBlockEventListener(TXZoneEventHandler listener) + { + // + Add( + listener, + mBearishOrderBlockEventListeners // + ); + } + + // + // Fai Value Gaps ... + + // + // Bullish FVGs ... + + /** + * Calls When new Bullish FVG Event ... + * + * @param event: ENUM_XPOI_EVENTS member ... + * @param zone: XZone instance ... + */ + virtual void OnBullishFVGEvent( + ENUM_XPOI_EVENTS event, + XZone &zone // + ) + { + } + + /** + * Register an Event Listener for New Bullish FVG Event ... + * + * @param listener: TXZoneEventHandler instance ... + */ + void AddBullishFVGEventListener(TXZoneEventHandler listener) + { + // + Add( + listener, + mBullishFVGEventListeners // + ); + } + + // + // Bearish FVGs ... + + /** + * Calls When new Bearish FVG Event ... + * + * @param event: ENUM_XPOI_EVENTS member ... + * @param zone: XZone instance ... + */ + virtual void OnBearishFVGEvent( + ENUM_XPOI_EVENTS event, + XZone &zone // + ) + { + } + + /** + * Register an Event Listener for New Bearish FVG Event ... + * + * @param listener: TXZoneEventHandler instance ... + */ + void AddBearishFVGEventListener(TXZoneEventHandler listener) + { + // + Add( + listener, + mBearishFVGEventListeners // + ); + } + + // + protected: + // + + // + // Actions ... + + /** + * Lock ... + */ + void Lock() + { + mLock = true; + } + + /** + * Unlock ... + */ + void Unlock() + { + mLock = false; + } + + /** + * Detect Required POI(s) ... + * + * @param barIndex: Integer Start bar index ... + * 0 is Default ... + */ + void DetectRequiredPOIs(int barIndex = 0) + { + // + // Validate Reuired POI(s) ... + int requiredPOIs = MaxNumberOfRequiredPOIs(); + if (requiredPOIs <= 0) + { + return; + } + + // + Lock(); + + // + // Normalize Bar Index ... + if (barIndex < 0) + { + barIndex = 0; + } + + // + bool canContinue = true; + while (canContinue) + { + // + // Define Index of Bars ... + int zIndex = barIndex; + int cIndex = zIndex + 1; + + // + datetime cTime = TimeCurrent(); + + // + XOHCL zBar; + bool isRetrieved = mBarTracker.GetBar(zBar, zIndex); + if (!isRetrieved) + { + break; + } + + // + XOHCL cBar; + isRetrieved = mBarTracker.GetBar(cBar, cIndex); + if (!isRetrieved) + { + break; + } + + // + // Detect POI(s) based On Current Bar ... + + // + // Trade Days ... + bool allowTradingDays = AllowTradingDays(); + int daysCount = ArraySize(mTradingDays); + if (allowTradingDays && + daysCount < requiredPOIs) + { + // + XOHCL zDayBar; + isRetrieved = zDayBar.Init( + mSymbol, + PERIOD_D1, + zIndex // + ); + if (!isRetrieved) + { + break; + } + + // + XOHCL cDayBar; + isRetrieved = cDayBar.Init( + mSymbol, + PERIOD_D1, + cIndex // + ); + if (!isRetrieved) + { + break; + } + + // + XTradeDay tradeDay; + tradeDay.from = zDayBar.time; + + // + datetime lastBarTime = zDayBar.GetLastBarTimeOfPeriod(mPeriod); + tradeDay.to = lastBarTime; + + // + int idx = HasTradeDay(tradeDay.from); + if (!IsValidIndex(idx)) + { + // + AddRef( + tradeDay, + mTradingDays // + ); + + // + daysCount = ArraySize(mTradingDays); + } + } + + // + // Market Sessions ... + int sessionsCount = ArraySize(mSessions); + bool allowMarketSessions = AllowMarketSessions(); + int marketSessionsCount = ArraySize(mMarketSessions); + if (allowMarketSessions && + IsValidSize(sessionsCount) && + marketSessionsCount < sessionsCount * requiredPOIs) + { + // + for (int i = 0; i < sessionsCount; i++) + { + // + XSession iSession = mSessions[i]; + int iCount = CountMarketSessions(iSession.session); + if (iCount >= requiredPOIs) + { + continue; + } + + // + datetime zTimeGMT = GetUTCTime(zBar.time); + string zTimeString = GetTimeString(zTimeGMT); + + // + bool isStarted = iSession.start == zTimeString; + bool isEnded = iSession.end == zTimeString; + + // + // Detect Sessions Based on Time ... + // Since All Session Close Times Related to Current Date and + // in Required POIs we Moving Back from Current Date ... + if (isEnded && iCount < requiredPOIs) + { + // + // Check Market Session Doesnt Exists by End Time ... + int iIDX = HasMarketSessionByEndTime( + iSession.session, + zBar.time // + ); + if (!IsValidIndex(iIDX)) + { + // + XMarketSession iMarketSession; + iMarketSession.session = iSession.session; + iMarketSession.to = zBar.time; + + // + int iSessionWorkingHoure = SessionOpenHours(); + int iSessionWorkingSeconds = iSessionWorkingHoure * 60 * 60; + iMarketSession.from = (datetime)((int)zBar.time - iSessionWorkingSeconds); + + // + AddRef( + iMarketSession, + mMarketSessions // + ); + + // + marketSessionsCount = ArraySize(mMarketSessions); + } + } + + // + } + } + + // + // Swning Highs and Lows ... + + // + // Swing Highs ... + bool allowSwingHighs = AllowSwingHighs(); + int swingHighsCount = ArraySize(mSwingHighs); + if (allowSwingHighs && + swingHighsCount < requiredPOIs) + { + // + bool isSwingHigh = cBar.IsSimpleSwingHigh(SwingHighThreshold()); + if (isSwingHigh) + { + // + bool isAdded = AddBar( + X_POI_SWING_HIGH, + cBar, + mSwingHighs // + ); + + // + if (isAdded) + { + swingHighsCount = ArraySize(mSwingHighs); + } + } + } + + // + // Swing Lows ... + bool allowSwingLows = AllowSwingLows(); + int swingLowsCount = ArraySize(mSwingLows); + if (allowSwingLows && + swingLowsCount < requiredPOIs) + { + // + bool isSwingLow = cBar.IsSimpleSwingLow(SwingLowThreshold()); + if (isSwingLow) + { + // + bool isAdded = AddBar( + X_POI_SWING_LOW, + cBar, + mSwingLows // + ); + + // + if (isAdded) + { + swingLowsCount = ArraySize(mSwingLows); + } + } + } + + // + // Momentum Bars ... + bool allowMomentumBars = AllowMomentumBars(); + int momentumBarsCount = ArraySize(mMomentumBars); + if (allowMomentumBars && + momentumBarsCount < requiredPOIs) + { + // + bool isStrongBar = cBar.IsStrong(MomentumBarPercent()); + + // + // Bullish ... + bool isSharpBullish = cBar.IsSharpBullish( + MomentumBarLoopBack(), + MomentumBarSharpRatio() // + ); + + // + // Bearish ... + bool isSharpBearish = cBar.IsSharpBearish( + MomentumBarLoopBack(), + MomentumBarSharpRatio() // + ); + + // + bool isMomentumBar = + isStrongBar && + (isSharpBearish || + isSharpBullish); + if (isMomentumBar) + { + // + bool isAdded = AddBar( + X_POI_MOMENTUM_BAR, + cBar, + mMomentumBars // + ); + + // + if (isAdded) + { + momentumBarsCount = ArraySize(mMomentumBars); + } + } + } + + // + // Rejection Bars ... + bool allowRejectionBars = AllowRejectionBars(); + int rejectionBarsCount = ArraySize(mRejectionBars); + if (allowRejectionBars && + rejectionBarsCount < requiredPOIs) + { + // + bool isRejectionBar = + cBar.HasStrongLowShadow( + RejectionBarPercent(), + RejectionBarLoopBack(), + RejectionBarSharpRatio() // + ) || + cBar.HasStrongHighShadow( + RejectionBarPercent(), + RejectionBarLoopBack(), + RejectionBarSharpRatio() // + ); + + // + if (isRejectionBar) + { + // + bool isAdded = AddBar( + X_POI_REJECTION_BAR, + cBar, + mRejectionBars // + ); + + // + if (isAdded) + { + rejectionBarsCount = ArraySize(mRejectionBars); + } + } + } + + // + // Support nad Resistance Zones ... + + // + // Support Zones ... + bool allowSupportZones = AllowSupportZones(); + int supportZonesCount = ArraySize(mSupportZones); + if (allowSupportZones && + supportZonesCount < requiredPOIs) + { + // + XOHCL support; + bool hasSupport = cBar.HasSupport( + support, + SupportZonePriceType(), + SupportZoneLoopBack() // + ); + + // + if (hasSupport) + { + // + bool isAdded = AddBar( + X_POI_SUPPORT_ZONE, + support, + mSupportZones // + ); + + // + if (isAdded) + { + supportZonesCount = ArraySize(mSupportZones); + } + } + } + + // + // Resistance Zones ... + bool allowResistanceZones = AllowResistanceZones(); + int resistanceZonesCount = ArraySize(mResistanceZones); + if (allowResistanceZones && + resistanceZonesCount < requiredPOIs) + { + // + XOHCL resistance; + bool hasResistance = cBar.HasResistance( + resistance, + ResistanceZonePriceType(), + ResistanceZoneLoopBack() // + ); + + // + if (hasResistance) + { + // + bool isAdded = AddBar( + X_POI_RESISTANCE_ZONE, + resistance, + mResistanceZones // + ); + + // + if (isAdded) + { + resistanceZonesCount = ArraySize(mResistanceZones); + } + } + } + + // + // Supply and Demand Zones ... + + // + // Supply Zones ... + bool allowSupplyZones = AllowSupplyZones(); + int supplyZonesCount = ArraySize(mSupplyZones); + if (allowSupplyZones && + supplyZonesCount < requiredPOIs) + { + // + datetime endTime = cBar.time; + + // + datetime cSupplyZoneStartTime = iTime( + mSymbol, + SupplyZonePeriod(), + supplyZonesCount + 1 // + ); + datetime startTime = cSupplyZoneStartTime; + + // + int cSupplyZoneStartIndex = iBarShift( + mSymbol, + mPeriod, + cSupplyZoneStartTime // + ); + + // + XOHCL swings[]; + for (int i = 0; i < cSupplyZoneStartIndex; i++) + { + // + XOHCL iBar; + bool isIBarInited = iBar.Init( + mSymbol, + mPeriod, + i // + ); + if (!isIBarInited) + { + continue; + } + + // + // Check is Bar Swing or not ... + bool isSwing = iBar.IsSimpleSwingHigh(); + if (!isSwing) + { + continue; + } + + // + AddRef( + iBar, + swings // + ); + } + + // + XOHCL selectedSwing; + int swingsCount = ArraySize(swings); + if (IsValidSize(swingsCount)) + { + // + for (int i = 0; i < swingsCount; i++) + { + // + XOHCL iSwing = swings[i]; + if (!selectedSwing.IsValid() || + selectedSwing.high < iSwing.high) + { + selectedSwing = iSwing; + } + } + } + + // + if (selectedSwing.IsValid()) + { + // + XZone zone; + bool isInited = zone.Init( + selectedSwing.high, + selectedSwing.low, + ToString(X_POI_SUPPLY_ZONE) + "_" + ToString(SupplyZonePeriod()), + startTime, + endTime // + ); + if (isInited) + { + // + AddRef( + zone, + mSupplyZones // + ); + + // + supplyZonesCount = ArraySize(mSupplyZones); + } + } + } + + // + // Demand Zones ... + bool allowDemandZones = AllowDemandZones(); + int demandZonesCount = ArraySize(mDemandZones); + if (allowDemandZones && + demandZonesCount < requiredPOIs) + { + // + datetime endTime = cBar.time; + + // + datetime cDemandZoneStartTime = iTime( + mSymbol, + DemandZonePeriod(), + demandZonesCount + 1 // + ); + datetime startTime = cDemandZoneStartTime; + + // + int cDemandZoneStartIndex = iBarShift( + mSymbol, + mPeriod, + cDemandZoneStartTime // + ); + + // + XOHCL swings[]; + for (int i = 0; i < cDemandZoneStartIndex; i++) + { + // + XOHCL iBar; + bool isIBarInited = iBar.Init( + mSymbol, + mPeriod, + i // + ); + if (!isIBarInited) + { + continue; + } + + // + // Check is Bar Swing or not ... + bool isSwing = iBar.IsSimpleSwingLow(); + if (!isSwing) + { + continue; + } + + // + AddRef( + iBar, + swings // + ); + } + + // + XOHCL selectedSwing; + int swingsCount = ArraySize(swings); + if (IsValidSize(swingsCount)) + { + // + for (int i = 0; i < swingsCount; i++) + { + // + XOHCL iSwing = swings[i]; + if (!selectedSwing.IsValid() || + selectedSwing.low > iSwing.low) + { + selectedSwing = iSwing; + } + } + } + + // + if (selectedSwing.IsValid()) + { + // + XZone zone; + bool isInited = zone.Init( + selectedSwing.high, + selectedSwing.low, + ToString(X_POI_DEMAND_ZONE) + "_" + ToString(DemandZonePeriod()), + startTime, + endTime // + ); + if (isInited) + { + // + AddRef( + zone, + mDemandZones // + ); + + // + demandZonesCount = ArraySize(mDemandZones); + } + } + } + + // + // Order Blocks ... + + // + // Bullish Order Blocks ... + bool allowBullishOrderBlocks = AllowBullishOrderBlocks(); + int bullishOrderBlocksCount = ArraySize(mBullishOrderBlocks); + if (allowBullishOrderBlocks && + bullishOrderBlocksCount < requiredPOIs) + { + // + XOHCL ob; + bool hasOB = cBar.HasBullishOrderBlock( + ob, + RequiredBarsForBullishOrderBlock() // + ); + if (hasOB) + { + // + XZone zone; + bool isAdded = AddZone( + zone, // + ob, + cBar.time, + X_POI_BULLISH_ORDERBLOCK, + mBullishOrderBlocks // + ); + if (isAdded) + { + bullishOrderBlocksCount = ArraySize(mBullishOrderBlocks); + } + } + } + + // + // Bearish Order Blocks ... + bool allowBearishOrderBlocks = AllowBearishOrderBlocks(); + int bearishOrderBlocksCount = ArraySize(mBearishOrderBlocks); + if (allowBearishOrderBlocks && + bearishOrderBlocksCount < requiredPOIs) + { + // + XOHCL ob; + bool hasOB = cBar.HasBearishOrderBlock( + ob, + RequiredBarsForBearishOrderBlock() // + ); + if (hasOB) + { + // + XZone zone; + bool isAdded = AddZone( + zone, // + ob, + cBar.time, + X_POI_BEARISH_ORDERBLOCK, + mBearishOrderBlocks // + ); + if (isAdded) + { + bullishOrderBlocksCount = ArraySize(mBearishOrderBlocks); + } + } + } + + // + // Fair Value Gaps ... + + // + // Bullish FVGs ... + bool allowBullishFVGs = AllowBullishFVGs(); + int bullishFVGsCount = ArraySize(mBullishFVGs); + if (allowBullishFVGs && + bullishFVGsCount < requiredPOIs) + { + // + double upper; + double lower; + datetime start; + datetime end; + bool hasBullishFVG = cBar.HasBullishFVG( + upper, + lower, + start, + end, + BullishFVGForceMiddleBarCheck(), + BullishFVGForceCheckLastBarDirection() // + ); + if (hasBullishFVG) + { + // + XZone zone; + bool isAdded = AddZone( + zone, + upper, + lower, + start, + end, + X_POI_BULLISH_FVG, + mBullishFVGs // + ); + if (isAdded) + { + bullishFVGsCount = ArraySize(mBullishFVGs); + } + } + } + + // + // Bearish FVGs ... + bool allowBearishFVGs = AllowBearishFVGs(); + int bearishFVGsCount = ArraySize(mBearishFVGs); + if (allowBearishFVGs && + bearishFVGsCount < requiredPOIs) + { + // + double upper; + double lower; + datetime start; + datetime end; + bool hasBearishFVG = cBar.HasBearishFVG( + upper, + lower, + start, + end, + BearishFVGForceMiddleBarCheck(), + BearishFVGForceCheckLastBarDirection() // + ); + if (hasBearishFVG) + { + // + XZone zone; + bool isAdded = AddZone( + zone, + upper, + lower, + start, + end, + X_POI_BEARISH_FVG, + mBearishFVGs // + ); + if (isAdded) + { + bearishFVGsCount = ArraySize(mBearishFVGs); + } + } + } + + // + // Detect Required Conditions for Loop ... + // + + // + // Market Sessions Requirements ... + bool isNeedMoreMarketSessions = (!IsValidSize(sessionsCount) + ? true + : marketSessionsCount < (sessionsCount * requiredPOIs)); + canContinue = + // + // Trade Days ... + (allowTradingDays && + daysCount < requiredPOIs) || + // + // Market Sessions ... + (allowMarketSessions && + isNeedMoreMarketSessions) || + // + // Swing High and Low (s) ... + (allowSwingHighs && + swingHighsCount < requiredPOIs) || + (allowSwingLows && + swingLowsCount < requiredPOIs) || + // + // Momentum Bars ... + (allowMomentumBars && + momentumBarsCount < requiredPOIs) || + // + // Rejection Bars ... + (allowRejectionBars && + rejectionBarsCount < requiredPOIs) || + // + // Support and Resistance Zones ... + (allowSupportZones && + supportZonesCount < requiredPOIs) || + (allowResistanceZones && + resistanceZonesCount < requiredPOIs) || + // + // Supply and Demand Zones ... + (allowSupplyZones && + supplyZonesCount < requiredPOIs) || + (allowDemandZones && + demandZonesCount < requiredPOIs) || + // + // Order Blocks ... + (allowBullishOrderBlocks && + bullishOrderBlocksCount < requiredPOIs) || + (allowBearishOrderBlocks && + bearishOrderBlocksCount < requiredPOIs) || + // + // Fair Value Gaps ... + (allowBullishFVGs && + bullishFVGsCount < requiredPOIs) || + (allowBearishFVGs && + bearishFVGsCount < requiredPOIs) + // + ; + if (canContinue) + { + barIndex++; + } + } + + // + // int errorArr[]; + // if (canContinue) + // { + // // + // int t = errorArr[5]; + // } + + // + // Complete Calculations ... + + // + // Reverse Trading Days ... + XTradeDay tmpDays[]; + Copy( + mTradingDays, + tmpDays // + ); + Clean(mTradingDays); + ArrayReverse(tmpDays); + Copy( + tmpDays, + mTradingDays // + ); + Clean(tmpDays); + + // + // Reverse Market Sessions ... + XMarketSession tmpSessions[]; + Copy( + mMarketSessions, + tmpSessions // + ); + Clean(mMarketSessions); + ArrayReverse(tmpSessions); + Copy( + tmpSessions, + mMarketSessions // + ); + + // + XOHCL tmpBars[]; + + // + // Reverse Swing Highs ... + Copy( + mSwingHighs, + tmpBars // + ); + Clean(mSwingHighs); + ArrayReverse(tmpBars); + Copy( + tmpBars, + mSwingHighs // + ); + Clean(tmpBars); + + // + // Reverse Swing Lows ... + Copy( + mSwingLows, + tmpBars // + ); + Clean(mSwingLows); + ArrayReverse(tmpBars); + Copy( + tmpBars, + mSwingLows // + ); + Clean(tmpBars); + + // + // Reverse Momentum Bars ... + Copy( + mMomentumBars, + tmpBars // + ); + Clean(mMomentumBars); + ArrayReverse(tmpBars); + Copy( + tmpBars, + mMomentumBars // + ); + Clean(tmpBars); + + // + // Reverse Rejection Bars ... + Copy( + mRejectionBars, + tmpBars // + ); + Clean(mRejectionBars); + ArrayReverse(tmpBars); + Copy( + tmpBars, + mRejectionBars // + ); + Clean(tmpBars); + + // + // Reverse Support Zones ... + Copy( + mSupportZones, + tmpBars // + ); + Clean(mSupportZones); + ArrayReverse(tmpBars); + Copy( + tmpBars, + mSupportZones // + ); + Clean(tmpBars); + + // + // Reverse Resistance Zones ... + Copy( + mResistanceZones, + tmpBars // + ); + Clean(mResistanceZones); + ArrayReverse(tmpBars); + Copy( + tmpBars, + mResistanceZones // + ); + Clean(tmpBars); + + // + XZone tmpZones[]; + + // + // Supply and Demand Zones ... + + // + Copy( + mSupplyZones, + tmpZones // + ); + Clean(mSupplyZones); + ArrayReverse(tmpZones); + Copy( + tmpZones, + mSupplyZones // + ); + Clean(tmpZones); + + // + Copy( + mDemandZones, + tmpZones // + ); + Clean(mDemandZones); + ArrayReverse(tmpZones); + Copy( + tmpZones, + mDemandZones // + ); + Clean(tmpZones); + + // + // Order Blocks ... + + // + Copy( + mBullishOrderBlocks, + tmpZones // + ); + Clean(mBullishOrderBlocks); + ArrayReverse(tmpZones); + Copy( + tmpZones, + mBullishOrderBlocks // + ); + Clean(tmpZones); + + // + Copy( + mBearishOrderBlocks, + tmpZones // + ); + Clean(mBearishOrderBlocks); + ArrayReverse(tmpZones); + Copy( + tmpZones, + mBearishOrderBlocks // + ); + Clean(tmpZones); + + // + // Fair Value Gaps ... + + // + Copy( + mBullishFVGs, + tmpZones // + ); + Clean(mBullishFVGs); + ArrayReverse(tmpZones); + Copy( + tmpZones, + mBullishFVGs // + ); + Clean(tmpZones); + + // + Copy( + mBearishFVGs, + tmpZones // + ); + Clean(mBearishFVGs); + ArrayReverse(tmpZones); + Copy( + tmpZones, + mBearishFVGs // + ); + Clean(tmpZones); + + // + // ... + + // + Unlock(); + DrawPOIs(); + } + + // + // Destroy POIs ... + + /** + * Destroy All POI(s) ... + */ + void DestroyPOIs() + { + // + // Trading Days ... + DestroyTradingDays(); + + // + // Market Sessions ... + DestroyMarketSessions(); + + // + // Momentum Bars ... + DestroyMomentumBars(); + + // + // Rejection Bars ... + DestroyRejectionBars(); + + // + // Swing High and Zone (s) ... + DestroySwingHighs(); + DestroySwingLows(); + + // + // Support and Resistance Zones ... + DestroySupportZones(); + DestroyResistanceZones(); + + // + // Supply and Demand Zones ... + DestroySupplyZones(); + DestroyDemandZones(); + + // + // Order Blocks ... + DestroyBullishOrderBlocks(); + DestroyBearishOrderBlocks(); + + // + // Fai Value Gaps ... + DestroyBullishFVGs(); + DestroyBearishFVGs(); + } + + /** + * Destroy Trading Days ... + */ + void DestroyTradingDays() + { + Clean(mTradingDays); + } + + /** + * Destroy Swing Highs ... + */ + void DestroySwingHighs() + { + Clean(mSwingHighs); + } + + /** + * Destroy Swing Lows ... + */ + void DestroySwingLows() + { + Clean(mSwingLows); + } + + /** + * Destroy Momentum Bars ... + */ + void DestroyMomentumBars() + { + Clean(mMomentumBars); + } + + /** + * Destroy Rejection Bars ... + */ + void DestroyRejectionBars() + { + Clean(mRejectionBars); + } + + /** + * Destroy Market Sessions ... + */ + void DestroyMarketSessions() + { + Clean(mMarketSessions); + } + + /** + * Destroy Support Zones ... + */ + void DestroySupportZones() + { + Clean(mSupportZones); + } + + /** + * Destroy Resistance Zones ... + */ + void DestroyResistanceZones() + { + Clean(mResistanceZones); + } + + /** + * Destroy Supply Zones ... + */ + void DestroySupplyZones() + { + Clean(mSupplyZones); + } + + /** + * Destroy Demand Zones ... + */ + void DestroyDemandZones() + { + Clean(mDemandZones); + } + + /** + * Destroy Bullish Order Blocks ... + */ + void DestroyBullishOrderBlocks() + { + Clean(mBullishOrderBlocks); + } + + /** + * Destroy Bearish Order Blocks ... + */ + void DestroyBearishOrderBlocks() + { + Clean(mBearishOrderBlocks); + } + + /** + * Destroy Bullish FVGs ... + */ + void DestroyBullishFVGs() + { + Clean(mBullishFVGs); + } + + /** + * Destroy Bearish FVGs ... + */ + void DestroyBearishFVGs() + { + Clean(mBearishFVGs); + } + + // + // Draw Actions ... + + /** + * Draw All POI(s) ... + */ + void DrawPOIs() + { + // + // Trading Days ... + DrawTradingDays(); + + // + // Market Sessions ... + DrawMarketSessions(); + + // + // Momentum Bars ... + DrawMomentumBars(); + + // + // Rejection Bars ... + DrawRejectionBars(); + + // + // Swing High and Low (s) ... + DrawSwingHighs(); + DrawSwingLows(); + + // + // Support and Resistance (s) ... + DrawSupportZones(); + DrawResistanceZones(); + + // + // Supply and Demand Zones ... + DrawSupplyZones(); + DrawDemandZones(); + + // + // Order Blocks ... + DrawBullishOrderBlocks(); + DrawBearishOrderBlocks(); + + // + // Fair Value Gaps ... + DrawBullishFVGs(); + DrawBearishFVGs(); + } + + /** + * Draw Trading Days ... + */ + void DrawTradingDays() + { + // + bool allow = AllowDrawTradingDays(); + if (!allow) + { + return; + } + + // + int count = ArraySize(mTradingDays); + if (!IsValidSize(count)) + { + return; + } + + // + for (int i = 0; i < count; i++) + { + // + XTradeDay iDay = mTradingDays[i]; + + // + string iName = iDay.GetTag(); + int iIDX = HasTradingDayObject( + iName // + ); + if (IsValidIndex(iIDX)) + { + continue; + } + + // + CreateTradingDayObject(iDay, iName); + } + } + + /** + * Check a Trading Day is Drawn Before or not ... + * + * @param name: String ... + * + * @return ( int ) + */ + int HasTradingDayObject( + string name // + ) + { + // + int result = -1; + + // + if (!IsValid(name)) + { + return result; + } + + // + int count = mTradingDayObjects.Total(); + if (!IsValidSize(count)) + { + return result; + } + + // + for (int i = 0; i < count; i++) + { + // + string objName = ((XCBaseObject *)mTradingDayObjects.At(i)).ObjName(); + if (objName == name) + { + // + result = i; + break; + } + } + + // + return result; + } + + /** + * Draw Swing Highs ... + */ + void DrawSwingHighs() + { + // + bool allow = AllowDrawSwingHighs(); + if (!allow) + { + return; + } + + // + int count = ArraySize(mSwingHighs); + if (!IsValidSize(count)) + { + return; + } + + // + for (int i = 0; i < count; i++) + { + // + XOHCL iSwing = mSwingHighs[i]; + + // + string iName = iSwing.GetTag(ToString(X_POI_SWING_HIGH)); + int iIDX = HasSwingHighObject( + iName // + ); + if (IsValidIndex(iIDX)) + { + continue; + } + + // + CreateSwingHighObject(iSwing, iName); + } + } + + /** + * Check a Swing High is Drawn Before or not ... + * + * @param name: String ... + * + * @return ( int ) + */ + int HasSwingHighObject( + string name // + ) + { + // + int result = -1; + + // + if (!IsValid(name)) + { + return result; + } + + // + int count = mSwingHighObjects.Total(); + if (!IsValidSize(count)) + { + return result; + } + + // + for (int i = 0; i < count; i++) + { + // + string objName = ((CChartObjectArrow *)mSwingHighObjects.At(i)).Name(); + if (objName == name) + { + // + result = i; + break; + } + } + + // + return result; + } + + /** + * Draw Swing Lows ... + */ + void DrawSwingLows() + { + // + bool allow = AllowDrawSwingLows(); + if (!allow) + { + return; + } + + // + int count = ArraySize(mSwingLows); + if (!IsValidSize(count)) + { + return; + } + + // + for (int i = 0; i < count; i++) + { + // + XOHCL iSwing = mSwingLows[i]; + + // + string iName = iSwing.GetTag(ToString(X_POI_SWING_LOW)); + int iIDX = HasSwingLowObject( + iName // + ); + if (IsValidIndex(iIDX)) + { + continue; + } + + // + CreateSwingLowObject(iSwing, iName); + } + } + + /** + * Check a Swing Low is Drawn Before or not ... + * + * @param name: String ... + * + * @return ( int ) + */ + int HasSwingLowObject( + string name // + ) + { + // + int result = -1; + + // + if (!IsValid(name)) + { + return result; + } + + // + int count = mSwingLowObjects.Total(); + if (!IsValidSize(count)) + { + return result; + } + + // + for (int i = 0; i < count; i++) + { + // + string objName = ((CChartObjectArrow *)mSwingLowObjects.At(i)).Name(); + if (objName == name) + { + // + result = i; + break; + } + } + + // + return result; + } + + /** + * Draw Momentum Bars ... + */ + void DrawMomentumBars() + { + // + bool allow = AllowDrawMomentumBars(); + if (!allow) + { + return; + } + + // + int count = ArraySize(mMomentumBars); + if (!IsValidSize(count)) + { + return; + } + + // + for (int i = 0; i < count; i++) + { + // + XOHCL iBar = mMomentumBars[i]; + + // + string iName = iBar.GetTag(ToString(X_POI_MOMENTUM_BAR)); + int iIDX = HasMomentumBarObject( + iName // + ); + if (IsValidIndex(iIDX)) + { + continue; + } + + // + CreateMomentumBarObject(iBar, iName); + } + } + + /** + * Check a Momentum Bar is Drawn Before or not ... + * + * @param name: String ... + * + * @return ( int ) + */ + int HasMomentumBarObject( + string name // + ) + { + // + int result = -1; + + // + if (!IsValid(name)) + { + return result; + } + + // + int count = mMomentumBarObjects.Total(); + if (!IsValidSize(count)) + { + return result; + } + + // + for (int i = 0; i < count; i++) + { + // + string objName = ((CChartObjectArrow *)mMomentumBarObjects.At(i)).Name(); + if (objName == name) + { + // + result = i; + break; + } + } + + // + return result; + } + + /** + * Draw Rejection Bars ... + */ + void DrawRejectionBars() + { + // + bool allow = AllowDrawRejectionBars(); + if (!allow) + { + return; + } + + // + int count = ArraySize(mRejectionBars); + if (!IsValidSize(count)) + { + return; + } + + // + for (int i = 0; i < count; i++) + { + // + XOHCL iBar = mRejectionBars[i]; + + // + string iName = iBar.GetTag(ToString(X_POI_REJECTION_BAR)); + int iIDX = HasRejectionBarObject( + iName // + ); + if (IsValidIndex(iIDX)) + { + continue; + } + + // + CreateRejectionBarObject(iBar, iName); + } + } + + /** + * Check a Rejection Bar is Drawn Before or not ... + * + * @param name: String ... + * + * @return ( int ) + */ + int HasRejectionBarObject( + string name // + ) + { + // + int result = -1; + + // + if (!IsValid(name)) + { + return result; + } + + // + int count = mRejectionBarObjects.Total(); + if (!IsValidSize(count)) + { + return result; + } + + // + for (int i = 0; i < count; i++) + { + // + string objName = ((CChartObjectArrow *)mRejectionBarObjects.At(i)).Name(); + if (objName == name) + { + // + result = i; + break; + } + } + + // + return result; + } + + /** + * Draw Market Sessions ... + */ + void DrawMarketSessions() + { + // + bool allow = AllowDrawMarketSessions(); + if (!allow) + { + return; + } + + // + int count = ArraySize(mMarketSessions); + if (!IsValidSize(count)) + { + return; + } + + // + for (int i = 0; i < count; i++) + { + // + XMarketSession iMarketSession = mMarketSessions[i]; + + // + string iName = iMarketSession.GetTag(); + int iIDX = HasMarketessionObject( + iName // + ); + if (IsValidIndex(iIDX)) + { + continue; + } + + // + CreateMarketSessionObject(iMarketSession, iName); + } + } + + /** + * Check a Market Session is Drawn Before or not ... + * + * @param name: String ... + * + * @return ( int ) + */ + int HasMarketessionObject( + string name // + ) + { + // + int result = -1; + + // + if (!IsValid(name)) + { + return result; + } + + // + int count = mMarketSessionObjects.Total(); + if (!IsValidSize(count)) + { + return result; + } + + // + for (int i = 0; i < count; i++) + { + // + string objName = ((XCMarketSessionObject *)mMarketSessionObjects.At(i)).ObjName(); + if (objName == name) + { + // + result = i; + break; + } + } + + // + return result; + } + + /** + * Draw Support Zones ... + */ + void DrawSupportZones() + { + // + bool allow = AllowDrawSupportZones(); + if (!allow) + { + return; + } + + // + int count = ArraySize(mSupportZones); + if (!IsValidSize(count)) + { + return; + } + + // + for (int i = 0; i < count; i++) + { + // + XOHCL iSupportZone = mSupportZones[i]; + + // + string iName = iSupportZone.GetTag(ToString(X_POI_SUPPORT_ZONE)); + int iIDX = HasSupportZoneObject( + iName // + ); + if (IsValidIndex(iIDX)) + { + continue; + } + + // + CreateSupportZoneObject(iSupportZone, iName); + } + } + + /** + * Check a Suport Zone is Drawn Before or not ... + * + * @param name: String ... + * + * @return ( int ) + */ + int HasSupportZoneObject( + string name // + ) + { + // + int result = -1; + + // + if (!IsValid(name)) + { + return result; + } + + // + int count = mSupportZoneObjects.Total(); + if (!IsValidSize(count)) + { + return result; + } + + // + for (int i = 0; i < count; i++) + { + // + string objName = ((XCSupportZoneObject *)mSupportZoneObjects.At(i)).ObjName(); + if (objName == name) + { + // + result = i; + break; + } + } + + // + return result; + } + + /** + * Draw Resistance Zones ... + */ + void DrawResistanceZones() + { + // + bool allow = AllowDrawResistanceZones(); + if (!allow) + { + return; + } + + // + int count = ArraySize(mResistanceZones); + if (!IsValidSize(count)) + { + return; + } + + // + for (int i = 0; i < count; i++) + { + // + XOHCL iResistanceZone = mResistanceZones[i]; + + // + string iName = iResistanceZone.GetTag(ToString(X_POI_RESISTANCE_ZONE)); + int iIDX = HasResistanceZoneObject( + iName // + ); + if (IsValidIndex(iIDX)) + { + continue; + } + + // + CreateResistanceZoneObject(iResistanceZone, iName); + } + } + + /** + * Check a Resistance Zone is Drawn Before or not ... + * + * @param name: String ... + * + * @return ( int ) + */ + int HasResistanceZoneObject( + string name // + ) + { + // + int result = -1; + + // + if (!IsValid(name)) + { + return result; + } + + // + int count = mResistanceZoneObjects.Total(); + if (!IsValidSize(count)) + { + return result; + } + + // + for (int i = 0; i < count; i++) + { + // + string objName = ((XCResistanceZoneObject *)mResistanceZoneObjects.At(i)).ObjName(); + if (objName == name) + { + // + result = i; + break; + } + } + + // + return result; + } + + /** + * Draw Supply Zones ... + */ + void DrawSupplyZones() + { + // + bool allow = AllowDrawSupplyZones(); + if (!allow) + { + return; + } + + // + int count = ArraySize(mSupplyZones); + if (!IsValidSize(count)) + { + return; + } + + // + for (int i = 0; i < count; i++) + { + // + XZone iSupplyZone = mSupplyZones[i]; + + // + string iName = iSupplyZone.GetTag(); + int iIDX = HasSupplyZoneObject( + iName // + ); + if (IsValidIndex(iIDX)) + { + continue; + } + + // + CreateSupplyZoneObject(iSupplyZone, iName); + } + } + + /** + * Check a Supply Zone is Drawn Before or not ... + * + * @param name: String ... + * + * @return ( int ) + */ + int HasSupplyZoneObject( + string name // + ) + { + // + int result = -1; + + // + if (!IsValid(name)) + { + return result; + } + + // + int count = mSupplyZoneObjects.Total(); + if (!IsValidSize(count)) + { + return result; + } + + // + for (int i = 0; i < count; i++) + { + // + string objName = ((XCSupplyZoneObject *)mSupplyZoneObjects.At(i)).ObjName(); + if (objName == name) + { + // + result = i; + break; + } + } + + // + return result; + } + + /** + * Draw Demand Zones ... + */ + void DrawDemandZones() + { + // + bool allow = AllowDrawDemandZones(); + if (!allow) + { + return; + } + + // + int count = ArraySize(mDemandZones); + if (!IsValidSize(count)) + { + return; + } + + // + for (int i = 0; i < count; i++) + { + // + XZone iDemandZone = mDemandZones[i]; + + // + string iName = iDemandZone.GetTag(); + int iIDX = HasDemandZoneObject( + iName // + ); + if (IsValidIndex(iIDX)) + { + continue; + } + + // + CreateDemandZoneObject(iDemandZone, iName); + } + } + + /** + * Check a Demand Zone is Drawn Before or not ... + * + * @param name: String ... + * + * @return ( int ) + */ + int HasDemandZoneObject( + string name // + ) + { + // + int result = -1; + + // + if (!IsValid(name)) + { + return result; + } + + // + int count = mDemandZoneObjects.Total(); + if (!IsValidSize(count)) + { + return result; + } + + // + for (int i = 0; i < count; i++) + { + // + string objName = ((XCDemandZoneObject *)mDemandZoneObjects.At(i)).ObjName(); + if (objName == name) + { + // + result = i; + break; + } + } + + // + return result; + } + + /** + * Draw Bullish Order Blocks ... + */ + void DrawBullishOrderBlocks() + { + // + bool allow = AllowDrawBullishOrderBlocks(); + if (!allow) + { + return; + } + + // + int count = ArraySize(mBullishOrderBlocks); + if (!IsValidSize(count)) + { + return; + } + + // + for (int i = 0; i < count; i++) + { + // + XZone iBullishOB = mBullishOrderBlocks[i]; + + // + string iName = iBullishOB.GetTag(); + int iIDX = HasBullishOrderBlockObject( + iName // + ); + if (IsValidIndex(iIDX)) + { + continue; + } + + // + CreateBullishOrderBlockObject(iBullishOB, iName); + } + } + + /** + * Check a Bullish Order Block is Drawn Before or not ... + * + * @param name: String ... + * + * @return ( int ) + */ + int HasBullishOrderBlockObject( + string name // + ) + { + // + int result = -1; + + // + if (!IsValid(name)) + { + return result; + } + + // + int count = mBullishOrderBlockObjects.Total(); + if (!IsValidSize(count)) + { + return result; + } + + // + for (int i = 0; i < count; i++) + { + // + string objName = ((XCBullishOrderBlockObject *)mBullishOrderBlockObjects.At(i)).ObjName(); + if (objName == name) + { + // + result = i; + break; + } + } + + // + return result; + } + + /** + * Draw Bearish Order Blocks ... + */ + void DrawBearishOrderBlocks() + { + // + bool allow = AllowDrawBearishOrderBlocks(); + if (!allow) + { + return; + } + + // + int count = ArraySize(mBearishOrderBlocks); + if (!IsValidSize(count)) + { + return; + } + + // + for (int i = 0; i < count; i++) + { + // + XZone iBearishOB = mBearishOrderBlocks[i]; + + // + string iName = iBearishOB.GetTag(); + int iIDX = HasBearishOrderBlockObject( + iName // + ); + if (IsValidIndex(iIDX)) + { + continue; + } + + // + CreateBearishOrderBlockObject(iBearishOB, iName); + } + } + + /** + * Check a Bearish Order Block is Drawn Before or not ... + * + * @param name: String ... + * + * @return ( int ) + */ + int HasBearishOrderBlockObject( + string name // + ) + { + // + int result = -1; + + // + if (!IsValid(name)) + { + return result; + } + + // + int count = mBearishOrderBlockObjects.Total(); + if (!IsValidSize(count)) + { + return result; + } + + // + for (int i = 0; i < count; i++) + { + // + string objName = ((XCBearishOrderBlockObject *)mBearishOrderBlockObjects.At(i)).ObjName(); + if (objName == name) + { + // + result = i; + break; + } + } + + // + return result; + } + + /** + * Draw Bullish FVGs ... + */ + void DrawBullishFVGs() + { + // + bool allow = AllowDrawBullishFVGs(); + if (!allow) + { + return; + } + + // + int count = ArraySize(mBullishFVGs); + if (!IsValidSize(count)) + { + return; + } + + // + for (int i = 0; i < count; i++) + { + // + XZone iFVG = mBullishFVGs[i]; + + // + string iName = iFVG.GetTag(); + int iIDX = HasBullishFVGObject( + iName // + ); + if (IsValidIndex(iIDX)) + { + continue; + } + + // + CreateBullishFVGObject(iFVG, iName); + } + } + + /** + * Check a Bullish FVG is Drawn Before or not ... + * + * @param name: String ... + * + * @return ( int ) + */ + int HasBullishFVGObject( + string name // + ) + { + // + int result = -1; + + // + if (!IsValid(name)) + { + return result; + } + + // + int count = mBullishFVGObjects.Total(); + if (!IsValidSize(count)) + { + return result; + } + + // + for (int i = 0; i < count; i++) + { + // + string objName = ((XCBullishFVGObject *)mBullishFVGObjects.At(i)).ObjName(); + if (objName == name) + { + // + result = i; + break; + } + } + + // + return result; + } + + /** + * Draw Bearish FVGs ... + */ + void DrawBearishFVGs() + { + // + bool allow = AllowDrawBearishFVGs(); + if (!allow) + { + return; + } + + // + int count = ArraySize(mBearishFVGs); + if (!IsValidSize(count)) + { + return; + } + + // + for (int i = 0; i < count; i++) + { + // + XZone iFVG = mBearishFVGs[i]; + + // + string iName = iFVG.GetTag(); + int iIDX = HasBearishFVGObject( + iName // + ); + if (IsValidIndex(iIDX)) + { + continue; + } + + // + CreateBearishFVGObject(iFVG, iName); + } + } + + /** + * Check a Bearish FVG is Drawn Before or not ... + * + * @param name: String ... + * + * @return ( int ) + */ + int HasBearishFVGObject( + string name // + ) + { + // + int result = -1; + + // + if (!IsValid(name)) + { + return result; + } + + // + int count = mBearishFVGObjects.Total(); + if (!IsValidSize(count)) + { + return result; + } + + // + for (int i = 0; i < count; i++) + { + // + string objName = ((XCBearishFVGObject *)mBearishFVGObjects.At(i)).ObjName(); + if (objName == name) + { + // + result = i; + break; + } + } + + // + return result; + } + + // + + /** + * Clean All Drawn Objects ... + */ + void DestroyObjects() + { + // + // Trading Days ... + DestroyTradingTradingDayObjects(); + + // + // Market Sessions ... + DestroyMarketSessionObjects(); + + // + // Momentum Bars ... + DestroyMomentumBarObjects(); + + // + // Rejection Bars ... + DestroyRejectionBarObjects(); + + // + // Swing High and Low (s) ... + DestroySwingLowObjects(); + DestroySwingHighObjects(); + + // + // Support and Resistanc (s) ... + DestroySupportZoneObjects(); + DestroyResistanceZoneObjects(); + + // + // Supply and Demand Zones .. + DestroySupplyZoneObjects(); + DestroyDemandZoneObjects(); + + // + // Order Blocks ... + DestroyBullishOrderBlockObjects(); + DestroyBearishOrderBlockObjects(); + + // + // Fair Value Gaps ... + DestroyBullishFVGObjects(); + DestroyBearishFVGObjects(); + } + + /** + * Clean Swing Highs Drawn Objects ... + */ + void DestroySwingHighObjects() + { + mSwingHighObjects.Clear(); + } + + /** + * Clean Swing Lows Drawn Objects ... + */ + void DestroySwingLowObjects() + { + mSwingLowObjects.Clear(); + } + + /** + * Clean Momentum Bars Drawn Objects ... + */ + void DestroyMomentumBarObjects() + { + mMomentumBarObjects.Clear(); + } + + /** + * Clean Rejection Bars Drawn Objects ... + */ + void DestroyRejectionBarObjects() + { + mRejectionBarObjects.Clear(); + } + + /** + * Clean Trading Day Drawn Objects ... + */ + void DestroyTradingTradingDayObjects() + { + mTradingDayObjects.Clear(); + } + + /** + * Destroy Market Sessions Drawn Objects ... + */ + void DestroyMarketSessionObjects() + { + mMarketSessionObjects.Clear(); + } + + /** + * Destroy Support Zone Drawn Objects ... + */ + void DestroySupportZoneObjects() + { + mSupportZoneObjects.Clear(); + } + + /** + * Destroy Resistance Zone Drawn Objects ... + */ + void DestroyResistanceZoneObjects() + { + mResistanceZoneObjects.Clear(); + } + + /** + * Destroy Supply Zone Drawn Objects ... + */ + void DestroySupplyZoneObjects() + { + mSupplyZoneObjects.Clear(); + } + + /** + * Destroy Demand Zone Drawn Objects ... + */ + void DestroyDemandZoneObjects() + { + mDemandZoneObjects.Clear(); + } + + /** + * Destroy Bullish Order Block Drawn Objects ... + */ + void DestroyBullishOrderBlockObjects() + { + mBullishOrderBlockObjects.Clear(); + } + + /** + * Destroy Bearish Order Block Drawn Objects ... + */ + void DestroyBearishOrderBlockObjects() + { + mBearishOrderBlockObjects.Clear(); + } + + /** + * Destroy Bullish FVG Drawn Objects ... + */ + void DestroyBullishFVGObjects() + { + mBullishFVGObjects.Clear(); + } + + /** + * Destroy Bearish FVG Drawn Objects ... + */ + void DestroyBearishFVGObjects() + { + mBearishFVGObjects.Clear(); + } + + // + // ... + + /** + * Detect an Object Exists in Array or not ... + * + * @param name: String ... + * @param array: CArrayObj instance ... + * + * @return ( int ): index of Object ... + */ + int HasObject( + string name, + CArrayObj &array // + ) + { + // + int result = -1; + + // + if (!IsValid(name)) + { + return result; + } + + // + int count = array.Total(); + if (!IsValidSize(count)) + { + return result; + } + + // + for (int i = 0; i < count; i++) + { + // + // XCBaseObject *iObj = ((XCBaseObject *)array.At(i)); + // string objName = iObj.ObjName(); + // if (objName == name) + // { + // // + // result = i; + // break; + // } + } + + // + return result; + } + + // + // Event Handler Notifiers ... + + // + // Trading Days ... + + /** + * Notify New Trading Day Event Handlers ... + * + * @param event: ENUM_XPOI_EVENTS member ... + */ + void NotifyTradingDayEventListeners( + ENUM_XPOI_EVENTS event // + ) + { + // + int count = ArraySize(mTradingDayEventListeners); + if (!IsValidSize(count)) + { + return; + } + + // + for (int i = 0; i < count; i++) + { + // + TXPOIEventHandler iListener = mTradingDayEventListeners[i]; + iListener(event); + } + } + + // + // Market Sessions ... + + /** + * Notify New Market Session Event Handlers ... + * + * @param session: ENUM_XSESSION member ... + * @param event: ENUM_XPOI_EVENTS member ... + */ + void NotifyMarketSessionEventListeners( + ENUM_XSESSION session, + ENUM_XPOI_EVENTS event // + ) + { + // + int count = ArraySize(mMarketSessionEventListeners); + if (!IsValidSize(count)) + { + return; + } + + // + for (int i = 0; i < count; i++) + { + // + TXSessionEventHandler iListener = mMarketSessionEventListeners[i]; + iListener(session, event); + } + } + + // + // Swings ... + + // + // Swing Highs ... + + /** + * Notify New Swing High Point Event Handlers ... + * + * @param event: ENUM_XPOI_EVENTS member ... + * @param bar: XOHCL instance ... + */ + void NotifySwingHighEventListeners( + ENUM_XPOI_EVENTS event, + XOHCL &bar // + ) + { + // + if (!bar.IsValid()) + { + return; + } + + // + int count = ArraySize(mSwingHighEventListeners); + if (!IsValidSize(count)) + { + return; + } + + // + for (int i = 0; i < count; i++) + { + // + TXOHCLEventHandler iListener = mSwingHighEventListeners[i]; + iListener(event, bar); + } + } + + // + // Swing Lows ... + + /** + * Notify New Swing Low Point Event Handlers ... + * + * @param event: ENUM_XPOI_EVENTS member ... + * @param bar: XOHCL instance ... + */ + void NotifySwingLowEventListeners( + ENUM_XPOI_EVENTS event, + XOHCL &bar // + ) + { + // + if (!bar.IsValid()) + { + return; + } + + // + int count = ArraySize(mSwingLowEventListeners); + if (!IsValidSize(count)) + { + return; + } + + // + for (int i = 0; i < count; i++) + { + // + TXOHCLEventHandler iListener = mSwingLowEventListeners[i]; + iListener(event, bar); + } + } + + // + // Momentum Bars ... + + /** + * Notify New Momentum Bar Event Handlers ... + * + * @param event: ENUM_XPOI_EVENTS member ... + * @param bar: XOHCL instance ... + */ + void NotifyMomentumBarEventListeners( + ENUM_XPOI_EVENTS event, + XOHCL &bar // + ) + { + // + if (!bar.IsValid()) + { + return; + } + + // + int count = ArraySize(mMomentumBarEventListeners); + if (!IsValidSize(count)) + { + return; + } + + // + for (int i = 0; i < count; i++) + { + // + TXOHCLEventHandler iListener = mMomentumBarEventListeners[i]; + iListener(event, bar); + } + } + + // + // Rejection Bars ... + + /** + * Notify New Rejection Bar Event Handlers ... + * + * @param event: ENUM_XPOI_EVENTS member ... + * @param bar: XOHCL instance ... + */ + void NotifyRejectionBarEventListeners( + ENUM_XPOI_EVENTS event, + XOHCL &bar // + ) + { + // + if (!bar.IsValid()) + { + return; + } + + // + int count = ArraySize(mRejectionBarEventListeners); + if (!IsValidSize(count)) + { + return; + } + + // + for (int i = 0; i < count; i++) + { + // + TXOHCLEventHandler iListener = mRejectionBarEventListeners[i]; + iListener(event, bar); + } + } + + // + // Support and Resistance Zones ... + + // + // Support Zones ... + + /** + * Notify New Support Zone Event Handlers ... + * + * @param event: ENUM_XPOI_EVENTS member ... + * @param bar: XOHCL instance ... + */ + void NotifySupportZoneEventListeners( + ENUM_XPOI_EVENTS event, + XOHCL &bar // + ) + { + // + if (!bar.IsValid()) + { + return; + } + + // + int count = ArraySize(mSupportZoneEventListeners); + if (!IsValidSize(count)) + { + return; + } + + // + for (int i = 0; i < count; i++) + { + // + TXOHCLEventHandler iListener = mSupportZoneEventListeners[i]; + iListener(event, bar); + } + } + + // + // Resistance Zones ... + + /** + * Notify New Resistance Zone Event Handlers ... + * + * @param event: ENUM_XPOI_EVENTS member ... + * @param bar: XOHCL instance ... + */ + void NotifyResistanceZoneEventListeners( + ENUM_XPOI_EVENTS event, + XOHCL &bar // + ) + { + // + if (!bar.IsValid()) + { + return; + } + + // + int count = ArraySize(mResistanceZoneEventListeners); + if (!IsValidSize(count)) + { + return; + } + + // + for (int i = 0; i < count; i++) + { + // + TXOHCLEventHandler iListener = mResistanceZoneEventListeners[i]; + iListener(event, bar); + } + } + + // + // Supply and Demand Zones ... + + // + // Supply Zones ... + + /** + * Notify New Supply Zone Event Handlers ... + * + * @param event: ENUM_XPOI_EVENTS member ... + * @param bar: XZone instance ... + */ + void NotifySupplyZoneEventListeners( + ENUM_XPOI_EVENTS event, + XZone &zone // + ) + { + // + if (!zone.IsValid()) + { + return; + } + + // + int count = ArraySize(mSupplyZoneEventListeners); + if (!IsValidSize(count)) + { + return; + } + + // + for (int i = 0; i < count; i++) + { + // + TXZoneEventHandler iListener = mSupplyZoneEventListeners[i]; + iListener(event, zone); + } + } + + // + // Demand Zones ... + + /** + * Notify New Demand Zone Event Handlers ... + * + * @param event: ENUM_XPOI_EVENTS member ... + * @param bar: XZone instance ... + */ + void NotifyDemandZoneEventListeners( + ENUM_XPOI_EVENTS event, + XZone &zone // + ) + { + // + if (!zone.IsValid()) + { + return; + } + + // + int count = ArraySize(mDemandZoneEventListeners); + if (!IsValidSize(count)) + { + return; + } + + // + for (int i = 0; i < count; i++) + { + // + TXZoneEventHandler iListener = mDemandZoneEventListeners[i]; + iListener(event, zone); + } + } + + // + // Order Blocks ... + + // + // Bullish Order Blocks ... + + /** + * Notify New Bullish Order Block Event Handlers ... + * + * @param event: ENUM_XPOI_EVENTS member ... + * @param bar: XZone instance ... + */ + void NotifyBullishOrderBlockEventListeners( + ENUM_XPOI_EVENTS event, + XZone &zone // + ) + { + // + if (!zone.IsValid()) + { + return; + } + + // + int count = ArraySize(mBullishOrderBlockEventListeners); + if (!IsValidSize(count)) + { + return; + } + + // + for (int i = 0; i < count; i++) + { + // + TXZoneEventHandler iListener = mBullishOrderBlockEventListeners[i]; + iListener(event, zone); + } + } + + // + // Bearish Order Blocks ... + + /** + * Notify New Bearish Order Block Event Handlers ... + * + * @param event: ENUM_XPOI_EVENTS member ... + * @param bar: XZone instance ... + */ + void NotifyBearishOrderBlockEventListeners( + ENUM_XPOI_EVENTS event, + XZone &zone // + ) + { + // + if (!zone.IsValid()) + { + return; + } + + // + int count = ArraySize(mBearishOrderBlockEventListeners); + if (!IsValidSize(count)) + { + return; + } + + // + for (int i = 0; i < count; i++) + { + // + TXZoneEventHandler iListener = mBearishOrderBlockEventListeners[i]; + iListener(event, zone); + } + } + + // + // Fair Value Gaps ... + + /** + * Notify New Bullish FVG Event Handlers ... + * + * @param event: ENUM_XPOI_EVENTS member ... + * @param bar: XZone instance ... + */ + void NotifyBullishFVGEventListeners( + ENUM_XPOI_EVENTS event, + XZone &zone // + ) + { + // + if (!zone.IsValid()) + { + return; + } + + // + int count = ArraySize(mBullishFVGEventListeners); + if (!IsValidSize(count)) + { + return; + } + + // + for (int i = 0; i < count; i++) + { + // + TXZoneEventHandler iListener = mBullishFVGEventListeners[i]; + iListener(event, zone); + } + } + + /** + * Notify New Bearish FVG Event Handlers ... + * + * @param event: ENUM_XPOI_EVENTS member ... + * @param bar: XZone instance ... + */ + void NotifyBearishFVGEventListeners( + ENUM_XPOI_EVENTS event, + XZone &zone // + ) + { + // + if (!zone.IsValid()) + { + return; + } + + // + int count = ArraySize(mBearishFVGEventListeners); + if (!IsValidSize(count)) + { + return; + } + + // + for (int i = 0; i < count; i++) + { + // + TXZoneEventHandler iListener = mBearishFVGEventListeners[i]; + iListener(event, zone); + } + } + + /** + * Destroy all Registered Event Listeners ... + */ + void DestroyEventListeners() + { + // + // Trading Days ... + Clean(mTradingDayEventListeners); + + // + // Market Sessions ... + Clean(mMarketSessionEventListeners); + + // + // Momentum Bars ... + Clean(mMomentumBarEventListeners); + + // + // Rejection Bars ... + Clean(mRejectionBarEventListeners); + + // + // Swing High and Low (s) ... + Clean(mSwingLowEventListeners); + Clean(mSwingHighEventListeners); + + // + // Support and Resistance Zones ... + Clean(mSupportZoneEventListeners); + Clean(mResistanceZoneEventListeners); + + // + // Supply and Demand Zones ... + Clean(mSupplyZoneEventListeners); + Clean(mDemandZoneEventListeners); + + // + // Order Blocks ... + Clean(mBullishOrderBlockEventListeners); + Clean(mBearishOrderBlockEventListeners); + + // + // Fair Value Gaps ... + Clean(mBullishFVGEventListeners); + Clean(mBearishFVGEventListeners); + } + + // + // ... + // + + // + // Session ... + + /** + * Find Specific Session Index ... + * + * @param session: ENUM_XSESSION member ... + * + * @return ( int ) + */ + int FindSession(ENUM_XSESSION session) + { + // + int result = -1; + + // + int count = ArraySize(mSessions); + if (!IsValidSize(count)) + { + return result; + } + + // + for (int i = 0; i < count; i++) + { + // + XSession iSession = mSessions[i]; + + // + if (iSession.session == session) + { + // + result = i; + break; + } + } + + // + return result; + } + + /** + * Destroy Sessions ... + */ + void DestroySessions() + { + Clean(mSessions); + } + + /** + * Find Specified Trade Day based on Start Time ... + * + * @param start: DateTime ... + * + * @return ( int ) + */ + int HasTradeDay(datetime start) + { + // + int result = -1; + + // + if (!IsValid(start)) + { + return result; + } + + // + int count = ArraySize(mTradingDays); + if (!IsValidSize(count)) + { + return result; + } + + // + for (int i = 0; i < count; i++) + { + // + XTradeDay iDay = mTradingDays[i]; + + // + if (iDay.from == start) + { + // + result = i; + break; + } + } + + // + return result; + } + + /** + * Find Specified Trade Day based on End Time ... + * + * @param start: DateTime ... + * + * @return ( int ) + */ + int HasTradeDayBayEndTime(datetime end) + { + // + int result = -1; + + // + if (!IsValid(end)) + { + return result; + } + + // + int count = ArraySize(mTradingDays); + if (!IsValidSize(count)) + { + return result; + } + + // + for (int i = 0; i < count; i++) + { + // + XTradeDay iDay = mTradingDays[i]; + + // + if (iDay.to == end) + { + // + result = i; + break; + } + } + + // + return result; + } + + // + + /** + * Find Market Session by Providing Start Time ... + * + * @param session: ENUM_XSESSION member ... + * @param start: DateTime ... + * + * @return ( int ) + */ + int HasMarketSessionByStartTime( + ENUM_XSESSION session, + datetime start // + ) + { + // + int result = -1; + + // + if (!IsValid(start)) + { + return result; + } + + // + int count = ArraySize(mMarketSessions); + if (!IsValidSize(count)) + { + return result; + } + + // + for (int i = 0; i < count; i++) + { + // + XMarketSession iMarketSession = mMarketSessions[i]; + + // + if (iMarketSession.session == session && + iMarketSession.from == start) + { + // + result = i; + break; + } + } + + // + return result; + } + + /** + * Find Market Session by Providing Start Time ... + * + * @param session: ENUM_XSESSION member ... + * @param end: DateTime ... + * + * @return ( int ) + */ + int HasMarketSessionByEndTime( + ENUM_XSESSION session, + datetime end // + ) + { + // + int result = -1; + + // + if (!IsValid(end)) + { + return result; + } + + // + int count = ArraySize(mMarketSessions); + if (!IsValidSize(count)) + { + return result; + } + + // + for (int i = 0; i < count; i++) + { + // + XMarketSession iMarketSession = mMarketSessions[i]; + + // + if (iMarketSession.session == session && + iMarketSession.to == end) + { + // + result = i; + break; + } + } + + // + return result; + } + + /** + * Count Specified Market Sessions ... + * + * @param session: ENUM_XSESSION member ... + * + * @return ( int ) + */ + int CountMarketSessions(ENUM_XSESSION session) + { + // + int result = 0; + + // + int count = ArraySize(mMarketSessions); + if (!IsValidSize(count)) + { + return result; + } + + // + for (int i = 0; i < count; i++) + { + // + XMarketSession iMarketSession = mMarketSessions[i]; + + // + if (iMarketSession.session == session) + { + result++; + } + } + + // + return result; + } + + // + int FindBarIndex( + ENUM_XPOIS type, + XOHCL &bar, + XOHCL &list[] // + ) + { + // + int result = -1; + + // + bool isValidType = + type == X_POI_SWING_LOW || + type == X_POI_SWING_HIGH || + type == X_POI_SUPPORT_ZONE || + type == X_POI_MOMENTUM_BAR || + type == X_POI_REJECTION_BAR || + type == X_POI_RESISTANCE_ZONE; + if (!isValidType) + { + return result; + } + + // + int count = ArraySize(list); + if (!IsValidSize(count)) + { + return result; + } + + // + for (int i = 0; i < count; i++) + { + // + XOHCL iBar = list[i]; + + // + bool isSameLow = + bar.low == iBar.low; + + // + bool isSameHigh = + bar.high == iBar.high; + + // + bool isSameUp = + bar.GetUp() == iBar.GetUp(); + + // + bool isSameDown = + bar.GetDown() == iBar.GetDown(); + + // + // Check Conditions Based On Type ... + bool canBreak = false; + if (type == X_POI_SWING_LOW || + type == X_POI_SWING_HIGH || + type == X_POI_MOMENTUM_BAR || + type == X_POI_REJECTION_BAR) + { + // + canBreak = + isSameUp && + isSameLow && + isSameHigh && + isSameDown; + } + else if (type == X_POI_SUPPORT_ZONE) + { + // + canBreak = + isSameLow && + isSameDown; + } + else if (type == X_POI_RESISTANCE_ZONE) + { + // + canBreak = + isSameUp && + isSameHigh; + } + + // + if (canBreak) + { + // + result = i; + break; + } + } + + // + return result; + } + + // + bool AddBar( + ENUM_XPOIS type, + XOHCL &bar, + XOHCL &list[] // + ) + { + // + bool result = false; + + // + result = bar.IsValid(); + if (!result) + { + return result; + } + + // + result = + type == X_POI_SWING_LOW || + type == X_POI_SWING_HIGH || + type == X_POI_SUPPORT_ZONE || + type == X_POI_MOMENTUM_BAR || + type == X_POI_REJECTION_BAR || + type == X_POI_RESISTANCE_ZONE; + if (!result) + { + return result; + } + + // + int idx = FindBarIndex( + type, + bar, + list // + ); + result = !IsValidIndex(idx); + if (!result) + { + return result; + } + + // + AddRef( + bar, + list // + ); + + // + return result; + } + + // + + /** + * Find Specified Zone Index ... + * + * @param zone: XZone instance + * @param list: XZone Collection ... + * + * @return ( int ) + */ + int FindZoneIndex( + XZone &zone, + XZone &list[] // + ) + { + // + int result = -1; + + // + int count = ArraySize(list); + if (!IsValidSize(count)) + { + return result; + } + + // + for (int i = 0; i < count; i++) + { + // + XZone iZone = list[i]; + + // + if (iZone.upper == zone.upper && + iZone.lower == zone.lower) + { + // + result = i; + break; + } + } + + // + return result; + } + + /** + * Add Specific Zone to List ... + * + * @param ob: XOHCL ... + * @param endTime: Datetime ... + * @param type: ENUM_X_POI member ... + * @param list: XZone instance Collection ... + * + * @return ( bool ) + */ + bool AddZone( + XZone &zone, + XOHCL &ob, + datetime endTime, + ENUM_XPOIS type, + XZone &list[] // + ) + { + // + bool result = false; + + // + result = type == X_POI_SUPPORT_ZONE || + type == X_POI_RESISTANCE_ZONE || + type == X_POI_BULLISH_ORDERBLOCK || + type == X_POI_BEARISH_ORDERBLOCK; + if (!result) + { + return result; + } + + // + NormalizeTime(endTime); + + // + datetime startTime = (datetime)((int)ob.time - (PeriodSeconds(mPeriod) * 2)); + + // + result = zone.Init( + ob.high, + ob.low, + ToString(type), + startTime, + endTime // + ); + if (!result) + { + return result; + } + + // + int idx = FindZoneIndex( + zone, + list // + ); + result = !IsValidIndex(idx); + if (!result) + { + return result; + } + + // + AddRef( + zone, + list // + ); + + // + return result; + } + + /** + * Initiate and Add Specific Zone to List ... + * + * @param zone: XZone instance ... + * @param upper: Double ... + * @param lower: Double ... + * @param start: DateTime ... + * @param end: DateTime ... + * @param type: ENUM_XPOIS member ... + * @param list: XZone instance Collection ... + * + * @return ( bool ) + */ + bool AddZone( + XZone &zone, + double upper, + double lower, + datetime start, + datetime end, + ENUM_XPOIS type, + XZone &list[] // + ) + { + // + bool result = false; + + // + result = zone.Init( + upper, + lower, + ToString(type), + start, + end // + ); + if (!result) + { + return result; + } + + // + int idx = FindZoneIndex( + zone, + list // + ); + result = !IsValidIndex(idx); + if (!result) + { + return result; + } + + // + AddRef( + zone, + list // + ); + + // + return result; + } + + /** + * Cleanup Unused Objects ... + */ + void CleanupUnusedPOIs() + { + // + int maxAllowed = MaxNumberOfPOIs(); + if (!IsValidSize(maxAllowed)) + { + return; + } + + // + int tradingDaysCount = ArraySize(mTradingDays); + int marketSessionsCount = ArraySize(mMarketSessions); + int swingHighsCount = ArraySize(mSwingHighs); + int swingLowsCount = ArraySize(mSwingLows); + int momentumBarsCount = ArraySize(mMomentumBars); + int rejectionBarsCount = ArraySize(mRejectionBars); + int supportZonesCount = ArraySize(mSupportZones); + int resistanceZonesCount = ArraySize(mResistanceZones); + int supplyZonesCount = ArraySize(mSupplyZones); + int demandZonesCount = ArraySize(mDemandZones); + int bullishOBsCount = ArraySize(mBullishOrderBlocks); + int bearishOBsCount = ArraySize(mBearishOrderBlocks); + int bullishFVGsCount = ArraySize(mBullishFVGs); + int bearishFVGsCount = ArraySize(mBearishFVGs); + + // + int from = 0; + int requiredPOIs = MaxNumberOfRequiredPOIs(); + int count = maxAllowed - requiredPOIs; + int to = count - 1; + + // + // Trading Days ... + if (tradingDaysCount >= maxAllowed) + { + // + ArrayRemove( + mTradingDays, + from, + count // + ); + + // + mTradingDayObjects.DeleteRange( + from, + to // + ); + } + + // + // Market Sessions ... + if (marketSessionsCount >= maxAllowed) + { + // + ArrayRemove( + mMarketSessions, + from, + count // + ); + + // + mMarketSessionObjects.DeleteRange( + from, + to // + ); + } + + // + // Momentum Bars ... + if (momentumBarsCount >= maxAllowed) + { + // + ArrayRemove( + mMomentumBars, + from, + count // + ); + + // + mMomentumBarObjects.DeleteRange( + from, + to // + ); + } + + // + // Rejection Bars ... + if (rejectionBarsCount >= maxAllowed) + { + // + ArrayRemove( + mRejectionBars, + from, + count // + ); + + // + mRejectionBarObjects.DeleteRange( + from, + to // + ); + } + + // + // Swing High and Low (s) ... + + // + // Swing Highs ... + if (swingHighsCount >= maxAllowed) + { + // + ArrayRemove( + mSwingHighs, + from, + count // + ); + + // + mSwingHighObjects.DeleteRange( + from, + to // + ); + } + + // + // Swing Lows ... + if (swingLowsCount >= maxAllowed) + { + // + ArrayRemove( + mSwingLows, + from, + count // + ); + + // + mSwingLowObjects.DeleteRange( + from, + to // + ); + } + + // + // Support and Resistance Zones ... + + // + // Support Zones ... + if (supportZonesCount >= maxAllowed) + { + // + ArrayRemove( + mSupportZones, + from, + count // + ); + + // + mSupportZoneObjects.DeleteRange( + from, + to // + ); + } + + // + // Resistance Zones ... + if (resistanceZonesCount >= maxAllowed) + { + // + ArrayRemove( + mResistanceZones, + from, + count // + ); + + // + mResistanceZoneObjects.DeleteRange( + from, + to // + ); + } + + // + // Supply and Demand Zones ... + + // + // Supply Zones ... + if (supplyZonesCount >= maxAllowed) + { + // + ArrayRemove( + mSupplyZones, + from, + count // + ); + + // + mSupplyZoneObjects.DeleteRange( + from, + to // + ); + } + + // + // Demand Zones ... + if (demandZonesCount >= maxAllowed) + { + // + ArrayRemove( + mDemandZones, + from, + count // + ); + + // + mDemandZoneObjects.DeleteRange( + from, + to // + ); + } + + // + // Order Blocks ... + + // + // Bullish Order Blocks ... + if (bullishOBsCount >= maxAllowed) + { + // + ArrayRemove( + mBullishOrderBlocks, + from, + count // + ); + + // + mBullishOrderBlockObjects.DeleteRange( + from, + to // + ); + } + + // + // Bearish Order Blocks ... + if (bearishOBsCount >= maxAllowed) + { + // + ArrayRemove( + mBearishOrderBlocks, + from, + count // + ); + + // + mBearishOrderBlockObjects.DeleteRange( + from, + to // + ); + } + + // + // Fair Vakue Gaps ... + + // + // Bullish FVGs ... + if (bullishFVGsCount >= maxAllowed) + { + // + ArrayRemove( + mBullishFVGs, + from, + count // + ); + + // + mBullishFVGObjects.DeleteRange( + from, + to // + ); + } + + // + // Bearish FVGs ... + if (bearishFVGsCount >= maxAllowed) + { + // + ArrayRemove( + mBearishFVGs, + from, + count // + ); + + // + mBearishFVGObjects.DeleteRange( + from, + to // + ); + } + + // + } + + // + private: + // + + // + // Props ... + + // + bool mLock; // Lock State ... + string mSymbol; // Market Symbol ... + ENUM_TIMEFRAMES mPeriod; // Market Period ... + long mChartID; // Chart ID ... + int mWindow; // Window ID ... + int mMaxNumberOfPOIs; // Max Allowed Number of POI(s) which Can Holds ... + int mMaxNumberOfRequiredPOIs; // Max Allowed Number of POI(s) which Must Find at Initializion Time ... + + // + XBarTracker mBarTracker; // Market Bar Tracker ... + + // + // POI Props ... + + // + // Trading Days ... + + // + bool mAllowTradingDays; // Detect Trading Days ... + bool mAllowDrawTradingDays; // Draw Trading Days ... + color mTradingDaysStartColor; // Trading Days Start Color ... + ENUM_LINE_STYLE mTradingDaysStartStyle; // Trading Days Start Style ... + color mTradingDaysEndColor; // Trading Days End Color ... + ENUM_LINE_STYLE mTradingDaysEndStyle; // Trading Days End Style ... + XTradeDay mTradingDays[]; // Trading Days ... + CArrayObj mTradingDayObjects; // Trading Day Chart Objects ... + TXPOIEventHandler mTradingDayEventListeners[]; // Trading Day Event Listeners ... + + /** + * Create an Object to Represent Trading Day on Chart ... + * + * @param day: XTradeDay instance ... + * @param name: String ... + */ + void CreateTradingDayObject( + XTradeDay &day, + string name // + ) + { + // + if (!day.IsValid() || + !IsValid(name)) + { + return; + } + + // + XCTardeDayObject *iObj; + iObj = new XCTardeDayObject(); + bool isCreated = iObj.CreateByDay( + ChartID(), + name, + Window(), + day // + ); + if (!isCreated) + { + return; + } + + // + iObj.FromColor(TradingDaysStartColor()); + iObj.FromStyle(TradingDaysStartStyle()); + + // + iObj.ToColor(TradingDaysEndColor()); + iObj.ToStyle(TradingDaysEndStyle()); + + // + mTradingDayObjects.Add(iObj); + } + + // + // Market Sessions ... + + // + bool mAllowMarketSessions; // Detect Market Sessions ... + bool mAllowDrawMarketSessions; // Draw Market Sessions ... + int mSessionOpenHours; // How many Hours a Session is Open + XSession mSessions[]; // Forex Sessions + XMarketSession mMarketSessions[]; // Founded Market Sessions ... + CArrayObj mMarketSessionObjects; // Founded Market Session Chart Ojects ... + TXSessionEventHandler mMarketSessionEventListeners[]; // Market Sessions Event Listeners ... + + /** + * Create an Object to Represent Market Session on Chart ... + * + * @param session: XMarketSession instance ... + * @param name: String ... + */ + void CreateMarketSessionObject( + XMarketSession &session, + string name // + ) + { + // + if (!session.IsValid() || + !IsValid(name)) + { + return; + } + + // + // Find XSession Instance ... + int sessionIDX = FindSession(session.session); + if (!IsValidIndex(sessionIDX) || + !mSessions[sessionIDX].allowDraw) + { + return; + } + + // + XCMarketSessionObject *iObj; + iObj = new XCMarketSessionObject(); + bool isCreated = iObj.CreateByMarketSession( + ChartID(), + name, + Window(), + session // + ); + if (!isCreated) + { + return; + } + + // + iObj.FromColor(mSessions[sessionIDX].startColor); + iObj.FromStyle(mSessions[sessionIDX].startStyle); + + // + iObj.ToColor(mSessions[sessionIDX].endColor); + iObj.ToStyle(mSessions[sessionIDX].endStyle); + + // + mMarketSessionObjects.Add(iObj); + } + + // + // Swing High and Low(s) ... + + // + // Swing Highs ... + + // + bool mAllowSwingHighs; // Detect Swing Highs ... + bool mAllowDrawSwingHighs; // Draw Swing Highs ... + char mSwingHighArrowCode; // Swing High Arrow Code ... + color mSwingHighColor; // Swing High Color ... + int mSwingHighWidth; // Swing High Width ... + double mSwingHighThreshold; // Threshold Required for Swing High Detection ... + XOHCL mSwingHighs[]; // Swing Highs ... + CArrayObj mSwingHighObjects; // Swing High Chart Objects ... + TXOHCLEventHandler mSwingHighEventListeners[]; // Swing High Event Listeners ... + + /** + * Create an Object to Represent Swing High on Chart ... + * + * @param bar: XOHCL instance ... + * @param name: String ... + */ + void CreateSwingHighObject( + XOHCL &bar, + string name // + ) + { + // + if (!bar.IsValid() || + !IsValid(name)) + { + return; + } + + // + CChartObjectArrow *iObj; + iObj = new CChartObjectArrow(); + bool isCreated = iObj.Create( + ChartID(), + name, + Window(), + bar.time, + bar.high, + SwingHighArrowCode() // + ); + if (!isCreated) + { + return; + } + + // + // Configure Object ... + iObj.Width(SwingHighWidth()); + iObj.Color(SwingHighColor()); + iObj.Anchor(ANCHOR_BOTTOM); + + // + mSwingHighObjects.Add(iObj); + } + + // + // Swing Lows ... + + // + bool mAllowSwingLows; // Detect Swing Lows ... + bool mAllowDrawSwingLows; // Draw Swing Lows ... + char mSwingLowArrowCode; // Swing Low Arrow Code ... + color mSwingLowColor; // Swing Low Color ... + int mSwingLowWidth; // Swing Low Width ... + double mSwingLowThreshold; // Threshold Required for Swing Low Detection ... + XOHCL mSwingLows[]; // Swing Lows ... + CArrayObj mSwingLowObjects; // Swing Low Chart Objects ... + TXOHCLEventHandler mSwingLowEventListeners[]; // Swing Low Event Listeners ... + + /** + * Create an Object to Represent Swing Low on Chart ... + * + * @param bar: XOHCL instance ... + * @param name: String ... + */ + void CreateSwingLowObject( + XOHCL &bar, + string name // + ) + { + // + if (!bar.IsValid() || + !IsValid(name)) + { + return; + } + + // + CChartObjectArrow *iObj; + iObj = new CChartObjectArrow(); + bool isCreated = iObj.Create( + ChartID(), + name, + Window(), + bar.time, + bar.low, + SwingLowArrowCode() // + ); + if (!isCreated) + { + return; + } + + // + // Configure Object ... + iObj.Width(SwingLowWidth()); + iObj.Color(SwingLowColor()); + iObj.Anchor(ANCHOR_TOP); + + // + mSwingLowObjects.Add(iObj); + } + + // + // Momentum Bars ... + + // + bool mAllowMomentumBars; // Detect Momentum Bars ... + bool mAllowDrawMomentumBars; // Draw Momentum Bars ... + int mMomentumBarPercent; // Momentum Bar Percent ... + double mMomentumBarSharpRatio; // Momentum Bar Sharp Ratio ... + int mMomentumBarLoopBack; // Momentum Bar Loopback ... + int mMomentumBarWidth; // Momentum Bar Width ... + char mMomentumBarBullishArrowCode; // Bullish Momentum Bar Arrow Code ... + char mMomentumBarBearishArrowCode; // Bullish Momentum Bar Color ... + color mMomentumBarBullishColor; // Bearish Momentum Bar Arrow Code ... + color mMomentumBarBearishColor; // Bearish Momentum Bar Color ... + XOHCL mMomentumBars[]; // Momentum Bars ... + CArrayObj mMomentumBarObjects; // Momentm Bar Chart Objects ... + TXOHCLEventHandler mMomentumBarEventListeners[]; // Momentum Bars Event Listeners ... + + /** + * Create an Object to Represent Momentum Bar on Chart ... + * + * @param bar: XOHCL instance ... + * @param name: String ... + */ + void CreateMomentumBarObject( + XOHCL &bar, + string name // + ) + { + // + if (!bar.IsValid() || + !IsValid(name)) + { + return; + } + + // + bool isBullish = bar.IsBullish(); + double price = + isBullish + ? bar.low + : bar.high; + char arrowCode = + isBullish + ? MomentumBarBullishArrowCode() + : MomentumBarBearishArrowCode(); + color clr = + isBullish + ? MomentumBarBullishColor() + : MomentumBarBearishColor(); + ENUM_ARROW_ANCHOR anchor = + isBullish + ? ANCHOR_TOP + : ANCHOR_BOTTOM; + + // + CChartObjectArrow *iObj; + iObj = new CChartObjectArrow(); + bool isCreated = iObj.Create( + ChartID(), + name, + Window(), + bar.time, + price, + arrowCode // + ); + if (!isCreated) + { + return; + } + + // + // Configure Object ... + iObj.Width(MomentumBarWidth()); + iObj.Color(clr); + iObj.Anchor(anchor); + + // + mMomentumBarObjects.Add(iObj); + } + + // + // Rejection Bars .... + + // + bool mAllowRejectionBars; // Detect Rejection Bars ... + bool mAllowDrawRejectionBars; // Draw Rejection Bars ... + int mRejectionBarPercent; // Rejection Bar Percent ... + double mRejectionBarSharpRatio; // Rejection Bar Sharp Ratio ... + int mRejectionBarLoopBack; // Rejection Bar Loopback ... + int mRejectionBarWidth; // Rejection Bar Width ... + char mRejectionBarBullishArrowCode; // Bullish Rejection Bar Arrow Code ... + char mRejectionBarBearishArrowCode; // Bullish Rejection Bar Color ... + color mRejectionBarBullishColor; // Bearish Rejection Bar Arrow Code ... + color mRejectionBarBearishColor; // Bearish Rejection Bar Color ... + XOHCL mRejectionBars[]; // Rejection Bars ... + CArrayObj mRejectionBarObjects; // Rejection Bar Chart Objects ... + TXOHCLEventHandler mRejectionBarEventListeners[]; // Rejection Bars Event Listeners ... + + /** + * Create an Object to Represent Rejection Bar on Chart ... + * + * @param bar: XOHCL instance ... + * @param name: String ... + */ + void CreateRejectionBarObject( + XOHCL &bar, + string name // + ) + { + // + if (!bar.IsValid() || + !IsValid(name)) + { + return; + } + + // + bool isBullish = bar.GetLowShadow() > bar.GetHighShadow(); + double price = + isBullish + ? bar.low + : bar.high; + char arrowCode = + isBullish + ? RejectionBarBullishArrowCode() + : RejectionBarBearishArrowCode(); + color clr = + isBullish + ? RejectionBarBullishColor() + : RejectionBarBearishColor(); + ENUM_ARROW_ANCHOR anchor = + isBullish + ? ANCHOR_TOP + : ANCHOR_BOTTOM; + + // + CChartObjectArrow *iObj; + iObj = new CChartObjectArrow(); + bool isCreated = iObj.Create( + ChartID(), + name, + Window(), + bar.time, + price, + arrowCode // + ); + if (!isCreated) + { + return; + } + + // + // Configure Object ... + iObj.Width(RejectionBarWidth()); + iObj.Color(clr); + iObj.Anchor(anchor); + + // + mRejectionBarObjects.Add(iObj); + } + + // + // Support and Resistance Zones ... + + // + // Support Zones ... + + // + bool mAllowSupportZones; // Detect Support Zone ... + bool mAllowDrawSupportZones; // Draw Support Zone ... + int mSupportZoneLoopBack; // Support Zone Loopback ... + int mSupportZoneWidth; // Support Zone Width ... + color mSupportZoneColor; // Support Zone Color ... + ENUM_LINE_STYLE mSupportZoneStyle; // Support Zone Style ... + ENUM_X_PRICE mSupportZonePriceType; // Support Zone Price Type ... + XOHCL mSupportZones[]; // Support Zones ... + CArrayObj mSupportZoneObjects; // Support Zone Chart Objects ... + TXOHCLEventHandler mSupportZoneEventListeners[]; // Support Zone Event Listeners ... + + /** + * Create an Object to Represent Support Zones on Chart ... + + * @param bar: XOHCL instance ... + * @param name: String ... + */ + void CreateSupportZoneObject( + XOHCL &bar, + string name // + ) + { + // + if (!bar.IsValid() || + !IsValid(name)) + { + return; + } + + // + datetime cBarTime = TimeCurrent(); + if (bar.Index() > 0) + { + // + cBarTime = iTime( + mSymbol, + mPeriod, + bar.Index() - 10 // + ); + } + + // + XCSupportZoneObject *iObj; + iObj = new XCSupportZoneObject(); + bool isCreated = iObj.CreateBySupport( + ChartID(), + name, + Window(), + bar, + cBarTime, + true // Force Draw Rect ... + ); + if (!isCreated) + { + return; + } + + // + // Configure Object ... + iObj.ZoneColor(SupportZoneColor()); + iObj.ZoneStyle(SupportZoneStyle()); + iObj.ZoneWidth(SupportZoneWidth()); + + // + mSupportZoneObjects.Add(iObj); + } + + // + // Resistance Zones ... + + // + bool mAllowResistanceZones; // Detect Resistance Zone ... + bool mAllowDrawResistanceZones; // Draw Resistance Zone ... + int mResistanceZoneLoopBack; // Resistance Zone Loopback ... + int mResistanceZoneWidth; // Resistance Zone Width ... + color mResistanceZoneColor; // Resistance Zone Color ... + ENUM_LINE_STYLE mResistanceZoneStyle; // Resistance Zone Style ... + ENUM_X_PRICE mResistanceZonePriceType; // Resistance Zone Price Type ... + XOHCL mResistanceZones[]; // Resistance Zones ... + CArrayObj mResistanceZoneObjects; // Resistance Zone Chart Objects ... + TXOHCLEventHandler mResistanceZoneEventListeners[]; // Resistance Zone Event Listeners ... + + /** + * Create an Object to Represent Resistance Zones on Chart ... + + * @param bar: XOHCL instance ... + * @param name: String ... + */ + void CreateResistanceZoneObject( + XOHCL &bar, + string name // + ) + { + // + if (!bar.IsValid() || + !IsValid(name)) + { + return; + } + + // + datetime cBarTime = TimeCurrent(); + if (bar.Index() > 0) + { + // + cBarTime = iTime( + mSymbol, + mPeriod, + bar.Index() - 10 // + ); + } + + // + XCResistanceZoneObject *iObj; + iObj = new XCResistanceZoneObject(); + bool isCreated = iObj.CreateByResistance( + ChartID(), + name, + Window(), + bar, + cBarTime, + true // Force Draw Rect ... + ); + if (!isCreated) + { + return; + } + + // + // Configure Object ... + iObj.ZoneColor(ResistanceZoneColor()); + iObj.ZoneStyle(ResistanceZoneStyle()); + iObj.ZoneWidth(ResistanceZoneWidth()); + + // + mResistanceZoneObjects.Add(iObj); + } + + // + // Supply and Demand Zones ... + + // + // Supply Zones ... + + // + bool mAllowSupplyZones; // Detect Supply Zone ... + bool mAllowDrawSupplyZones; // Draw Supply Zone ... + int mSupplyZoneWidth; // Supply Zone Width ... + color mSupplyZoneColor; // Supply Zone Color ... + ENUM_LINE_STYLE mSupplyZoneStyle; // Supply Zone Style ... + ENUM_TIMEFRAMES mSupplyZonePeriod; // Supply Zone Detection Period ... + XZone mSupplyZones[]; // Supply Zones ... + CArrayObj mSupplyZoneObjects; // Supply Zone Chart Objects ... + TXZoneEventHandler mSupplyZoneEventListeners[]; // Supply Zone Event Listeners ... + + /** + * Create an Object to Represent Supply Zones on Chart ... + + * @param bar: XZone instance ... + * @param name: String ... + */ + void CreateSupplyZoneObject( + XZone &zone, + string name // + ) + { + // + if (!zone.IsValid() || + !IsValid(name)) + { + return; + } + + // + XCSupplyZoneObject *iObj; + iObj = new XCSupplyZoneObject(); + bool isCreated = iObj.CreateByZone( + ChartID(), + name, + Window(), + zone, + NULL, // Object Prefix ... + true // Force Draw Rect ... + ); + if (!isCreated) + { + return; + } + + // + // Configure Object ... + iObj.ZoneColor(SupplyZoneColor()); + iObj.ZoneStyle(SupplyZoneStyle()); + iObj.ZoneWidth(SupplyZoneWidth()); + + // + mSupplyZoneObjects.Add(iObj); + } + + // + // Demand Zones ... + + // + bool mAllowDemandZones; // Detect Demand Zone ... + bool mAllowDrawDemandZones; // Draw Demand Zone ... + int mDemandZoneWidth; // Demand Zone Width ... + color mDemandZoneColor; // Demand Zone Color ... + ENUM_LINE_STYLE mDemandZoneStyle; // Demand Zone Style ... + ENUM_TIMEFRAMES mDemandZonePeriod; // Demand Zone Detection Period ... + XZone mDemandZones[]; // Demand Zones ... + CArrayObj mDemandZoneObjects; // Demand Zone Chart Objects ... + TXZoneEventHandler mDemandZoneEventListeners[]; // Demand Zone Event Listeners ... + + /** + * Create an Object to Represent Demand Zones on Chart ... + + * @param bar: XZone instance ... + * @param name: String ... + */ + void CreateDemandZoneObject( + XZone &zone, + string name // + ) + { + // + if (!zone.IsValid() || + !IsValid(name)) + { + return; + } + + // + XCDemandZoneObject *iObj; + iObj = new XCDemandZoneObject(); + bool isCreated = iObj.CreateByZone( + ChartID(), + name, + Window(), + zone, + NULL, // Object Prefix ... + true // Force Draw Rect ... + ); + if (!isCreated) + { + return; + } + + // + // Configure Object ... + iObj.ZoneColor(DemandZoneColor()); + iObj.ZoneStyle(DemandZoneStyle()); + iObj.ZoneWidth(DemandZoneWidth()); + + // + mDemandZoneObjects.Add(iObj); + } + + // + // Order Blocks ... + + // + // Bullish Order Blocks ... + + // + bool mAllowBullishOrderBlocks; // Detect Bullish Order Blocks ... + bool mAllowDrawBullishOrderBlocks; // Draw Bullish Order Blocks ... + int mBullishOrderBlockWidth; // Bullish Order Block Width ... + color mBullishOrderBlockColor; // Bullish Order Block Color ... + ENUM_LINE_STYLE mBullishOrderBlockStyle; // Bullish Order Block Style ... + int mRequiredBarsForBullishOrderBlock; // Minimum Required Same Bars for Bullish Order Blocks ... + XZone mBullishOrderBlocks[]; // Bullish Order Blocks ... + CArrayObj mBullishOrderBlockObjects; // Bullish Order Block Objects ... + TXZoneEventHandler mBullishOrderBlockEventListeners[]; // Bullish Order Block Event Listeners ... + + /** + * Create an Object to Represent Bullish Order Block on Chart ... + + * @param bar: XZone instance ... + * @param name: String ... + */ + void CreateBullishOrderBlockObject( + XZone &zone, + string name // + ) + { + // + if (!zone.IsValid() || + !IsValid(name)) + { + return; + } + + // + XCBullishOrderBlockObject *iObj; + iObj = new XCBullishOrderBlockObject(); + bool isCreated = iObj.CreateByZone( + ChartID(), + name, + Window(), + zone, + NULL, // Object Prefix ... + true // Force Draw Rect ... + ); + if (!isCreated) + { + return; + } + + // + // Configure Object ... + iObj.ZoneColor(BullishOrderBlockColor()); + iObj.ZoneStyle(BullishOrderBlockStyle()); + iObj.ZoneWidth(BullishOrderBlockWidth()); + + // + mBullishOrderBlockObjects.Add(iObj); + } + + // + // Bearish Order Blocks ... + + // + bool mAllowBearishOrderBlocks; // Detect Bearish Order Blocks ... + bool mAllowDrawBearishOrderBlocks; // Draw Bearish Order Blocks ... + int mBearishOrderBlockWidth; // Bearish Order Block Width ... + color mBearishOrderBlockColor; // Bearish Order Block Color ... + ENUM_LINE_STYLE mBearishOrderBlockStyle; // Bearish Order Block Style ... + int mRequiredBarsForBearishOrderBlock; // Minimum Required Same Bars for Bearish Order Blocks ... + XZone mBearishOrderBlocks[]; // Bearish Order Blocks ... + CArrayObj mBearishOrderBlockObjects; // Bearish Order Block Objects ... + TXZoneEventHandler mBearishOrderBlockEventListeners[]; // Bearish Order Block Event Listeners ... + + /** + * Create an Object to Represent Bearish Order Block on Chart ... + + * @param bar: XZone instance ... + * @param name: String ... + */ + void CreateBearishOrderBlockObject( + XZone &zone, + string name // + ) + { + // + if (!zone.IsValid() || + !IsValid(name)) + { + return; + } + + // + XCBearishOrderBlockObject *iObj; + iObj = new XCBearishOrderBlockObject(); + bool isCreated = iObj.CreateByZone( + ChartID(), + name, + Window(), + zone, + NULL, // Object Prefix ... + true // Force Draw Rect ... + ); + if (!isCreated) + { + return; + } + + // + // Configure Object ... + iObj.ZoneColor(BearishOrderBlockColor()); + iObj.ZoneStyle(BearishOrderBlockStyle()); + iObj.ZoneWidth(BearishOrderBlockWidth()); + + // + mBearishOrderBlockObjects.Add(iObj); + } + + // + // Fair Value Gaps ... + + // + // Bullish Fair Value Gaps ... + + // + bool mAllowBullishFVGs; // Detect Bullish Fair Value Gaps ... + bool mAllowDrawBullishFVGs; // Draw Bullish Fair Value Gaps ... + bool mBullishFVGForceMiddleBarCheck; // Bullish FVG Force Middle Bar Check ... + bool mBullishFVGForceCheckLastBarDirection; // Bullish FVG Check Last Bar Direction ... + int mBullishFVGWidth; // Bullish FVG Width ... + color mBullishFVGColor; // Bullish FVG Color ... + ENUM_LINE_STYLE mBullishFVGStyle; // Bullish FVG Style ... + XZone mBullishFVGs[]; // Bullish FVGs ... + CArrayObj mBullishFVGObjects; // Bullish FVG Objects ... + TXZoneEventHandler mBullishFVGEventListeners[]; // Bullish FVG Event Listeners ... + + /** + * Create an Object to Represent Bullish FVG on Chart ... + + * @param bar: XZone instance ... + * @param name: String ... + */ + void CreateBullishFVGObject( + XZone &zone, + string name // + ) + { + // + if (!zone.IsValid() || + !IsValid(name)) + { + return; + } + + // + XCBullishFVGObject *iObj; + iObj = new XCBullishFVGObject(); + bool isCreated = iObj.CreateByZone( + ChartID(), + name, + Window(), + zone, + NULL, // Object Prefix ... + true // Force Draw Rect ... + ); + if (!isCreated) + { + return; + } + + // + // Configure Object ... + iObj.ZoneColor(BullishFVGColor()); + iObj.ZoneStyle(BullishFVGStyle()); + iObj.ZoneWidth(BullishFVGWidth()); + + // + mBullishFVGObjects.Add(iObj); + } + + // + // Bearish Fair Value Gaps ... + + // + bool mAllowBearishFVGs; // Detect Bearish Fair Value Gaps ... + bool mAllowDrawBearishFVGs; // Draw Bearish Fair Value Gaps ... + bool mBearishFVGForceMiddleBarCheck; // Bearish FVG Force Middle Bar Check ... + bool mBearishFVGForceCheckLastBarDirection; // Bearish FVG Check Last Bar Direction ... + int mBearishFVGWidth; // Bearish FVG Width ... + color mBearishFVGColor; // Bearish FVG Color ... + ENUM_LINE_STYLE mBearishFVGStyle; // Bearish FVG Style ... + XZone mBearishFVGs[]; // Bearish FVGs ... + CArrayObj mBearishFVGObjects; // Bearish FVG Objects ... + TXZoneEventHandler mBearishFVGEventListeners[]; // Bearish FVG Event Listeners ... + + /** + * Create an Object to Represent Bearish FVG on Chart ... + + * @param bar: XZone instance ... + * @param name: String ... + */ + void CreateBearishFVGObject( + XZone &zone, + string name // + ) + { + // + if (!zone.IsValid() || + !IsValid(name)) + { + return; + } + + // + XCBearishFVGObject *iObj; + iObj = new XCBearishFVGObject(); + bool isCreated = iObj.CreateByZone( + ChartID(), + name, + Window(), + zone, + NULL, // Object Prefix ... + true // Force Draw Rect ... + ); + if (!isCreated) + { + return; + } + + // + // Configure Object ... + iObj.ZoneColor(BearishFVGColor()); + iObj.ZoneStyle(BearishFVGStyle()); + iObj.ZoneWidth(BearishFVGWidth()); + + // + mBearishFVGObjects.Add(iObj); + } + + // +}; + +// \ No newline at end of file diff --git a/X121SMCEA/Libraries/x-121.smc.lib.mq5 b/X121SMCEA/Libraries/x-121.smc.lib.mq5 index 7e2d0cd5..09e60860 100644 --- a/X121SMCEA/Libraries/x-121.smc.lib.mq5 +++ b/X121SMCEA/Libraries/x-121.smc.lib.mq5 @@ -51,8 +51,10 @@ struct X121SMCStrategyConditions // XZone supplyZone; - XZone bearishOrderBlock; - XZone bearishFVG; + + // + XZone bearishOrderBlocks[]; + XZone bearishFVGs[]; // XOHCL swingHighs[]; @@ -62,8 +64,10 @@ struct X121SMCStrategyConditions // XZone demandZone; - XZone bullishOrderBlock; - XZone bullishFVG; + + // + XZone bullishOrderBlocks[]; + XZone bullishFVGs[]; // XOHCL supports[]; @@ -92,13 +96,17 @@ struct X121SMCStrategyConditions // supplyZone.Clean(); - bearishOrderBlock.Clean(); - bearishFVG.Clean(); + + // + Clean(bearishFVGs); + Clean(bearishOrderBlocks); // demandZone.Clean(); - bullishOrderBlock.Clean(); - bullishFVG.Clean(); + + // + Clean(bullishFVGs); + Clean(bullishOrderBlocks); // Clean(swingHighs); diff --git a/X121SMCEA/Strategy/x-121.smc.strategy.class.mq5 b/X121SMCEA/Strategy/x-121.smc.strategy.class.mq5 index 5abc84fe..0ed61301 100644 --- a/X121SMCEA/Strategy/x-121.smc.strategy.class.mq5 +++ b/X121SMCEA/Strategy/x-121.smc.strategy.class.mq5 @@ -97,6 +97,68 @@ class XCX121SMCStrategy : public XSCBaseAlert return mForceDisabled; } + /** + * Get Chart Id ... + * + * @return ( long ) + */ + long ChartIdentification() + { + return mChartID; + } + + /** + * Set Chart Id ... + * + * @param value: Long ... + */ + void ChartIdentification(long value) + { + // + if (value < 0) + { + value = 0; + } + + // + mChartID = value; + if (mPOIDrawer != NULL) + { + mPOIDrawer.ChartIdentification(value); + } + } + + /** + * Get Sub Window Id ... + * + * @return ( int ) + */ + int SubWindowIdentification() + { + return mSubWindow; + } + + /** + * Set Sub Window Id ... + * + * @param value: Integer ... + */ + void SubWindowIdentification(int value) + { + // + if (value < 0) + { + value = 0; + } + + // + mSubWindow = value; + if (mPOIDrawer != NULL) + { + mPOIDrawer.SubWindowIdentification(value); + } + } + /** * Get Signal Volume ... * @@ -336,10 +398,11 @@ class XCX121SMCStrategy : public XSCBaseAlert ); // - DrawSignal( - signal, - conditions // - ); + // TODO: ... + // DrawSignal( + // signal, + // conditions // + // ); // // ClearDraws(); @@ -457,26 +520,14 @@ class XCX121SMCStrategy : public XSCBaseAlert // - [] contains Engulfing ... // - [] has Order Block ... // - [] has FVG ... - DetectImportantPOIs( + bool isDetected = DetectImportantPOIs( conditions, _4HSupDemState, _4HState, _15MState, _5MState // ); - if (conditions.supplyZone.IsValid() || - conditions.bearishFVG.IsValid() || - conditions.bearishOrderBlock.IsValid()) - { - // - AddRef( - conditions, - mConditions // - ); - } - else if (conditions.demandZone.IsValid() || - conditions.bullishFVG.IsValid() || - conditions.bullishOrderBlock.IsValid()) + if (isDetected) { // AddRef( @@ -514,6 +565,9 @@ class XCX121SMCStrategy : public XSCBaseAlert break; } + // + DrawConditions(iConditions); + // // Longs ... bool isAllowLong = AllowLong(); @@ -522,6 +576,10 @@ class XCX121SMCStrategy : public XSCBaseAlert // hasLong = false; + // + // Find Demand Zone ... + hasLong = iConditions.demandZone.IsValid(); + // if (hasLong) { @@ -1046,6 +1104,26 @@ class XCX121SMCStrategy : public XSCBaseAlert R2R(2); Volume(0.01); + // + ChartIdentification(0); + SubWindowIdentification(0); + + // + // Configure POI Drawer if Required ... + mPOIDrawer = new XCPOIDrawer(); + mPOIDrawer.ChartIdentification(0); + mPOIDrawer.SubWindowIdentification(0); + + // + mPOIDrawer.DemandZoneFill(false); + mPOIDrawer.SupplyZoneFill(false); + mPOIDrawer.BullishFVGFill(false); + mPOIDrawer.BearishFVGFill(false); + mPOIDrawer.SupportZoneFill(false); + mPOIDrawer.ResistanceZoneFill(false); + mPOIDrawer.BullishOrderBlockFill(false); + mPOIDrawer.BearishOrderBlockFill(false); + // string symbol = Symbol(); ENUM_TIMEFRAMES period = Period(); @@ -1068,14 +1146,14 @@ class XCX121SMCStrategy : public XSCBaseAlert symbol, PERIOD_M15 // ); - m4HSupDemPOI.Window(0); m4HSupDemPOI.DisablePOIs(); m4HSupDemPOI.DisableDrawPOIs(); - m4HSupDemPOI.ChartID(ChartID()); m4HSupDemPOI.AllowSupplyZones(true); m4HSupDemPOI.AllowDemandZones(true); m4HSupDemPOI.SupplyZonePeriod(PERIOD_H4); m4HSupDemPOI.DemandZonePeriod(PERIOD_H4); + m4HSupDemPOI.SubWindowIdentification(0); + m4HSupDemPOI.ChartIdentification(ChartID()); // m4HSupDemPOI.Init(); @@ -1089,11 +1167,11 @@ class XCX121SMCStrategy : public XSCBaseAlert ); // - m4HPOI.Window(0); m4HPOI.DisableDrawPOIs(); - m4HPOI.ChartID(ChartID()); m4HPOI.SupplyZonePeriod(PERIOD_H4); m4HPOI.DemandZonePeriod(PERIOD_H4); + m4HPOI.SubWindowIdentification(0); + m4HPOI.ChartIdentification(ChartID()); // m4HPOI.Init(); @@ -1107,12 +1185,12 @@ class XCX121SMCStrategy : public XSCBaseAlert ); // - m15MPOI.Window(0); m15MPOI.DisableDrawPOIs(); - m15MPOI.ChartID(ChartID()); m15MPOI.MaxNumberOfRequiredPOIs(2); m15MPOI.SupplyZonePeriod(PERIOD_M15); m15MPOI.DemandZonePeriod(PERIOD_M15); + m15MPOI.SubWindowIdentification(0); + m15MPOI.ChartIdentification(ChartID()); // m15MPOI.Init(); @@ -1126,12 +1204,12 @@ class XCX121SMCStrategy : public XSCBaseAlert ); // - m5MPOI.Window(0); m5MPOI.DisableDrawPOIs(); - m5MPOI.ChartID(ChartID()); m5MPOI.MaxNumberOfRequiredPOIs(2); m5MPOI.SupplyZonePeriod(PERIOD_M5); m5MPOI.DemandZonePeriod(PERIOD_M5); + m5MPOI.SubWindowIdentification(0); + m5MPOI.ChartIdentification(ChartID()); // m5MPOI.Init(); @@ -1148,7 +1226,10 @@ class XCX121SMCStrategy : public XSCBaseAlert delete m4HPOI; delete m5MPOI; delete m15MPOI; - // delete m4HSupDemPOI; + delete m4HSupDemPOI; + + // + delete mPOIDrawer; // ClearDraws(); @@ -1205,7 +1286,7 @@ class XCX121SMCStrategy : public XSCBaseAlert * * @param state: Argument 1 */ - void DetectImportantPOIs( + bool DetectImportantPOIs( X121SMCStrategyConditions &conditions, XPOIState &supplyAndDemandZoneState, XPOIState &orderBlocksState, @@ -1213,6 +1294,9 @@ class XCX121SMCStrategy : public XSCBaseAlert XPOIState &triggerState // ) { + // + bool result = false; + // int supplyZonesCount = ArraySize(supplyAndDemandZoneState.supplyZones); int demandZonesCount = ArraySize(supplyAndDemandZoneState.demandZones); @@ -1259,7 +1343,7 @@ class XCX121SMCStrategy : public XSCBaseAlert !IsValidSize(supplyZonesCount) || !IsValidSize(demandZonesCount)) { - return; + return result; } // @@ -1271,7 +1355,7 @@ class XCX121SMCStrategy : public XSCBaseAlert ); if (!isInited) { - return; + return result; } // @@ -1292,7 +1376,30 @@ class XCX121SMCStrategy : public XSCBaseAlert tmpBar = iSwing; } } - DrawSwingHigh(tmpBar); + if (tmpBar.IsValid()) + { + // + mSwingHigh = tmpBar; + string name = tmpBar.GetTag(ToString(X_POI_SWING_HIGH)); + if (mSwingHighObject != NULL) + { + mSwingHighObject.Delete(); + } + mSwingHighObject = new CChartObjectHLine(); + bool isCreated = mSwingHighObject.Create( + ChartIdentification(), + name, + SubWindowIdentification(), + tmpBar.high // + ); + if (isCreated) + { + // + mSwingHighObject.Width(2); + mSwingHighObject.Color(clrRed); + mSwingHighObject.Style(STYLE_DASHDOTDOT); + } + } // // Swing Low ... @@ -1309,202 +1416,404 @@ class XCX121SMCStrategy : public XSCBaseAlert tmpBar = iSwing; } } - DrawSwingLow(tmpBar); - tmpBar.Clean(); - - // - // Supply Zone ... - for (int i = 0; i < supplyZonesCount; i++) + if (tmpBar.IsValid()) { // - XZone iSupplyZone = supplyAndDemandZoneState.supplyZones[i]; - conditions.supplyZone = iSupplyZone; - - // - XZone iBearishOrderBlock; - XZone iBearishFVG; - - // - bool isPassed = false; - int orderBlocksCount = ArraySize(orderBlocksState.bearishOrderBlocks); - isPassed = IsValidSize(orderBlocksCount); - if (!isPassed) + mSwingLow = tmpBar; + string name = tmpBar.GetTag(ToString(X_POI_SWING_LOW)); + if (mSwingLowObject != NULL) { - continue; + mSwingLowObject.Delete(); } - - // - // Find Related Order Block ... - isPassed = false; - for (int j = 0; j < orderBlocksCount; j++) + mSwingLowObject = new CChartObjectHLine(); + bool isCreated = mSwingLowObject.Create( + ChartIdentification(), + name, + SubWindowIdentification(), + tmpBar.low // + ); + if (isCreated) { // - XZone jOrderBlock = orderBlocksState.bearishOrderBlocks[j]; - - // - bool isOrderBlockInsideZone = IsSupplyZoneOrderBlock( - iSupplyZone, - jOrderBlock // - ); - if (isOrderBlockInsideZone) - { - // - isPassed = true; - iBearishOrderBlock = jOrderBlock; - conditions.bearishOrderBlock = jOrderBlock; - break; - } + mSwingLowObject.Width(2); + mSwingLowObject.Color(clrLime); + mSwingLowObject.Style(STYLE_DASHDOTDOT); } - if (!isPassed) - { - continue; - } - - // - isPassed = false; - int fairValueGapsCount = ArraySize(fvgsState.bearishFVGs); - isPassed = IsValidSize(fairValueGapsCount); - if (!isPassed) - { - continue; - } - - // - // Find Related Fair Value Gaps ... - isPassed = false; - for (int j = 0; j < fairValueGapsCount; j++) - { - // - XZone jFVG = fvgsState.bearishFVGs[j]; - - // - bool isBelongs = IsBearishOrderBlockFVG( - iBearishOrderBlock, - jFVG // - ); - if (isBelongs) - { - // - iBearishFVG = jFVG; - conditions.bearishFVG = jFVG; - - // - isPassed = true; - break; - } - } - // if (!isPassed) - // { - // continue; - // } - - // // - // if (isPassed) - // { - // // - // DrawSupplyZone(iSupplyZone); - // DrawBearishOrderBlock(iBearishOrderBlock); - // DrawBearishFVG(iBearishFVG); - // } } + tmpBar.Clean(); // // Demand Zone ... for (int i = 0; i < demandZonesCount; i++) { // + // Demand Zone ... XZone iDemandZone = supplyAndDemandZoneState.demandZones[i]; conditions.demandZone = iDemandZone; // - XZone iBullishOrderBlock; - XZone iBullishFVG; - - // - bool isPassed = false; + // Order Blocks ... int orderBlocksCount = ArraySize(orderBlocksState.bullishOrderBlocks); - isPassed = IsValidSize(orderBlocksCount); - if (!isPassed) - { - continue; - } - - // - // Find Related Order Block ... - isPassed = false; - for (int j = 0; j < orderBlocksCount; j++) + if (IsValidSize(orderBlocksCount)) { // - XZone jOrderBlock = orderBlocksState.bullishOrderBlocks[j]; - - // - bool isOrderBlockInsideZone = IsDemandZoneOrderBlock( - iDemandZone, - jOrderBlock // - ); - if (isOrderBlockInsideZone) + for (int j = 0; j < orderBlocksCount; j++) { // - isPassed = true; - iBullishOrderBlock = jOrderBlock; - conditions.bullishOrderBlock = jOrderBlock; - break; + XZone jZone = orderBlocksState.bullishOrderBlocks[j]; + + // + bool isInside = + jZone.from >= iDemandZone.from && + jZone.lower > iDemandZone.lower && + jZone.lower < iDemandZone.upper; + if (isInside) + { + // + AddRef( + jZone, + conditions.bullishOrderBlocks // + ); + } } } - if (!isPassed) - { - continue; - } // - isPassed = false; - int fairValueGapsCount = ArraySize(fvgsState.bullishFVGs); - isPassed = IsValidSize(fairValueGapsCount); - if (!isPassed) - { - continue; - } - - // - // Find Related Fair Value Gaps ... - isPassed = false; - for (int j = 0; j < fairValueGapsCount; j++) + // Support Zones ... + int supportsCount = ArraySize(fvgsState.supportZones); + if (IsValidSize(supportsCount)) { // - XZone jFVG = fvgsState.bullishFVGs[j]; - - // - bool isBelongs = IsBullishOrderBlockFVG( - iBullishOrderBlock, - jFVG // - ); - if (isBelongs) + for (int j = 0; j < supportsCount; j++) { // - iBullishFVG = jFVG; - conditions.bullishFVG = jFVG; + XOHCL jBar = fvgsState.supportZones[j]; // - isPassed = true; - break; + bool isInside = + jBar.time > iDemandZone.from && + jBar.low > iDemandZone.lower && + jBar.low < iDemandZone.upper; + if (isInside) + { + // + AddRef( + jBar, + conditions.supports // + ); + } } } - // if (!isPassed) - // { - // continue; - // } - // // - // if (isPassed) - // { - // // - // DrawDemandZone(iDemandZone); - // DrawBullishOrderBlock(iBullishOrderBlock); - // DrawBullishFVG(iBullishFVG); - // } + // + // Bullish FVGs ... + int fvgsCount = ArraySize(fvgsState.bullishFVGs); + if (IsValidSize(fvgsCount)) + { + // + for (int j = 0; j < fvgsCount; j++) + { + // + XZone jFVG = fvgsState.bullishFVGs[j]; + + // + bool isInside = + jFVG.from > iDemandZone.from; + if (isInside) + { + // + AddRef( + jFVG, + conditions.bullishFVGs // + ); + } + } + } + + // + // Swing Lows ... + int swingLowsCount = ArraySize(triggerState.swingLows); + if (IsValidSize(swingLowsCount)) + { + // + for (int j = 0; j < swingLowsCount; j++) + { + // + XOHCL jBar = triggerState.swingLows[j]; + + // + bool isInside = + jBar.time > iDemandZone.from && + jBar.low > iDemandZone.lower && + jBar.GetDown() < iDemandZone.upper; + if (isInside) + { + // + AddRef( + jBar, + conditions.swingLows // + ); + } + } + } + + // + // Bullish Momentum Bars ... + int bullishMomentumBarsCount = ArraySize(triggerState.momentumBars); + if (IsValidSize(bullishMomentumBarsCount)) + { + // + for (int j = 0; j < bullishMomentumBarsCount; j++) + { + // + XOHCL jBar = triggerState.momentumBars[j]; + + // + bool isInside = + jBar.IsBullish() && + jBar.time > iDemandZone.from && + jBar.low > iDemandZone.lower && + jBar.low < iDemandZone.upper; + if (isInside) + { + // + AddRef( + jBar, + conditions.bullishMomentumBars // + ); + } + } + } + + // + // Bullish Rejection Bars ... + int bullishRejectionBarsCount = ArraySize(triggerState.rejectionBars); + if (IsValidSize(bullishRejectionBarsCount)) + { + // + for (int j = 0; j < bullishRejectionBarsCount; j++) + { + // + XOHCL jBar = triggerState.rejectionBars[j]; + + // + bool isInside = + jBar.GetLowShadow() > jBar.GetHighShadow() && + jBar.time > iDemandZone.from && + jBar.low > iDemandZone.lower && + jBar.low < iDemandZone.upper; + if (isInside) + { + // + AddRef( + jBar, + conditions.bullishRejectionBars // + ); + } + } + } } // + // Supply Zone ... + for (int i = 0; i < demandZonesCount; i++) + { + // + // Supply Zone ... + XZone iSupplyZone = supplyAndDemandZoneState.supplyZones[i]; + conditions.supplyZone = iSupplyZone; + + // + // Order Blocks ... + int orderBlocksCount = ArraySize(orderBlocksState.bearishOrderBlocks); + if (IsValidSize(orderBlocksCount)) + { + // + for (int j = 0; j < orderBlocksCount; j++) + { + // + XZone jZone = orderBlocksState.bearishOrderBlocks[j]; + + // + bool isInside = + jZone.from > iSupplyZone.from && + jZone.upper > iSupplyZone.lower && + jZone.upper < iSupplyZone.upper; + if (isInside) + { + // + AddRef( + jZone, + conditions.bearishOrderBlocks // + ); + } + } + } + + // + // Resistance Zones ... + int resistancesCount = ArraySize(fvgsState.resistanceZones); + if (IsValidSize(resistancesCount)) + { + // + for (int j = 0; j < resistancesCount; j++) + { + // + XOHCL jBar = fvgsState.resistanceZones[j]; + + // + bool isInside = + jBar.time > iSupplyZone.from && + jBar.high > iSupplyZone.lower && + jBar.high < iSupplyZone.upper; + if (isInside) + { + // + AddRef( + jBar, + conditions.resistances // + ); + } + } + } + + // + // Bearish FVGs ... + int fvgsCount = ArraySize(fvgsState.bearishFVGs); + if (IsValidSize(fvgsCount)) + { + // + for (int j = 0; j < fvgsCount; j++) + { + // + XZone jZone = fvgsState.bearishFVGs[j]; + + // + bool isInside = + jZone.from > iSupplyZone.from && + jZone.upper > iSupplyZone.lower && + jZone.upper < iSupplyZone.upper; + if (isInside) + { + // + AddRef( + jZone, + conditions.bearishFVGs // + ); + } + } + } + + // + // Swing Highs ... + int swingHighsCount = ArraySize(triggerState.swingHighs); + if (IsValidSize(swingHighsCount)) + { + // + for (int j = 0; j < swingHighsCount; j++) + { + // + XOHCL jBar = triggerState.swingHighs[j]; + + // + bool isInside = + jBar.time > iSupplyZone.from && + jBar.high > iSupplyZone.lower && + jBar.high < iSupplyZone.upper; + if (isInside) + { + // + AddRef( + jBar, + conditions.swingHighs // + ); + } + } + } + + // + // Bearish Momentum Bars ... + int bearishMomentumBarsCount = ArraySize(triggerState.momentumBars); + if (IsValidSize(bearishMomentumBarsCount)) + { + // + for (int j = 0; j < bearishMomentumBarsCount; j++) + { + // + XOHCL jBar = fvgsState.momentumBars[j]; + + // + bool isInside = + jBar.IsBearish() && + jBar.time > iSupplyZone.from && + jBar.high > iSupplyZone.lower && + jBar.high < iSupplyZone.upper; + if (isInside) + { + // + AddRef( + jBar, + conditions.bearishMomentumBars // + ); + } + } + } + + // + // Bearish Rejection Bars ... + int bearishRejectionBarsCount = ArraySize(triggerState.rejectionBars); + if (IsValidSize(bearishRejectionBarsCount)) + { + // + for (int j = 0; j < bearishRejectionBarsCount; j++) + { + // + XOHCL jBar = fvgsState.rejectionBars[j]; + + // + bool isInside = + jBar.GetHighShadow() > jBar.GetLowShadow() && + jBar.time > iSupplyZone.from && + jBar.high > iSupplyZone.lower && + jBar.high < iSupplyZone.upper; + if (isInside) + { + // + AddRef( + jBar, + conditions.bearishRejectionBars // + ); + } + } + } + } + + // + bool isConditionReadyForDemand = + conditions.demandZone.IsValid() && + (ArraySize(conditions.supports) > 0 || + ArraySize(conditions.swingLows) > 0 || + ArraySize(conditions.bullishFVGs) > 0 || + ArraySize(conditions.bullishOrderBlocks) > 0 || + ArraySize(conditions.bullishMomentumBars) > 0 || + ArraySize(conditions.bullishRejectionBars) > 0); + + // + bool isConditionReadyForSupply = + conditions.supplyZone.IsValid() && + (ArraySize(conditions.swingHighs) > 0 || + ArraySize(conditions.bearishFVGs) > 0 || + ArraySize(conditions.resistances) > 0 || + ArraySize(conditions.bearishOrderBlocks) > 0 || + ArraySize(conditions.bearishMomentumBars) > 0 || + ArraySize(conditions.bearishRejectionBars) > 0); + + // + result = isConditionReadyForDemand || + isConditionReadyForSupply; + + // + return result; } // @@ -1547,742 +1856,375 @@ class XCX121SMCStrategy : public XSCBaseAlert } } - // - // Tools Functions ... - - /** - * Check an Order Block belongs to a Supply Zone ... - * - * @param supply: XZone instance ... - * @param orderBlock: XZone instance ... - * - * @return ( bool ) - */ - bool IsSupplyZoneOrderBlock( - XZone &supply, - XZone &orderBlock // - ) - { - // - bool result = false; - - // - result = supply.IsValid() && - orderBlock.IsValid(); - if (!result) - { - return result; - } - - // - result = - orderBlock.upper <= supply.upper; - - // - return result; - } - - /** - * Check an Order Block belongs to a Demand Zone ... - * - * @param demand: XZone instance ... - * @param orderBlock: XZone instance ... - * - * @return ( bool ) - */ - bool IsDemandZoneOrderBlock( - XZone &demand, - XZone &orderBlock // - ) - { - // - bool result = false; - - // - result = demand.IsValid() && - orderBlock.IsValid(); - if (!result) - { - return result; - } - - // - result = - orderBlock.lower >= demand.lower; - - // - return result; - } - - /** - * Check a Bearish FVG belongs to a Bearish Order Block ... - * - * @param orderBlock: XZone instance ... - * @param fvg: XZone instance ... - * - * @return ( bool ) - */ - bool IsBearishOrderBlockFVG( - XZone &orderBlock, - XZone &fvg // - ) - { - // - bool result = false; - - // - result = fvg.IsValid() && - orderBlock.IsValid(); - if (!result) - { - return result; - } - - // - result = - fvg.upper <= orderBlock.upper && - fvg.upper > orderBlock.lower; - - // - return result; - } - - /** - * Check a Bullish FVG belongs to a Bullish Order Block ... - * - * @param orderBlock: XZone instance ... - * @param fvg: XZone instance ... - * - * @return ( bool ) - */ - bool IsBullishOrderBlockFVG( - XZone &orderBlock, - XZone &fvg // - ) - { - // - bool result = false; - - // - result = fvg.IsValid() && - orderBlock.IsValid(); - if (!result) - { - return result; - } - - // - result = - fvg.lower >= orderBlock.lower && - fvg.lower < orderBlock.upper; - - // - return result; - } - // // Draw Functions ... - /** - * Draw Specific Swing High ... - * - * @param swing: XOHCL instance which represents Swing Point ... - */ - void DrawSwingHigh(XOHCL &swing) - { - // - if (!swing.IsValid()) - { - return; - } - - // - string name = swing.GetTag(ToString(X_POI_SWING_HIGH)); - - // - if (mSwingHigh.IsValid()) - { - // - mSwingHigh.Clean(); - mSwingHighObject.Delete(); - } - - // - mSwingHigh = swing; - mSwingHighObject = new CChartObjectHLine(); - bool isCreated = mSwingHighObject.Create( - ChartID(), - name, - 0, - swing.high // - ); - if (!isCreated) - { - return; - } - - // - mSwingHighObject.Width(1); - mSwingHighObject.Color(clrBrown); - mSwingHighObject.Style(STYLE_SOLID); - } - - /** - * Draw Specific Swing Low ... - * - * @param swing: XOHCL instance which represents Swing Point ... - */ - void DrawSwingLow(XOHCL &swing) - { - // - if (!swing.IsValid()) - { - return; - } - - // - string name = swing.GetTag(ToString(X_POI_SWING_LOW)); - - // - if (mSwingLow.IsValid()) - { - // - mSwingLow.Clean(); - mSwingLowObject.Delete(); - } - - // - mSwingLow = swing; - mSwingLowObject = new CChartObjectHLine(); - - // - bool isCreated = mSwingLowObject.Create( - ChartID(), - name, - 0, - swing.low // - ); - if (!isCreated) - { - return; - } - - // - mSwingLowObject.Width(1); - mSwingLowObject.Color(clrGreen); - mSwingLowObject.Style(STYLE_SOLID); - } - - /** - * Draw Supply Zone ... - * - * @param zone: XZone instance ... - */ - void DrawSupplyZone(XZone &zone) - { - // - if (!zone.IsValid()) - { - return; - } - - // - string name = zone.GetTag(); - RemoveObject(name); - - // - zone.to = TimeCurrent(); - name = zone.GetTag(); - - // - XCSupplyZoneObject *iObj; - iObj = new XCSupplyZoneObject(); - bool isCreated = iObj.CreateByZone( - ChartID(), - name, - 0, - zone, - NULL, - true // - ); - if (!isCreated) - { - return; - } - - // - iObj.ZoneWidth(1); - iObj.ZoneStyle(STYLE_DOT); - iObj.ZoneColor(clrMagenta); - - // - mDrawnObjects.Add(iObj); - } - - /** - * Draw Demand Zone ... - * - * @param zone: XZone instance ... - */ - void DrawDemandZone(XZone &zone) - { - // - if (!zone.IsValid()) - { - return; - } - - // - string name = zone.GetTag(); - RemoveObject(name); - - // - zone.to = TimeCurrent(); - name = zone.GetTag(); - - // - XCDemandZoneObject *iObj; - iObj = new XCDemandZoneObject(); - bool isCreated = iObj.CreateByZone( - ChartID(), - name, - 0, - zone, - NULL, - true // - ); - if (!isCreated) - { - return; - } - - // - iObj.ZoneWidth(1); - iObj.ZoneStyle(STYLE_DOT); - iObj.ZoneColor(clrAqua); - - // - mDrawnObjects.Add(iObj); - } - - /** - * Draw Specific Bearish Order Block ... - * - * @param zone: XZone instance ... - */ - void DrawBearishOrderBlock(XZone &zone) - { - // - if (!zone.IsValid()) - { - return; - } - - // - string name = zone.GetTag(); - RemoveObject(name); - - // - zone.to = TimeCurrent(); - name = zone.GetTag(); - - // - XCBearishOrderBlockObject *iObj; - iObj = new XCBearishOrderBlockObject(); - bool isCreated = iObj.CreateByZone( - ChartID(), - name, - 0, - zone, - NULL, - true // - ); - if (!isCreated) - { - return; - } - - // - iObj.ZoneWidth(1); - iObj.ZoneColor(clrRed); - iObj.ZoneStyle(STYLE_DASH); - - // - mDrawnObjects.Add(iObj); - } - - /** - * Draw Specific Bullish Order Block ... - * - * @param zone: XZone instance ... - */ - void DrawBullishOrderBlock(XZone &zone) - { - // - if (!zone.IsValid()) - { - return; - } - - // - string name = zone.GetTag(); - RemoveObject(name); - - // - zone.to = TimeCurrent(); - name = zone.GetTag(); - - // - XCBullishOrderBlockObject *iObj; - iObj = new XCBullishOrderBlockObject(); - bool isCreated = iObj.CreateByZone( - ChartID(), - name, - 0, - zone, - NULL, - true // - ); - if (!isCreated) - { - return; - } - - // - iObj.ZoneWidth(1); - iObj.ZoneColor(clrLime); - iObj.ZoneStyle(STYLE_DASH); - - // - mDrawnObjects.Add(iObj); - } - - /** - * Draw Specific Bearish FVG ... - * - * @param zone: XZone instance ... - */ - void DrawBearishFVG(XZone &zone) - { - // - if (!zone.IsValid()) - { - return; - } - - // - string name = zone.GetTag(); - RemoveObject(name); - - // - zone.to = TimeCurrent(); - name = zone.GetTag(); - - // - XCBearishFVGObject *iObj; - iObj = new XCBearishFVGObject(); - bool isCreated = iObj.CreateByZone( - ChartID(), - name, - 0, - zone, - NULL, - true // - ); - if (!isCreated) - { - return; - } - - // - iObj.ZoneWidth(1); - iObj.ZoneColor(clrOrange); - iObj.ZoneStyle(STYLE_DASHDOT); - - // - mDrawnObjects.Add(iObj); - } - - /** - * Draw Specific Bullish FVG ... - * - * @param zone: XZone instance ... - */ - void DrawBullishFVG(XZone &zone) - { - // - if (!zone.IsValid()) - { - return; - } - - // - string name = zone.GetTag(); - RemoveObject(name); - - // - zone.to = TimeCurrent(); - name = zone.GetTag(); - - // - XCBullishFVGObject *iObj; - iObj = new XCBullishFVGObject(); - bool isCreated = iObj.CreateByZone( - ChartID(), - name, - 0, - zone, - NULL, - true // - ); - if (!isCreated) - { - return; - } - - // - iObj.ZoneWidth(1); - iObj.ZoneColor(clrSteelBlue); - iObj.ZoneStyle(STYLE_DASHDOT); - - // - mDrawnObjects.Add(iObj); - } - - /** - * Draw Specified Swing Bars ... - * - * @param bar: XOHLC instance ... - * @param isLow: Boolean ... - */ - void DrawSwingBar( - XOHCL &bar, - bool isLow // - ) - { - // - if (!bar.IsValid()) - { - return; - } - - // - string tagPref = - isLow - ? ToString(X_POI_SWING_LOW) - : ToString(X_POI_SWING_HIGH); - string name = bar.GetTag(tagPref); - RemoveObject(name); - - // - double price = - isLow - ? bar.low - : bar.high; - char arrowCode = - isLow - ? (char)188 - : (char)108; - color clr = - isLow - ? clrAqua - : clrMagenta; - ENUM_ARROW_ANCHOR anchor = - isLow - ? ANCHOR_TOP - : ANCHOR_BOTTOM; - - // - CChartObjectArrow *iObj; - iObj = new CChartObjectArrow(); - bool isCreated = iObj.Create( - ChartID(), - name, - 0, - bar.time, - price, - arrowCode // - ); - if (!isCreated) - { - return; - } - - // - // Configure Object ... - iObj.Width(1); - iObj.Color(clr); - iObj.Anchor(anchor); - - // - mDrawnObjects.Add(iObj); - } - - /** - * Draw Momentum Bar ... - * - * @param bar: XOHCL instance ... - */ - void DrawMomentumBar(XOHCL &bar) - { - // - if (!bar.IsValid()) - { - return; - } - - // - bool isBullish = bar.IsBullish(); - string name = bar.GetTag(ToString(X_POI_MOMENTUM_BAR)); - RemoveObject(name); - - // - double price = - isBullish - ? bar.low - : bar.high; - char arrowCode = - isBullish - ? (char)225 - : (char)226; - color clr = - isBullish - ? clrAqua - : clrMagenta; - ENUM_ARROW_ANCHOR anchor = - isBullish - ? ANCHOR_TOP - : ANCHOR_BOTTOM; - - // - CChartObjectArrow *iObj; - iObj = new CChartObjectArrow(); - bool isCreated = iObj.Create( - ChartID(), - name, - 0, - bar.time, - price, - arrowCode // - ); - if (!isCreated) - { - return; - } - - // - // Configure Object ... - iObj.Width(1); - iObj.Color(clr); - iObj.Anchor(anchor); - - // - mDrawnObjects.Add(iObj); - } - - /** - * Draw Bullish Rejection Bar ... - * - * @param bar: XOHCL instance ... - */ - void DrawRejectionBar(XOHCL &bar) - { - // - if (!bar.IsValid()) - { - return; - } - - // - bool isBullish = bar.GetLowShadow() > bar.GetHighShadow(); - string name = bar.GetTag(ToString(X_POI_REJECTION_BAR)); - RemoveObject(name); - - // - double price = - isBullish - ? bar.low - : bar.high; - char arrowCode = - isBullish - ? (char)217 - : (char)218; - color clr = - isBullish - ? clrAqua - : clrMagenta; - ENUM_ARROW_ANCHOR anchor = - isBullish - ? ANCHOR_TOP - : ANCHOR_BOTTOM; - - // - CChartObjectArrow *iObj; - iObj = new CChartObjectArrow(); - bool isCreated = iObj.Create( - ChartID(), - name, - 0, - bar.time, - price, - arrowCode // - ); - if (!isCreated) - { - return; - } - - // - // Configure Object ... - iObj.Width(1); - iObj.Color(clr); - iObj.Anchor(anchor); - - // - mDrawnObjects.Add(iObj); - } + // + long mChartID; // Chart ID ... + int mSubWindow; // Sub Window ID ... + XCPOIDrawer *mPOIDrawer; // POI Drawer Class ... /** * Draw Specific Condition ... * - * @param conditions: Argument 1 + * @param conditions: X121SMCStrategyConditions instance ... */ void DrawConditions(X121SMCStrategyConditions &conditions) { // - if (conditions.supplyZone.IsValid()) + if (!conditions.IsValid()) { - DrawSupplyZone(conditions.supplyZone); - } - - // - if (conditions.bearishOrderBlock.IsValid()) - { - DrawBearishOrderBlock(conditions.bearishOrderBlock); - } - - // - if (conditions.bearishFVG.IsValid()) - { - DrawBearishFVG(conditions.bearishFVG); + return; } // + // Demand Zone ... if (conditions.demandZone.IsValid()) { - DrawDemandZone(conditions.demandZone); + // + // Demand ... + XCDemandZoneObject *iObj; + bool isCreated = mPOIDrawer.CreateDemandZone( + conditions.demandZone, + iObj // + ); + if (isCreated) + { + // + // RemoveObject(iObj.ObjName()); + mDrawnObjects.Add(iObj); + } + + // + // Order Blocks ... + int obsCount = ArraySize(conditions.bullishOrderBlocks); + if (IsValidSize(obsCount)) + { + // + for (int i = 0; i < obsCount; i++) + { + // + XZone iZone = conditions.bullishOrderBlocks[i]; + + // + XCBullishOrderBlockObject *iObj; + bool isCreated = mPOIDrawer.CreateBullishOrderBlock( + iZone, + iObj // + ); + if (isCreated) + { + // + // RemoveObject(iObj.ObjName()); + mDrawnObjects.Add(iObj); + } + } + } + + // + // Fair Value Gaps ... + int fvgsCount = ArraySize(conditions.bullishFVGs); + if (IsValidSize(fvgsCount)) + { + // + for (int i = 0; i < fvgsCount; i++) + { + // + XZone iZone = conditions.bullishFVGs[i]; + + // + XCBullishFVGObject *iObj; + bool isCreated = mPOIDrawer.CreateBullishFVG( + iZone, + iObj // + ); + if (isCreated) + { + // + // RemoveObject(iObj.ObjName()); + mDrawnObjects.Add(iObj); + } + } + } + + // + // Supports ... + int supportsCount = ArraySize(conditions.supports); + if (IsValidSize(supportsCount)) + { + // + for (int i = 0; i < supportsCount; i++) + { + // + XOHCL iBar = conditions.supports[i]; + + // + XCSupportZoneObject *iObj; + bool isCreated = mPOIDrawer.CreateSupportZone( + iBar, + iObj // + ); + if (isCreated) + { + // + // RemoveObject(iObj.ObjName()); + mDrawnObjects.Add(iObj); + } + } + } + + // + // Swings ... + int swingsCount = ArraySize(conditions.swingLows); + if (IsValidSize(swingsCount)) + { + // + for (int i = 0; i < swingsCount; i++) + { + // + XOHCL iBar = conditions.swingLows[i]; + + // + XCSwingLowObject *iObj; + bool isCreated = mPOIDrawer.CreateSwingLow( + iBar, + iObj // + ); + if (isCreated) + { + // + // RemoveObject(iObj.ObjName()); + mDrawnObjects.Add(iObj); + } + } + } + + // + // Momentum Bars ... + int momentumBarsCount = ArraySize(conditions.bullishMomentumBars); + if (IsValidSize(momentumBarsCount)) + { + // + for (int i = 0; i < momentumBarsCount; i++) + { + // + XOHCL iBar = conditions.bullishMomentumBars[i]; + + // + XCBullishMomentumBarObject *iObj; + bool isCreated = mPOIDrawer.CreateBullishMomentumBar( + iBar, + iObj // + ); + if (isCreated) + { + // + // RemoveObject(iObj.ObjName()); + mDrawnObjects.Add(iObj); + } + } + } + + // + // Rejection Bars ... + int rejectionBarsCount = ArraySize(conditions.bullishRejectionBars); + if (IsValidSize(rejectionBarsCount)) + { + // + for (int i = 0; i < rejectionBarsCount; i++) + { + // + XOHCL iBar = conditions.bullishRejectionBars[i]; + + // + XCBullishRejectionBarObject *iObj; + bool isCreated = mPOIDrawer.CreateBullishRejectionBar( + iBar, + iObj // + ); + if (isCreated) + { + // + // RemoveObject(iObj.ObjName()); + mDrawnObjects.Add(iObj); + } + } + } } // - if (conditions.bullishOrderBlock.IsValid()) + // Supply Zone ... + if (conditions.supplyZone.IsValid()) { - DrawBullishOrderBlock(conditions.bullishOrderBlock); - } + // + // Supply ... + XCSupplyZoneObject *iObj; + bool isCreated = mPOIDrawer.CreateSupplyZone( + conditions.supplyZone, + iObj // + ); + if (isCreated) + { + // + // RemoveObject(iObj.ObjName()); + mDrawnObjects.Add(iObj); + } - // - if (conditions.bullishFVG.IsValid()) - { - DrawBullishFVG(conditions.bullishFVG); + // + // Order Blocks ... + int obsCount = ArraySize(conditions.bearishOrderBlocks); + if (IsValidSize(obsCount)) + { + // + for (int i = 0; i < obsCount; i++) + { + // + XZone iZone = conditions.bearishOrderBlocks[i]; + + // + XCBearishOrderBlockObject *iObj; + bool isCreated = mPOIDrawer.CreateBearishOrderBlock( + iZone, + iObj // + ); + if (isCreated) + { + // + // RemoveObject(iObj.ObjName()); + mDrawnObjects.Add(iObj); + } + } + } + + // + // Fair Value Gaps ... + int fvgsCount = ArraySize(conditions.bearishFVGs); + if (IsValidSize(fvgsCount)) + { + // + for (int i = 0; i < fvgsCount; i++) + { + // + XZone iZone = conditions.bearishFVGs[i]; + + // + XCBearishFVGObject *iObj; + bool isCreated = mPOIDrawer.CreateBearishFVG( + iZone, + iObj // + ); + if (isCreated) + { + // + // RemoveObject(iObj.ObjName()); + mDrawnObjects.Add(iObj); + } + } + } + + // + // Resistances ... + int resistancesCount = ArraySize(conditions.resistances); + if (IsValidSize(resistancesCount)) + { + // + for (int i = 0; i < resistancesCount; i++) + { + // + XOHCL iBar = conditions.resistances[i]; + + // + XCResistanceZoneObject *iObj; + bool isCreated = mPOIDrawer.CreateResistanceZone( + iBar, + iObj // + ); + if (isCreated) + { + // + // RemoveObject(iObj.ObjName()); + mDrawnObjects.Add(iObj); + } + } + } + + // + // Swings ... + int swingsCount = ArraySize(conditions.swingHighs); + if (IsValidSize(swingsCount)) + { + // + for (int i = 0; i < swingsCount; i++) + { + // + XOHCL iBar = conditions.swingHighs[i]; + + // + XCSwingHighObject *iObj; + bool isCreated = mPOIDrawer.CreateSwingHigh( + iBar, + iObj // + ); + if (isCreated) + { + // + // RemoveObject(iObj.ObjName()); + mDrawnObjects.Add(iObj); + } + } + } + + // + // Momentum Bars ... + int momentumBarsCount = ArraySize(conditions.bearishMomentumBars); + if (IsValidSize(momentumBarsCount)) + { + // + for (int i = 0; i < momentumBarsCount; i++) + { + // + XOHCL iBar = conditions.bearishMomentumBars[i]; + + // + XCBearishMomentumBarObject *iObj; + bool isCreated = mPOIDrawer.CreateBearishMomentumBar( + iBar, + iObj // + ); + if (isCreated) + { + // + // RemoveObject(iObj.ObjName()); + mDrawnObjects.Add(iObj); + } + } + } + + // + // Rejection Bars ... + int rejectionBarsCount = ArraySize(conditions.bearishRejectionBars); + if (IsValidSize(rejectionBarsCount)) + { + // + for (int i = 0; i < rejectionBarsCount; i++) + { + // + XOHCL iBar = conditions.bearishRejectionBars[i]; + + // + XCBearishRejectionBarObject *iObj; + bool isCreated = mPOIDrawer.CreateBearishRejectionBar( + iBar, + iObj // + ); + if (isCreated) + { + // + // RemoveObject(iObj.ObjName()); + mDrawnObjects.Add(iObj); + } + } + } } }