From a345aa52c1a234127eafcb59701897103b309ba2 Mon Sep 17 00:00:00 2001 From: Hadi Khazaee Asl Date: Tue, 19 Nov 2024 22:03:44 +0330 Subject: [PATCH] Last ... --- Classes/x-saherelm.x-cobject.class.mq5 | 247 +++++++- Classes/x-saherelm.x-poi.class.mq5 | 1 + Classes/x-saherelm.x-poi.drawer.class.mq5 | 201 ++++++- Libraries/x-saherelm.x-poi.lib.mq5 | 3 - .../Classes/x-121.smc.base.strategy.class.mq5 | 53 +- X121SMCEA/Libraries/x-121.smc.lib.mq5 | 1 + .../x-121.smc.test.strategy.class.mq5 | 540 +++++++++++++++++- 7 files changed, 1003 insertions(+), 43 deletions(-) diff --git a/Classes/x-saherelm.x-cobject.class.mq5 b/Classes/x-saherelm.x-cobject.class.mq5 index 96ee552a..0076b403 100644 --- a/Classes/x-saherelm.x-cobject.class.mq5 +++ b/Classes/x-saherelm.x-cobject.class.mq5 @@ -1801,6 +1801,168 @@ class XCSignalObject : public XCBaseObject // // 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 { // @@ -2028,6 +2190,7 @@ class XCTicksZoneObject : public XCBaseObject long chart_id, int window, XCTicksZone &zone, + XTickZoneLevelSpecs &specs[], string prefix = NULL // ) { @@ -2057,7 +2220,7 @@ class XCTicksZoneObject : public XCBaseObject XCTickZone *iZone = zone.GetZone(i); XCTickZoneObject *iObj; iObj = new XCTickZoneObject(); - result = iObj.Create( + bool isCreated = iObj.Create( chart_id, window, ToString(i) + "_" + name, @@ -2066,11 +2229,35 @@ class XCTicksZoneObject : public XCBaseObject iZone, prefix // ); - if (!result) + 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); } @@ -2108,11 +2295,67 @@ class XCTicksZoneObject : public XCBaseObject // // 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: // diff --git a/Classes/x-saherelm.x-poi.class.mq5 b/Classes/x-saherelm.x-poi.class.mq5 index 663e9937..6a4b3980 100644 --- a/Classes/x-saherelm.x-poi.class.mq5 +++ b/Classes/x-saherelm.x-poi.class.mq5 @@ -1156,6 +1156,7 @@ class XCPOIDetector : public XCBaseAlert // state.ticksZone = mTicksZone; + // } diff --git a/Classes/x-saherelm.x-poi.drawer.class.mq5 b/Classes/x-saherelm.x-poi.drawer.class.mq5 index ec793199..abff976c 100644 --- a/Classes/x-saherelm.x-poi.drawer.class.mq5 +++ b/Classes/x-saherelm.x-poi.drawer.class.mq5 @@ -1372,6 +1372,139 @@ class XCPOIDrawer : public XCBase BearishFVGStyle(STYLE_DOT); BearishFVGColor(clrRed); + // + // Add Default TickZone Specs ... + bool isSpecsInited = false; + bool fillTickZone = false; + XTickZoneLevelSpecs specs10; + isSpecsInited = specs10.Init( + 10, + clrWhite, + clrWhite, + fillTickZone // + ); + if (isSpecsInited) + { + AddTickZoneLevelSpecs(specs10); + } + + // + XTickZoneLevelSpecs specs20; + isSpecsInited = specs20.Init( + 20, + clrOrange, + clrOrange, + fillTickZone // + ); + if (isSpecsInited) + { + AddTickZoneLevelSpecs(specs20); + } + + // + XTickZoneLevelSpecs specs30; + isSpecsInited = specs30.Init( + 30, + clrOrange, + clrOrange, + fillTickZone // + ); + if (isSpecsInited) + { + AddTickZoneLevelSpecs(specs30); + } + + // + XTickZoneLevelSpecs specs40; + isSpecsInited = specs40.Init( + 40, + clrOrange, + clrOrange, + fillTickZone // + ); + if (isSpecsInited) + { + AddTickZoneLevelSpecs(specs40); + } + + // + XTickZoneLevelSpecs specs50; + isSpecsInited = specs50.Init( + 50, + clrYellow, + clrYellow, + fillTickZone // + ); + if (isSpecsInited) + { + AddTickZoneLevelSpecs(specs50); + } + + // + XTickZoneLevelSpecs specs60; + isSpecsInited = specs60.Init( + 60, + clrYellow, + clrYellow, + fillTickZone // + ); + if (isSpecsInited) + { + AddTickZoneLevelSpecs(specs60); + } + + // + XTickZoneLevelSpecs specs70; + isSpecsInited = specs70.Init( + 70, + clrYellow, + clrYellow, + fillTickZone // + ); + if (isSpecsInited) + { + AddTickZoneLevelSpecs(specs70); + } + + // + XTickZoneLevelSpecs specs80; + isSpecsInited = specs80.Init( + 80, + clrRed, + clrRed, + fillTickZone // + ); + if (isSpecsInited) + { + AddTickZoneLevelSpecs(specs80); + } + + // + XTickZoneLevelSpecs specs90; + isSpecsInited = specs90.Init( + 90, + clrRed, + clrRed, + fillTickZone // + ); + if (isSpecsInited) + { + AddTickZoneLevelSpecs(specs90); + } + + // + XTickZoneLevelSpecs specs100; + isSpecsInited = specs100.Init( + 100, + clrRed, + clrRed, + fillTickZone // + ); + if (isSpecsInited) + { + AddTickZoneLevelSpecs(specs100); + } + // } @@ -2280,9 +2413,64 @@ class XCPOIDrawer : public XCBase // // Ticks Zone ... + /** + * Add Tick Zone Draw Specifications ... + * + * @param specs: XTickZoneLevelSpecs instance ... + */ + void AddTickZoneLevelSpecs( + XTickZoneLevelSpecs &specs // + ) + { + // + if (!specs.IsValid()) + { + return; + } + + // + bool isExists = false; + int count = ArraySize(mTicksZoneSpecs); + if (IsValidSize(count)) + { + // + for (int i = 0; i < count; i++) + { + // + XTickZoneLevelSpecs iSpec = mTicksZoneSpecs[i]; + + // + isExists = specs.percent == iSpec.percent; + if (isExists) + { + break; + } + } + } + if (isExists) + { + return; + } + + // + AddRef( + specs, + mTicksZoneSpecs // + ); + } + + /** + * Draw Specified Ticker Zone ... + * + * @param zone: XCTicksZone instance Specified Ticker Zone ... + * @param object: XCTicksZoneObject pointer ... + * + * @return ( bool ) + */ bool CreateTicksZone( XCTicksZone &zone, - XCTicksZoneObject *&object) + XCTicksZoneObject *&object // + ) { // bool result = false; @@ -2311,6 +2499,7 @@ class XCPOIDrawer : public XCBase chartID, window, zone, + mTicksZoneSpecs, prefix // ); @@ -2320,12 +2509,6 @@ class XCPOIDrawer : public XCBase return result; } - // - // object.ZoneFill(fill); - // object.ZoneColor(crl); - // object.ZoneWidth(width); - // object.ZoneStyle(style); - // return result; } @@ -2438,5 +2621,9 @@ class XCPOIDrawer : public XCBase color mBearishFVGColor; // Bearish FVG Color ... ENUM_LINE_STYLE mBearishFVGStyle; // Bearish FVG Style ... + // + // Ticks Zone ... + XTickZoneLevelSpecs mTicksZoneSpecs[]; // Zone Draw Specifications ... + // }; \ No newline at end of file diff --git a/Libraries/x-saherelm.x-poi.lib.mq5 b/Libraries/x-saherelm.x-poi.lib.mq5 index a258d7bd..c2543003 100644 --- a/Libraries/x-saherelm.x-poi.lib.mq5 +++ b/Libraries/x-saherelm.x-poi.lib.mq5 @@ -3057,9 +3057,6 @@ struct XPOIState */ void Fill(XPOIState &dest) { - // - dest.Clean(); - // if (!IsValid() || !HasChild()) diff --git a/X121SMCEA/Classes/x-121.smc.base.strategy.class.mq5 b/X121SMCEA/Classes/x-121.smc.base.strategy.class.mq5 index 3635eb92..f26cc049 100644 --- a/X121SMCEA/Classes/x-121.smc.base.strategy.class.mq5 +++ b/X121SMCEA/Classes/x-121.smc.base.strategy.class.mq5 @@ -557,8 +557,8 @@ class XCX121SMCBaseStrategy : public XCBaseAlert MqlTick mLastTick; // Last Issued Tick ... // - XBarTracker mBarTracker; // Strategy Time Tracker ... - XCBarAnalyser mBarAnalyser; // Bar Analyser Instance + XBarTracker mBarTracker; // Strategy Time Tracker ... + XCBarAnalyser mBarAnalyser; // Bar Analyser Instance // X121SMCStrategyConditions mConditions; // Market Conditions ... // @@ -993,7 +993,8 @@ class XCX121SMCBaseStrategy : public XCBaseAlert bool drawBullishRejectionBars = true, bool drawBearishRejectionBars = true, bool drawBullishMomentumBars = true, - bool drawBearishMomentumBars = true // + bool drawBearishMomentumBars = true, + bool drawTicksZone = true // ) { // @@ -1075,7 +1076,8 @@ class XCX121SMCBaseStrategy : public XCBaseAlert { // XCSupportZone item = state.supportZones[i]; - if (forceUpdateTo) { + if (forceUpdateTo) + { item.To(cTime); } @@ -1106,7 +1108,8 @@ class XCX121SMCBaseStrategy : public XCBaseAlert { // XCResistanceZone item = state.resistanceZones[i]; - if (forceUpdateTo) { + if (forceUpdateTo) + { item.To(cTime); } @@ -1140,7 +1143,8 @@ class XCX121SMCBaseStrategy : public XCBaseAlert { // XCSupplyZone item = state.supplyZones[i]; - if (forceUpdateTo) { + if (forceUpdateTo) + { item.To(cTime); } @@ -1171,7 +1175,8 @@ class XCX121SMCBaseStrategy : public XCBaseAlert { // XCDemandZone item = state.demandZones[i]; - if (forceUpdateTo) { + if (forceUpdateTo) + { item.To(cTime); } @@ -1205,7 +1210,8 @@ class XCX121SMCBaseStrategy : public XCBaseAlert { // XCOrderBlock item = state.bullishOrderBlocks[i]; - if (forceUpdateTo) { + if (forceUpdateTo) + { item.To(cTime); } @@ -1236,7 +1242,8 @@ class XCX121SMCBaseStrategy : public XCBaseAlert { // XCOrderBlock item = state.bearishOrderBlocks[i]; - if (forceUpdateTo) { + if (forceUpdateTo) + { item.To(cTime); } @@ -1270,7 +1277,8 @@ class XCX121SMCBaseStrategy : public XCBaseAlert { // XCFVG item = state.bullishFairValueGaps[i]; - if (forceUpdateTo) { + if (forceUpdateTo) + { item.To(cTime); } @@ -1301,7 +1309,8 @@ class XCX121SMCBaseStrategy : public XCBaseAlert { // XCFVG item = state.bearishFairValueGaps[i]; - if (forceUpdateTo) { + if (forceUpdateTo) + { item.To(cTime); } @@ -1439,10 +1448,28 @@ class XCX121SMCBaseStrategy : public XCBaseAlert // // Ticks Zone ... - if (state.ticksZone != NULL) + if (drawTicksZone && + state.ticksZone != NULL) { // - // TODO: Implement this ... + XCTicksZone *iZone = state.ticksZone; + + // + if (forceUpdateTo) + { + iZone.To(cTime); + } + + // + XCTicksZoneObject *iObj; + bool isCreated = mPOIDrawer.CreateTicksZone( + iZone, + iObj // + ); + if (isCreated) + { + AddObjectIfNotExists(iObj); + } } } diff --git a/X121SMCEA/Libraries/x-121.smc.lib.mq5 b/X121SMCEA/Libraries/x-121.smc.lib.mq5 index 63c702f0..e61f7a36 100644 --- a/X121SMCEA/Libraries/x-121.smc.lib.mq5 +++ b/X121SMCEA/Libraries/x-121.smc.lib.mq5 @@ -62,6 +62,7 @@ struct XPVPivot ENUM_XPV_PIVOTS type; // + // Combined all States ... XPOIState state; // diff --git a/X121SMCEA/Strategy/x-121.smc.test.strategy.class.mq5 b/X121SMCEA/Strategy/x-121.smc.test.strategy.class.mq5 index dee80b76..ed3c653b 100644 --- a/X121SMCEA/Strategy/x-121.smc.test.strategy.class.mq5 +++ b/X121SMCEA/Strategy/x-121.smc.test.strategy.class.mq5 @@ -71,6 +71,9 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy delete xpvHelper; delete x3maHelper; delete x3vwapHelper; + + // + IndicatorRelease(mPSarHandler); } /** @@ -408,6 +411,11 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy X3VWAPInputs x3vwapInputs; XCX3VWAPHelper *x3vwapHelper; + // + // Parabolic Sar ... + int mPSarHandler; + double mPSars[]; + // XPVPivot mOrderFlow[]; ENUM_X_DIRECTION mOrderFlowDir; @@ -481,6 +489,21 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy return result; } + // + // Retrieve Parabolic Sars ... + int sarsCopied = CopyBuffer( + mPSarHandler, + 0, + 0, + conditionsLoopback, + mPSars // + ); + result = sarsCopied >= conditionsLoopback; + if (!result) + { + return result; + } + // // Only Detect Order Flow when there isn't ... if (ArraySize(mOrderFlow) == 0 || @@ -839,6 +862,7 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy { // XPVPivot iPivot = mOrderFlow[i]; + mOrderFlow[i].state.ticksZone = _5MState.ticksZone; // // D1 ... @@ -1116,6 +1140,7 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy */ void RedrawOrderFlow( bool forceClearDraws = true, + bool forceDrawSamePeriod = true, bool drawOrderFlow = true, bool drawOrderFlowState = true, bool drawOnlyLastOrderFlow = false, @@ -1171,7 +1196,11 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy drawOnlyLastOrderFlowState)); if (canDrawState) { - CustomStateDrawing(iPivot.state); + // + CustomStateDrawing( + iPivot.state, + forceDrawSamePeriod // + ); } // @@ -1204,27 +1233,491 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy * Custom Drawing State ... * * @param state: XPOIState instance reference, Specified Which state to Draw ... + * @param forceDrawSamePeriod: Boolean ... */ - void CustomStateDrawing(XPOIState &state) + void CustomStateDrawing( + XPOIState &state, + bool forceDrawSamePeriod = false // + ) { + // + XPOIState tmpState = state; + if (forceDrawSamePeriod) + { + // + int count = 0; + ENUM_TIMEFRAMES period = GetPeriod(); + + // + count = state.CountSwingHighs(); + if (IsValidSize(count)) + { + // + for (int i = 0; i < count; i++) + { + // + XCSwing iSwing = state.swingHighs[i]; + + // + XOHCL iBar; + bool isFilled = iSwing.FillBar(iBar); + if (!isFilled) + { + continue; + } + + // + bool isSamePeriod = iBar.period == period; + if (!isSamePeriod) + { + // + ArrayRemove( + tmpState.swingHighs, + i, + 1 // + ); + } + } + } + + // + count = state.CountSwingLows(); + if (IsValidSize(count)) + { + // + for (int i = 0; i < count; i++) + { + // + XCSwing iSwing = state.swingLows[i]; + + // + XOHCL iBar; + bool isFilled = iSwing.FillBar(iBar); + if (!isFilled) + { + continue; + } + + // + bool isSamePeriod = iBar.period == period; + if (!isSamePeriod) + { + // + ArrayRemove( + tmpState.swingLows, + i, + 1 // + ); + } + } + } + + // + count = state.CountBullishMomentumBars(); + if (IsValidSize(count)) + { + // + for (int i = 0; i < count; i++) + { + // + XCMomentumBar iMomentum = state.bullishMomentumBars[i]; + + // + XOHCL iBar; + bool isFilled = iMomentum.FillBar(iBar); + if (!isFilled) + { + continue; + } + + // + bool isSamePeriod = iBar.period == period; + if (!isSamePeriod) + { + // + ArrayRemove( + tmpState.bullishMomentumBars, + i, + 1 // + ); + } + } + } + + // + count = state.CountBearishMomentumBars(); + if (IsValidSize(count)) + { + // + for (int i = 0; i < count; i++) + { + // + XCMomentumBar iMomentum = state.bearishMomentumBars[i]; + + // + XOHCL iBar; + bool isFilled = iMomentum.FillBar(iBar); + if (!isFilled) + { + continue; + } + + // + bool isSamePeriod = iBar.period == period; + if (!isSamePeriod) + { + // + ArrayRemove( + tmpState.bearishMomentumBars, + i, + 1 // + ); + } + } + } + + // + count = state.CountBullishRejectionBars(); + if (IsValidSize(count)) + { + // + for (int i = 0; i < count; i++) + { + // + XCRejectionBar iRejection = state.bullishRejectionBars[i]; + + // + XOHCL iBar; + bool isFilled = iRejection.FillBar(iBar); + if (!isFilled) + { + continue; + } + + // + bool isSamePeriod = iBar.period == period; + if (!isSamePeriod) + { + // + ArrayRemove( + tmpState.bullishRejectionBars, + i, + 1 // + ); + } + } + } + + // + count = state.CountBearishRejectionBars(); + if (IsValidSize(count)) + { + // + for (int i = 0; i < count; i++) + { + // + XCRejectionBar iRejection = state.bearishRejectionBars[i]; + + // + XOHCL iBar; + bool isFilled = iRejection.FillBar(iBar); + if (!isFilled) + { + continue; + } + + // + bool isSamePeriod = iBar.period == period; + if (!isSamePeriod) + { + // + ArrayRemove( + tmpState.bearishRejectionBars, + i, + 1 // + ); + } + } + } + + // + count = state.CountSupportZones(); + if (IsValidSize(count)) + { + // + for (int i = 0; i < count; i++) + { + // + XCSupportZone iZone = state.supportZones[i]; + + // + XOHCL iBar; + bool isFilled = iZone.FillBar(iBar); + if (!isFilled) + { + continue; + } + + // + bool isSamePeriod = iBar.period == period; + if (!isSamePeriod) + { + // + ArrayRemove( + tmpState.supportZones, + i, + 1 // + ); + } + } + } + + // + count = state.CountResistanceZones(); + if (IsValidSize(count)) + { + // + for (int i = 0; i < count; i++) + { + // + XCResistanceZone iZone = state.resistanceZones[i]; + + // + XOHCL iBar; + bool isFilled = iZone.FillBar(iBar); + if (!isFilled) + { + continue; + } + + // + bool isSamePeriod = iBar.period == period; + if (!isSamePeriod) + { + // + ArrayRemove( + tmpState.resistanceZones, + i, + 1 // + ); + } + } + } + + // + count = state.CountSupplyZones(); + if (IsValidSize(count)) + { + // + for (int i = 0; i < count; i++) + { + // + XCSupplyZone iZone = state.supplyZones[i]; + + // + XOHCL iBar; + bool isFilled = iZone.FillBar(iBar); + if (!isFilled) + { + continue; + } + + // + bool isSamePeriod = iBar.period == period; + if (!isSamePeriod) + { + // + ArrayRemove( + tmpState.supplyZones, + i, + 1 // + ); + } + } + } + + // + count = state.CountDemandZones(); + if (IsValidSize(count)) + { + // + for (int i = 0; i < count; i++) + { + // + XCDemandZone iZone = state.demandZones[i]; + + // + XOHCL iBar; + bool isFilled = iZone.FillBar(iBar); + if (!isFilled) + { + continue; + } + + // + bool isSamePeriod = iBar.period == period; + if (!isSamePeriod) + { + // + ArrayRemove( + tmpState.demandZones, + i, + 1 // + ); + } + } + } + + // + count = state.CountBullishOrderBlocks(); + if (IsValidSize(count)) + { + // + for (int i = 0; i < count; i++) + { + // + XCOrderBlock iZone = state.bullishOrderBlocks[i]; + + // + XOHCL iBar; + bool isFilled = iZone.FillBar(iBar); + if (!isFilled) + { + continue; + } + + // + bool isSamePeriod = iBar.period == period; + if (!isSamePeriod) + { + // + ArrayRemove( + tmpState.bullishOrderBlocks, + i, + 1 // + ); + } + } + } + + // + count = state.CountBearishOrderBlocks(); + if (IsValidSize(count)) + { + // + for (int i = 0; i < count; i++) + { + // + XCOrderBlock iZone = state.bearishOrderBlocks[i]; + + // + XOHCL iBar; + bool isFilled = iZone.FillBar(iBar); + if (!isFilled) + { + continue; + } + + // + bool isSamePeriod = iBar.period == period; + if (!isSamePeriod) + { + // + ArrayRemove( + tmpState.bearishOrderBlocks, + i, + 1 // + ); + } + } + } + + // + count = state.CountBullishFairValueGaps(); + if (IsValidSize(count)) + { + // + for (int i = 0; i < count; i++) + { + // + XCFVG iZone = state.bullishFairValueGaps[i]; + + // + XOHCL iBar; + bool isFilled = iZone.FillStartBar(iBar); + if (!isFilled) + { + continue; + } + + // + bool isSamePeriod = iBar.period == period; + if (!isSamePeriod) + { + // + ArrayRemove( + tmpState.bullishFairValueGaps, + i, + 1 // + ); + } + } + } + + // + count = state.CountBearishFairValueGaps(); + if (IsValidSize(count)) + { + // + for (int i = 0; i < count; i++) + { + // + XCFVG iZone = state.bearishFairValueGaps[i]; + + // + XOHCL iBar; + bool isFilled = iZone.FillStartBar(iBar); + if (!isFilled) + { + continue; + } + + // + bool isSamePeriod = iBar.period == period; + if (!isSamePeriod) + { + // + ArrayRemove( + tmpState.bearishFairValueGaps, + i, + 1 // + ); + } + } + } + + // + } + // DrawState( - state, // State ... - true, // Update To of all Drawings Till now ... - false, // Draw SwingHighs .. - false, // Draw SwingLows .. - false, // Draw SupportZones .. - false, // Draw ResistanceZones .. - false, // Draw SupplyZones .. - false, // Draw DemandZones .. - true, // Draw BullishOrderBlocks .. - true, // Draw BearishOrderBlocks .. - false, // Draw BullishFairValueGaps .. - false, // Draw BearishFairValueGaps .. - false, // Draw BullishRejectionBars .. - false, // Draw BearishRejectionBars .. - false, // Draw BullishMomentumBars .. - false // Draw BearishMomentumBars .. + tmpState, // State ... + true, // Update To of all Drawings Till now ... + false, // Draw SwingHighs .. + false, // Draw SwingLows .. + false, // Draw SupportZones .. + false, // Draw ResistanceZones .. + false, // Draw SupplyZones .. + false, // Draw DemandZones .. + false, // Draw BullishOrderBlocks .. + false, // Draw BearishOrderBlocks .. + false, // Draw BullishFairValueGaps .. + false, // Draw BearishFairValueGaps .. + false, // Draw BullishRejectionBars .. + false, // Draw BearishRejectionBars .. + false, // Draw BullishMomentumBars .. + false, // Draw BearishMomentumBars .. + true // Draw Ticks Zone ... ); } @@ -1334,6 +1827,17 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy period, x3vwapInputs // ); + + // + // Initialize PSar ... + double sarStep = 0.02; + double sarMax = 0.2; + mPSarHandler = iSAR( + symbol, + period, + sarStep, + sarMax // + ); } //