/////////////////////////////////////////////////////// // // SaherElm IT Center MQL5 Class Library // -------------------------------------- // Name: XChartObjects // Description: provides all require Chart Objects ... // // // 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 // #include "../Libraries/x-saherelm.x-poi.lib.mq5" #include "../Libraries/x-saherelm.x-trade.lib.mq5" // #include #include #include #include #include // // Definitions ... enum ENUM_XCHARTOBJECTS { // // Global ... X_ZONE_OBJ = 7860, X_FROM_TO_OBJ = 7861, X_BAR_ARROW_OBJ = 7862, // X_SIGNAL_OBJ = 8860, X_TREND_OBJ = 8861, // // 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, X_TICK_ZONE_OBJ = 9876, X_TICKS_ZONE_OBJ = 9877, }; enum ENUM_X_CHART_IDS { X_TO, X_FROM, X_UPPER, X_LOWER, X_ENTRY, X_SL, X_TP }; // // Implementation ... // // Global Chart Objects ... // // Bas Chart Object ... class XCBaseObject : public CChartObject { // public: // // // Getter(s) / Setter(s) ... /** * Get Object Specified Name ... * * @return ( string ) */ string ObjName() { return mObjName; } /** * Set Object Specified Name ... * * @param value: String ... */ void ObjName(string value) { mObjName = value; } // private: // // // Props ... string mObjName; // Object Specified Name ... // }; class XCBarArrowObject : public XCBaseObject { // public: // /** * Creator ... * * @param chart_id: Long, Specified Chart ID ... * @param name: String, Specified Object ID ... * @param window: Integer, Specified Chart Window ID ... * @param swing: XCSwing instance ... * * @return ( bool ) */ bool CreateByBar( long chart_id, string name, int window, int arrow, XOHCL &bar, ENUM_X_PRICE priceType // ) { // bool result = false; // result = // bar.IsValid() // ; if (!result) { return result; } // datetime time = bar.time; double price = bar.GetPrice(priceType); // result = mArrow.Create( chart_id, name, window, time, price, (char)arrow // ); // if (result) { ObjName(name); } // return result; } // // Virtual ... // // Setter(s) ... /** * Set Arrow Anchor ... * * @param value: ENUM_ARROW_ANCHOR member ... */ void ArrowAnchor(ENUM_ARROW_ANCHOR value) { mArrow.Anchor(value); } /** * Set Arrow Color ... * * @param value: Color ... */ void ArrowColor(color value) { mArrow.Color(value); } /** * Set Arrow Width ... * * @param value: Integer ... */ void ArrowWidth(int value) { mArrow.Width(value); } // private: // CChartObjectArrow mArrow; // }; // // Swing ... class XCSwingObject : public XCBarArrowObject { // public: // /** * Creator ... * * @param chart_id: Long, Specified Chart ID ... * @param window: Integer, Specified Chart Window ID ... * @param swing: XCSwing instance ... * @param prefix: String ... * * @return ( bool ) */ bool CreateBySwing( long chart_id, int window, int arrow, XCSwing &swing, string prefix = NULL // ) { // bool result = false; // result = // swing.IsValid() // ; if (!result) { return result; } // string name = swing.GetTag(); if (IsValid(prefix)) { name = prefix + "_" + name; } // XOHCL bar; result = swing.FillBar(bar); if (!result) { return result; } // ENUM_X_PRICE price = swing.IsSwingHigh() ? X_PRICE_HIGH : X_PRICE_LOW; // result = CreateByBar( chart_id, name, window, arrow, bar, price // ); // if (result) { ObjName(name); } // return result; } }; // // Swing High ... class XCSwingHighObject : public XCSwingObject { // public: // /** * Creator ... * * @param chart_id: Long, Specified Chart ID ... * @param window: Integer, Specified Chart Window ID ... * @param arrow: Integer, Specified Arrow Code ... * @param swing: XCSwing instance ... * @param prefix: String ... * * @return ( bool ) */ bool Create( long chart_id, int window, int arrow, XCSwing &swing, string prefix = NULL // ) { // bool result = false; // result = swing.IsValid() && swing.IsSwingHigh(); if (!result) { return result; } // result = CreateBySwing( chart_id, window, arrow, swing, prefix // ); // return result; } /** * Retrieve Object Type ... * * @return ( ENUM_XCHARTOBJECTS ) */ virtual ENUM_XCHARTOBJECTS Type() { return X_SWING_HIGH_OBJ; } // }; // // Swing Low ... class XCSwingLowObject : public XCSwingObject { // public: // /** * Creator ... * * @param chart_id: Long, Specified Chart ID ... * @param window: Integer, Specified Chart Window ID ... * @param arrow: Integer, Specified Arrow Code ... * @param swing: XCSwing instance ... * @param prefix: String ... * * @return ( bool ) */ bool Create( long chart_id, int window, int arrow, XCSwing &swing, string prefix = NULL // ) { // bool result = false; // result = swing.IsValid() && swing.IsSwingLow(); if (!result) { return result; } // result = CreateBySwing( chart_id, window, arrow, swing, prefix // ); // return result; } /** * Retrieve Object Type ... * * @return ( ENUM_XCHARTOBJECTS ) */ virtual ENUM_XCHARTOBJECTS Type() { return X_SWING_LOW_OBJ; } // }; // // Momentum ... class XCMomentumBarObject : public XCBarArrowObject { // public: // /** * Creator ... * * @param chart_id: Long, Specified Chart ID ... * @param window: Integer, Specified Chart Window ID ... * @param momentumBar: XCMomentumBar instance ... * @param prefix: String ... * * @return ( bool ) */ bool CreateByMomentum( long chart_id, int window, int arrow, XCMomentumBar &momentumBar, string prefix = NULL // ) { // bool result = false; // result = // momentumBar.IsValid() // ; if (!result) { return result; } // string name = momentumBar.GetTag(); if (IsValid(prefix)) { name = prefix + "_" + name; } // XOHCL bar; result = momentumBar.FillBar(bar); if (!result) { return result; } // ENUM_X_PRICE price = momentumBar.IsBullish() ? X_PRICE_LOW : X_PRICE_HIGH; // result = CreateByBar( chart_id, name, window, arrow, bar, price // ); // if (result) { ObjName(name); } // return result; } }; // // Bullish Momentum Bar ... class XCBullishMomentumBarObject : public XCMomentumBarObject { // public: // /** * Creator ... * * @param chart_id: Long, Specified Chart ID ... * @param window: Integer, Specified Chart Window ID ... * @param arrow: Integer, Specified Arrow Code ... * @param momentumBar: XCMomentumBar instance ... * @param prefix: String ... * * @return ( bool ) */ bool Create( long chart_id, int window, int arrow, XCMomentumBar &momentumBar, string prefix = NULL // ) { // bool result = false; // result = momentumBar.IsValid() && momentumBar.IsBullish(); if (!result) { return result; } // result = CreateByMomentum( chart_id, window, arrow, momentumBar, prefix // ); // return result; } /** * Retrieve Object Type ... * * @return ( ENUM_XCHARTOBJECTS ) */ virtual ENUM_XCHARTOBJECTS Type() { return X_BULLISH_MOMENTUM_BAR_OBJ; } // }; // // Bearish Momentum Bar ... class XCBearishMomentumBarObject : public XCMomentumBarObject { // public: // /** * Creator ... * * @param chart_id: Long, Specified Chart ID ... * @param window: Integer, Specified Chart Window ID ... * @param arrow: Integer, Specified Arrow Code ... * @param momentumBar: XCMomentumBar instance ... * @param prefix: String ... * * @return ( bool ) */ bool Create( long chart_id, int window, int arrow, XCMomentumBar &momentumBar, string prefix = NULL // ) { // bool result = false; // result = momentumBar.IsValid() && momentumBar.IsBearish(); if (!result) { return result; } // result = CreateByMomentum( chart_id, window, arrow, momentumBar, prefix // ); // return result; } /** * Retrieve Object Type ... * * @return ( ENUM_XCHARTOBJECTS ) */ virtual ENUM_XCHARTOBJECTS Type() { return X_BEARISH_MOMENTUM_BAR_OBJ; } // }; // // Rejection ... class XCRejectionBarObject : public XCBarArrowObject { // public: // /** * Creator ... * * @param chart_id: Long, Specified Chart ID ... * @param window: Integer, Specified Chart Window ID ... * @param rejectionBar: XCRejectionBar instance ... * @param prefix: String ... * * @return ( bool ) */ bool CreateByRejection( long chart_id, int window, int arrow, XCRejectionBar &rejectionBar, string prefix = NULL // ) { // bool result = false; // result = // rejectionBar.IsValid() // ; if (!result) { return result; } // string name = rejectionBar.GetTag(); if (IsValid(prefix)) { name = prefix + "_" + name; } // XOHCL bar; result = rejectionBar.FillBar(bar); if (!result) { return result; } // ENUM_X_PRICE price = rejectionBar.IsBullish() ? X_PRICE_LOW : X_PRICE_HIGH; // result = CreateByBar( chart_id, name, window, arrow, bar, price // ); // if (result) { ObjName(name); } // return result; } }; // // Bullish Rejection Bar ... class XCBullishRejectionBarObject : public XCRejectionBarObject { // public: // /** * Creator ... * * @param chart_id: Long, Specified Chart ID ... * @param window: Integer, Specified Chart Window ID ... * @param arrow: Integer, Specified Arrow Code ... * @param rejectionBar: XCRejectionBar instance ... * @param prefix: String ... * * @return ( bool ) */ bool Create( long chart_id, int window, int arrow, XCRejectionBar &rejectionBar, string prefix = NULL // ) { // bool result = false; // result = rejectionBar.IsValid() && rejectionBar.IsBullish(); if (!result) { return result; } // result = CreateByRejection( chart_id, window, arrow, rejectionBar, prefix // ); // return result; } /** * Retrieve Object Type ... * * @return ( ENUM_XCHARTOBJECTS ) */ virtual ENUM_XCHARTOBJECTS Type() { return X_BULLISH_REJECTION_BAR_OBJ; } // }; // // Bearish Rejection Bar ... class XCBearishRejectionBarObject : public XCRejectionBarObject { // public: // /** * Creator ... * * @param chart_id: Long, Specified Chart ID ... * @param window: Integer, Specified Chart Window ID ... * @param arrow: Integer, Specified Arrow Code ... * @param rejectionBar: XCRejectionBar instance ... * @param prefix: String ... * * @return ( bool ) */ bool Create( long chart_id, int window, int arrow, XCRejectionBar &rejectionBar, string prefix = NULL // ) { // bool result = false; // result = rejectionBar.IsValid() && rejectionBar.IsBearish(); if (!result) { return result; } // result = CreateByRejection( chart_id, window, arrow, rejectionBar, prefix // ); // return result; } /** * Retrieve Object Type ... * * @return ( ENUM_XCHARTOBJECTS ) */ virtual ENUM_XCHARTOBJECTS Type() { return X_BEARISH_REJECTION_BAR_OBJ; } // }; // // XCZoneObject ... class XCZoneObject : public XCBaseObject { // public: // /** * Creator ... * * @param chart_id: Long, Specified Chart ID ... * @param name: String, Specified Object Identifier on Chart ... * @param window: Integer, Specified Chart Window ID ... * @param zone: XCZone instance ... * @param prefix: String ... * * @return ( bool ) */ bool CreateByZone( long chart_id, string name, int window, XCZone &zone, string prefix = NULL // ) { // bool result = false; // bool isValidFrom = zone.IsValidFrom(); bool isValidBoundary = zone.IsValidBoundary(); // result = // IsValid(name) && isValidFrom && isValidBoundary // ; if (!result) { return result; } // if (IsValid(prefix)) { name = prefix + "_" + name; } // datetime from = zone.From(); datetime to = NormalizeTime(zone.To()); // double upper = zone.Upper(); double lower = zone.Lower(); // result = mRect.Create( chart_id, name, window, from, upper, to, lower // ); // if (result) { ObjName(name); } // return result; } // // Virtual ... /** * Retrieve Object Type ... * * @return ( ENUM_XCHARTOBJECTS ) */ virtual ENUM_XCHARTOBJECTS Type() { return X_ZONE_OBJ; } // // Setter(s) ... /** * Set Zone Width ... * * @param value: Integer ... */ void ZoneWidth(int value) { // if (value < 1) { value = 1; } // mRect.Width(value); } /** * Set Zone Color ... * * @param value: Color ... */ void ZoneColor(color value) { mRect.Color(value); } /** * Set Zone Style ... * * @param value: ENUM_LINE_STYLE member ... */ void ZoneStyle(ENUM_LINE_STYLE value) { mRect.Style(value); } /** * Set Zone Fill ... * * @param value: Boolean ... */ void ZoneFill(bool value) { mRect.Fill(value); } // private: // CChartObjectRectangle mRect; // }; // // Support Zone ... class XCSupportZoneObject : public XCZoneObject { // public: // /** * Creator ... * * @param chart_id: Long, Specified Chart ID ... * @param window: Integer, Specified Chart Window ID ... * @param zone: XCSupportZone instance ... * @param prefix: String ... * * @return ( bool ) */ bool Create( long chart_id, int window, XCSupportZone &zone, string prefix = NULL // ) { // bool result = false; // result = zone.IsValid(); if (!result) { return result; } // string name = zone.GetTag(); // result = CreateByZone( chart_id, name, window, zone, prefix // ); // return result; } // // Virtual ... /** * Retrieve Object Type ... * * @return ( ENUM_XCHARTOBJECTS ) */ virtual ENUM_XCHARTOBJECTS Type() { return X_SUPPORT_ZONE_OBJ; } }; // // Resistance Zone ... class XCResistanceZoneObject : public XCZoneObject { // public: // /** * Creator ... * * @param chart_id: Long, Specified Chart ID ... * @param window: Integer, Specified Chart Window ID ... * @param zone: XCResistanceZone instance ... * @param prefix: String ... * * @return ( bool ) */ bool Create( long chart_id, int window, XCResistanceZone &zone, string prefix = NULL // ) { // bool result = false; // result = zone.IsValid(); if (!result) { return result; } // string name = zone.GetTag(); // result = CreateByZone( chart_id, name, window, zone, prefix // ); // return result; } // // Virtual ... /** * Retrieve Object Type ... * * @return ( ENUM_XCHARTOBJECTS ) */ virtual ENUM_XCHARTOBJECTS Type() { return X_RESISTANCE_ZONE_OBJ; } }; // // Supply Zone ... class XCSupplyZoneObject : public XCZoneObject { // public: // /** * Creator ... * * @param chart_id: Long, Specified Chart ID ... * @param window: Integer, Specified Chart Window ID ... * @param zone: XCSupplyZone instance ... * @param prefix: String ... * * @return ( bool ) */ bool Create( long chart_id, int window, XCSupplyZone &zone, string prefix = NULL // ) { // bool result = false; // result = zone.IsValid(); if (!result) { return result; } // string name = zone.GetTag(); // result = CreateByZone( chart_id, name, window, zone, prefix // ); // return result; } // // Virtual ... /** * Retrieve Object Type ... * * @return ( ENUM_XCHARTOBJECTS ) */ virtual ENUM_XCHARTOBJECTS Type() { return X_SUPPLY_ZONE_OBJ; } }; // // Demand Zone ... class XCDemandZoneObject : public XCZoneObject { // public: // /** * Creator ... * * @param chart_id: Long, Specified Chart ID ... * @param window: Integer, Specified Chart Window ID ... * @param zone: XCDemandZone instance ... * @param prefix: String ... * * @return ( bool ) */ bool Create( long chart_id, int window, XCDemandZone &zone, string prefix = NULL // ) { // bool result = false; // result = zone.IsValid(); if (!result) { return result; } // string name = zone.GetTag(); // result = CreateByZone( chart_id, name, window, zone, prefix // ); // return result; } // // Virtual ... /** * Retrieve Object Type ... * * @return ( ENUM_XCHARTOBJECTS ) */ virtual ENUM_XCHARTOBJECTS Type() { return X_DEMAND_ZONE_OBJ; } }; // // Bullish Order Block ... class XCBullishOrderBlockObject : public XCZoneObject { // public: // /** * Creator ... * * @param chart_id: Long, Specified Chart ID ... * @param window: Integer, Specified Chart Window ID ... * @param zone: XCOrderBlock instance ... * @param prefix: String ... * * @return ( bool ) */ bool Create( long chart_id, int window, XCOrderBlock &zone, string prefix = NULL // ) { // bool result = false; // result = zone.IsValid() && zone.IsBullish(); if (!result) { return result; } // string name = zone.GetTag(); // result = CreateByZone( chart_id, name, window, zone, prefix // ); // return result; } // // Virtual ... /** * Retrieve Object Type ... * * @return ( ENUM_XCHARTOBJECTS ) */ virtual ENUM_XCHARTOBJECTS Type() { return X_BULLISH_ORDERBLOCK_OBJ; } }; // // Bearish Order Block ... class XCBearishOrderBlockObject : public XCZoneObject { // public: // /** * Creator ... * * @param chart_id: Long, Specified Chart ID ... * @param window: Integer, Specified Chart Window ID ... * @param zone: XCOrderBlock instance ... * @param prefix: String ... * * @return ( bool ) */ bool Create( long chart_id, int window, XCOrderBlock &zone, string prefix = NULL // ) { // bool result = false; // result = zone.IsValid() && zone.IsBearish(); if (!result) { return result; } // string name = zone.GetTag(); // result = CreateByZone( chart_id, name, window, zone, prefix // ); // return result; } // // Virtual ... /** * Retrieve Object Type ... * * @return ( ENUM_XCHARTOBJECTS ) */ virtual ENUM_XCHARTOBJECTS Type() { return X_BULLISH_ORDERBLOCK_OBJ; } }; // // Bullish Fair Value Gaps ... class XCBullishFairValueGapObject : public XCZoneObject { // public: // /** * Creator ... * * @param chart_id: Long, Specified Chart ID ... * @param window: Integer, Specified Chart Window ID ... * @param zone: XCOrderBlock instance ... * @param prefix: String ... * * @return ( bool ) */ bool Create( long chart_id, int window, XCFVG &zone, string prefix = NULL // ) { // bool result = false; // result = zone.IsValid() && zone.IsBullish(); if (!result) { return result; } // string name = zone.GetTag(); // result = CreateByZone( chart_id, name, window, zone, prefix // ); // return result; } // // Virtual ... /** * Retrieve Object Type ... * * @return ( ENUM_XCHARTOBJECTS ) */ virtual ENUM_XCHARTOBJECTS Type() { return X_BULLISH_FVG_OBJ; } }; // // Bearish Fair Value Gaps ... class XCBearishFairValueGapObject : public XCZoneObject { // public: // /** * Creator ... * * @param chart_id: Long, Specified Chart ID ... * @param window: Integer, Specified Chart Window ID ... * @param zone: XCOrderBlock instance ... * @param prefix: String ... * * @return ( bool ) */ bool Create( long chart_id, int window, XCFVG &zone, string prefix = NULL // ) { // bool result = false; // result = zone.IsValid() && zone.IsBearish(); if (!result) { return result; } // string name = zone.GetTag(); // result = CreateByZone( chart_id, name, window, zone, prefix // ); // return result; } // // Virtual ... /** * Retrieve Object Type ... * * @return ( ENUM_XCHARTOBJECTS ) */ virtual ENUM_XCHARTOBJECTS Type() { return X_BEARISH_FVG_OBJ; } }; // // Signal ... class XCSignalObject : public XCBaseObject { // public: // // // Constructor ... void XCSignalObject() { } // // Deconstructor ... void ~XCSignalObject() { } /** * Create a Signal Object on Chart ... * * @param chart_id: Long ... * @param name: String ... * @param window: Integer ... * @param signal: XSignal instance ... * * @return ( bool ) */ bool Create( long chart_id, const string name, const int window, XSignal &signal // ) { // bool result = false; // result = IsValid(name) && signal .IsValid(); if (!result) { return result; } // string nameMD5 = ToMD5(name); // int delay = (PeriodSeconds(signal.period) * 2); datetime time1 = (datetime)((int)signal.time - delay); datetime time2 = (datetime)((int)signal.time + delay); // // TP ... string tpName = ToString(X_TP) + "_" + nameMD5; result = mTPTrend.Create( chart_id, tpName, window, time1, signal.tp, time2, signal.tp // ); if (!result) { return result; } // // SL ... string slName = ToString(X_SL) + "_" + nameMD5; result = mSLTrend.Create( chart_id, slName, window, time1, signal.sl, time2, signal.sl // ); if (!result) { // mTPTrend.Delete(); return result; } // // ENTRY ... string entrName = ToString(X_ENTRY) + "_" + nameMD5; result = mEntryTrend.Create( chart_id, entrName, window, time1, signal.entry, time2, signal.entry // ); if (!result) { // mTPTrend.Delete(); mSLTrend.Delete(); return result; } // // Set Object Name ... ObjName(name); // return result; } // // Setter(s) ... // // TP ... /** * Set TP Width ... * * @param value: Integer ... */ void TPWidth(int value) { // if (value < 1) { value = 1; } // mTPTrend.Width(value); } /** * Set TP Color ... * * @param value: Color ... */ void TPColor(color value) { mTPTrend.Color(value); } /** * Set TP Style ... * * @param value: ENUM_LINE_STYLE ... */ void TPStyle(ENUM_LINE_STYLE value) { mTPTrend.Style(value); } // // SL ... /** * Set SL Width ... * * @param value: Integer ... */ void SLWidth(int value) { // if (value < 1) { value = 1; } // mSLTrend.Width(value); } /** * Set SL Color ... * * @param value: Color ... */ void SLColor(color value) { mSLTrend.Color(value); } /** * Set SL Style ... * * @param value: ENUM_LINE_STYLE ... */ void SLStyle(ENUM_LINE_STYLE value) { mSLTrend.Style(value); } // // ENTRY ... /** * Set Entry Width ... * * @param value: Integer ... */ void EntryWidth(int value) { // if (value < 1) { value = 1; } // mEntryTrend.Width(value); } /** * Set Entry Color ... * * @param value: Color ... */ void EntryColor(color value) { mEntryTrend.Color(value); } /** * Set Entry Style ... * * @param value: ENUM_LINE_STYLE ... */ void EntryStyle(ENUM_LINE_STYLE value) { mEntryTrend.Style(value); } /** * Retrieve Object Type ... * * @return ( ENUM_XCHARTOBJECTS ) */ virtual ENUM_XCHARTOBJECTS Type() { return X_SIGNAL_OBJ; } // private: // // CChartObjectTrend mTPTrend; CChartObjectTrend mSLTrend; CChartObjectTrend mEntryTrend; }; // // Zone Ticks ... // // Specify How to Draws Specified Levels ... struct XTickZoneLevelSpecs { // double percent; // Max Allowed Percent of Tick Zone ... // // Label Info ... color labelColor; string labelFont; int labelFontSize; double labelAngel; // // Zone Info ... bool zoneFill; int zoneWidth; color zoneColor; ENUM_LINE_STYLE zoneStyle; // // Constructor ... XTickZoneLevelSpecs() { Default(); } // // Tools ... /** * Initialize Drawing Specs ... * * @param _percent: Double, Max Allowed Percent ... * @param _labelColor: Color, Specified Label Color ... * @param _zoneColoe: Color, Specified Zone Color ... * @param _zoneFill: Boolean, Specified Fill Zone or not ... * @param _zoneStyle: ENUM_LINE_STYLE member, Specified Zone Style ... * @param _labelFontSize: Integer, Specified Label Font Size ... * @param _labelFont: String, Specified Label Font Name ... * @param _labelAngel: Double, Specified Label Angel ... * * @return ( bool ) */ bool Init( double _percent, color _labelColor = clrWhite, color _zoneColor = clrWhite, bool _zoneFill = false, ENUM_LINE_STYLE _zoneStyle = STYLE_DOT, int _zoneWidth = 1, int _labelFontSize = 12, string _labelFont = "Arial", double _labelAngel = 0 // ) { // bool result = false; // Default(); // result = _percent > 0; if (!result) { return result; } // percent = _percent; labelColor = _labelColor; zoneColor = _zoneColor; zoneFill = _zoneFill; zoneStyle = _zoneStyle; // if (_zoneWidth > 0) { zoneWidth = _zoneWidth; } // if (_labelFontSize > 0) { labelFontSize = _labelFontSize; } // if (IsSpecifiedValid(_labelFont)) { labelFont = _labelFont; } // if (_labelAngel >= 0) { labelAngel = _labelAngel; } // result = IsValid(); // return result; } /** * Set Default Properties ... */ void Default() { // percent = 0; // // Label ... labelAngel = 0; labelFontSize = 13; labelFont = "Arial"; labelColor = clrWhite; // // Zone ... zoneWidth = 1; zoneFill = false; zoneColor = clrWhite; zoneStyle = STYLE_DOT; } /** * Validate ... * * @return ( bool ) */ bool IsValid() { // bool result = false; // result = // percent > 0 && // // Zone ... zoneWidth > 0 && // // Label ... labelFontSize > 0 && IsSpecifiedValid(labelFont) // ; // return result; } // }; class XCTickZoneObject : public XCBaseObject { // public: // /** * Creator ... * * @param chart_id: Long, Specified Chart ID ... * @param window: Integer, Specified Chart Window ID ... * @param name: String, Specify Chart Object Identifier ... * @param from: Datetime ... * @param to: Datetime ... * @param zone: XCTickZone instance ... * @param prefix: String ... * * @return ( bool ) */ bool Create( long chart_id, int window, string name, datetime from, datetime to, XCTickZone *zone, string prefix = NULL // ) { // bool result = false; // result = IsValid(name) && zone.IsValid() && IsValid(to) && IsValid(from); if (!result) { return result; } // if (IsValid(prefix)) { name = prefix + "_" + name; } // string rectName = "TKZ_" + name; result = mRect.Create( chart_id, rectName, window, from, zone.high, to, zone.low // ); if (!result) { return result; } // string lblName = "LBL_" + name; result = mLabel.Create( chart_id, lblName, window, from, zone.high // ); if (!result) { return result; } // mLabel.Description(ToString(zone.percent) + "%"); // ObjName(name); // return result; } // // Virtual ... /** * Retrieve Object Type ... * * @return ( ENUM_XCHARTOBJECTS ) */ virtual ENUM_XCHARTOBJECTS Type() { return X_TICK_ZONE_OBJ; } // // Getter(s) / Setter(s) ... /** * Set Zone Width ... * * @param value: Integer ... */ void ZoneWidth(int value) { // if (value < 1) { value = 1; } // mRect.Width(value); } /** * Set Zone Color ... * * @param value: Color ... */ void ZoneColor(color value) { mRect.Color(value); } /** * Set Zone Style ... * * @param value: ENUM_LINE_STYLE member ... */ void ZoneStyle(ENUM_LINE_STYLE value) { mRect.Style(value); } /** * Set Zone Fill ... * * @param value: Boolean ... */ void ZoneFill(bool value) { mRect.Fill(value); } /** * Set Label Color ... * * @param value: Color ... */ void LabelColor(color value) { mLabel.Color(value); } /** * Set Label Size ... * * @param value: Integer ... */ void LabelSize(int value) { mLabel.FontSize(value); } /** * Set Label Font ... * * @param value: String ... */ void LabelFont(string value) { mLabel.Font(value); } /** * Set Label Angle ... * * @param value: double ... */ void LabelAngle(double value) { mLabel.Angle(value); } // private: // // Props ... CChartObjectRectangle mRect; CChartObjectLabel mLabel; // }; class XCTicksZoneObject : public XCBaseObject { // public: // // void ~XCTicksZoneObject() { mZones.Clear(); } /** * Creator ... * * @param chart_id: Long, Specified Chart ID ... * @param window: Integer, Specified Chart Window ID ... * @param zone: XCTicksZone instance ... * @param prefix: String ... * * @return ( bool ) */ bool Create( long chart_id, int window, XCTicksZone &zone, XTickZoneLevelSpecs &specs[], string prefix = NULL // ) { // bool result = false; // result = zone.IsValid(); if (!result) { return result; } // string name = zone.GetTag(); int levels = zone.Levels(); result = levels > 0; if (!result) { return result; } // for (int i = 0; i < levels; i++) { // XCTickZone *iZone = zone.GetZone(i); XCTickZoneObject *iObj; iObj = new XCTickZoneObject(); bool isCreated = iObj.Create( chart_id, window, ToString(i) + "_" + name, zone.From(), zone.To(), iZone, prefix // ); if (!isCreated) { break; } // XTickZoneLevelSpecs iSpec; bool hasSpecs = FindSpecs( iZone, iSpec, specs // ); if (hasSpecs) { // // Label ... iObj.LabelFont(iSpec.labelFont); iObj.LabelAngle(iSpec.labelAngel); iObj.LabelColor(iSpec.labelColor); iObj.LabelSize(iSpec.labelFontSize); // // Zone ... iObj.ZoneFill(iSpec.zoneFill); iObj.ZoneColor(iSpec.zoneColor); iObj.ZoneWidth(iSpec.zoneWidth); iObj.ZoneStyle(iSpec.zoneStyle); } // mZones.Add(iObj); } // if (result) { ObjName(name); } else { mZones.Clear(); } // return result; } // // Virtual ... /** * Retrieve Object Type ... * * @return ( ENUM_XCHARTOBJECTS ) */ virtual ENUM_XCHARTOBJECTS Type() { return X_TICKS_ZONE_OBJ; } // // Getter(s) / Setter(s) ... // // Actions ... /** * Destroy Object ... */ void Destroy() { mZones.Clear(); } /** * Find Specified TickZone Drawing Specs ... * * @param zone: XCTickZone instance, reference to Search For it ... * @param spec: XTickZoneLevelSpecs instance, reference to Result ... * @param specs: XTickZoneLevelSpecs instance Collection for Search ... * * @return ( bool ) */ bool FindSpecs( XCTickZone *zone, XTickZoneLevelSpecs &spec, XTickZoneLevelSpecs &specs[] // ) { // bool result = false; // int count = ArraySize(specs); result = zone.IsValid() && IsValidSize(count); if (!result) { return result; } // for (int i = 0; i < count; i++) { // XTickZoneLevelSpecs iSpecs = specs[i]; // bool isSpecValidForZone = !spec.IsValid() ? zone.percent <= iSpecs.percent : zone.percent <= iSpecs.percent && spec.percent > iSpecs.percent; if (isSpecValidForZone) { spec = iSpecs; } } // result = spec.IsValid(); // return result; } // private: // // Props ... CArrayObj mZones; // }; //