From 3b7ce3816a1990a5e2be00547498f5cea7526a18 Mon Sep 17 00:00:00 2001 From: Hadi Khazaee Asl Date: Sat, 8 Mar 2025 22:00:36 +0330 Subject: [PATCH] Add support for Golden Zone inside XPV indicator and it's Helper ... --- Documents/BKP/testob.mq5 | 275 ++++++++++++++++++ Helpers/x-saherelm.x121.helper.mq5 | 12 + Helpers/x-saherelm.x121.xpv.helper.mq5 | 210 +++++++++++-- Indicators/x-saherelm.x121.xpv.mq5 | 88 +++++- .../x-121.smc.market.cycle.helper.class.mq5 | 15 +- X121SMCEA/Experts/x-121.smc.expert.class.mq5 | 5 + .../Signals/x-121.smc.xwz.signal.class.mq5 | 33 ++- .../Signals/x-121.smc.xwz.signal.lib.mq5 | 165 ++++++----- .../Strategy/x-121.smc.strategy.class.mq5 | 11 +- 9 files changed, 682 insertions(+), 132 deletions(-) create mode 100644 Documents/BKP/testob.mq5 diff --git a/Documents/BKP/testob.mq5 b/Documents/BKP/testob.mq5 new file mode 100644 index 00000000..8910672e --- /dev/null +++ b/Documents/BKP/testob.mq5 @@ -0,0 +1,275 @@ +//+------------------------------------------------------------------+ +//| OrderBlockDetector.mq5| +//| Copyright 2023, MetaQuotes Software Corp. | +//| https://www.mql5.com| +//+------------------------------------------------------------------+ +#property strict + +// +// Input Parameters +input int ConsolidationPeriod = 20; // Bars for consolidation detection +input int AtrPeriod = 14; // ATR period for volatility +input double AtrMultiplier = 2.0; // Threshold multiplier (ATR * multiplier) +input int VolumeThreshold = 1000; // Minimum volume for breakout +input bool RequireRetest = true; // Retest confirmation required? +input int VpvrBars = 50; // Bars for VPVR calculation +input int TrendCheckPeriod = 30; // Bars for trend structure analysis +input int MACDFast = 12; // MACD Fast EMA period +input int MACDSlow = 26; // MACD Slow EMA period +input int MACDSignal = 9; // MACD Signal period +input int RSIPeriod = 14; // RSI period +input double RSILevel = 50; // RSI threshold level + +// Global Variables +int ObjectId = 0; +string Prefix = "OrderBlock_"; + +// +enum ENUM_X_DIRECTION +{ + X_DIRECTION_NONE, + X_DIRECTION_BULISH, + X_DIRECTION_BEARISH, +}; + +// +int atrHandler = INVALID_HANDLE; +double atrBuffer[]; + +// +int rsiHandler = INVALID_HANDLE; +double rsiBuffer[]; + +// +int macdHandler = INVALID_HANDLE; +double macdMainBuffer[]; +double macdSignalBuffer[]; + +//+------------------------------------------------------------------+ +//| Expert initialization function | +//+------------------------------------------------------------------+ +int OnInit() +{ + // + ArraySetAsSeries(atrBuffer, true); + atrHandler = iATR(_Symbol, _Period, AtrPeriod); + + // + ArraySetAsSeries(rsiBuffer, true); + rsiHandler = iRSI(_Symbol, _Period, RSIPeriod, PRICE_CLOSE); + + // + ArraySetAsSeries(macdMainBuffer, true); + ArraySetAsSeries(macdSignalBuffer, true); + macdHandler = iMACD(_Symbol, _Period, MACDFast, MACDSlow, MACDSignal, PRICE_CLOSE); + + // + ObjectsDeleteAll(0, Prefix); + return (INIT_SUCCEEDED); +} + +//+------------------------------------------------------------------+ +//| Expert deinitialization function | +//+------------------------------------------------------------------+ +void OnDeinit(const int reason) +{ + // + IndicatorRelease(atrHandler); + ObjectsDeleteAll(0, Prefix); +} + +//+------------------------------------------------------------------+ +//| Expert tick function | +//+------------------------------------------------------------------+ +void OnTick() +{ + DetectOrderBlocks(); +} + +//+------------------------------------------------------------------+ +//| Detect Order Blocks with ATR Dynamic Threshold | +//+------------------------------------------------------------------+ +void DetectOrderBlocks() +{ + double high, low, vpvrPrice, atr, dynamicThreshold; + datetime startTime, endTime; + bool isBullish, isBearish; + int bars = Bars(_Symbol, _Period); + + for (int i = ConsolidationPeriod; i < bars; i++) + { + // + // Get consolidation range + high = iHigh(_Symbol, _Period, iHighest(_Symbol, _Period, MODE_HIGH, ConsolidationPeriod, i)); + low = iLow(_Symbol, _Period, iLowest(_Symbol, _Period, MODE_LOW, ConsolidationPeriod, i)); + double range = high - low; + + // + // Calculate dynamic threshold using ATR + CopyBuffer(atrHandler, MAIN_LINE, i, 2, atrBuffer); + atr = atrBuffer[0]; + dynamicThreshold = atr * AtrMultiplier; + + // Check if consolidation range is within ATR-based threshold + if (range <= dynamicThreshold) + { + // VPVR Integration + vpvrPrice = CalculateVPVR(i, ConsolidationPeriod); + bool validVPVR = (vpvrPrice > low && vpvrPrice < high); + + // Check breakout direction + isBullish = iClose(_Symbol, _Period, i - ConsolidationPeriod) > high; + isBearish = iClose(_Symbol, _Period, i - ConsolidationPeriod) < low; + + // Trend Verification + ENUM_X_DIRECTION trend = CheckTrendStructure(TrendCheckPeriod); + + // MACD/RSI Verification + bool macdValid = CheckMACD(trend); + bool rsiValid = CheckRSI(trend); + + // Validate all conditions + if ((isBullish || isBearish) && validVPVR && + (trend != -1) && macdValid && rsiValid) + { + double breakoutVolume = (double)iVolume(_Symbol, _Period, i - ConsolidationPeriod); + if (breakoutVolume < VolumeThreshold) + continue; + + // Define order block time window + startTime = iTime(_Symbol, _Period, i); + endTime = iTime(_Symbol, _Period, i + ConsolidationPeriod); + + // Check retest (if required) + if (RequireRetest) + { + bool retestFound = false; + for (int j = i - ConsolidationPeriod; j > 0; j--) + { + if ((isBullish && iLow(_Symbol, _Period, j) <= low && iLow(_Symbol, _Period, j) >= high) || + (isBearish && iHigh(_Symbol, _Period, j) >= high && iHigh(_Symbol, _Period, j) <= low)) + { + retestFound = true; + break; + } + } + if (!retestFound) + continue; + } + + // Draw order block with ATR annotation + string name = Prefix + IntegerToString(ObjectId++); + DrawOrderBlock(name, startTime, endTime, low, high, + isBullish ? clrGreen : clrRed, vpvrPrice, dynamicThreshold); + } + } + } +} + +//+------------------------------------------------------------------+ +//| Trend Detection using Price Structure | +//+------------------------------------------------------------------+ +ENUM_X_DIRECTION CheckTrendStructure(int period) +{ + int currentStart = 1; + int previousStart = period + 1; + + double currentHigh = iHigh(_Symbol, _Period, iHighest(_Symbol, _Period, MODE_HIGH, period, currentStart)); + double previousHigh = iHigh(_Symbol, _Period, iHighest(_Symbol, _Period, MODE_HIGH, period, previousStart)); + double currentLow = iLow(_Symbol, _Period, iLowest(_Symbol, _Period, MODE_LOW, period, currentStart)); + double previousLow = iLow(_Symbol, _Period, iLowest(_Symbol, _Period, MODE_LOW, period, previousStart)); + + if (currentHigh > previousHigh && currentLow > previousLow) + return (X_DIRECTION_BULISH); // Uptrend + else if (currentHigh < previousHigh && currentLow < previousLow) + return (X_DIRECTION_BEARISH); // Downtrend + else + return (X_DIRECTION_NONE); // No clear trend +} + +//+------------------------------------------------------------------+ +//| MACD Trend Verification | +//+------------------------------------------------------------------+ +bool CheckMACD(ENUM_X_DIRECTION trend) +{ + // + CopyBuffer(macdHandler, MAIN_LINE, 0, 1, macdMainBuffer); + CopyBuffer(macdHandler, SIGNAL_LINE, 0, 1, macdSignalBuffer); + double macdMain = macdMainBuffer[0]; + double macdSignal = macdSignalBuffer[0]; + + // + if (trend == X_DIRECTION_BULISH) + return (macdMain > macdSignal); + if (trend == X_DIRECTION_BEARISH) + return (macdMain < macdSignal); + return (false); +} + +//+------------------------------------------------------------------+ +//| RSI Trend Verification | +//+------------------------------------------------------------------+ +bool CheckRSI(ENUM_X_DIRECTION trend) +{ + // + CopyBuffer(rsiHandler, MAIN_LINE, 0, 1, rsiBuffer); + double rsiValue = rsiBuffer[0]; + + // + if (trend == X_DIRECTION_BULISH) + return (rsiValue > RSILevel); + if (trend == X_DIRECTION_BEARISH) + return (rsiValue < RSILevel); + return (false); +} + +//+------------------------------------------------------------------+ +//| Calculate VPVR High Volume Node | +//+------------------------------------------------------------------+ +double CalculateVPVR(int startIdx, int period) +{ + double maxVolume = 0; + double vpvrPrice = 0; + double price, volume; + + for (int i = startIdx; i < startIdx + period; i++) + { + price = (iHigh(_Symbol, _Period, i) + iLow(_Symbol, _Period, i)) / 2; + volume = (double)iVolume(_Symbol, _Period, i); + if (volume > maxVolume) + { + maxVolume = volume; + vpvrPrice = price; + } + } + return (vpvrPrice); +} + +//+------------------------------------------------------------------+ +//| Draw Order Block with ATR Annotation | +//+------------------------------------------------------------------+ +void DrawOrderBlock(string name, datetime startTime, datetime endTime, + double bottom, double top, color clr, double vpvrPrice, double atrThreshold) +{ + // Draw rectangle + ObjectCreate(0, name + "_rect", OBJ_RECTANGLE, 0, startTime, top, endTime, bottom); + ObjectSetInteger(0, name + "_rect", OBJPROP_COLOR, clr); + ObjectSetInteger(0, name + "_rect", OBJPROP_FILL, true); + ObjectSetInteger(0, name + "_rect", OBJPROP_BACK, true); + ObjectSetInteger(0, name + "_rect", OBJPROP_WIDTH, 2); + + // Draw VPVR marker + if (vpvrPrice > 0) + { + ObjectCreate(0, name + "_vpvr", OBJ_HLINE, 0, 0, vpvrPrice); + ObjectSetInteger(0, name + "_vpvr", OBJPROP_COLOR, clrYellow); + ObjectSetInteger(0, name + "_vpvr", OBJPROP_WIDTH, 1); + } + + // Add ATR threshold label + string atrLabel = StringFormat("ATR Threshold: %.5f", atrThreshold); + ObjectCreate(0, name + "_atr", OBJ_TEXT, 0, startTime, top); + ObjectSetString(0, name + "_atr", OBJPROP_TEXT, atrLabel); + ObjectSetInteger(0, name + "_atr", OBJPROP_COLOR, clrWhite); +} +//+------------------------------------------------------------------+ \ No newline at end of file diff --git a/Helpers/x-saherelm.x121.helper.mq5 b/Helpers/x-saherelm.x121.helper.mq5 index 57d109bb..f97ba868 100644 --- a/Helpers/x-saherelm.x121.helper.mq5 +++ b/Helpers/x-saherelm.x121.helper.mq5 @@ -2403,6 +2403,18 @@ class XCX121Helper : public XCBase // Deconstructor ... ~XCX121Helper() { + // + mInputs.Clean(); + xpvInputs.Clean(); + xhkInputs.Clean(); + xatrInputs.Clean(); + xdonInputs.Clean(); + xstrInputs.Clean(); + xcheInputs.Clean(); + x3maInputs.Clean(); + xvwapInputs.Clean(); + xtrendInputs.Clean(); + // delete xpvHelper; delete xhkHelper; diff --git a/Helpers/x-saherelm.x121.xpv.helper.mq5 b/Helpers/x-saherelm.x121.xpv.helper.mq5 index 8f5addd0..993a1848 100644 --- a/Helpers/x-saherelm.x121.xpv.helper.mq5 +++ b/Helpers/x-saherelm.x121.xpv.helper.mq5 @@ -35,16 +35,18 @@ enum ENUM_X121_XPV_BUFFERS X121_XPV_PEAK_LINE = 0, X121_XPV_VALE_LINE = 1, X121_XPV_SAR_LINE = 2, - X121_XPV_C_HH_LINE = 3, - X121_XPV_C_LL_LINE = 4, - X121_XPV_S_HH_LINE = 5, - X121_XPV_S_LL_LINE = 6, - X121_XPV_M_HH_LINE = 7, - X121_XPV_M_LL_LINE = 8, - X121_XPV_L_HH_LINE = 9, - X121_XPV_L_LL_LINE = 10, - X121_XPV_H_HH_LINE = 11, - X121_XPV_H_LL_LINE = 12, + X121_XPV_PEAK_GOLDEN_ZONE_LINE = 3, + X121_XPV_VALE_GOLDEN_ZONE_LINE = 4, + X121_XPV_C_HH_LINE = 5, + X121_XPV_C_LL_LINE = 6, + X121_XPV_S_HH_LINE = 7, + X121_XPV_S_LL_LINE = 8, + X121_XPV_M_HH_LINE = 9, + X121_XPV_M_LL_LINE = 10, + X121_XPV_L_HH_LINE = 11, + X121_XPV_L_LL_LINE = 12, + X121_XPV_H_HH_LINE = 13, + X121_XPV_H_LL_LINE = 14, }; // @@ -76,8 +78,9 @@ struct X121XPVInputs // // Boundary Detection ... - ENUM_SERIESMODE hhMode; // Highest High Calculation Method - ENUM_SERIESMODE llMode; // Lowest Low Calculation Method + ENUM_SERIESMODE hhMode; // Highest High Calculation Method + ENUM_SERIESMODE llMode; // Lowest Low Calculation Method + ENUM_X_FIBO_LEVELS goldenZoneLevel; // Golden Zone Detection // // Parabolic Sar Detection ... @@ -93,9 +96,10 @@ struct X121XPVInputs int valesArrowCode; // Vales Arrow Code // - bool showSar; // Show Parabolic Sar - bool showPeaks; // Show Peaks - bool showVales; // Show Vales + bool showSar; // Show Parabolic Sar + bool showPeaks; // Show Peaks + bool showVales; // Show Vales + bool showGoldenZones; // Show Golden Zones // // Constructor(s) ... @@ -136,6 +140,7 @@ struct X121XPVInputs // Boundary Detection ... hhMode = MODE_HIGH; llMode = MODE_LOW; + goldenZoneLevel = X_FIBO_LEVEL_382; // sarStep = 0; @@ -153,6 +158,7 @@ struct X121XPVInputs showSar = false; showPeaks = false; showVales = false; + showGoldenZones = true; // ZeroMemory(this); @@ -186,6 +192,7 @@ struct X121XPVInputs // Boundary Detection ... hhMode = MODE_HIGH; llMode = MODE_LOW; + goldenZoneLevel = X_FIBO_LEVEL_382; // sarStep = 0.02; @@ -203,6 +210,7 @@ struct X121XPVInputs showSar = true; showPeaks = true; showVales = true; + showGoldenZones = true; } // @@ -261,6 +269,8 @@ struct X121XPVConditions // Buffers ... double peaksBuffer[]; double valesBuffer[]; + double peaksGoldenBuffer[]; + double valesGoldenBuffer[]; double sarBuffer[]; double cHHBuffer[]; double cLLBuffer[]; @@ -331,6 +341,8 @@ struct X121XPVConditions // Clean(peaksBuffer); Clean(valesBuffer); + Clean(peaksGoldenBuffer); + Clean(valesGoldenBuffer); Clean(sarBuffer); Clean(cHHBuffer); Clean(cLLBuffer); @@ -350,6 +362,8 @@ struct X121XPVConditions // ArraySetAsSeries(peaksBuffer, true); ArraySetAsSeries(valesBuffer, true); + ArraySetAsSeries(peaksGoldenBuffer, true); + ArraySetAsSeries(valesGoldenBuffer, true); ArraySetAsSeries(sarBuffer, true); ArraySetAsSeries(cHHBuffer, true); ArraySetAsSeries(cLLBuffer, true); @@ -541,6 +555,8 @@ class XCX121XPVHelper : public XCBaseHelper // Clean(peaksBuffer); Clean(valesBuffer); + Clean(peaksGoldenBuffer); + Clean(valesGoldenBuffer); Clean(sarBuffer); Clean(cHHBuffer); Clean(cLLBuffer); @@ -579,6 +595,8 @@ class XCX121XPVHelper : public XCBaseHelper // ArraySetAsSeries(peaksBuffer, true); ArraySetAsSeries(valesBuffer, true); + ArraySetAsSeries(peaksGoldenBuffer, true); + ArraySetAsSeries(valesGoldenBuffer, true); ArraySetAsSeries(sarBuffer, true); ArraySetAsSeries(cHHBuffer, true); ArraySetAsSeries(cLLBuffer, true); @@ -629,6 +647,7 @@ class XCX121XPVHelper : public XCBaseHelper "", mInputs.hhMode, mInputs.llMode, + mInputs.goldenZoneLevel, // // SAr Detection ... "", @@ -645,7 +664,8 @@ class XCX121XPVHelper : public XCBaseHelper // mInputs.showSar, mInputs.showPeaks, - mInputs.showVales + mInputs.showVales, + mInputs.showGoldenZones // ); result = mHandler != INVALID_HANDLE; @@ -843,6 +863,110 @@ class XCX121XPVHelper : public XCBaseHelper ); } + // + // GOLDEN PEAKS ... + + // + double GetPeakGoldenZone( + int barIndex // Bar Index + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + Calculate(); + + // + int count = ArraySize(peaksGoldenBuffer); + if (barIndex >= count) + { + barIndex = count - 1; + } + + // + return peaksGoldenBuffer[barIndex]; + } + + // + int CopyPeakGoldenZone( + int start, // Start + int count, // Number of Items for read + double &buffer[], // Dest Buffer + bool forceClean = true // Force To Clean buffer + ) + { + // + // Update Calculations ... + Calculate(); + + // + // Copy Items ... + return Copy( + start, + count, + peaksGoldenBuffer, + buffer, + forceClean + // + ); + } + + // + // GOLDEN VALES ... + + // + double GetValeGoldenZone( + int barIndex // Bar Index + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + Calculate(); + + // + int count = ArraySize(valesGoldenBuffer); + if (barIndex >= count) + { + barIndex = count - 1; + } + + // + return valesGoldenBuffer[barIndex]; + } + + // + int CopyValeGoldenZone( + int start, // Start + int count, // Number of Items for read + double &buffer[], // Dest Buffer + bool forceClean = true // Force To Clean buffer + ) + { + // + // Update Calculations ... + Calculate(); + + // + // Copy Items ... + return Copy( + start, + count, + valesGoldenBuffer, + buffer, + forceClean + // + ); + } + // // // @@ -1929,6 +2053,20 @@ class XCX121XPVHelper : public XCBaseHelper conditions.valesBuffer // ); + // + CopyPeakGoldenZone( + zIndex, + loopback, + conditions.peaksGoldenBuffer // + ); + + // + CopyValeGoldenZone( + zIndex, + loopback, + conditions.valesGoldenBuffer // + ); + // CopyCHH( zIndex, @@ -2075,14 +2213,14 @@ class XCX121XPVHelper : public XCBaseHelper conditions.isNewValeUnderLast = isNewValeUnderLast; conditions.isRejectedPrevVale = isRejectedPrevVale; conditions.isBreakedDownPrevVale = isBreakedDownPrevVale; - + // Cleanup(); // zBar.Clean(); cBar.Clean(); - pBar.Clean(); + pBar.Clean(); // return result; @@ -2102,6 +2240,8 @@ class XCX121XPVHelper : public XCBaseHelper // Buffers ... double peaksBuffer[]; double valesBuffer[]; + double peaksGoldenBuffer[]; + double valesGoldenBuffer[]; double sarBuffer[]; double cHHBuffer[]; double cLLBuffer[]; @@ -2158,6 +2298,28 @@ class XCX121XPVHelper : public XCBaseHelper // ); + // + // GOLDEN PEAKS ... + CopyBuffer( + mHandler, + X121_XPV_PEAK_GOLDEN_ZONE_LINE, + 0, + maxRequiredBars, + peaksGoldenBuffer + // + ); + + // + // GOLDEN VALES ... + CopyBuffer( + mHandler, + X121_XPV_VALE_GOLDEN_ZONE_LINE, + 0, + maxRequiredBars, + valesGoldenBuffer + // + ); + // // CURRENT ... @@ -2301,6 +2463,18 @@ class XCX121XPVHelper : public XCBaseHelper maxAllowed // ); + // + CleanupArray( + peaksGoldenBuffer, + maxAllowed // + ); + + // + CleanupArray( + valesGoldenBuffer, + maxAllowed // + ); + // CleanupArray( sarBuffer, diff --git a/Indicators/x-saherelm.x121.xpv.mq5 b/Indicators/x-saherelm.x121.xpv.mq5 index 2b2e4b1c..0af0a37e 100644 --- a/Indicators/x-saherelm.x121.xpv.mq5 +++ b/Indicators/x-saherelm.x121.xpv.mq5 @@ -58,8 +58,9 @@ input ENUM_TIMEFRAMES hcPeriod = NULL; // Time Period // input group "Boundary Detection"; -input ENUM_SERIESMODE hhMode = MODE_HIGH; // Highest High Calculation Method -input ENUM_SERIESMODE llMode = MODE_LOW; // Lowest Low Calculation Method +input ENUM_SERIESMODE hhMode = MODE_HIGH; // Highest High Calculation Method +input ENUM_SERIESMODE llMode = MODE_LOW; // Lowest Low Calculation Method +input ENUM_X_FIBO_LEVELS goldenZoneLevel = X_FIBO_LEVEL_382; // Golden Zone Detection // input group "Sar Detection"; @@ -77,9 +78,10 @@ input int peaksArrowCode = 159; // Peaks Arrow Code input int valesArrowCode = 159; // Vales Arrow Code // -input bool showSar = true; // Show Parabolic Sar -input bool showPeaks = true; // Show Peaks -input bool showVales = true; // Show Vales +input bool showSar = true; // Show Parabolic Sar +input bool showPeaks = true; // Show Peaks +input bool showVales = true; // Show Vales +input bool showGoldenZones = true; // Show Golden Zones // // Buffers ... @@ -94,8 +96,8 @@ input bool showVales = true; // Show Vales #property indicator_chart_window // -#property indicator_buffers 13 -#property indicator_plots 3 +#property indicator_buffers 15 +#property indicator_plots 5 // // Plot Buffers ... @@ -136,11 +138,33 @@ double sarBuffer[]; #property indicator_color3 clrYellow #property indicator_width3 1 +// +#define peaksGoldenZoneBufferIndex 3 +double peaksGoldenZoneBuffer[]; + +// +#property indicator_label4 "X121 PEAKGZ" +#property indicator_type4 DRAW_LINE +#property indicator_color4 clrGold +#property indicator_style4 STYLE_DOT +#property indicator_width4 1 + +// +#define valesGoldenZoneBufferIndex 4 +double valesGoldenZoneBuffer[]; + +// +#property indicator_label5 "X121 VALEGZ" +#property indicator_type5 DRAW_LINE +#property indicator_color5 clrGold +#property indicator_style5 STYLE_DOT +#property indicator_width5 1 + // // Data Buffers ... // -int mLastBufferIndex = 2; +int mLastBufferIndex = 4; // // CURRENT ... @@ -529,6 +553,34 @@ void DefineBuffers() PlotIndexSetDouble(sarBufferIndex, PLOT_EMPTY_VALUE, 0); PlotIndexSetInteger(sarBufferIndex, PLOT_ARROW, sarArrowCode); + // + // Golden Zones ... + + // + ENUM_DRAW_TYPE goldenZonesDrawType = showGoldenZones ? DRAW_LINE : DRAW_NONE; + + // + // PEAK Golden Zone ... + + // + ArraySetAsSeries(peaksGoldenZoneBuffer, true); + SetIndexBuffer(peaksGoldenZoneBufferIndex, peaksGoldenZoneBuffer, INDICATOR_DATA); + + // + PlotIndexSetInteger(peaksGoldenZoneBufferIndex, PLOT_SHOW_DATA, showGoldenZones); + PlotIndexSetInteger(peaksGoldenZoneBufferIndex, PLOT_DRAW_TYPE, goldenZonesDrawType); + + // + // VALE Golden Zone ... + + // + ArraySetAsSeries(valesGoldenZoneBuffer, true); + SetIndexBuffer(valesGoldenZoneBufferIndex, valesGoldenZoneBuffer, INDICATOR_DATA); + + // + PlotIndexSetInteger(valesGoldenZoneBufferIndex, PLOT_SHOW_DATA, showGoldenZones); + PlotIndexSetInteger(valesGoldenZoneBufferIndex, PLOT_DRAW_TYPE, goldenZonesDrawType); + // // Data Buffers ... @@ -997,6 +1049,26 @@ void CalculatePeaksAndVales(int barIndex) ? sValue : lastVale; valesBuffer[barIndex] = iVale; + + // + // Peaks Golden Zone ... + double iPeakGoldenZone = GetFibonacciLevel( + iPeak, + iVale, + goldenZoneLevel, + X_DIRECTION_BULLISH // + ); + peaksGoldenZoneBuffer[barIndex] = iPeakGoldenZone; + + // + // Vales Golden Zone ... + double iValeGoldenZone = GetFibonacciLevel( + iPeak, + iVale, + goldenZoneLevel, + X_DIRECTION_BEARISH // + ); + valesGoldenZoneBuffer[barIndex] = iValeGoldenZone; } // \ No newline at end of file diff --git a/X121SMCEA/Classes/x-121.smc.market.cycle.helper.class.mq5 b/X121SMCEA/Classes/x-121.smc.market.cycle.helper.class.mq5 index 94612298..da8f3653 100644 --- a/X121SMCEA/Classes/x-121.smc.market.cycle.helper.class.mq5 +++ b/X121SMCEA/Classes/x-121.smc.market.cycle.helper.class.mq5 @@ -653,7 +653,6 @@ class XC121SMCCycleHelper : public XCBase color mVolumesColor = clrGreen; // volumes color // - ChartSetInteger(chartId, CHART_MODE, mMode); ChartSetInteger(chartId, CHART_SHOW_BID_LINE, mShowBidLine); ChartSetInteger(chartId, CHART_SHOW_ASK_LINE, mShowAskLine); ChartSetInteger(chartId, CHART_SHOW_GRID, mShowGrid); @@ -663,16 +662,20 @@ class XC121SMCCycleHelper : public XCBase ChartSetInteger(chartId, CHART_QUICK_NAVIGATION, mQuickNavigation); ChartSetInteger(chartId, CHART_COLOR_FOREGROUND, mForeGroundColor); ChartSetInteger(chartId, CHART_COLOR_BACKGROUND, mBackGroundColor); - ChartSetInteger(chartId, CHART_COLOR_CHART_UP, mUpColor); - ChartSetInteger(chartId, CHART_COLOR_CHART_DOWN, mDownColor); - ChartSetInteger(chartId, CHART_COLOR_CANDLE_BULL, mBullishColor); - ChartSetInteger(chartId, CHART_COLOR_CANDLE_BEAR, mBearishColor); ChartSetInteger(chartId, CHART_COLOR_GRID, mGridColor); ChartSetInteger(chartId, CHART_COLOR_BID, mBidLineColor); ChartSetInteger(chartId, CHART_COLOR_ASK, mAskLineColor); ChartSetInteger(chartId, CHART_COLOR_STOP_LEVEL, mStopColor); - ChartSetInteger(chartId, CHART_COLOR_CHART_LINE, mLineColor); ChartSetInteger(chartId, CHART_COLOR_VOLUME, mVolumesColor); + + // + // For Enabling XCC ... + // ChartSetInteger(chartId, CHART_MODE, mMode); + // ChartSetInteger(chartId, CHART_COLOR_CHART_UP, mUpColor); + // ChartSetInteger(chartId, CHART_COLOR_CHART_DOWN, mDownColor); + // ChartSetInteger(chartId, CHART_COLOR_CANDLE_BULL, mBullishColor); + // ChartSetInteger(chartId, CHART_COLOR_CANDLE_BEAR, mBearishColor); + // ChartSetInteger(chartId, CHART_COLOR_CHART_LINE, mLineColor); } // diff --git a/X121SMCEA/Experts/x-121.smc.expert.class.mq5 b/X121SMCEA/Experts/x-121.smc.expert.class.mq5 index 71081081..c79eaa1a 100644 --- a/X121SMCEA/Experts/x-121.smc.expert.class.mq5 +++ b/X121SMCEA/Experts/x-121.smc.expert.class.mq5 @@ -63,6 +63,7 @@ class XC121SMCExpert : public XCBaseExpert // Constructor(s) ... XC121SMCExpert() { + mShowCandles = false; } // @@ -1185,6 +1186,7 @@ class XC121SMCExpert : public XCBaseExpert // X121XCCInputs xccInputs; xccInputs.Default(); + xccInputs.showCandles = mShowCandles; xccHelper = new XCX121XCCHelper(); result = xccHelper.Init( _Symbol, @@ -1905,6 +1907,9 @@ class XC121SMCExpert : public XCBaseExpert // // Props ... + // + bool mShowCandles; // Show Candles ... + // // Signalling Props ... bool mAllowLong; // Allow Long Signals ... diff --git a/X121SMCEA/Signals/x-121.smc.xwz.signal.class.mq5 b/X121SMCEA/Signals/x-121.smc.xwz.signal.class.mq5 index 1600c3d6..ee6631bb 100644 --- a/X121SMCEA/Signals/x-121.smc.xwz.signal.class.mq5 +++ b/X121SMCEA/Signals/x-121.smc.xwz.signal.class.mq5 @@ -282,29 +282,30 @@ class XCX121SMCXWZSignalDetector : public XCBase // Detect Signal Box ... // - // TODO: Check This ... - // bool isZoneActivated = - // hasWorkingZone && - // hasWaitingZones && - // workingZone.IsZoneActivated( - // activatedZoneIDX, - // activatedFVGIDX, - // provider, - // zIndex // - // ); - - // - hasSignalBox = + bool isZoneActivated = hasWorkingZone && - hasWaitingBoxes && - workingZone.IsBoxActivated( - signalBox, + hasWaitingZones && + workingZone.IsZoneActivated( + activatedZoneIDX, + activatedFVGIDX, signalBoxDir, signalProvider, provider, zIndex // ); + // + // hasSignalBox = + // hasWorkingZone && + // hasWaitingBoxes && + // workingZone.IsBoxActivated( + // signalBox, + // signalBoxDir, + // signalProvider, + // provider, + // zIndex // + // ); + // if (hasSignalBox) { diff --git a/X121SMCEA/Signals/x-121.smc.xwz.signal.lib.mq5 b/X121SMCEA/Signals/x-121.smc.xwz.signal.lib.mq5 index 30f4788d..9ff3873e 100644 --- a/X121SMCEA/Signals/x-121.smc.xwz.signal.lib.mq5 +++ b/X121SMCEA/Signals/x-121.smc.xwz.signal.lib.mq5 @@ -470,8 +470,7 @@ struct X121SMCStrategyXWZWorkingZone // // Detect OB FVG ... - if (false && - hasNewOrderBlock) + if (hasNewOrderBlock) { // XOHCL obStartedBar; @@ -483,8 +482,7 @@ struct X121SMCStrategyXWZWorkingZone ); // - has = isOBStarted && - isOBStartedBodyOut; + has = isOBStarted; if (has) { // @@ -534,21 +532,21 @@ struct X121SMCStrategyXWZWorkingZone ob // ) // - || - // - (isBullish - ? IsAboveDiff( - iFVG, - ob, - true // Ignore Inside ... - ) - : IsBelowDiff( - iFVG, - ob, - true // Ignore Inside ... - ) - // - ) + // || + // // + // (isBullish + // ? IsAboveDiff( + // iFVG, + // ob, + // true // Ignore Inside ... + // ) + // : IsBelowDiff( + // iFVG, + // ob, + // true // Ignore Inside ... + // ) + // // + // ) // ; @@ -611,86 +609,91 @@ struct X121SMCStrategyXWZWorkingZone // // - // Check New Order Block Detection Analyse ... - XBoxZone analyseOBBox; - XCOrderBlock *analyseOB = NULL; - bool hasNewAnalyseOrderBlock = - Contains( - X_BULLISH_ORDERBLOCK_DETECTED, - provider - .analysePoiEvents // - ) || - Contains( - X_BEARISH_ORDERBLOCK_DETECTED, - provider - .analysePoiEvents // - ); - if (hasNewAnalyseOrderBlock) + bool lookingOthers = false; + if (lookingOthers) { // - idx = GetYoungest(provider - .analyseState - .orderBlocks // - ); - has = IsValidIndex(idx); - if (has) + // Check New Order Block Detection Analyse ... + XBoxZone analyseOBBox; + XCOrderBlock *analyseOB = NULL; + bool hasNewAnalyseOrderBlock = + Contains( + X_BULLISH_ORDERBLOCK_DETECTED, + provider + .analysePoiEvents // + ) || + Contains( + X_BEARISH_ORDERBLOCK_DETECTED, + provider + .analysePoiEvents // + ); + if (hasNewAnalyseOrderBlock) { // - analyseOB = provider - .analyseState - .orderBlocks[idx]; - has = ToBox( - analyseOBBox, - analyseOB // + idx = GetYoungest(provider + .analyseState + .orderBlocks // ); + has = IsValidIndex(idx); if (has) { // - analyseOB.To(cTime); - analyseOBBox.to = cTime; - hasNewAnalyseOrderBlock = analyseOBBox.IsValid(); + analyseOB = provider + .analyseState + .orderBlocks[idx]; + has = ToBox( + analyseOBBox, + analyseOB // + ); + if (has) + { + // + analyseOB.To(cTime); + analyseOBBox.to = cTime; + hasNewAnalyseOrderBlock = analyseOBBox.IsValid(); + } } } - } - - // - // Checking Analyse Order Block ... - if (hasNewAnalyseOrderBlock) - { - // - XOHCL obStartedBar; - bool isOBStartedBodyOut = false; - bool isOBStarted = analyseOB.IsStarted( - analyseOB.GetDirection(), - obStartedBar, - isOBStartedBodyOut // - ); // - has = isOBStarted && - isOBStartedBodyOut; - if (has) + // Checking Analyse Order Block ... + if (hasNewAnalyseOrderBlock) { // - analyseOBBox.from = - obStartedBar.NextAt(); + XOHCL obStartedBar; + bool isOBStartedBodyOut = false; + bool isOBStarted = analyseOB.IsStarted( + analyseOB.GetDirection(), + obStartedBar, + isOBStartedBodyOut // + ); // - has = IsExists(analyseOBBox); - if (!has) + has = isOBStarted && + isOBStartedBodyOut; + if (has) { // - AddRef( - analyseOBBox, - waitingBoxes // - ); + analyseOBBox.from = + obStartedBar.NextAt(); + + // + has = IsExists(analyseOBBox); + if (!has) + { + // + AddRef( + analyseOBBox, + waitingBoxes // + ); + } } } - } - // - analyseOBBox.Clean(); - ZeroMemory(analyseOB); + // + analyseOBBox.Clean(); + ZeroMemory(analyseOB); + } // // @@ -1051,10 +1054,14 @@ struct X121SMCStrategyXWZWorkingZone // // Combine Result ... - result = isPVPassed; + // result = isPVPassed; // || isPVPassed // || isPV50Passed // || isRejected; + + // + result = isPVPassed; + if (result) { // diff --git a/X121SMCEA/Strategy/x-121.smc.strategy.class.mq5 b/X121SMCEA/Strategy/x-121.smc.strategy.class.mq5 index effe5ef8..eab17ada 100644 --- a/X121SMCEA/Strategy/x-121.smc.strategy.class.mq5 +++ b/X121SMCEA/Strategy/x-121.smc.strategy.class.mq5 @@ -762,16 +762,17 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy // // XPV ... - x121Inputs.xpvInputs.showSar = showAll || false; + x121Inputs.xpvInputs.showSar = showAll || true; x121Inputs.xpvInputs.showPeaks = showAll || true; x121Inputs.xpvInputs.showVales = showAll || true; + x121Inputs.xpvInputs.showGoldenZones = showAll || true; // // XHK ... // x121Inputs.xhkInputs.drawRawXHKCandles = showAll || false; - x121Inputs.xhkInputs.drawSmoothedXHKCandles = showAll || false; + x121Inputs.xhkInputs.drawSmoothedXHKCandles = showAll || true; // // XATR ... @@ -806,9 +807,9 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy // // X3MA ... - x121Inputs.x3maInputs.showX3MaFast = showAll || true; - x121Inputs.x3maInputs.showX3MaMid = showAll || true; - x121Inputs.x3maInputs.showX3MaSlow = showAll || true; + x121Inputs.x3maInputs.showX3MaFast = showAll || false; + x121Inputs.x3maInputs.showX3MaMid = showAll || false; + x121Inputs.x3maInputs.showX3MaSlow = showAll || false; // // Initialize Cycle Helpers ...