From c94bfb2678bccf30961e4363ef9c1486dbdbebf0 Mon Sep 17 00:00:00 2001 From: Hadi Khazaee Asl Date: Thu, 27 Feb 2025 02:04:50 +0330 Subject: [PATCH] last ... --- Classes/x-saherelm.x-poi.class.mq5 | 8 + Documents/BKP/1.ind.ai.mq5 | 196 +++ Helpers/x-saherelm.x121.helper.mq5 | 1077 ++++++++++++----- Helpers/x-saherelm.x121.xvwap.helper.mq5 | 4 +- Libraries/x-saherelm.x-poi.state.lib.mq5 | 2 +- .../Signals/x-121.smc.xwz.signal.class.mq5 | 109 +- .../Signals/x-121.smc.xwz.signal.lib.mq5 | 350 +++++- 7 files changed, 1375 insertions(+), 371 deletions(-) create mode 100644 Documents/BKP/1.ind.ai.mq5 diff --git a/Classes/x-saherelm.x-poi.class.mq5 b/Classes/x-saherelm.x-poi.class.mq5 index 282255b2..c7ac30e0 100644 --- a/Classes/x-saherelm.x-poi.class.mq5 +++ b/Classes/x-saherelm.x-poi.class.mq5 @@ -705,6 +705,13 @@ class XCPOIDetector : public XCBaseAlert { return; } + + // + // Check Bar Tracker if Waits ... + if (!mBarTracker.IsNewBar()) + { + return; + } // mLock = true; @@ -1150,6 +1157,7 @@ class XCPOIDetector : public XCBaseAlert // iBar.Clean(); mLock = false; + mBarTracker.Waits(); // if (HasChild(events)) diff --git a/Documents/BKP/1.ind.ai.mq5 b/Documents/BKP/1.ind.ai.mq5 new file mode 100644 index 00000000..34d2e5f4 --- /dev/null +++ b/Documents/BKP/1.ind.ai.mq5 @@ -0,0 +1,196 @@ +//+------------------------------------------------------------------+ +//| HH_LH_LL_HL.mq5 | +//| Indicator for detecting HH, LH, LL, HL | +//| Created by [Your Name] | +//+------------------------------------------------------------------+ + +#property copyright "Your Name" +#property link "yourwebsite.com" +#property version "1.00" +#property indicator_chart_window +#property indicator_buffers 4 +#property indicator_plots 4 + +//--- Input parameters +input int LookbackPeriod = 20; // Number of bars to look back for pattern detection + +//--- Buffer declarations +double HH_Buffer[]; // Buffer for Higher Highs +double HL_Buffer[]; // Buffer for Higher Lows +double LH_Buffer[]; // Buffer for Lower Highs +double LL_Buffer[]; // Buffer for Lower Lows + +//--- Plot settings +#property indicator_label1 "Higher Highs" +#property indicator_type1 DRAW_ARROW +#property indicator_color1 clrGreen +#property indicator_style1 STYLE_SOLID +#property indicator_width1 1 + +#property indicator_label2 "Higher Lows" +#property indicator_type2 DRAW_ARROW +#property indicator_color2 clrBlue +#property indicator_style2 STYLE_SOLID +#property indicator_width2 1 + +#property indicator_label3 "Lower Highs" +#property indicator_type3 DRAW_ARROW +#property indicator_color3 clrRed +#property indicator_style3 STYLE_SOLID +#property indicator_width3 1 + +#property indicator_label4 "Lower Lows" +#property indicator_type4 DRAW_ARROW +#property indicator_color4 clrYellow +#property indicator_style4 STYLE_SOLID +#property indicator_width4 1 + +//+------------------------------------------------------------------+ +//| Initialization function | +//+------------------------------------------------------------------+ +int OnInit() +{ + // Set buffer properties + SetIndexBuffer(0, HH_Buffer); + SetIndexBuffer(1, HL_Buffer); + SetIndexBuffer(2, LH_Buffer); + SetIndexBuffer(3, LL_Buffer); + + // Clear buffers at each bar + ArrayInitialize(HH_Buffer, 0.0); + ArrayInitialize(HL_Buffer, 0.0); + ArrayInitialize(LH_Buffer, 0.0); + ArrayInitialize(LL_Buffer, 0.0); + + return(INIT_SUCCEEDED); +} + +//+------------------------------------------------------------------+ +//| Deinitialization function | +//+------------------------------------------------------------------+ +void OnDeinit(const int reason) +{ + // Cleanup if necessary +} + +//+------------------------------------------------------------------+ +//| Calculate function | +//+------------------------------------------------------------------+ +int OnCalculate(const int rates_total, + const int prev_calculated, + const datetime &time[], + const double &open[], + const double &high[], + const double &low[], + const double &close[], + const long &tick_volume[], + const long &volume[], + const int &spread[]) +{ + // Start from the last calculated bar + int start_bar = MathMax(prev_calculated - 1, 0); + + // Loop through bars + for (int i = start_bar; i < rates_total; i++) + { + // Get current high and low + double current_high = high[i]; + double current_low = low[i]; + + // Check for Higher High (HH) + if (IsHigherHigh(i, high, LookbackPeriod)) + { + HH_Buffer[i] = current_high; + HL_Buffer[i] = 0.0; // Reset other buffers + LH_Buffer[i] = 0.0; + LL_Buffer[i] = 0.0; + } + // Check for Higher Low (HL) + else if (IsHigherLow(i, low, LookbackPeriod)) + { + HL_Buffer[i] = current_low; + HH_Buffer[i] = 0.0; + LH_Buffer[i] = 0.0; + LL_Buffer[i] = 0.0; + } + // Check for Lower High (LH) + else if (IsLowerHigh(i, high, LookbackPeriod)) + { + LH_Buffer[i] = current_high; + HH_Buffer[i] = 0.0; + HL_Buffer[i] = 0.0; + LL_Buffer[i] = 0.0; + } + // Check for Lower Low (LL) + else if (IsLowerLow(i, low, LookbackPeriod)) + { + LL_Buffer[i] = current_low; + HH_Buffer[i] = 0.0; + HL_Buffer[i] = 0.0; + LH_Buffer[i] = 0.0; + } + else + { + // Reset all buffers if no pattern is detected + HH_Buffer[i] = 0.0; + HL_Buffer[i] = 0.0; + LH_Buffer[i] = 0.0; + LL_Buffer[i] = 0.0; + } + } + + // + return rates_total; +} + +//+------------------------------------------------------------------+ +//| Function to detect Higher High | +//+------------------------------------------------------------------+ +bool IsHigherHigh(int index, const double &high[], int lookback) +{ + for (int i = 1; i <= lookback; i++) + { + if (index - i < 0) continue; // Ensure we don't go out of bounds + if (high[index] <= high[index - i]) return false; + } + return true; +} + +//+------------------------------------------------------------------+ +//| Function to detect Higher Low | +//+------------------------------------------------------------------+ +bool IsHigherLow(int index, const double &low[], int lookback) +{ + for (int i = 1; i <= lookback; i++) + { + if (index - i < 0) continue; // Ensure we don't go out of bounds + if (low[index] <= low[index - i]) return false; + } + return true; +} + +//+------------------------------------------------------------------+ +//| Function to detect Lower High | +//+------------------------------------------------------------------+ +bool IsLowerHigh(int index, const double &high[], int lookback) +{ + for (int i = 1; i <= lookback; i++) + { + if (index - i < 0) continue; // Ensure we don't go out of bounds + if (high[index] >= high[index - i]) return false; + } + return true; +} + +//+------------------------------------------------------------------+ +//| Function to detect Lower Low | +//+------------------------------------------------------------------+ +bool IsLowerLow(int index, const double &low[], int lookback) +{ + for (int i = 1; i <= lookback; i++) + { + if (index - i < 0) continue; // Ensure we don't go out of bounds + if (low[index] >= low[index - i]) return false; + } + return true; +} \ No newline at end of file diff --git a/Helpers/x-saherelm.x121.helper.mq5 b/Helpers/x-saherelm.x121.helper.mq5 index 8f566976..57d109bb 100644 --- a/Helpers/x-saherelm.x121.helper.mq5 +++ b/Helpers/x-saherelm.x121.helper.mq5 @@ -456,170 +456,124 @@ struct X121Conditions // // Complex Conditions ... + + // double cheMin; double cheMax; + double x3maMin; + double x3maMax; double vwapMin; double vwapMax; // + bool isSarIncreased; + bool isSarDecreased; + bool isX3MaFatsOverMid; + bool isSarEqualsToPeak; + bool isSarEqualsToVale; + bool isStrEqualsToPeak; + bool isStrEqualsToVale; + bool isX3MaMinBreakedUp; + bool isX3MaMaxBreakedUp; + bool isX3MaFatsUnderMid; + bool isX3MaFatsOverSlow; + bool isAtrUpperOverPeak; + bool isPeakOverAtrUpper; + bool isStrUpperOverPeak; + bool isStrLowerOverVale; + bool isBreakedUpPrevSar; + bool isBreakedUpPrevStr; + bool isVWapMinBreakedUp; + bool isVWapMaxBreakedUp; + bool isClosedOverCheMin; + bool isClosedOverCheMax; + bool isX3MaFatsUnderSlow; + bool isAtrLowerUnderVale; + bool isClosedOverX3MaMin; + bool isClosedOverX3MaMax; + bool isValeUnderAtrLower; + bool isStrUpperUnderPeak; + bool isStrLowerUnderVale; + bool isClosedUnderCheMin; + bool isClosedUnderCheMax; + bool isClosedOverVWapMin; + bool isClosedOverVWapMax; + bool isX3MaMinBreakedDown; + bool isX3MaMaxBreakedDown; + bool isClosedUnderX3MaMin; + bool isClosedUnderX3MaMax; + bool isBreakedDownPrevSar; + bool isBreakedDownPrevStr; + bool isStrCrossedOverVale; + bool isSarCrossedOverVale; + bool isClosedUnderVWapMin; + bool isClosedUnderVWapMax; + bool isVWapMinBreakedDown; + bool isVWapMaxBreakedDown; + bool isX3MaFatsOverMidPrev; + bool isSarCrossedUnderPeak; + bool isStrCrossedUnderPeak; + bool isNewPeakOverAtrUpper; bool isBreakedUpPrevCheMin; bool isBreakedUpPrevCheMax; - bool isBreakedDownPrevCheMin; - bool isBreakedDownPrevCheMax; bool isBreakedUpPrevCheLE1; bool isBreakedUpPrevCheLE2; bool isBreakedUpPrevCheSE1; bool isBreakedUpPrevCheSE2; + bool isX3MaFatsUnderMidPrev; + bool isX3MaFatsOverSlowPrev; + bool isAtrUpperEqualsToPeak; + bool isAtrLowerEqualsToVale; + bool isStrUpperOverAtrUpper; + bool isStrLowerOverAtrLower; + bool isNewValeUnderAtrLower; + bool isAtrUpperCrossedUpPeak; + bool isAtrLowerCrossedUpVale; + bool isStrUpperUnderAtrUpper; + bool isStrLowerUnderAtrLower; + bool isX3MaFatsUnderSlowPrev; + bool isBreakedUpPrevAtrUpper; + bool isBreakedUpPrevAtrLower; + bool isBreakedDownPrevCheMin; + bool isBreakedDownPrevCheMax; bool isBreakedDownPrevCheLE1; bool isBreakedDownPrevCheLE2; bool isBreakedDownPrevCheSE1; bool isBreakedDownPrevCheSE2; - - // - bool isClosedOverCheMin; - bool isClosedOverCheMax; - bool isClosedUnderCheMin; - bool isClosedUnderCheMax; - - // - bool isSarIncreased; - bool isSarDecreased; - - // - bool isVWapMinBreakedUp; - bool isVWapMaxBreakedUp; - - // - bool isVWapMinBreakedDown; - bool isVWapMaxBreakedDown; - - // - bool isClosedOverVWapMin; - bool isClosedUnderVWapMin; - - // - bool isClosedOverVWapMax; - bool isClosedUnderVWapMax; - - // - bool isVWapFastCrossedOverMid; - bool isVWapFastCrossedUnderMid; - - // - bool isVWapFastCrossedOverSlow; - bool isVWapFastCrossedUnderSlow; - - // - bool isBreakedUpPrevSar; - bool isBreakedDownPrevSar; - - // - bool isBreakedUpPrevStr; - bool isBreakedDownPrevStr; - - // - bool isBreakedUpPrevAtrUpper; - bool isBreakedDownPrevAtrUpper; - - // - bool isBreakedUpPrevAtrLower; - bool isBreakedDownPrevAtrLower; - - // + bool isX3MaFastCrossedOverMid; bool isRejectedUpPrevAtrUpper; - bool isRejectedDownPrevAtrUpper; - - // bool isRejectedUpPrevAtrLower; - bool isRejectedDownPrevAtrLower; - - // - bool isSarEqualsToPeak; - bool isSarEqualsToVale; - - // - bool isSarCrossedUnderPeak; - bool isSarCrossedOverVale; - - // - bool isStrEqualsToPeak; - bool isStrEqualsToVale; - - // - bool isStrCrossedUnderPeak; - bool isStrCrossedOverVale; - - // - bool isPeakOverAtrUpper; - bool isValeUnderAtrLower; - - // - bool isNewPeakOverAtrUpper; - bool isNewValeUnderAtrLower; - - // - bool isStrUpperOverPeak; - bool isStrUpperUnderPeak; - - // - bool isStrUpperCrossedOverPeak; - bool isStrUpperCrossedUnderPeak; - - // - bool isStrLowerOverVale; - bool isStrLowerUnderVale; - - // - bool isStrLowerCrossedOverVale; - bool isStrLowerCrossedUnderVale; - - // - bool isDonHighUpperEqualsToPeak; - bool isDonLowLowerEqualsToVale; - - // - bool isStrUpperOverAtrUpper; - bool isStrUpperUnderAtrUpper; - - // - bool isStrLowerOverAtrLower; - bool isStrLowerUnderAtrLower; - - // - bool isStrUpperCrossedOverAtrUpper; - bool isStrUpperCrossedUnderAtrUpper; - - // - bool isStrLowerCrossedOverAtrLower; - bool isStrLowerCrossedUnderAtrLower; - - // - bool isStrUpperOverDonHighUpper; - bool isStrUpperUnderDonHighUpper; - - // - bool isStrLowerOverDonLowLower; - bool isStrLowerUnderDonLowLower; - - // - bool isStrUpperCrossedOverDonHighUpper; - bool isStrUpperCrossedUnderDonHighUpper; - - // - bool isStrLowerCrossedOverDonLowLower; - bool isStrLowerCrossedUnderDonLowLower; - - // - bool isAtrUpperOverPeak; - bool isAtrUpperEqualsToPeak; - bool isAtrUpperCrossedUpPeak; + bool isVWapFastCrossedOverMid; + bool isX3MaFastCrossedUnderMid; + bool isX3MaFastCrossedOverSlow; bool isAtrUpperCrossedDownPeak; - - // - bool isAtrLowerUnderVale; - bool isAtrLowerEqualsToVale; - bool isAtrLowerCrossedUpVale; bool isAtrLowerCrossedDownVale; + bool isStrLowerOverDonLowLower; + bool isVWapFastCrossedUnderMid; + bool isBreakedDownPrevAtrUpper; + bool isBreakedDownPrevAtrLower; + bool isStrUpperCrossedOverPeak; + bool isStrLowerCrossedOverVale; + bool isDonLowLowerEqualsToVale; + bool isVWapFastCrossedOverSlow; + bool isX3MaFastCrossedUnderSlow; + bool isStrUpperOverDonHighUpper; + bool isStrLowerUnderDonLowLower; + bool isVWapFastCrossedUnderSlow; + bool isStrUpperCrossedUnderPeak; + bool isStrLowerCrossedUnderVale; + bool isDonHighUpperEqualsToPeak; + bool isRejectedDownPrevAtrUpper; + bool isRejectedDownPrevAtrLower; + bool isStrUpperUnderDonHighUpper; + bool isStrUpperCrossedOverAtrUpper; + bool isStrLowerCrossedOverAtrLower; + bool isStrUpperCrossedUnderAtrUpper; + bool isStrLowerCrossedUnderAtrLower; + bool isStrLowerCrossedOverDonLowLower; + bool isStrUpperCrossedOverDonHighUpper; + bool isStrLowerCrossedUnderDonLowLower; + bool isStrUpperCrossedUnderDonHighUpper; // // Constructor ... @@ -796,6 +750,8 @@ struct X121Conditions cheMax = 0; vwapMin = 0; vwapMax = 0; + x3maMin = 0; + x3maMax = 0; // // Slopes ... @@ -846,28 +802,18 @@ struct X121Conditions // ATR ... // + isBreakedUpAtrUpper = false; + isBreakedUpAtrLower = false; isClosedOverAtrUpper = false; isClosedOverAtrLower = false; - - // + isRejectedUpAtrUpper = false; + isRejectedUpAtrLower = false; isClosedUnderAtrUpper = false; isClosedUnderAtrLower = false; - - // - isRejectedUpAtrUpper = false; - isRejectedDownAtrUpper = false; - - // - isRejectedUpAtrLower = false; - isRejectedDownAtrLower = false; - - // - isBreakedUpAtrUpper = false; isBreakedDownAtrUpper = false; - - // - isBreakedUpAtrLower = false; isBreakedDownAtrLower = false; + isRejectedDownAtrUpper = false; + isRejectedDownAtrLower = false; // // DON ... @@ -877,20 +823,14 @@ struct X121Conditions isRejectedDonHighUpper = false; isRejectedDonLowUpper = false; isRejectedDonCloseUpper = false; - - // isRejectedDonOpenLower = false; isRejectedDonHighLower = false; isRejectedDonLowLower = false; isRejectedDonCloseLower = false; - - // isBreakedDonOpenUpper = false; isBreakedDonHighUpper = false; isBreakedDonLowUpper = false; isBreakedDonCloseUpper = false; - - // isBreakedDonOpenLower = false; isBreakedDonHighLower = false; isBreakedDonLowLower = false; @@ -902,8 +842,6 @@ struct X121Conditions // isSarBullish = false; isSarBearish = false; - - // isSarSwitchedToBullish = false; isSarSwitchedToBearish = false; @@ -930,8 +868,6 @@ struct X121Conditions // isStrBullish = false; isStrBearish = false; - - // isStrSwitchedToBullish = false; isStrSwitchedToBearish = false; @@ -985,42 +921,28 @@ struct X121Conditions isX3MaSwitchedToBearishState = false; isX3MaSwitchedToNeuturalState = false; isX3MaSwitchedToBullishOrdered = false; - isX3MaSwitchedToBearishOrdered = false; + isX3MaSwitchedToBearishOrdered = false; // // CHE ... - // - isChe1Bullish = false; - isChe1Bearish = false; - - // - isChe1SwitchedToBullish = false; - isChe1SwitchedToBearish = false; - - // - isChe2Bullish = false; - isChe2Bearish = false; - - // - isChe2SwitchedToBullish = false; - isChe2SwitchedToBearish = false; - // isCheBullish = false; isCheBearish = false; - - // - isCheSwitchedToBullish = false; - isCheSwitchedToBearish = false; - - // + isChe1Bullish = false; + isChe1Bearish = false; + isChe2Bullish = false; + isChe2Bearish = false; isClosedOverCheMin = false; isClosedOverCheMax = false; - - // isClosedUnderCheMin = false; isClosedUnderCheMax = false; + isCheSwitchedToBullish = false; + isCheSwitchedToBearish = false; + isChe1SwitchedToBullish = false; + isChe1SwitchedToBearish = false; + isChe2SwitchedToBullish = false; + isChe2SwitchedToBearish = false; // // XHK ... @@ -1053,158 +975,114 @@ struct X121Conditions // Complex Conditions ... // + isSarIncreased = false; + isSarDecreased = false; + isX3MaFatsOverMid = false; + isSarEqualsToPeak = false; + isSarEqualsToVale = false; + isStrEqualsToPeak = false; + isStrEqualsToVale = false; + isX3MaMinBreakedUp = false; + isX3MaMaxBreakedUp = false; + isX3MaFatsUnderMid = false; + isX3MaFatsOverSlow = false; + isAtrUpperOverPeak = false; + isPeakOverAtrUpper = false; + isStrUpperOverPeak = false; + isStrLowerOverVale = false; + isBreakedUpPrevSar = false; + isBreakedUpPrevStr = false; isVWapMinBreakedUp = false; isVWapMaxBreakedUp = false; - - // + isClosedOverCheMin = false; + isClosedOverCheMax = false; + isX3MaFatsUnderSlow = false; + isAtrLowerUnderVale = false; + isClosedOverX3MaMin = false; + isClosedOverX3MaMax = false; + isValeUnderAtrLower = false; + isStrUpperUnderPeak = false; + isStrLowerUnderVale = false; + isClosedUnderCheMin = false; + isClosedUnderCheMax = false; + isClosedOverVWapMin = false; + isClosedOverVWapMax = false; + isX3MaMinBreakedDown = false; + isX3MaMaxBreakedDown = false; + isClosedUnderX3MaMin = false; + isClosedUnderX3MaMax = false; + isBreakedDownPrevSar = false; + isBreakedDownPrevStr = false; + isStrCrossedOverVale = false; + isSarCrossedOverVale = false; + isClosedUnderVWapMin = false; + isClosedUnderVWapMax = false; isVWapMinBreakedDown = false; isVWapMaxBreakedDown = false; - - // - isClosedOverVWapMin = false; - isClosedUnderVWapMin = false; - - // - isClosedOverVWapMax = false; - isClosedUnderVWapMax = false; - - // - isVWapFastCrossedOverMid = false; - isVWapFastCrossedUnderMid = false; - - // - isVWapFastCrossedOverSlow = false; - isVWapFastCrossedUnderSlow = false; - - // - isBreakedUpPrevSar = false; - isBreakedDownPrevSar = false; - - // - isBreakedUpPrevStr = false; - isBreakedDownPrevStr = false; - - // - isBreakedUpPrevAtrUpper = false; - isBreakedDownPrevAtrUpper = false; - - // - isRejectedUpPrevAtrUpper = false; - isRejectedDownPrevAtrUpper = false; - - // - isBreakedUpPrevAtrLower = false; - isBreakedDownPrevAtrLower = false; - - // - isRejectedUpPrevAtrLower = false; - isRejectedDownPrevAtrLower = false; - - // + isX3MaFatsOverMidPrev = false; + isSarCrossedUnderPeak = false; + isStrCrossedUnderPeak = false; + isNewPeakOverAtrUpper = false; isBreakedUpPrevCheMin = false; isBreakedUpPrevCheMax = false; - isBreakedDownPrevCheMin = false; - isBreakedDownPrevCheMax = false; isBreakedUpPrevCheLE1 = false; isBreakedUpPrevCheLE2 = false; isBreakedUpPrevCheSE1 = false; isBreakedUpPrevCheSE2 = false; + isX3MaFatsUnderMidPrev = false; + isX3MaFatsOverSlowPrev = false; + isAtrUpperEqualsToPeak = false; + isAtrLowerEqualsToVale = false; + isStrUpperOverAtrUpper = false; + isStrLowerOverAtrLower = false; + isNewValeUnderAtrLower = false; + isAtrUpperCrossedUpPeak = false; + isAtrLowerCrossedUpVale = false; + isStrUpperUnderAtrUpper = false; + isStrLowerUnderAtrLower = false; + isX3MaFatsUnderSlowPrev = false; + isBreakedUpPrevAtrUpper = false; + isBreakedUpPrevAtrLower = false; + isBreakedDownPrevCheMin = false; + isBreakedDownPrevCheMax = false; isBreakedDownPrevCheLE1 = false; isBreakedDownPrevCheLE2 = false; isBreakedDownPrevCheSE1 = false; isBreakedDownPrevCheSE2 = false; - - // - isSarIncreased = false; - isSarDecreased = false; - - // - isSarEqualsToPeak = false; - isSarEqualsToVale = false; - - // - isSarCrossedUnderPeak = false; - isSarCrossedOverVale = false; - - // - isStrEqualsToPeak = false; - isStrEqualsToVale = false; - - // - isStrCrossedUnderPeak = false; - isStrCrossedOverVale = false; - - // - isPeakOverAtrUpper = false; - isValeUnderAtrLower = false; - - // - isNewPeakOverAtrUpper = false; - isNewValeUnderAtrLower = false; - - // - isStrUpperOverPeak = false; - isStrUpperUnderPeak = false; - - // - isStrUpperCrossedOverPeak = false; - isStrUpperCrossedUnderPeak = false; - - // - isStrLowerOverVale = false; - isStrLowerUnderVale = false; - - // - isAtrUpperOverPeak = false; - isAtrUpperEqualsToPeak = false; - isAtrUpperCrossedUpPeak = false; + isX3MaFastCrossedOverMid = false; + isRejectedUpPrevAtrUpper = false; + isRejectedUpPrevAtrLower = false; + isVWapFastCrossedOverMid = false; + isX3MaFastCrossedUnderMid = false; + isX3MaFastCrossedOverSlow = false; isAtrUpperCrossedDownPeak = false; - - // - isAtrLowerUnderVale = false; - isAtrLowerEqualsToVale = false; - isAtrLowerCrossedUpVale = false; isAtrLowerCrossedDownVale = false; - - // - isStrLowerCrossedOverVale = false; - isStrLowerCrossedUnderVale = false; - - // - isDonHighUpperEqualsToPeak = false; - isDonLowLowerEqualsToVale = false; - - // - isStrUpperOverAtrUpper = false; - isStrUpperUnderAtrUpper = false; - - // - isStrLowerOverAtrLower = false; - isStrLowerUnderAtrLower = false; - - // - isStrUpperCrossedOverAtrUpper = false; - isStrUpperCrossedUnderAtrUpper = false; - - // - isStrLowerCrossedOverAtrLower = false; - isStrLowerCrossedUnderAtrLower = false; - - // - isStrUpperOverDonHighUpper = false; - isStrUpperUnderDonHighUpper = false; - - // isStrLowerOverDonLowLower = false; + isVWapFastCrossedUnderMid = false; + isBreakedDownPrevAtrUpper = false; + isBreakedDownPrevAtrLower = false; + isStrUpperCrossedOverPeak = false; + isStrLowerCrossedOverVale = false; + isDonLowLowerEqualsToVale = false; + isVWapFastCrossedOverSlow = false; + isX3MaFastCrossedUnderSlow = false; + isStrUpperOverDonHighUpper = false; isStrLowerUnderDonLowLower = false; - - // - isStrUpperCrossedOverDonHighUpper = false; - isStrUpperCrossedUnderDonHighUpper = false; - - // + isVWapFastCrossedUnderSlow = false; + isStrUpperCrossedUnderPeak = false; + isStrLowerCrossedUnderVale = false; + isDonHighUpperEqualsToPeak = false; + isRejectedDownPrevAtrUpper = false; + isRejectedDownPrevAtrLower = false; + isStrUpperUnderDonHighUpper = false; + isStrUpperCrossedOverAtrUpper = false; + isStrLowerCrossedOverAtrLower = false; + isStrUpperCrossedUnderAtrUpper = false; + isStrLowerCrossedUnderAtrLower = false; isStrLowerCrossedOverDonLowLower = false; + isStrUpperCrossedOverDonHighUpper = false; isStrLowerCrossedUnderDonLowLower = false; + isStrUpperCrossedUnderDonHighUpper = false; // ZeroMemory(this); @@ -1226,8 +1104,8 @@ struct X121Conditions bearishScore = 0; // - double minScore = 0.5; double score = 1; + double minScore = 0.5; double highScore = 1.5; // @@ -1316,11 +1194,6 @@ struct X121Conditions bearishScore += highScore; } - // - // TODO: ... - // there many other complex conditions which may used lter ... - // - // // XTREND ... @@ -1682,6 +1555,437 @@ struct X121Conditions bearishScore += highScore; } + // + // Complex Conditions ... + + // + if (isSarIncreased) + { + bullishScore += minScore; + } + if (isSarEqualsToVale) + { + bullishScore += minScore; + } + if (isBreakedUpPrevSar) + { + bullishScore += minScore; + } + if (isSarCrossedOverVale) + { + bullishScore += score; + } + + // + if (isAtrLowerUnderVale) + { + bullishScore += minScore; + } + if (isValeUnderAtrLower) + { + bullishScore += minScore; + } + if (isNewValeUnderAtrLower) + { + bullishScore += minScore; + } + if (isAtrLowerEqualsToVale) + { + bullishScore += minScore; + } + if (isStrLowerOverAtrLower) + { + bullishScore += minScore; + } + if (isStrUpperOverAtrUpper) + { + bullishScore += minScore; + } + if (isAtrLowerCrossedUpVale) + { + bullishScore += score; + } + if (isAtrUpperCrossedUpPeak) + { + bullishScore += score; + } + if (isBreakedUpPrevAtrLower) + { + bullishScore += minScore; + } + if (isBreakedUpPrevAtrUpper) + { + bullishScore += minScore; + } + if (isRejectedUpPrevAtrUpper) + { + bullishScore += minScore; + } + if (isRejectedUpPrevAtrLower) + { + bullishScore += minScore; + } + if (isStrLowerCrossedOverAtrLower) + { + bullishScore += score; + } + if (isStrUpperCrossedOverAtrUpper) + { + bullishScore += score; + } + + // + if (isBreakedUpPrevStr) + { + bullishScore += minScore; + } + if (isStrEqualsToVale) + { + bullishScore += minScore; + } + if (isStrLowerOverVale) + { + bullishScore += minScore; + } + if (isStrLowerUnderVale) + { + bullishScore += minScore; + } + if (isStrCrossedOverVale) + { + bullishScore += score; + } + if (isStrUpperCrossedOverPeak) + { + bullishScore += score; + } + if (isStrLowerCrossedOverVale) + { + bullishScore += score; + } + if (isStrLowerUnderDonLowLower) + { + bullishScore += minScore; + } + if (isStrLowerCrossedOverDonLowLower) + { + bullishScore += score; + } + if (isStrUpperCrossedOverDonHighUpper) + { + bullishScore += score; + } + + // + if (isVWapMinBreakedUp) + { + bullishScore += minScore; + } + if (isVWapMaxBreakedUp) + { + bullishScore += minScore; + } + if (isClosedOverVWapMin) + { + bullishScore += minScore; + } + if (isClosedOverVWapMax) + { + bullishScore += minScore; + } + if (isVWapFastCrossedOverMid) + { + bullishScore += score; + } + if (isVWapFastCrossedOverSlow) + { + bullishScore += score; + } + + // + if (isX3MaMinBreakedUp) + { + bullishScore += minScore; + } + if (isX3MaMaxBreakedUp) + { + bullishScore += minScore; + } + if (isClosedOverX3MaMin) + { + bullishScore += minScore; + } + if (isClosedOverX3MaMax) + { + bullishScore += minScore; + } + if (isX3MaFastCrossedOverMid) + { + bullishScore += score; + } + if (isX3MaFastCrossedOverSlow) + { + bullishScore += score; + } + + // + if (isClosedOverCheMin) + { + bullishScore += minScore; + } + if (isClosedOverCheMax) + { + bullishScore += minScore; + } + if (isBreakedUpPrevCheMin) + { + bullishScore += minScore; + } + if (isBreakedUpPrevCheMax) + { + bullishScore += minScore; + } + if (isBreakedUpPrevCheLE1) + { + bullishScore += minScore; + } + if (isBreakedUpPrevCheLE2) + { + bullishScore += minScore; + } + if (isBreakedUpPrevCheSE1) + { + bullishScore += minScore; + } + if (isBreakedUpPrevCheSE2) + { + bullishScore += minScore; + } + if (isDonLowLowerEqualsToVale) + { + bullishScore += minScore; + } + + // + // + // + + // + if (isSarDecreased) + { + bearishScore += minScore; + } + if (isSarEqualsToPeak) + { + bearishScore += minScore; + } + if (isBreakedDownPrevSar) + { + bearishScore += minScore; + } + if (isSarCrossedUnderPeak) + { + bearishScore += score; + } + + // + if (isAtrUpperOverPeak) + { + bearishScore += minScore; + } + if (isPeakOverAtrUpper) + { + bearishScore += minScore; + } + if (isNewPeakOverAtrUpper) + { + bearishScore += minScore; + } + if (isAtrUpperEqualsToPeak) + { + bearishScore += minScore; + } + if (isStrLowerUnderAtrLower) + { + bearishScore += minScore; + } + if (isStrUpperUnderAtrUpper) + { + bearishScore += minScore; + } + if (isAtrLowerCrossedDownVale) + { + bearishScore += score; + } + if (isAtrUpperCrossedDownPeak) + { + bearishScore += score; + } + if (isBreakedDownPrevAtrUpper) + { + bearishScore += minScore; + } + if (isBreakedDownPrevAtrLower) + { + bearishScore += minScore; + } + if (isRejectedDownPrevAtrUpper) + { + bearishScore += minScore; + } + if (isRejectedDownPrevAtrLower) + { + bearishScore += minScore; + } + if (isStrLowerCrossedUnderAtrLower) + { + bearishScore += score; + } + if (isStrUpperCrossedUnderAtrUpper) + { + bearishScore += score; + } + + // + if (isStrEqualsToPeak) + { + bearishScore += minScore; + } + if (isStrUpperOverPeak) + { + bearishScore += minScore; + } + if (isStrUpperUnderPeak) + { + bearishScore += minScore; + } + if (isBreakedDownPrevStr) + { + bearishScore += minScore; + } + if (isStrCrossedUnderPeak) + { + bearishScore += score; + } + if (isStrLowerOverDonLowLower) + { + bearishScore += minScore; + } + if (isStrUpperOverDonHighUpper) + { + bearishScore += minScore; + } + if (isStrUpperCrossedUnderPeak) + { + bearishScore += score; + } + if (isStrLowerCrossedUnderVale) + { + bearishScore += score; + } + if (isStrUpperUnderDonHighUpper) + { + bearishScore += minScore; + } + if (isStrLowerCrossedUnderDonLowLower) + { + bearishScore += score; + } + if (isStrUpperCrossedUnderDonHighUpper) + { + bearishScore += score; + } + + // + if (isClosedUnderVWapMin) + { + bearishScore += minScore; + } + if (isClosedUnderVWapMax) + { + bearishScore += minScore; + } + if (isVWapMinBreakedDown) + { + bearishScore += minScore; + } + if (isVWapMaxBreakedDown) + { + bearishScore += minScore; + } + if (isVWapFastCrossedUnderMid) + { + bearishScore += score; + } + if (isVWapFastCrossedUnderSlow) + { + bearishScore += score; + } + + // + if (isX3MaMinBreakedDown) + { + bearishScore += minScore; + } + if (isX3MaMaxBreakedDown) + { + bearishScore += minScore; + } + if (isClosedUnderX3MaMin) + { + bearishScore += minScore; + } + if (isClosedUnderX3MaMax) + { + bearishScore += minScore; + } + if (isX3MaFastCrossedUnderMid) + { + bearishScore += score; + } + if (isX3MaFastCrossedUnderSlow) + { + bearishScore += score; + } + + // + if (isClosedUnderCheMin) + { + bearishScore += minScore; + } + if (isClosedUnderCheMax) + { + bearishScore += minScore; + } + if (isBreakedDownPrevCheMin) + { + bearishScore += minScore; + } + if (isBreakedDownPrevCheMax) + { + bearishScore += minScore; + } + if (isBreakedDownPrevCheLE1) + { + bearishScore += minScore; + } + if (isBreakedDownPrevCheLE2) + { + bearishScore += minScore; + } + if (isBreakedDownPrevCheSE1) + { + bearishScore += minScore; + } + if (isBreakedDownPrevCheSE2) + { + bearishScore += minScore; + } + if (isDonHighUpperEqualsToPeak) + { + bearishScore += minScore; + } + // // // @@ -2466,8 +2770,8 @@ class XCX121Helper : public XCBase // X3MA ... bool Get3MAConditions( X121X3MAConditions &conditions, // - int barIndex = 0, // - int loopback = 5 // + int barIndex = 0, // + int loopback = 5 // ) { // @@ -3463,6 +3767,86 @@ class XCX121Helper : public XCBase // // Complex Conditions ... + // + double x3maFast = conditions.x3maFastBuffer[cIDX]; + double x3maMid = conditions.x3maMidBuffer[cIDX]; + double x3maSlow = conditions.x3maSlowBuffer[cIDX]; + + // + double x3mas[3] = { + x3maFast, + x3maMid, + x3maSlow // + }; + + // + double x3maMin = GetMin(x3mas); + double x3maMax = GetMax(x3mas); + + // + bool isX3MaMinBreakedUp = IsBarBreak( + x3maMin, + X_DIRECTION_BULLISH, + cBar // + ); + bool isX3MaMinBreakedDown = IsBarBreak( + x3maMin, + X_DIRECTION_BEARISH, + cBar // + ); + + // + bool isX3MaMaxBreakedUp = IsBarBreak( + x3maMax, + X_DIRECTION_BULLISH, + cBar // + ); + bool isX3MaMaxBreakedDown = IsBarBreak( + x3maMax, + X_DIRECTION_BEARISH, + cBar // + ); + + // + bool isX3MaFatsOverMid = conditions.x3maFastBuffer[cIDX] > conditions.x3maMidBuffer[cIDX]; + bool isX3MaFatsOverMidPrev = conditions.x3maFastBuffer[pIDX] > conditions.x3maMidBuffer[pIDX]; + + // + bool isX3MaFatsUnderMid = conditions.x3maFastBuffer[cIDX] < conditions.x3maMidBuffer[cIDX]; + bool isX3MaFatsUnderMidPrev = conditions.x3maFastBuffer[pIDX] < conditions.x3maMidBuffer[pIDX]; + + // + bool isX3MaFatsOverSlow = conditions.x3maFastBuffer[cIDX] > conditions.x3maSlowBuffer[cIDX]; + bool isX3MaFatsOverSlowPrev = conditions.x3maFastBuffer[pIDX] > conditions.x3maSlowBuffer[pIDX]; + + // + bool isX3MaFatsUnderSlow = conditions.x3maFastBuffer[cIDX] < conditions.x3maSlowBuffer[cIDX]; + bool isX3MaFatsUnderSlowPrev = conditions.x3maFastBuffer[pIDX] < conditions.x3maSlowBuffer[pIDX]; + + // + bool isX3MaFastCrossedOverMid = isX3MaFatsOverMid && + !isX3MaFatsOverMidPrev; + bool isX3MaFastCrossedUnderMid = isX3MaFatsUnderMid && + !isX3MaFatsUnderMidPrev; + + // + bool isX3MaFastCrossedOverSlow = isX3MaFatsOverSlow && + !isX3MaFatsOverSlowPrev; + bool isX3MaFastCrossedUnderSlow = isX3MaFatsUnderSlow && + !isX3MaFatsUnderSlowPrev; + + // + bool isClosedOverX3MaMin = cBar.close > x3maMin; + bool isClosedUnderX3MaMin = cBar.close < x3maMin; + + // + bool isClosedOverX3MaMax = cBar.close > x3maMax; + bool isClosedUnderX3MaMax = cBar.close < x3maMax; + + // + // + // + // double vwapFast = conditions.vwapFastBuffer[cIDX]; double vwapMid = conditions.vwapMidBuffer[cIDX]; @@ -3907,6 +4291,8 @@ class XCX121Helper : public XCBase // conditions.cheMin = cheMin; conditions.cheMax = cheMax; + conditions.x3maMin = x3maMin; + conditions.x3maMax = x3maMax; conditions.vwapMin = vwapMin; conditions.vwapMax = vwapMax; @@ -3917,6 +4303,11 @@ class XCX121Helper : public XCBase conditions.isSarEqualsToVale = isSarEqualsToVale; conditions.isStrEqualsToPeak = isStrEqualsToPeak; conditions.isStrEqualsToVale = isStrEqualsToVale; + conditions.isX3MaFatsOverMid = isX3MaFatsOverMid; + conditions.isX3MaMinBreakedUp = isX3MaMinBreakedUp; + conditions.isX3MaMaxBreakedUp = isX3MaMaxBreakedUp; + conditions.isX3MaFatsUnderMid = isX3MaFatsUnderMid; + conditions.isX3MaFatsOverSlow = isX3MaFatsOverSlow; conditions.isStrUpperOverPeak = isStrUpperOverPeak; conditions.isPeakOverAtrUpper = isPeakOverAtrUpper; conditions.isStrLowerOverVale = isStrLowerOverVale; @@ -3925,12 +4316,19 @@ class XCX121Helper : public XCBase conditions.isBreakedUpPrevSar = isBreakedUpPrevSar; conditions.isBreakedUpPrevStr = isBreakedUpPrevStr; conditions.isAtrUpperOverPeak = isAtrUpperOverPeak; + conditions.isClosedOverX3MaMin = isClosedOverX3MaMin; + conditions.isClosedOverX3MaMax = isClosedOverX3MaMax; + conditions.isX3MaFatsUnderSlow = isX3MaFatsUnderSlow; conditions.isAtrLowerUnderVale = isAtrLowerUnderVale; conditions.isStrLowerUnderVale = isStrLowerUnderVale; conditions.isStrUpperUnderPeak = isStrUpperUnderPeak; conditions.isValeUnderAtrLower = isValeUnderAtrLower; conditions.isClosedOverVWapMin = isClosedOverVWapMin; conditions.isClosedOverVWapMax = isClosedOverVWapMax; + conditions.isClosedUnderX3MaMin = isClosedUnderX3MaMin; + conditions.isClosedUnderX3MaMax = isClosedUnderX3MaMax; + conditions.isX3MaMinBreakedDown = isX3MaMinBreakedDown; + conditions.isX3MaMaxBreakedDown = isX3MaMaxBreakedDown; conditions.isClosedUnderVWapMin = isClosedUnderVWapMin; conditions.isClosedUnderVWapMax = isClosedUnderVWapMax; conditions.isVWapMinBreakedDown = isVWapMinBreakedDown; @@ -3939,6 +4337,7 @@ class XCX121Helper : public XCBase conditions.isStrCrossedOverVale = isStrCrossedOverVale; conditions.isBreakedDownPrevStr = isBreakedDownPrevStr; conditions.isBreakedDownPrevSar = isBreakedDownPrevSar; + conditions.isX3MaFatsOverMidPrev = isX3MaFatsOverMidPrev; conditions.isSarCrossedUnderPeak = isSarCrossedUnderPeak; conditions.isStrCrossedUnderPeak = isStrCrossedUnderPeak; conditions.isNewPeakOverAtrUpper = isNewPeakOverAtrUpper; @@ -3948,11 +4347,14 @@ class XCX121Helper : public XCBase conditions.isBreakedUpPrevCheSE2 = isBreakedUpPrevCheSE2; conditions.isBreakedUpPrevCheMin = isBreakedUpPrevCheMin; conditions.isBreakedUpPrevCheMax = isBreakedUpPrevCheMax; + conditions.isX3MaFatsUnderMidPrev = isX3MaFatsUnderMidPrev; + conditions.isX3MaFatsOverSlowPrev = isX3MaFatsOverSlowPrev; conditions.isAtrUpperEqualsToPeak = isAtrUpperEqualsToPeak; conditions.isAtrLowerEqualsToVale = isAtrLowerEqualsToVale; conditions.isNewValeUnderAtrLower = isNewValeUnderAtrLower; conditions.isStrUpperOverAtrUpper = isStrUpperOverAtrUpper; conditions.isStrLowerOverAtrLower = isStrLowerOverAtrLower; + conditions.isX3MaFatsUnderSlowPrev = isX3MaFatsUnderSlowPrev; conditions.isBreakedDownPrevCheMin = isBreakedDownPrevCheMin; conditions.isBreakedDownPrevCheMax = isBreakedDownPrevCheMax; conditions.isBreakedDownPrevCheLE1 = isBreakedDownPrevCheLE1; @@ -3965,9 +4367,12 @@ class XCX121Helper : public XCBase conditions.isBreakedUpPrevAtrLower = isBreakedUpPrevAtrLower; conditions.isAtrUpperCrossedUpPeak = isAtrUpperCrossedUpPeak; conditions.isAtrLowerCrossedUpVale = isAtrLowerCrossedUpVale; + conditions.isX3MaFastCrossedOverMid = isX3MaFastCrossedOverMid; conditions.isVWapFastCrossedOverMid = isVWapFastCrossedOverMid; conditions.isRejectedUpPrevAtrUpper = isRejectedUpPrevAtrUpper; conditions.isRejectedUpPrevAtrLower = isRejectedUpPrevAtrLower; + conditions.isX3MaFastCrossedUnderMid = isX3MaFastCrossedUnderMid; + conditions.isX3MaFastCrossedOverSlow = isX3MaFastCrossedOverSlow; conditions.isAtrUpperCrossedDownPeak = isAtrUpperCrossedDownPeak; conditions.isAtrLowerCrossedDownVale = isAtrLowerCrossedDownVale; conditions.isBreakedDownPrevAtrUpper = isBreakedDownPrevAtrUpper; @@ -3978,6 +4383,7 @@ class XCX121Helper : public XCBase conditions.isStrLowerCrossedOverVale = isStrLowerCrossedOverVale; conditions.isStrLowerOverDonLowLower = isStrLowerOverDonLowLower; conditions.isVWapFastCrossedOverSlow = isVWapFastCrossedOverSlow; + conditions.isX3MaFastCrossedUnderSlow = isX3MaFastCrossedUnderSlow; conditions.isRejectedDownPrevAtrUpper = isRejectedDownPrevAtrUpper; conditions.isRejectedDownPrevAtrLower = isRejectedDownPrevAtrLower; conditions.isVWapFastCrossedUnderSlow = isVWapFastCrossedUnderSlow; @@ -4003,6 +4409,7 @@ class XCX121Helper : public XCBase xstrConditions.Clean(); xcheConditions.Clean(); xdonConditions.Clean(); + x3maConditions.Clean(); xvwapConditions.Clean(); xtrendConditions.Clean(); diff --git a/Helpers/x-saherelm.x121.xvwap.helper.mq5 b/Helpers/x-saherelm.x121.xvwap.helper.mq5 index 769dfa96..4f7a4efa 100644 --- a/Helpers/x-saherelm.x121.xvwap.helper.mq5 +++ b/Helpers/x-saherelm.x121.xvwap.helper.mq5 @@ -109,8 +109,8 @@ struct X121XVWAPInputs { // vwapFastLength = 20; - vwapMidLength = 40; - vwapSlowLength = 60; + vwapMidLength = 50; + vwapSlowLength = 100; vwapAppliedTo = PRICE_CLOSE; // diff --git a/Libraries/x-saherelm.x-poi.state.lib.mq5 b/Libraries/x-saherelm.x-poi.state.lib.mq5 index c9ea5313..717685fa 100644 --- a/Libraries/x-saherelm.x-poi.state.lib.mq5 +++ b/Libraries/x-saherelm.x-poi.state.lib.mq5 @@ -3646,7 +3646,7 @@ int ExtractOBFVGs( XPOIState &fvgState, // ENUM_X_OBFVG_FVG_FILTERS filterFVGs = X_OBFVG_FVG_FILTER_INSIDE_OR, - ENUM_X_OBFVG_FVG_SELECTION selectFVG = X_OBFVG_FVG_SELECT_HIGHEST_LOWEST, + ENUM_X_OBFVG_FVG_SELECTION selectFVG = X_OBFVG_FVG_SELECT_OLDEST, // ENUM_TIMEFRAMES forPeriod = NULL, // diff --git a/X121SMCEA/Signals/x-121.smc.xwz.signal.class.mq5 b/X121SMCEA/Signals/x-121.smc.xwz.signal.class.mq5 index 3e7262d6..2418cee2 100644 --- a/X121SMCEA/Signals/x-121.smc.xwz.signal.class.mq5 +++ b/X121SMCEA/Signals/x-121.smc.xwz.signal.class.mq5 @@ -312,6 +312,9 @@ class XCX121SMCXWZSignalDetector : public XCBase // // Setup Conditions ... + XOBFVG selectedZone; + bool hasSelectedZone = false; + bool isSelectedZoneReversal = false; // // First We Have to Has Working Zone ... @@ -358,7 +361,44 @@ class XCX121SMCXWZSignalDetector : public XCBase workingZone.HasInsideZones(); if (hasInsideZones) { - Print("Has Inside Zones"); + // + int selectedIDX = -1; + int count = workingZone.CountInsideZones(); + for (int i = 0; i < count; i++) + { + // + bool has = CheckOBFVGXWZConditions( + isSelectedZoneReversal, + workingZone.insideZones[i], + decisionState, + decisionXConditions // + ); + + // + if (has) + { + // + selectedIDX = i; + selectedZone = workingZone.insideZones[i]; + + // + break; + } + } + + // + if (IsValidIndex(selectedIDX)) + { + // + ArrayRemove( + workingZone.insideZones, + selectedIDX, + 1 // + ); + + // + hasSelectedZone = selectedZone.IsValid(); + } } // @@ -366,7 +406,55 @@ class XCX121SMCXWZSignalDetector : public XCBase workingZone.HasBreakedZones(); if (hasBreakedZones) { - Print("Has Breaked Zones"); + // + if (!hasSelectedZone) + { + // + int selectedIDX = -1; + int count = workingZone.CountBreakedZones(); + for (int i = 0; i < count; i++) + { + // + bool has = CheckOBFVGXWZConditions( + isSelectedZoneReversal, + workingZone.breakedZones[i], + decisionState, + decisionXConditions // + ); + + // + if (has) + { + // + selectedIDX = i; + selectedZone = workingZone.breakedZones[i]; + + // + break; + } + } + + // + if (IsValidIndex(selectedIDX)) + { + // + ArrayRemove( + workingZone.breakedZones, + selectedIDX, + 1 // + ); + + // + hasSelectedZone = selectedZone.IsValid(); + } + } + } + + // + if (hasSelectedZone) + { + // + Print("Has Selected Zone ..."); } // @@ -378,14 +466,15 @@ class XCX121SMCXWZSignalDetector : public XCBase // workingZone.Draw( drawer, - true, // Force Clean ... - true, - true, - true, - true, - true, - true, - true // + true, // Draw Waiting Zones .. + true, // Draw Inside Zones .. + true, // Draw Breaked Zones .. + false, // Draw Supply Zone .. + false, // Draw Demand Zone .. + false, // Draw Supply Zones .. + false, // Draw Demand Zones .. + false, // Draw Support Zones .. + false // Draw Resistance Zones .. ); } diff --git a/X121SMCEA/Signals/x-121.smc.xwz.signal.lib.mq5 b/X121SMCEA/Signals/x-121.smc.xwz.signal.lib.mq5 index c33d7497..ff20bd47 100644 --- a/X121SMCEA/Signals/x-121.smc.xwz.signal.lib.mq5 +++ b/X121SMCEA/Signals/x-121.smc.xwz.signal.lib.mq5 @@ -79,7 +79,10 @@ struct X121SMCStrategyXWZWorkingZone XOBFVG waitingZones[]; // - CArrayObj mObjects; + CArrayObj mInsideZoneObjects; + CArrayObj mBreakedZoneObjects; + CArrayObj mWaitingZoneObjects; + CArrayObj mWorkingZoneObjects; // // Constructor ... @@ -121,7 +124,10 @@ struct X121SMCStrategyXWZWorkingZone ZeroMemory(demandZone); // - mObjects.Clear(); + mInsideZoneObjects.Clear(); + mBreakedZoneObjects.Clear(); + mWaitingZoneObjects.Clear(); + mWorkingZoneObjects.Clear(); } // @@ -352,6 +358,7 @@ struct X121SMCStrategyXWZWorkingZone } // + // Detect OBFVG(s) ... ExtractOBFVGs( waitingZones, mtfState, @@ -1088,14 +1095,39 @@ struct X121SMCStrategyXWZWorkingZone } } + // + has = HasInsideZones(); + if (has) + { + // + count = CountInsideZones(); + for (int i = 0; i < count; i++) + { + insideZones[i].UpdateTo(value); + } + } + + // + has = HasBreakedZones(); + if (has) + { + // + count = CountBreakedZones(); + for (int i = 0; i < count; i++) + { + breakedZones[i].UpdateTo(value); + } + } + // } // void Draw( XCPOIDrawer *drawer, - bool forceClean = false, bool drawWaitingZones = true, + bool drawInsideZones = false, + bool drawBreakedZones = false, bool drawSupplyZone = false, bool drawDemandZone = false, bool drawSupplyZones = false, @@ -1110,12 +1142,6 @@ struct X121SMCStrategyXWZWorkingZone return; } - // - if (forceClean) - { - mObjects.Clear(); - } - // int count = 0; bool has = false; @@ -1145,7 +1171,7 @@ struct X121SMCStrategyXWZWorkingZone // if (isCreated) { - mObjects.Add(iObj); + mWorkingZoneObjects.Add(iObj); } } } @@ -1172,7 +1198,7 @@ struct X121SMCStrategyXWZWorkingZone // if (isCreated) { - mObjects.Add(iObj); + mWorkingZoneObjects.Add(iObj); } } } @@ -1196,7 +1222,7 @@ struct X121SMCStrategyXWZWorkingZone // if (isCreated) { - mObjects.Add(iObj); + mWorkingZoneObjects.Add(iObj); } } } @@ -1223,7 +1249,7 @@ struct X121SMCStrategyXWZWorkingZone // if (isCreated) { - mObjects.Add(iObj); + mWorkingZoneObjects.Add(iObj); } } } @@ -1251,7 +1277,7 @@ struct X121SMCStrategyXWZWorkingZone // if (isCreated) { - mObjects.Add(iObj); + mWorkingZoneObjects.Add(iObj); } } } @@ -1279,7 +1305,7 @@ struct X121SMCStrategyXWZWorkingZone // if (isCreated) { - mObjects.Add(iObj); + mWorkingZoneObjects.Add(iObj); } } } @@ -1309,7 +1335,73 @@ struct X121SMCStrategyXWZWorkingZone // for (int j = 0; j < objectsCount; j++) { - mObjects.Add(objects[j]); + mWaitingZoneObjects.Add(objects[j]); + } + } + } + } + } + + // + // Inside Zones ... + if (drawInsideZones) + { + // + has = HasInsideZones(); + if (has) + { + // + count = CountInsideZones(); + for (int i = 0; i < count; i++) + { + // + XCBaseObject *objects[]; + int objectsCount = drawer.DrawOBFVG( + insideZones[i], + objects // + ); + + // + has = IsValidSize(objectsCount); + if (has) + { + // + for (int i = 0; i < objectsCount; i++) + { + mInsideZoneObjects.Add(objects[i]); + } + } + } + } + } + + // + // Breaked Zones ... + if (drawBreakedZones) + { + // + has = HasBreakedZones(); + if (has) + { + // + count = CountBreakedZones(); + for (int i = 0; i < count; i++) + { + // + XCBaseObject *objects[]; + int objectsCount = drawer.DrawOBFVG( + breakedZones[i], + objects // + ); + + // + has = IsValidSize(objectsCount); + if (has) + { + // + for (int i = 0; i < objectsCount; i++) + { + mBreakedZoneObjects.Add(objects[i]); } } } @@ -1348,7 +1440,7 @@ struct X121SMCStrategyXWZWorkingZone zoneUpperLine.Color(clrRed); // - mObjects.Add(zoneUpperLine); + mWaitingZoneObjects.Add(zoneUpperLine); } // @@ -1367,7 +1459,7 @@ struct X121SMCStrategyXWZWorkingZone zoneLowerLine.Color(clrRed); // - mObjects.Add(zoneLowerLine); + mWaitingZoneObjects.Add(zoneLowerLine); } // @@ -1386,7 +1478,7 @@ struct X121SMCStrategyXWZWorkingZone upperLine.Color(clrLime); // - mObjects.Add(upperLine); + mWaitingZoneObjects.Add(upperLine); } // @@ -1405,7 +1497,7 @@ struct X121SMCStrategyXWZWorkingZone lowerLine.Color(clrLime); // - mObjects.Add(lowerLine); + mWaitingZoneObjects.Add(lowerLine); } // @@ -1427,7 +1519,7 @@ struct X121SMCStrategyXWZWorkingZone q1Line.Color(clrYellow); // - mObjects.Add(q1Line); + mWaitingZoneObjects.Add(q1Line); } // @@ -1446,7 +1538,7 @@ struct X121SMCStrategyXWZWorkingZone q2Line.Color(clrYellow); // - mObjects.Add(q2Line); + mWaitingZoneObjects.Add(q2Line); } // @@ -1465,7 +1557,7 @@ struct X121SMCStrategyXWZWorkingZone q3Line.Color(clrYellow); // - mObjects.Add(q3Line); + mWaitingZoneObjects.Add(q3Line); } } } @@ -1660,4 +1752,216 @@ struct X121SMCStrategyXWZSignalConditions // }; +// +// Extension Functions ... + +/** + * Check an XOBFVG instance has Required Conditions ... + * + * @param zone: XOBFVG instance ... + * @param state: XPOIState instance ... + * @param conditions: X121Conditions instance ... + * + * @return ( bool ) + */ +bool CheckOBFVGXWZConditions( + bool &isReversal, + XOBFVG &zone, + XPOIState &state, + X121Conditions &conditions // +) +{ + // + bool result = false; + + // + isReversal = false; + + // + result = + zone.IsValid() && + state.IsValid() && + state.HasChild(); + if (!result) + { + return result; + } + + // + bool isBullish = zone.IsBullish(); + bool isBearish = zone.IsBearish(); + + // + bool isBullishTrend = conditions.isTrendBullish || + conditions.isTrendSwitchedToBullish; + bool isBearishTrend = conditions.isTrendBearish || + conditions.isTrendSwitchedToBearish; + + // + double bullishScore = 0; + double bearishScore = 0; + conditions.GenerateScore( + bullishScore, + bearishScore // + ); + + // + // VWap ... + + // + double vwapFast = conditions.vwapFastBuffer[0]; + double vwapMid = conditions.vwapMidBuffer[0]; + double vwapSlow = conditions.vwapSlowBuffer[0]; + + // + bool isVWapInside = + // + vwapFast > zone.ob.Lower() && + vwapFast < zone.ob.Upper() + // + && + vwapMid > zone.ob.Lower() && + vwapMid < zone.ob.Upper() + // + ; + + // + bool isVWapBullish = + // + (conditions.isVWapBullishState && + conditions.isVWapSwitchedToBullishOrdered) + // + || + // + (conditions.isVWapBullishOrdered && + conditions.isVWapSwitchedToBullishState) + // + ; + + // + bool isVWapBearish = + // + (conditions.isVWapBearishState && + conditions.isVWapSwitchedToBearishOrdered) + // + || + // + (conditions.isVWapBearishOrdered && + conditions.isVWapSwitchedToBearishState) + // + ; + + // + // X3Ma ... + + // + double x3maFast = conditions.x3maFastBuffer[0]; + double x3maMid = conditions.x3maMidBuffer[0]; + double x3maSlow = conditions.x3maSlowBuffer[0]; + + // + bool isX3MaInside = + // + x3maFast > zone.ob.Lower() && + x3maFast < zone.ob.Upper() + // + && + x3maMid > zone.ob.Lower() && + x3maMid < zone.ob.Upper() + // + ; + + // + bool isX3MaBullish = + // + (conditions.isX3MaBullishState && + conditions.isX3MaSwitchedToBullishOrdered) + // + || + // + (conditions.isX3MaBullishOrdered && + conditions.isX3MaSwitchedToBullishState) + // + ; + + // + bool isX3MaBearish = + // + (conditions.isX3MaBearishState && + conditions.isX3MaSwitchedToBearishOrdered) + // + || + // + (conditions.isX3MaBearishOrdered && + conditions.isX3MaSwitchedToBearishState) + // + ; + + // + // + // + + // + bool isInside = + // + isVWapInside || + isX3MaInside + // + ; + + // + bool isVWap3MaBullish = + isVWapBullish || + isX3MaBullish; + + // + bool isVWap3MaBearish = + isVWapBearish || + isX3MaBearish; + + // + // + // + + // + bool isDirectionalBullishPassed = + // + isInside && + isBullish && + isBullishTrend && + isVWap3MaBullish && + bullishScore > 0 && + bearishScore >= 0 && + bullishScore > bearishScore + // + ; + + // + bool isDirectionalBearishPassed = + // + isInside && + isBearish && + isBearishTrend && + isVWap3MaBearish && + bearishScore > 0 && + bullishScore >= 0 && + bearishScore > bullishScore + // + ; + + // + if (isInside) + { + // + Print("X3MA VWAP Inside ..."); + } + + // + result = isDirectionalBullishPassed || + isDirectionalBearishPassed; + + // + return result; +} + // \ No newline at end of file