/////////////////////////////////////////////////////// // // SaherElm IT Center MQL5 Seriallize Library // --------------------------------------- // Name: XPOILib // Description: All models related to POIs ... // // // Maintainer: // ------------ // Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com) // ////////////////////////////////////////////////////// // // Global Properties ... #property library #property copyright "Copyright `023, SaherElm IT Center" #property link "https://www.saherelm.ir" #property version "1.00" #property strict // // Imports ... #include "../Libraries/x-saherelm.x-poi.extensions.lib.mq5" #include "../Libraries/x-saherelm.x-poi.lib.mq5" // enum ENUM_X_OBFVG_FVG_FILTERS { X_OBFVG_FVG_FILTER_NONE, X_OBFVG_FVG_FILTER_INSIDE_OR, X_OBFVG_FVG_FILTER_ABOVE_BELOW, }; // enum ENUM_X_OBFVG_FVG_SELECTION { X_OBFVG_FVG_SELECT_NONE, X_OBFVG_FVG_SELECT_OLDEST, X_OBFVG_FVG_SELECT_LOWEST, X_OBFVG_FVG_SELECT_HIGHEST, X_OBFVG_FVG_SELECT_YOUNGEST, X_OBFVG_FVG_SELECT_HIGHEST_LOWEST, X_OBFVG_FVG_SELECT_LOWEST_HIGHEST, }; // struct XOBFVGPivot { // // Props ... double value; datetime at; // // Constructor ... XOBFVGPivot() { Clean(); } // // Tools ... // void Clean() { // value = 0; at = NULL; // ZeroMemory(this); } // bool IsValid() { // bool result = false; // result = value > 0 && IsValid(at); // return result; } }; // struct XOBFVG { // // Props ... XCFVG *fvgs[]; XCOrderBlock *ob; // // Constructor ... XOBFVG() { Clean(); } // // Tools ... // void Clean() { // Clean(fvgs); ZeroMemory(ob); // ZeroMemory(this); } // bool IsValid() { return HasOB() && HasFVGs(); } // bool HasOB() { return ob != NULL && ob.IsValid(); } // bool HasFVGs() { return HasChild(fvgs); } // int CountFVGs() { return ArraySize(fvgs); } // ENUM_X_DIRECTION GetDirection() { // ENUM_X_DIRECTION result = X_DIRECTION_NONE; // bool isValid = IsValid(); if (!isValid) { return result; } // result = ob.GetDirection(); // return result; } // bool IsBullish() { return IsBullish(GetDirection()); } // bool IsBearish() { return IsBearish(GetDirection()); } // int GetSwings( XOBFVGPivot &pivots[] // ) { // int result = 0; // Clean(pivots); // if (!IsValid()) { return result; } // ENUM_X_DIRECTION forDir = GetDirection(); bool isBullish = IsBullish(forDir); // XOHCL passedBar; XOBFVGPivot iPivot; bool isPassed = false; double appliedPrice = 0; bool isBodyState = false; // // Start ... isPassed = ob.IsStarted( forDir, passedBar, isBodyState // ); if (isPassed) { // appliedPrice = isBullish ? passedBar.low : passedBar.high; // iPivot.Clean(); iPivot.value = appliedPrice; iPivot.at = passedBar.time; // AddRef( iPivot, pivots // ); // iPivot.Clean(); } // // Activation ... isPassed = ob.IsActivated( forDir, passedBar, isBodyState // ); if (isPassed) { // appliedPrice = isBullish ? passedBar.low : passedBar.high; // iPivot.Clean(); iPivot.value = appliedPrice; iPivot.at = passedBar.time; // AddRef( iPivot, pivots // ); // iPivot.Clean(); } // // Worked ... isPassed = ob.IsWorked( forDir, passedBar, isBodyState // ); if (isPassed) { // appliedPrice = isBullish ? passedBar.low : passedBar.high; // iPivot.Clean(); iPivot.value = appliedPrice; iPivot.at = passedBar.time; // AddRef( iPivot, pivots // ); // iPivot.Clean(); } // passedBar.Clean(); // result = ArraySize(pivots); // return result; } // void AddFVG(XCFVG *fvg) { // int idx = -1; bool has = false; // has = fvg != NULL && fvg.IsValid(); if (!has) { return; } // idx = FindIndex( fvg, fvgs // ); has = !IsValidIndex(idx); if (!has) { return; } // Add( fvg, fvgs // ); } // bool IsSameAs(XOBFVG &item) { // bool result = false; // result = IsValid() && IsSame(ob, item.ob); // return result; } // void UpdateTo(datetime value = NULL) { // value = NormalizeTime(value); // int count = 0; bool has = false; // has = HasOB(); if (has) { ob.To(value); } // has = HasFVGs(); if (has) { // count = CountFVGs(); for (int i = 0; i < count; i++) { fvgs[i].To(value); } } } }; // // // Model Exists Founded POIs ... struct XPOIState { // string symbol; ENUM_TIMEFRAMES period; datetime time; // XCSwing *swings[]; // Holds Founded Swing ... XCSwing *swingLows[]; // Holds Founded Swing Lows ... XCSwing *swingHighs[]; // Holds Founded Swing Highs ... // XCMomentumBar *momentumBars[]; // Holds Founded Momentum Bars ... XCMomentumBar *bullishMomentumBars[]; // Holds Founded Bullish Momentum Bars ... XCMomentumBar *bearishMomentumBars[]; // Holds Founded Bearish Momentum Bars ... // XCRejectionBar *rejectionBars[]; // Holds Founded Rejection Bars ... XCRejectionBar *bullishRejectionBars[]; // Holds Founded Bullish Rejection Bars ... XCRejectionBar *bearishRejectionBars[]; // Holds Founded Bearish Rejection Bars ... // XCSupportZone *supportZones[]; // Holds Founded Support Zones ... XCResistanceZone *resistanceZones[]; // Holds Founded Resistance Zones ... // XCSupplyZone *supplyZones[]; // Holds Founded Supply Zones ... XCDemandZone *demandZones[]; // Holds Founded Demand Zones ... // XCOrderBlock *orderBlocks[]; // Holds Founded Order Blocks ... XCOrderBlock *bullishOrderBlocks[]; // Holds Founded Bullish Order Blocks ... XCOrderBlock *bearishOrderBlocks[]; // Holds Founded Bearish Order Blocks ... // XCFVG *fairValueGaps[]; // Holds Founded Fair Value Gaps ... XCFVG *bullishFairValueGaps[]; // Holds Founded Bullish Fair Value Gaps ... XCFVG *bearishFairValueGaps[]; // Holds Founded Bearish Fair Value Gaps ... // XConsolidationZone consolidationZones[]; // Holds Founded Consolidation Zones ... XConsolidationZone bullishConsolidationZones[]; // Holds Founded Bullish Consolidation Zones ... XConsolidationZone bearishConsolidationZones[]; // Holds Founded Bearih Consolidation Zones ... // // Constructor ... void XPOIState() { Clean(); } // // Actions ... /** * Cleanup all props ... */ void Clean() { // time = NULL; symbol = NULL; period = NULL; // Clean(swings); Clean(swingLows); Clean(swingHighs); // Clean(momentumBars); Clean(bullishMomentumBars); Clean(bearishMomentumBars); // Clean(rejectionBars); Clean(bullishRejectionBars); Clean(bearishRejectionBars); // Clean(supportZones); Clean(resistanceZones); // Clean(supplyZones); Clean(demandZones); // Clean(orderBlocks); Clean(bullishOrderBlocks); Clean(bearishOrderBlocks); // Clean(fairValueGaps); Clean(bullishFairValueGaps); Clean(bearishFairValueGaps); // Clean(consolidationZones); Clean(bullishConsolidationZones); Clean(bearishConsolidationZones); // ZeroMemory(this); } /** * Validate ... * * @return ( bool ) */ bool IsValid() { // bool result = false; // result = IsSpecifiedValid(symbol) && IsSpecifiedValid(period) && IsSpecifiedValid(time); // return result; } /** * Check State has Childs or not ... * * @return ( bool ) */ bool HasChild() { // bool result = false; // result = // HasSwingLows() || HasSwingHighs() || HasSupplyZones() || HasDemandZones() || HasSupportZones() || HasResistanceZones() || HasBullishOrderBlocks() || HasBearishOrderBlocks() || HasBullishMomentumBars() || HasBearishMomentumBars() || HasBullishRejectionBars() || HasBearishRejectionBars() || HasBullishFairValueGaps() || HasBearishFairValueGaps() || HasBullishConsolidationZones() || HasBearishConsolidationZones() // ; // return result; } // // Counters ... // int CountSwings() { // int result = 0; // if (!IsValid()) { return result; } // result = ArraySize(swings); // return result; } // bool HasSwings() { return IsValidSize(CountSwings()); } // int CountSwingHighs() { // int result = 0; // if (!IsValid()) { return result; } // result = ArraySize(swingHighs); // return result; } // bool HasSwingHighs() { return IsValidSize(CountSwingHighs()); } // int CountSwingLows() { // int result = 0; // if (!IsValid()) { return result; } // result = ArraySize(swingLows); // return result; } // bool HasSwingLows() { return IsValidSize(CountSwingLows()); } // int CountMomentumBars() { // int result = 0; // if (!IsValid()) { return result; } // result = ArraySize(momentumBars); // return result; } // bool HasMomentumBars() { return IsValidSize(CountMomentumBars()); } // int CountBullishMomentumBars() { // int result = 0; // if (!IsValid()) { return result; } // result = ArraySize(bullishMomentumBars); // return result; } // bool HasBullishMomentumBars() { return IsValidSize(CountBullishMomentumBars()); } // int CountBearishMomentumBars() { // int result = 0; // if (!IsValid()) { return result; } // result = ArraySize(bearishMomentumBars); // return result; } // bool HasBearishMomentumBars() { return IsValidSize(CountBearishMomentumBars()); } // int CountRejectionBars() { // int result = 0; // if (!IsValid()) { return result; } // result = ArraySize(rejectionBars); // return result; } // bool HasRejectionBars() { return IsValidSize(CountRejectionBars()); } // int CountBullishRejectionBars() { // int result = 0; // if (!IsValid()) { return result; } // result = ArraySize(bullishRejectionBars); // return result; } // bool HasBullishRejectionBars() { return IsValidSize(CountBullishRejectionBars()); } // int CountBearishRejectionBars() { // int result = 0; // if (!IsValid()) { return result; } // result = ArraySize(bearishRejectionBars); // return result; } // bool HasBearishRejectionBars() { return IsValidSize(CountBearishRejectionBars()); } // int CountSupportZones() { // int result = 0; // if (!IsValid()) { return result; } // result = ArraySize(supportZones); // return result; } // bool HasSupportZones() { return IsValidSize(CountSupportZones()); } // int CountResistanceZones() { // int result = 0; // if (!IsValid()) { return result; } // result = ArraySize(resistanceZones); // return result; } // bool HasResistanceZones() { return IsValidSize(CountResistanceZones()); } // int CountSupplyZones() { // int result = 0; // if (!IsValid()) { return result; } // result = ArraySize(supplyZones); // return result; } // bool HasSupplyZones() { return IsValidSize(CountSupplyZones()); } // int CountDemandZones() { // int result = 0; // if (!IsValid()) { return result; } // result = ArraySize(demandZones); // return result; } // bool HasDemandZones() { return IsValidSize(CountDemandZones()); } // int CountOrderBlocks() { // int result = 0; // if (!IsValid()) { return result; } // result = ArraySize(orderBlocks); // return result; } // bool HasOrderBlocks() { return IsValidSize(CountOrderBlocks()); } // int CountBullishOrderBlocks() { // int result = 0; // if (!IsValid()) { return result; } // result = ArraySize(bullishOrderBlocks); // return result; } // bool HasBullishOrderBlocks() { return IsValidSize(CountBullishOrderBlocks()); } // int CountBearishOrderBlocks() { // int result = 0; // if (!IsValid()) { return result; } // result = ArraySize(bearishOrderBlocks); // return result; } // bool HasBearishOrderBlocks() { return IsValidSize(CountBearishOrderBlocks()); } // int CountFairValueGaps() { // int result = 0; // if (!IsValid()) { return result; } // result = ArraySize(fairValueGaps); // return result; } // bool HasFairValueGaps() { return IsValidSize(CountFairValueGaps()); } // int CountBullishFairValueGaps() { // int result = 0; // if (!IsValid()) { return result; } // result = ArraySize(bullishFairValueGaps); // return result; } // bool HasBullishFairValueGaps() { return IsValidSize(CountBullishFairValueGaps()); } // int CountBearishFairValueGaps() { // int result = 0; // if (!IsValid()) { return result; } // result = ArraySize(bearishFairValueGaps); // return result; } // bool HasBearishFairValueGaps() { return IsValidSize(CountBearishFairValueGaps()); } // bool HasConsolidationZones() { return HasChild(consolidationZones); } // int CountConsolidationZones() { return ArraySize(consolidationZones); } // bool HasBullishConsolidationZones() { return HasChild(bullishConsolidationZones); } // int CountBullishConsolidationZones() { return ArraySize(bullishConsolidationZones); } // bool HasBearishConsolidationZones() { return HasChild(bearishConsolidationZones); } // int CountBearishConsolidationZones() { return ArraySize(bearishConsolidationZones); } // void UpdateTo(datetime value = NULL) { // value = NormalizeTime(value); // int count = 0; bool has = false; // has = HasMomentumBars(); if (has) { // count = CountMomentumBars(); for (int i = 0; i < count; i++) { momentumBars[i].To(value); } } // has = HasBullishMomentumBars(); if (has) { // count = CountBullishMomentumBars(); for (int i = 0; i < count; i++) { bullishMomentumBars[i].To(value); } } // has = HasBearishMomentumBars(); if (has) { // count = CountBearishMomentumBars(); for (int i = 0; i < count; i++) { bearishMomentumBars[i].To(value); } } // has = HasRejectionBars(); if (has) { // count = CountRejectionBars(); for (int i = 0; i < count; i++) { rejectionBars[i].To(value); } } // has = HasBullishRejectionBars(); if (has) { // count = CountBullishRejectionBars(); for (int i = 0; i < count; i++) { bullishRejectionBars[i].To(value); } } // has = HasBearishRejectionBars(); if (has) { // count = CountBearishRejectionBars(); for (int i = 0; i < count; i++) { bearishRejectionBars[i].To(value); } } // has = HasSupportZones(); if (has) { // count = CountSupportZones(); for (int i = 0; i < count; i++) { supportZones[i].To(value); } } // has = HasResistanceZones(); if (has) { // count = CountResistanceZones(); for (int i = 0; i < count; i++) { resistanceZones[i].To(value); } } // has = HasSupplyZones(); if (has) { // count = CountSupplyZones(); for (int i = 0; i < count; i++) { supplyZones[i].To(value); } } // has = HasDemandZones(); if (has) { // count = CountDemandZones(); for (int i = 0; i < count; i++) { demandZones[i].To(value); } } // has = HasOrderBlocks(); if (has) { // count = CountOrderBlocks(); for (int i = 0; i < count; i++) { orderBlocks[i].To(value); } } // has = HasBullishOrderBlocks(); if (has) { // count = CountBullishOrderBlocks(); for (int i = 0; i < count; i++) { bullishOrderBlocks[i].To(value); } } // has = HasBearishOrderBlocks(); if (has) { // count = CountBearishOrderBlocks(); for (int i = 0; i < count; i++) { bearishOrderBlocks[i].To(value); } } // has = HasFairValueGaps(); if (has) { // count = CountFairValueGaps(); for (int i = 0; i < count; i++) { fairValueGaps[i].To(value); } } // has = HasBullishFairValueGaps(); if (has) { // count = CountBullishFairValueGaps(); for (int i = 0; i < count; i++) { bullishFairValueGaps[i].To(value); } } // has = HasBearishFairValueGaps(); if (has) { // count = CountBearishFairValueGaps(); for (int i = 0; i < count; i++) { bearishFairValueGaps[i].To(value); } } } // // Filter Zones ... // // Support ... int FilterSupportZones( XCSupportZone *&dest[], ENUM_TIMEFRAMES forPeriod = NULL, // // Start ... ENUM_XZONE_STATE startState = XZONE_STATE_PASSED, bool forceStartedBodyOut = false, // // Activation ... ENUM_XZONE_STATE activeState = XZONE_STATE_FAILED, bool forceActivatedBodyIn = false, // // Breaktion ... ENUM_XZONE_STATE breakState = XZONE_STATE_FAILED, bool forceBreakedBodyOut = false, // // Works ... ENUM_XZONE_STATE workState = XZONE_STATE_FAILED, bool forceWorkedBodyOut = false // ) { // int result = 0; // int idx = -1; int count = 0; bool has = false; // Clean(dest); // if (!IsValid(forPeriod)) { forPeriod = period; } // has = IsValid() && HasSupportZones(); if (!has) { return result; } // XOHCL passedBar; ENUM_X_DIRECTION passedDir = X_DIRECTION_NONE; passedDir = X_DIRECTION_BULLISH; count = CountSupportZones(); for (int i = 0; i < count; i++) { // XCSupportZone *iZone = supportZones[i]; // // Check Started State ... if (startState == XZONE_STATE_PASSED || startState == XZONE_STATE_FAILED) { // bool isBodyOut = false; bool isStarted = iZone.IsStarted( passedDir, passedBar, isBodyOut, forPeriod // ); // bool isPassed = startState == XZONE_STATE_FAILED ? !isStarted : !forceStartedBodyOut ? isStarted : isStarted && isBodyOut; // passedBar.Clean(); if (!isPassed) { continue; } } // // Check Activation State ... if (activeState == XZONE_STATE_PASSED || activeState == XZONE_STATE_FAILED) { // bool isBodyIn = false; bool isActivated = iZone.IsActivated( passedDir, passedBar, isBodyIn, forceStartedBodyOut, forPeriod // ); // bool isPassed = activeState == XZONE_STATE_FAILED ? !isActivated : !forceActivatedBodyIn ? isActivated : isActivated && isBodyIn; // passedBar.Clean(); if (!isPassed) { continue; } } // // Check Break State ... if (breakState == XZONE_STATE_PASSED || breakState == XZONE_STATE_FAILED) { // bool isBodyOut = false; bool isBreaked = iZone.IsBreaked( passedDir, passedBar, isBodyOut, forceStartedBodyOut, forPeriod // ); // bool isPassed = breakState == XZONE_STATE_FAILED ? !isBreaked : !forceBreakedBodyOut ? isBreaked : isBreaked && isBodyOut; // passedBar.Clean(); if (!isPassed) { continue; } } // // Check Work State ... if (workState == XZONE_STATE_PASSED || workState == XZONE_STATE_FAILED) { // bool ignoreActivation = activeState != XZONE_STATE_PASSED; // bool isBodyOut = false; bool isWorked = iZone.IsWorked( passedDir, passedBar, isBodyOut, ignoreActivation, forceStartedBodyOut, forceActivatedBodyIn, forPeriod // ); // bool isPassed = workState == XZONE_STATE_FAILED ? !isWorked : !forceWorkedBodyOut ? isWorked : isWorked && isBodyOut; // passedBar.Clean(); if (!isPassed) { continue; } } // // Check Filtered Zone Doesn't Exists ... has = FindIndex( idx, iZone, dest // ); if (has) { // passedBar.Clean(); continue; } // Add( iZone, dest // ); // // End For ... } // result = ArraySize(dest); // return result; } // // Resistance ... int FilterResistanceZones( XCResistanceZone *&dest[], ENUM_TIMEFRAMES forPeriod = NULL, // // Start ... ENUM_XZONE_STATE startState = XZONE_STATE_PASSED, bool forceStartedBodyOut = false, // // Activation ... ENUM_XZONE_STATE activeState = XZONE_STATE_FAILED, bool forceActivatedBodyIn = false, // // Breaktion ... ENUM_XZONE_STATE breakState = XZONE_STATE_FAILED, bool forceBreakedBodyOut = false, // // Works ... ENUM_XZONE_STATE workState = XZONE_STATE_FAILED, bool forceWorkedBodyOut = false // ) { // int result = 0; // int idx = -1; int count = 0; bool has = false; // Clean(dest); // if (!IsValid(forPeriod)) { forPeriod = period; } // has = IsValid() && HasResistanceZones(); if (!has) { return result; } // XOHCL passedBar; ENUM_X_DIRECTION passedDir = X_DIRECTION_NONE; passedDir = X_DIRECTION_BEARISH; count = CountResistanceZones(); for (int i = 0; i < count; i++) { // XCResistanceZone *iZone = resistanceZones[i]; // // Check Started State ... if (startState == XZONE_STATE_PASSED || startState == XZONE_STATE_FAILED) { // bool isBodyOut = false; bool isStarted = iZone.IsStarted( passedDir, passedBar, isBodyOut, forPeriod // ); // bool isPassed = startState == XZONE_STATE_FAILED ? !isStarted : !forceStartedBodyOut ? isStarted : isStarted && isBodyOut; // passedBar.Clean(); if (!isPassed) { continue; } } // // Check Activation State ... if (activeState == XZONE_STATE_PASSED || activeState == XZONE_STATE_FAILED) { // bool isBodyIn = false; bool isActivated = iZone.IsActivated( passedDir, passedBar, isBodyIn, forceStartedBodyOut, forPeriod // ); // bool isPassed = activeState == XZONE_STATE_FAILED ? !isActivated : !forceActivatedBodyIn ? isActivated : isActivated && isBodyIn; // passedBar.Clean(); if (!isPassed) { continue; } } // // Check Break State ... if (breakState == XZONE_STATE_PASSED || breakState == XZONE_STATE_FAILED) { // bool isBodyOut = false; bool isBreaked = iZone.IsBreaked( passedDir, passedBar, isBodyOut, forceStartedBodyOut, forPeriod // ); // bool isPassed = breakState == XZONE_STATE_FAILED ? !isBreaked : !forceBreakedBodyOut ? isBreaked : isBreaked && isBodyOut; // passedBar.Clean(); if (!isPassed) { continue; } } // // Check Work State ... if (workState == XZONE_STATE_PASSED || workState == XZONE_STATE_FAILED) { // bool ignoreActivation = activeState != XZONE_STATE_PASSED; // bool isBodyOut = false; bool isWorked = iZone.IsWorked( passedDir, passedBar, isBodyOut, ignoreActivation, forceStartedBodyOut, forceActivatedBodyIn, forPeriod // ); // bool isPassed = workState == XZONE_STATE_FAILED ? !isWorked : !forceWorkedBodyOut ? isWorked : isWorked && isBodyOut; // passedBar.Clean(); if (!isPassed) { continue; } } // // Check Filtered Zone Doesn't Exists ... has = FindIndex( idx, iZone, dest // ); if (has) { // passedBar.Clean(); continue; } // Add( iZone, dest // ); // // End For ... } // result = ArraySize(dest); // return result; } // // Supply ... int FilterSupplyZones( XCSupplyZone *&dest[], ENUM_TIMEFRAMES forPeriod = NULL, // // Start ... ENUM_XZONE_STATE startState = XZONE_STATE_PASSED, bool forceStartedBodyOut = false, // // Activation ... ENUM_XZONE_STATE activeState = XZONE_STATE_FAILED, bool forceActivatedBodyIn = false, // // Breaktion ... ENUM_XZONE_STATE breakState = XZONE_STATE_FAILED, bool forceBreakedBodyOut = false, // // Works ... ENUM_XZONE_STATE workState = XZONE_STATE_FAILED, bool forceWorkedBodyOut = false // ) { // int result = 0; // int idx = -1; int count = 0; bool has = false; // Clean(dest); // if (!IsValid(forPeriod)) { forPeriod = period; } // has = IsValid() && HasSupplyZones(); if (!has) { return result; } // XOHCL passedBar; ENUM_X_DIRECTION passedDir = X_DIRECTION_NONE; passedDir = X_DIRECTION_BEARISH; count = CountSupplyZones(); for (int i = 0; i < count; i++) { // XCSupplyZone *iZone = supplyZones[i]; // // Check Started State ... if (startState == XZONE_STATE_PASSED || startState == XZONE_STATE_FAILED) { // bool isBodyOut = false; bool isStarted = iZone.IsStarted( passedDir, passedBar, isBodyOut, forPeriod // ); // bool isPassed = startState == XZONE_STATE_FAILED ? !isStarted : !forceStartedBodyOut ? isStarted : isStarted && isBodyOut; // passedBar.Clean(); if (!isPassed) { continue; } } // // Check Activation State ... if (activeState == XZONE_STATE_PASSED || activeState == XZONE_STATE_FAILED) { // bool isBodyIn = false; bool isActivated = iZone.IsActivated( passedDir, passedBar, isBodyIn, forceStartedBodyOut, forPeriod // ); // bool isPassed = activeState == XZONE_STATE_FAILED ? !isActivated : !forceActivatedBodyIn ? isActivated : isActivated && isBodyIn; // passedBar.Clean(); if (!isPassed) { continue; } } // // Check Break State ... if (breakState == XZONE_STATE_PASSED || breakState == XZONE_STATE_FAILED) { // bool isBodyOut = false; bool isBreaked = iZone.IsBreaked( passedDir, passedBar, isBodyOut, forceStartedBodyOut, forPeriod // ); // bool isPassed = breakState == XZONE_STATE_FAILED ? !isBreaked : !forceBreakedBodyOut ? isBreaked : isBreaked && isBodyOut; // passedBar.Clean(); if (!isPassed) { continue; } } // // Check Work State ... if (workState == XZONE_STATE_PASSED || workState == XZONE_STATE_FAILED) { // bool ignoreActivation = activeState != XZONE_STATE_PASSED; // bool isBodyOut = false; bool isWorked = iZone.IsWorked( passedDir, passedBar, isBodyOut, ignoreActivation, forceStartedBodyOut, forceActivatedBodyIn, forPeriod // ); // bool isPassed = workState == XZONE_STATE_FAILED ? !isWorked : !forceWorkedBodyOut ? isWorked : isWorked && isBodyOut; // passedBar.Clean(); if (!isPassed) { continue; } } // // Check Filtered Zone Doesn't Exists ... has = FindIndex( idx, iZone, dest // ); if (has) { // passedBar.Clean(); continue; } // Add( iZone, dest // ); // // End For ... } // result = ArraySize(dest); // return result; } // // Demand ... int FilterDemandZones( XCDemandZone *&dest[], ENUM_TIMEFRAMES forPeriod = NULL, // // Start ... ENUM_XZONE_STATE startState = XZONE_STATE_PASSED, bool forceStartedBodyOut = false, // // Activation ... ENUM_XZONE_STATE activeState = XZONE_STATE_FAILED, bool forceActivatedBodyIn = false, // // Breaktion ... ENUM_XZONE_STATE breakState = XZONE_STATE_FAILED, bool forceBreakedBodyOut = false, // // Works ... ENUM_XZONE_STATE workState = XZONE_STATE_FAILED, bool forceWorkedBodyOut = false // ) { // int result = 0; // int idx = -1; int count = 0; bool has = false; // Clean(dest); // if (!IsValid(forPeriod)) { forPeriod = period; } // has = IsValid() && HasDemandZones(); if (!has) { return result; } // XOHCL passedBar; ENUM_X_DIRECTION passedDir = X_DIRECTION_NONE; passedDir = X_DIRECTION_BULLISH; count = CountDemandZones(); for (int i = 0; i < count; i++) { // XCDemandZone *iZone = demandZones[i]; // // Check Started State ... if (startState == XZONE_STATE_PASSED || startState == XZONE_STATE_FAILED) { // bool isBodyOut = false; bool isStarted = iZone.IsStarted( passedDir, passedBar, isBodyOut, forPeriod // ); // bool isPassed = startState == XZONE_STATE_FAILED ? !isStarted : !forceStartedBodyOut ? isStarted : isStarted && isBodyOut; // passedBar.Clean(); if (!isPassed) { continue; } } // // Check Activation State ... if (activeState == XZONE_STATE_PASSED || activeState == XZONE_STATE_FAILED) { // bool isBodyIn = false; bool isActivated = iZone.IsActivated( passedDir, passedBar, isBodyIn, forceStartedBodyOut, forPeriod // ); // bool isPassed = activeState == XZONE_STATE_FAILED ? !isActivated : !forceActivatedBodyIn ? isActivated : isActivated && isBodyIn; // passedBar.Clean(); if (!isPassed) { continue; } } // // Check Break State ... if (breakState == XZONE_STATE_PASSED || breakState == XZONE_STATE_FAILED) { // bool isBodyOut = false; bool isBreaked = iZone.IsBreaked( passedDir, passedBar, isBodyOut, forceStartedBodyOut, forPeriod // ); // bool isPassed = breakState == XZONE_STATE_FAILED ? !isBreaked : !forceBreakedBodyOut ? isBreaked : isBreaked && isBodyOut; // passedBar.Clean(); if (!isPassed) { continue; } } // // Check Work State ... if (workState == XZONE_STATE_PASSED || workState == XZONE_STATE_FAILED) { // bool ignoreActivation = activeState != XZONE_STATE_PASSED; // bool isBodyOut = false; bool isWorked = iZone.IsWorked( passedDir, passedBar, isBodyOut, ignoreActivation, forceStartedBodyOut, forceActivatedBodyIn, forPeriod // ); // bool isPassed = workState == XZONE_STATE_FAILED ? !isWorked : !forceWorkedBodyOut ? isWorked : isWorked && isBodyOut; // passedBar.Clean(); if (!isPassed) { continue; } } // // Check Filtered Zone Doesn't Exists ... has = FindIndex( idx, iZone, dest // ); if (has) { // passedBar.Clean(); continue; } // Add( iZone, dest // ); // // End For ... } // result = ArraySize(dest); // return result; } // // OrderBlock ... int FilterOrderBlocks( XCOrderBlock *&dest[], ENUM_TIMEFRAMES forPeriod = NULL, // // Start ... ENUM_XZONE_STATE startState = XZONE_STATE_PASSED, bool forceStartedBodyOut = false, // // Activation ... ENUM_XZONE_STATE activeState = XZONE_STATE_FAILED, bool forceActivatedBodyIn = false, // // Breaktion ... ENUM_XZONE_STATE breakState = XZONE_STATE_FAILED, bool forceBreakedBodyOut = false, // // Works ... ENUM_XZONE_STATE workState = XZONE_STATE_FAILED, bool forceWorkedBodyOut = false // ) { // int result = 0; // int idx = -1; int count = 0; bool has = false; // Clean(dest); // if (!IsValid(forPeriod)) { forPeriod = period; } // has = IsValid() && HasOrderBlocks(); if (!has) { return result; } // XOHCL passedBar; ENUM_X_DIRECTION passedDir = X_DIRECTION_NONE; count = CountOrderBlocks(); for (int i = 0; i < count; i++) { // XCOrderBlock *iZone = orderBlocks[i]; passedDir = iZone.GetDirection(); // // Check Started State ... if (startState == XZONE_STATE_PASSED || startState == XZONE_STATE_FAILED) { // bool isBodyOut = false; bool isStarted = iZone.IsStarted( passedDir, passedBar, isBodyOut, forPeriod // ); // bool isPassed = startState == XZONE_STATE_FAILED ? !isStarted : !forceStartedBodyOut ? isStarted : isStarted && isBodyOut; // passedBar.Clean(); if (!isPassed) { continue; } } // // Check Activation State ... if (activeState == XZONE_STATE_PASSED || activeState == XZONE_STATE_FAILED) { // bool isBodyIn = false; bool isActivated = iZone.IsActivated( passedDir, passedBar, isBodyIn, forceStartedBodyOut, forPeriod // ); // bool isPassed = activeState == XZONE_STATE_FAILED ? !isActivated : !forceActivatedBodyIn ? isActivated : isActivated && isBodyIn; // passedBar.Clean(); if (!isPassed) { continue; } } // // Check Break State ... if (breakState == XZONE_STATE_PASSED || breakState == XZONE_STATE_FAILED) { // bool isBodyOut = false; bool isBreaked = iZone.IsBreaked( passedDir, passedBar, isBodyOut, forceStartedBodyOut, forPeriod // ); // bool isPassed = breakState == XZONE_STATE_FAILED ? !isBreaked : !forceBreakedBodyOut ? isBreaked : isBreaked && isBodyOut; // passedBar.Clean(); if (!isPassed) { continue; } } // // Check Work State ... if (workState == XZONE_STATE_PASSED || workState == XZONE_STATE_FAILED) { // bool ignoreActivation = activeState != XZONE_STATE_PASSED; // bool isBodyOut = false; bool isWorked = iZone.IsWorked( passedDir, passedBar, isBodyOut, ignoreActivation, forceStartedBodyOut, forceActivatedBodyIn, forPeriod // ); // bool isPassed = workState == XZONE_STATE_FAILED ? !isWorked : !forceWorkedBodyOut ? isWorked : isWorked && isBodyOut; // passedBar.Clean(); if (!isPassed) { continue; } } // // Check Filtered Zone Doesn't Exists ... has = FindIndex( idx, iZone, dest // ); if (has) { // passedBar.Clean(); continue; } // Add( iZone, dest // ); // // End For ... } // result = ArraySize(dest); // return result; } // // Bullish OrderBlock ... int FilterBullishOrderBlocks( XCOrderBlock *&dest[], ENUM_TIMEFRAMES forPeriod = NULL, // // Start ... ENUM_XZONE_STATE startState = XZONE_STATE_PASSED, bool forceStartedBodyOut = false, // // Activation ... ENUM_XZONE_STATE activeState = XZONE_STATE_FAILED, bool forceActivatedBodyIn = false, // // Breaktion ... ENUM_XZONE_STATE breakState = XZONE_STATE_FAILED, bool forceBreakedBodyOut = false, // // Works ... ENUM_XZONE_STATE workState = XZONE_STATE_FAILED, bool forceWorkedBodyOut = false // ) { // int result = 0; // int idx = -1; int count = 0; bool has = false; // Clean(dest); // if (!IsValid(forPeriod)) { forPeriod = period; } // has = IsValid() && HasBullishOrderBlocks(); if (!has) { return result; } // XOHCL passedBar; ENUM_X_DIRECTION passedDir = X_DIRECTION_NONE; passedDir = X_DIRECTION_BULLISH; count = CountBullishOrderBlocks(); for (int i = 0; i < count; i++) { // XCOrderBlock *iZone = bullishOrderBlocks[i]; // // Check Started State ... if (startState == XZONE_STATE_PASSED || startState == XZONE_STATE_FAILED) { // bool isBodyOut = false; bool isStarted = iZone.IsStarted( passedDir, passedBar, isBodyOut, forPeriod // ); // bool isPassed = startState == XZONE_STATE_FAILED ? !isStarted : !forceStartedBodyOut ? isStarted : isStarted && isBodyOut; // passedBar.Clean(); if (!isPassed) { continue; } } // // Check Activation State ... if (activeState == XZONE_STATE_PASSED || activeState == XZONE_STATE_FAILED) { // bool isBodyIn = false; bool isActivated = iZone.IsActivated( passedDir, passedBar, isBodyIn, forceStartedBodyOut, forPeriod // ); // bool isPassed = activeState == XZONE_STATE_FAILED ? !isActivated : !forceActivatedBodyIn ? isActivated : isActivated && isBodyIn; // passedBar.Clean(); if (!isPassed) { continue; } } // // Check Break State ... if (breakState == XZONE_STATE_PASSED || breakState == XZONE_STATE_FAILED) { // bool isBodyOut = false; bool isBreaked = iZone.IsBreaked( passedDir, passedBar, isBodyOut, forceStartedBodyOut, forPeriod // ); // bool isPassed = breakState == XZONE_STATE_FAILED ? !isBreaked : !forceBreakedBodyOut ? isBreaked : isBreaked && isBodyOut; // passedBar.Clean(); if (!isPassed) { continue; } } // // Check Work State ... if (workState == XZONE_STATE_PASSED || workState == XZONE_STATE_FAILED) { // bool ignoreActivation = activeState != XZONE_STATE_PASSED; // bool isBodyOut = false; bool isWorked = iZone.IsWorked( passedDir, passedBar, isBodyOut, ignoreActivation, forceStartedBodyOut, forceActivatedBodyIn, forPeriod // ); // bool isPassed = workState == XZONE_STATE_FAILED ? !isWorked : !forceWorkedBodyOut ? isWorked : isWorked && isBodyOut; // passedBar.Clean(); if (!isPassed) { continue; } } // // Check Filtered Zone Doesn't Exists ... has = FindIndex( idx, iZone, dest // ); if (has) { // passedBar.Clean(); continue; } // Add( iZone, dest // ); // // End For ... } // result = ArraySize(dest); // return result; } // // Bearish OrderBlock ... int FilterBearishOrderBlocks( XCOrderBlock *&dest[], ENUM_TIMEFRAMES forPeriod = NULL, // // Start ... ENUM_XZONE_STATE startState = XZONE_STATE_PASSED, bool forceStartedBodyOut = false, // // Activation ... ENUM_XZONE_STATE activeState = XZONE_STATE_FAILED, bool forceActivatedBodyIn = false, // // Breaktion ... ENUM_XZONE_STATE breakState = XZONE_STATE_FAILED, bool forceBreakedBodyOut = false, // // Works ... ENUM_XZONE_STATE workState = XZONE_STATE_FAILED, bool forceWorkedBodyOut = false // ) { // int result = 0; // int idx = -1; int count = 0; bool has = false; // Clean(dest); // if (!IsValid(forPeriod)) { forPeriod = period; } // has = IsValid() && HasBearishOrderBlocks(); if (!has) { return result; } // XOHCL passedBar; ENUM_X_DIRECTION passedDir = X_DIRECTION_NONE; passedDir = X_DIRECTION_BEARISH; count = CountBearishOrderBlocks(); for (int i = 0; i < count; i++) { // XCOrderBlock *iZone = bearishOrderBlocks[i]; // // Check Started State ... if (startState == XZONE_STATE_PASSED || startState == XZONE_STATE_FAILED) { // bool isBodyOut = false; bool isStarted = iZone.IsStarted( passedDir, passedBar, isBodyOut, forPeriod // ); // bool isPassed = startState == XZONE_STATE_FAILED ? !isStarted : !forceStartedBodyOut ? isStarted : isStarted && isBodyOut; // passedBar.Clean(); if (!isPassed) { continue; } } // // Check Activation State ... if (activeState == XZONE_STATE_PASSED || activeState == XZONE_STATE_FAILED) { // bool isBodyIn = false; bool isActivated = iZone.IsActivated( passedDir, passedBar, isBodyIn, forceStartedBodyOut, forPeriod // ); // bool isPassed = activeState == XZONE_STATE_FAILED ? !isActivated : !forceActivatedBodyIn ? isActivated : isActivated && isBodyIn; // passedBar.Clean(); if (!isPassed) { continue; } } // // Check Break State ... if (breakState == XZONE_STATE_PASSED || breakState == XZONE_STATE_FAILED) { // bool isBodyOut = false; bool isBreaked = iZone.IsBreaked( passedDir, passedBar, isBodyOut, forceStartedBodyOut, forPeriod // ); // bool isPassed = breakState == XZONE_STATE_FAILED ? !isBreaked : !forceBreakedBodyOut ? isBreaked : isBreaked && isBodyOut; // passedBar.Clean(); if (!isPassed) { continue; } } // // Check Work State ... if (workState == XZONE_STATE_PASSED || workState == XZONE_STATE_FAILED) { // bool ignoreActivation = activeState != XZONE_STATE_PASSED; // bool isBodyOut = false; bool isWorked = iZone.IsWorked( passedDir, passedBar, isBodyOut, ignoreActivation, forceStartedBodyOut, forceActivatedBodyIn, forPeriod // ); // bool isPassed = workState == XZONE_STATE_FAILED ? !isWorked : !forceWorkedBodyOut ? isWorked : isWorked && isBodyOut; // passedBar.Clean(); if (!isPassed) { continue; } } // // Check Filtered Zone Doesn't Exists ... has = FindIndex( idx, iZone, dest // ); if (has) { // passedBar.Clean(); continue; } // Add( iZone, dest // ); // // End For ... } // result = ArraySize(dest); // return result; } // // FairValueGap ... int FilterFairValueGaps( XCFVG *&dest[], ENUM_TIMEFRAMES forPeriod = NULL, // // Start ... ENUM_XZONE_STATE startState = XZONE_STATE_PASSED, bool forceStartedBodyOut = false, // // Activation ... ENUM_XZONE_STATE activeState = XZONE_STATE_FAILED, bool forceActivatedBodyIn = false, // // Breaktion ... ENUM_XZONE_STATE breakState = XZONE_STATE_FAILED, bool forceBreakedBodyOut = false, // // Works ... ENUM_XZONE_STATE workState = XZONE_STATE_FAILED, bool forceWorkedBodyOut = false // ) { // int result = 0; // int idx = -1; int count = 0; bool has = false; // Clean(dest); // if (!IsValid(forPeriod)) { forPeriod = period; } // has = IsValid() && HasFairValueGaps(); if (!has) { return result; } // XOHCL passedBar; ENUM_X_DIRECTION passedDir = X_DIRECTION_NONE; count = CountFairValueGaps(); for (int i = 0; i < count; i++) { // XCFVG *iZone = fairValueGaps[i]; passedDir = iZone.GetDirection(); // // Check Started State ... if (startState == XZONE_STATE_PASSED || startState == XZONE_STATE_FAILED) { // bool isBodyOut = false; bool isStarted = iZone.IsStarted( passedDir, passedBar, isBodyOut, forPeriod // ); // bool isPassed = startState == XZONE_STATE_FAILED ? !isStarted : !forceStartedBodyOut ? isStarted : isStarted && isBodyOut; // passedBar.Clean(); if (!isPassed) { continue; } } // // Check Activation State ... if (activeState == XZONE_STATE_PASSED || activeState == XZONE_STATE_FAILED) { // bool isBodyIn = false; bool isActivated = iZone.IsActivated( passedDir, passedBar, isBodyIn, forceStartedBodyOut, forPeriod // ); // bool isPassed = activeState == XZONE_STATE_FAILED ? !isActivated : !forceActivatedBodyIn ? isActivated : isActivated && isBodyIn; // passedBar.Clean(); if (!isPassed) { continue; } } // // Check Break State ... if (breakState == XZONE_STATE_PASSED || breakState == XZONE_STATE_FAILED) { // bool isBodyOut = false; bool isBreaked = iZone.IsBreaked( passedDir, passedBar, isBodyOut, forceStartedBodyOut, forPeriod // ); // bool isPassed = breakState == XZONE_STATE_FAILED ? !isBreaked : !forceBreakedBodyOut ? isBreaked : isBreaked && isBodyOut; // passedBar.Clean(); if (!isPassed) { continue; } } // // Check Work State ... if (workState == XZONE_STATE_PASSED || workState == XZONE_STATE_FAILED) { // bool ignoreActivation = activeState != XZONE_STATE_PASSED; // bool isBodyOut = false; bool isWorked = iZone.IsWorked( passedDir, passedBar, isBodyOut, ignoreActivation, forceStartedBodyOut, forceActivatedBodyIn, forPeriod // ); // bool isPassed = workState == XZONE_STATE_FAILED ? !isWorked : !forceWorkedBodyOut ? isWorked : isWorked && isBodyOut; // passedBar.Clean(); if (!isPassed) { continue; } } // // Check Filtered Zone Doesn't Exists ... has = FindIndex( idx, iZone, dest // ); if (has) { // passedBar.Clean(); continue; } // Add( iZone, dest // ); // // End For ... } // result = ArraySize(dest); // return result; } // // Bullish FairValueGap ... int FilterBullishFairValueGaps( XCFVG *&dest[], ENUM_TIMEFRAMES forPeriod = NULL, // // Start ... ENUM_XZONE_STATE startState = XZONE_STATE_PASSED, bool forceStartedBodyOut = false, // // Activation ... ENUM_XZONE_STATE activeState = XZONE_STATE_FAILED, bool forceActivatedBodyIn = false, // // Breaktion ... ENUM_XZONE_STATE breakState = XZONE_STATE_FAILED, bool forceBreakedBodyOut = false, // // Works ... ENUM_XZONE_STATE workState = XZONE_STATE_FAILED, bool forceWorkedBodyOut = false // ) { // int result = 0; // int idx = -1; int count = 0; bool has = false; // Clean(dest); // if (!IsValid(forPeriod)) { forPeriod = period; } // has = IsValid() && HasBullishFairValueGaps(); if (!has) { return result; } // XOHCL passedBar; ENUM_X_DIRECTION passedDir = X_DIRECTION_NONE; passedDir = X_DIRECTION_BULLISH; count = CountBullishFairValueGaps(); for (int i = 0; i < count; i++) { // XCFVG *iZone = bullishFairValueGaps[i]; // // Check Started State ... if (startState == XZONE_STATE_PASSED || startState == XZONE_STATE_FAILED) { // bool isBodyOut = false; bool isStarted = iZone.IsStarted( passedDir, passedBar, isBodyOut, forPeriod // ); // bool isPassed = startState == XZONE_STATE_FAILED ? !isStarted : !forceStartedBodyOut ? isStarted : isStarted && isBodyOut; // passedBar.Clean(); if (!isPassed) { continue; } } // // Check Activation State ... if (activeState == XZONE_STATE_PASSED || activeState == XZONE_STATE_FAILED) { // bool isBodyIn = false; bool isActivated = iZone.IsActivated( passedDir, passedBar, isBodyIn, forceStartedBodyOut, forPeriod // ); // bool isPassed = activeState == XZONE_STATE_FAILED ? !isActivated : !forceActivatedBodyIn ? isActivated : isActivated && isBodyIn; // passedBar.Clean(); if (!isPassed) { continue; } } // // Check Break State ... if (breakState == XZONE_STATE_PASSED || breakState == XZONE_STATE_FAILED) { // bool isBodyOut = false; bool isBreaked = iZone.IsBreaked( passedDir, passedBar, isBodyOut, forceStartedBodyOut, forPeriod // ); // bool isPassed = breakState == XZONE_STATE_FAILED ? !isBreaked : !forceBreakedBodyOut ? isBreaked : isBreaked && isBodyOut; // passedBar.Clean(); if (!isPassed) { continue; } } // // Check Work State ... if (workState == XZONE_STATE_PASSED || workState == XZONE_STATE_FAILED) { // bool ignoreActivation = activeState != XZONE_STATE_PASSED; // bool isBodyOut = false; bool isWorked = iZone.IsWorked( passedDir, passedBar, isBodyOut, ignoreActivation, forceStartedBodyOut, forceActivatedBodyIn, forPeriod // ); // bool isPassed = workState == XZONE_STATE_FAILED ? !isWorked : !forceWorkedBodyOut ? isWorked : isWorked && isBodyOut; // passedBar.Clean(); if (!isPassed) { continue; } } // // Check Filtered Zone Doesn't Exists ... has = FindIndex( idx, iZone, dest // ); if (has) { // passedBar.Clean(); continue; } // Add( iZone, dest // ); // // End For ... } // result = ArraySize(dest); // return result; } // // Bearish FairValueGap ... int FilterBearishFairValueGaps( XCFVG *&dest[], ENUM_TIMEFRAMES forPeriod = NULL, // // Start ... ENUM_XZONE_STATE startState = XZONE_STATE_PASSED, bool forceStartedBodyOut = false, // // Activation ... ENUM_XZONE_STATE activeState = XZONE_STATE_FAILED, bool forceActivatedBodyIn = false, // // Breaktion ... ENUM_XZONE_STATE breakState = XZONE_STATE_FAILED, bool forceBreakedBodyOut = false, // // Works ... ENUM_XZONE_STATE workState = XZONE_STATE_FAILED, bool forceWorkedBodyOut = false // ) { // int result = 0; // int idx = -1; int count = 0; bool has = false; // Clean(dest); // if (!IsValid(forPeriod)) { forPeriod = period; } // has = IsValid() && HasBearishFairValueGaps(); if (!has) { return result; } // XOHCL passedBar; ENUM_X_DIRECTION passedDir = X_DIRECTION_NONE; passedDir = X_DIRECTION_BEARISH; count = CountBearishFairValueGaps(); for (int i = 0; i < count; i++) { // XCFVG *iZone = bearishFairValueGaps[i]; // // Check Started State ... if (startState == XZONE_STATE_PASSED || startState == XZONE_STATE_FAILED) { // bool isBodyOut = false; bool isStarted = iZone.IsStarted( passedDir, passedBar, isBodyOut, forPeriod // ); // bool isPassed = startState == XZONE_STATE_FAILED ? !isStarted : !forceStartedBodyOut ? isStarted : isStarted && isBodyOut; // passedBar.Clean(); if (!isPassed) { continue; } } // // Check Activation State ... if (activeState == XZONE_STATE_PASSED || activeState == XZONE_STATE_FAILED) { // bool isBodyIn = false; bool isActivated = iZone.IsActivated( passedDir, passedBar, isBodyIn, forceStartedBodyOut, forPeriod // ); // bool isPassed = activeState == XZONE_STATE_FAILED ? !isActivated : !forceActivatedBodyIn ? isActivated : isActivated && isBodyIn; // passedBar.Clean(); if (!isPassed) { continue; } } // // Check Break State ... if (breakState == XZONE_STATE_PASSED || breakState == XZONE_STATE_FAILED) { // bool isBodyOut = false; bool isBreaked = iZone.IsBreaked( passedDir, passedBar, isBodyOut, forceStartedBodyOut, forPeriod // ); // bool isPassed = breakState == XZONE_STATE_FAILED ? !isBreaked : !forceBreakedBodyOut ? isBreaked : isBreaked && isBodyOut; // passedBar.Clean(); if (!isPassed) { continue; } } // // Check Work State ... if (workState == XZONE_STATE_PASSED || workState == XZONE_STATE_FAILED) { // bool ignoreActivation = activeState != XZONE_STATE_PASSED; // bool isBodyOut = false; bool isWorked = iZone.IsWorked( passedDir, passedBar, isBodyOut, ignoreActivation, forceStartedBodyOut, forceActivatedBodyIn, forPeriod // ); // bool isPassed = workState == XZONE_STATE_FAILED ? !isWorked : !forceWorkedBodyOut ? isWorked : isWorked && isBodyOut; // passedBar.Clean(); if (!isPassed) { continue; } } // // Check Filtered Zone Doesn't Exists ... has = FindIndex( idx, iZone, dest // ); if (has) { // passedBar.Clean(); continue; } // Add( iZone, dest // ); // // End For ... } // result = ArraySize(dest); // return result; } // void Filter( XPOIState &dest, ENUM_TIMEFRAMES forPeriod = NULL, // // Start ... ENUM_XZONE_STATE startState = XZONE_STATE_PASSED, bool forceStartedBodyOut = false, // // Activation ... ENUM_XZONE_STATE activeState = XZONE_STATE_FAILED, bool forceActivatedBodyIn = false, // // Breaktion ... ENUM_XZONE_STATE breakState = XZONE_STATE_FAILED, bool forceBreakedBodyOut = false, // // Works ... ENUM_XZONE_STATE workState = XZONE_STATE_FAILED, bool forceWorkedBodyOut = false // ) { // int count = 0; bool has = false; // dest.Clean(); // if (!IsValid(forPeriod)) { forPeriod = period; } // has = IsValid() && HasChild(); if (!has) { return; } // dest = this; // // Support Zones ... FilterSupportZones( dest.supportZones, forPeriod, startState, forceStartedBodyOut, activeState, forceActivatedBodyIn, breakState, forceBreakedBodyOut, workState, forceWorkedBodyOut // ); // // Resistance Zones ... FilterResistanceZones( dest.resistanceZones, forPeriod, startState, forceStartedBodyOut, activeState, forceActivatedBodyIn, breakState, forceBreakedBodyOut, workState, forceWorkedBodyOut // ); // // Supply Zones ... FilterSupplyZones( dest.supplyZones, forPeriod, startState, forceStartedBodyOut, activeState, forceActivatedBodyIn, breakState, forceBreakedBodyOut, workState, forceWorkedBodyOut // ); // // Demand Zones ... FilterDemandZones( dest.demandZones, forPeriod, startState, forceStartedBodyOut, activeState, forceActivatedBodyIn, breakState, forceBreakedBodyOut, workState, forceWorkedBodyOut // ); // // OrderBlocks ... FilterOrderBlocks( dest.orderBlocks, forPeriod, startState, forceStartedBodyOut, activeState, forceActivatedBodyIn, breakState, forceBreakedBodyOut, workState, forceWorkedBodyOut // ); // // Bullish OrderBlocks ... FilterBullishOrderBlocks( dest.bullishOrderBlocks, forPeriod, startState, forceStartedBodyOut, activeState, forceActivatedBodyIn, breakState, forceBreakedBodyOut, workState, forceWorkedBodyOut // ); // // Bearish OrderBlocks ... FilterBearishOrderBlocks( dest.bearishOrderBlocks, forPeriod, startState, forceStartedBodyOut, activeState, forceActivatedBodyIn, breakState, forceBreakedBodyOut, workState, forceWorkedBodyOut // ); // // FairValueGaps ... FilterFairValueGaps( dest.fairValueGaps, forPeriod, startState, forceStartedBodyOut, activeState, forceActivatedBodyIn, breakState, forceBreakedBodyOut, workState, forceWorkedBodyOut // ); // // Bullish FairValueGaps ... FilterBullishFairValueGaps( dest.bullishFairValueGaps, forPeriod, startState, forceStartedBodyOut, activeState, forceActivatedBodyIn, breakState, forceBreakedBodyOut, workState, forceWorkedBodyOut // ); // // Bearish FairValueGaps ... FilterBearishFairValueGaps( dest.bearishFairValueGaps, forPeriod, startState, forceStartedBodyOut, activeState, forceActivatedBodyIn, breakState, forceBreakedBodyOut, workState, forceWorkedBodyOut // ); // } // }; // // Extensions Functions ... // /** * Update to Time of Specifiex Collection ... * * @param items: XOBFVG instance Collection ... * @param value: datetime ... */ void SpecifiedUpdateTo( XOBFVG &items[], datetime value = NULL // ) { // value = NormalizeTime(value); // int count = ArraySize(items); bool has = HasChild(items); if (!has) { return; } // for (int i = 0; i < count; i++) { items[i].UpdateTo(value); } } /** * Converts to XBoxZone ... * * @return ( bool ) */ bool ToBox( XBoxZone &box, XOBFVG &item // ) { // bool result = false; // result = ToBox( box, item.ob // ); // return result; } /** * Converts to XBoxZone ... * * @return ( bool ) */ int ToBox( XOBFVG &source[], XBoxZone &dest[] // ) { // int result = 0; // Clean(dest); int count = ArraySize(source); if (!IsValidSize(count)) { return result; } // for (int i = 0; i < count; i++) { // XOBFVG iZone = source[i]; // XBoxZone iBox; bool hasBox = ToBox( iBox, iZone // ); // if (hasBox) { // AddRef( iBox, dest // ); } // iBox.Clean(); iZone.Clean(); } // result = ArraySize(dest); // return result; } // // // /** * Get Oldest Index ... * * @param source: XOBFVG instance Reference Collection ... * * @return ( int ) */ int GetOldest( XOBFVG &source[] // ) { // int result = -1; // int count = ArraySize(source); if (!IsValidSize(count)) { return result; } // XBoxZone tmpBoxes[]; int boxesCount = ToBox( source, tmpBoxes // ); if (!IsValidSize(boxesCount)) { // Clean(tmpBoxes); return result; } // XBoxZone selected; for (int i = 0; i < boxesCount; i++) { // XBoxZone iBox = tmpBoxes[i]; // bool canSet = !selected.IsValid() ? true : selected.from > iBox.from; if (canSet) { // result = i; selected = iBox; } } // Clean(tmpBoxes); selected.Clean(); // return result; } /** * Get Youngest Index ... * * @param source: XOBFVG instance Reference Collection ... * * @return ( int ) */ int GetYoungest( XOBFVG &source[] // ) { // int result = -1; // int count = ArraySize(source); if (!IsValidSize(count)) { return result; } // XBoxZone tmpBoxes[]; int boxesCount = ToBox( source, tmpBoxes // ); if (!IsValidSize(boxesCount)) { // Clean(tmpBoxes); return result; } // XBoxZone selected; for (int i = 0; i < boxesCount; i++) { // XBoxZone iBox = tmpBoxes[i]; // bool canSet = !selected.IsValid() ? true : selected.from < iBox.from; if (canSet) { // result = i; selected = iBox; } } // Clean(tmpBoxes); selected.Clean(); // return result; } /** * Get Highest Index ... * * @param source: XOBFVG instance Reference Collection ... * * @return ( int ) */ int GetHighest( XOBFVG &source[] // ) { // int result = -1; // int count = ArraySize(source); if (!IsValidSize(count)) { return result; } // XBoxZone tmpBoxes[]; int boxesCount = ToBox( source, tmpBoxes // ); if (!IsValidSize(boxesCount)) { // Clean(tmpBoxes); return result; } // XBoxZone selected; for (int i = 0; i < boxesCount; i++) { // XBoxZone iBox = tmpBoxes[i]; // bool canSet = !selected.IsValid() ? true : selected.upper < iBox.upper; if (canSet) { // result = i; selected = iBox; } } // Clean(tmpBoxes); selected.Clean(); // return result; } /** * Get Lowest Index ... * * @param source: XOBFVG instance Reference Collection ... * * @return ( int ) */ int GetLowest( XOBFVG &source[] // ) { // int result = -1; // int count = ArraySize(source); if (!IsValidSize(count)) { return result; } // XBoxZone tmpBoxes[]; int boxesCount = ToBox( source, tmpBoxes // ); if (!IsValidSize(boxesCount)) { // Clean(tmpBoxes); return result; } // XBoxZone selected; for (int i = 0; i < boxesCount; i++) { // XBoxZone iBox = tmpBoxes[i]; // bool canSet = !selected.IsValid() ? true : selected.lower > iBox.lower; if (canSet) { // result = i; selected = iBox; } } // Clean(tmpBoxes); selected.Clean(); // return result; } bool AddIfNotExists( XOBFVG &item, XOBFVG &items[] // ) { // bool result = false; // result = item.IsValid(); if (!result) { return result; } // int before = ArraySize(items); // int idx = FindIndex( item, items // ); bool has = IsValidIndex(idx); result = !has; if (!result) { return result; } // AddRef( item, items // ); // int after = ArraySize(items); // result = after > before; // return result; } int AddIfNotExists( XOBFVG &items[], XOBFVG &sources[] // ) { // int result = 0; // bool has = HasChild(items); if (!has) { return result; } // int before = ArraySize(sources); // int count = ArraySize(items); for (int i = 0; i < count; i++) { // has = AddIfNotExists( items[i], sources // ); } // int after = ArraySize(sources); // result = after > before; // return result; } //