diff --git a/Documents/BKP/tmp.sig.codes.mq5 b/Documents/BKP/tmp.sig.codes.mq5 new file mode 100644 index 00000000..40eb6785 --- /dev/null +++ b/Documents/BKP/tmp.sig.codes.mq5 @@ -0,0 +1,214 @@ + + // + // Checking Bar Based on Positions State ... + ENUM_X_DIRECTION iBarPosDir; + bool isBarValidForDir = cHelper + .mBarAnalyser + .IsValidForPosition( + cBar, + iBarPosDir // + ); + bool isBarValidForBullish = + isBarValidForDir && + IsBullish(iBarPosDir); + bool isBarValidForBearish = + isBarValidForDir && + IsBearish(iBarPosDir); + + // + // Check Bar Place Based on Golden Zones ... + + // + bool isBarInPeaksGoldenZone = + cBar.high <= cXConditions.peaksBuffer[cIDX] && + cBar.low >= cXConditions.peaksGoldenBuffer[cIDX]; + + // + bool isBarInValesGoldenZone = + cBar.high >= cXConditions.valesBuffer[cIDX] && + cBar.low <= cXConditions.valesGoldenBuffer[cIDX]; + + // + XCPOIDrawer *drawer = provider.visionCycleHelper.mPOIDrawer; + + // + // X3MA ... + + // + bool isX3MaFastMidOverPeaksGoldeZone = + isX3MaFastOverPeaksGoldenZone && + isX3MaMidOverPeaksGoldenZone; + + // + bool isX3MaFastMidUnderValesGoldeZone = + isX3MaFastUnderValesGoldenZone && + isX3MaMidUnderValesGoldenZone; + + // + // XVWAP ... + + // + bool isVWapFastMidOverPeaksGoldeZone = + isVWapFastOverPeaksGoldenZone && + isVWapMidOverPeaksGoldenZone; + + // + bool isVWapFastMidUnderValesGoldeZone = + isVWapFastUnderValesGoldenZone && + isVWapMidUnderValesGoldenZone; + + // + // + + // + bool isX3MaVWapFastUnderValuesGoldenZone = + isX3MaFastUnderValesGoldenZone && + isVWapFastUnderValesGoldenZone; + + // + bool isX3MaVWapFastOverPeaksGoldenZone = + isX3MaFastOverPeaksGoldenZone && + isVWapFastOverPeaksGoldenZone; + + // + // + + // + double x3MaFastMidMax = MathMax( + cXConditions.x3maFastBuffer[cIDX], + cXConditions.x3maMidBuffer[cIDX] // + ); + + // + double x3MaFastMidMin = MathMin( + cXConditions.x3maFastBuffer[cIDX], + cXConditions.x3maMidBuffer[cIDX] // + ); + + // + double vwapFastMidMax = MathMax( + cXConditions.vwapFastBuffer[cIDX], + cXConditions.vwapMidBuffer[cIDX] // + ); + + // + double vwapFastMidMin = MathMin( + cXConditions.vwapFastBuffer[cIDX], + cXConditions.vwapMidBuffer[cIDX] // + ); + + // + // + + // + double x3maVWapFastMidMax = MathMax(x3MaFastMidMax, vwapFastMidMax); + double x3maVWapFastMidMin = MathMin(x3MaFastMidMin, vwapFastMidMin); + + // + double x3maVWapMax = MathMax(cXConditions.x3maMax, cXConditions.vwapMax); + double x3maVWapMin = MathMin(cXConditions.x3maMin, cXConditions.vwapMin); + + // + double x3maVWapDiff = x3maVWapMax - x3maVWapMin; + + // + double atr = cXConditions.atrBuffer[cIDX]; + + // + bool isConsolidate = x3maVWapDiff <= (3 * atr); + + // + bool isX3MaVWapSwitchedToBullish = + // + // VWap ... + ( + // + (cXConditions.isVWapBullishOrdered && + cXConditions.isVWapSwitchedToBullishState) || + (cXConditions.isVWapBullishState && + cXConditions.isVWapSwitchedToBullishOrdered) + // + ) + // + || + // + // X3Ma ... + ( + // + (cXConditions.isX3MaBullishOrdered && + cXConditions.isX3MaSwitchedToBullishState) || + (cXConditions.isX3MaBullishState && + cXConditions.isX3MaSwitchedToBullishOrdered) + // + ) + // + ; + + // + bool isX3MaVWapSwitchedToBearish = + // + // VWap ... + ( + // + (cXConditions.isVWapBearishOrdered && + cXConditions.isVWapSwitchedToBearishState) || + (cXConditions.isVWapBearishState && + cXConditions.isVWapSwitchedToBearishOrdered) + // + ) + // + || + // + // X3Ma ... + ( + // + (cXConditions.isX3MaBearishOrdered && + cXConditions.isX3MaSwitchedToBearishState) || + (cXConditions.isX3MaBearishState && + cXConditions.isX3MaSwitchedToBearishOrdered) + // + ) + // + ; + + // + // Bullish Conditions ... + isBullish = + // + // Base Condition ... + ( + // + false + // + // isConsolidate && + // isBarValidForBullish && + // cXConditions.isSarBullish && + // isX3MaVWapSwitchedToBullish && + // cXConditions.isNewPeakOverLast // && + // isVWapFastMidUnderValesGoldeZone // && + // cXConditions.isAtrLowerSlopeBullish + // + ) + // + ; + + // + // Bearish Conditions ... + isBearish = + // + // Base Condition ... + ( + // + false + // + // isConsolidate && + // isBarValidForBearish && + // cXConditions.isSarBearish && + // isX3MaVWapSwitchedToBearish && + // cXConditions.isNewValeUnderLast // && + // isVWapFastMidOverPeaksGoldeZone // && + // cXConditions.isAtrUpperSlopeBearish + // + ) + // + ; diff --git a/Documents/BKP/x-121.smc.market.cycle.helper.class.mq5 b/Documents/BKP/x-121.smc.market.cycle.helper.class.mq5 new file mode 100644 index 00000000..810bc744 --- /dev/null +++ b/Documents/BKP/x-121.smc.market.cycle.helper.class.mq5 @@ -0,0 +1,4024 @@ +/////////////////////////////////////////////////////// +// +// SaherElm IT Center MQL5 Class Library +// -------------------------------------- +// Name: XC121SMCCycleHelper +// Description: provides all based classes for use ... +// +// +// Maintainer: +// ------------ +// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com) +// +////////////////////////////////////////////////////// +// +// Global Properties ... +#property library +#property copyright "Copyright 2023, SaherElm IT Center" +#property link "https://www.saherelm.ir" +#property version "1.00" +#property strict + +// +// Imports ... +#include "../../Classes/x-saherelm.x-bar.analyser.class.mq5" +#include "../../Classes/x-saherelm.x-poi.class.mq5" +#include "../Libraries/x-121.smc.lib.mq5" + +// +// Definitions ... + +// +// Implementations ... + +// +// Cycles Enumeration ... +enum ENUM_X_CYCLES +{ + X_CYCLE_NONE, + X_CYCLE_TRIGGER, + X_CYCLE_DECISION, + X_CYCLE_ANALYSE, + X_CYCLE_VERIFICATION, + X_CYCLE_CONSOLIDATION, + X_CYCLE_VISION, +}; + +// +// String Representation of Cycles Enumeration ... +string ToString(ENUM_X_CYCLES value) +{ + // + string result = EnumToString(value); + + // + StringReplace(result, "X_CYCLE_", ""); + + // + return result; +} + +// +// Validate a Cycle ... +bool IsValid(ENUM_X_CYCLES value) +{ + // + bool result = false; + + // + result = + value != X_CYCLE_NONE; + + // + return result; +} + +// +// Cycle Events Enumeration ... +enum ENUM_X_CYCLE_EVENTS +{ + SAR_CHANGE_DETECTED, + NEW_PEAK_DETECTED, + NEW_VALE_DETECTED, + PIVOT_POINT_DETECTED, + VWAP_ORDER_CHANGE_ETECTED, + VWAP_STATE_CHANGE_DETCTED, + CONSOLIDATION_BREAKED_DETECTED, + PEAK_PIVOT_STARTED, + PEAK_PIVOT_ENDED, + VALE_PIVOT_STARTED, + VALE_PIVOT_ENDED, +}; + +// +// Cycle Helper ... +class XC121SMCCycleHelper : public XCBase +{ + // + public: + // + // Props ... + + // + // X121 ... + XCX121Helper *mX121Helper; + + // + // POI Detector ... + XCPOIDrawer *mPOIDrawer; + XCPOIDetector *mPOIDetector; + + // + // Bar Analyser + XCBarAnalyser *mBarAnalyser; + + // + // Constructor(s) ... + XC121SMCCycleHelper() + { + Default(); + } + + // + // Deconstructor ... + ~XC121SMCCycleHelper() + { + DeInit(); + } + + // + // Getter/Setter(s) ... + + // + // Actions ... + + /** + * Initialize ... + * + * @param symbol: String ... + * @param period: ENUM_TIMEFRAMES member ... + * @param x121Inputs: X121Inputs instance ... + * + * @return ( bool ) + */ + bool Init( + string symbol, + ENUM_TIMEFRAMES period, + X121Inputs &x121Inputs, + int requiredPOIs = 50 // + ) + { + // + bool result = false; + + // + if (requiredPOIs < 0) + { + requiredPOIs = 0; + } + + // + result = IsValid(symbol) && + IsValid(period); + if (!result) + { + return result; + } + + // + mSymbol = symbol; + mPeriod = period; + + // + // X121 ... + mX121Helper = new XCX121Helper(); + result = mX121Helper.Init( + symbol, + period, + x121Inputs // + ); + if (!result) + { + return result; + } + + // + mPOIDetector = new XCPOIDetector( + symbol, + period // + ); + mPOIDetector.MaxRequiredPOIs(requiredPOIs); + + // + int maxLoopbackBars = mPOIDetector.MaxAllowedLoopbackForInit(); + int periodSeconds = PeriodSeconds(period); + if (periodSeconds > PeriodSeconds(PERIOD_M15)) + { + // + int multiplier = periodSeconds / PeriodSeconds(PERIOD_M15); + + // + if (multiplier >= 1) + { + maxLoopbackBars *= 2; + } + } + mPOIDetector.MaxAllowedLoopbackForInit(maxLoopbackBars); + mPOIDetector.Init(); + + // + // Initialize Bar Analyser Class Instance ... + mBarAnalyser = new XCBarAnalyser(); + + // + // Initial and Configure POI Drawer if Required ... + mPOIDrawer = new XCPOIDrawer(); + mPOIDrawer.ChartIdentification(0); + mPOIDrawer.SubWindowIdentification(0); + + // + mPOIDrawer.DemandZoneFill(false); + mPOIDrawer.SupplyZoneFill(false); + mPOIDrawer.BullishFVGFill(false); + mPOIDrawer.BearishFVGFill(false); + mPOIDrawer.SupportZoneFill(false); + mPOIDrawer.ResistanceZoneFill(false); + mPOIDrawer.BullishOrderBlockFill(false); + mPOIDrawer.BearishOrderBlockFill(false); + + // + // Set Chart Style ... + ApplyChartStyle(); + + // + return result; + } + + /** + * Retrieve Symbol ... + * + * @return ( string ) + */ + string GetSymbol() + { + return mSymbol; + } + + /** + * Retrieve TimeFrame (Period) ... + * + * @return ( ENUM_TIMEFRAMES ) + */ + ENUM_TIMEFRAMES GetPeriod() + { + return mPeriod; + } + + /** + * Get Specified Bar ... + * + * @param source: XOHCL instance, Source Bar ... + * @param bar: XOHCL instance, Dest Bar ... + * + * @return ( bool ) + */ + bool GetBar( + XOHCL &source, + XOHCL &bar // + ) + { + // + bool result = false; + + // + bar.Clean(); + + // + string symbol = GetSymbol(); + ENUM_TIMEFRAMES period = GetPeriod(); + + // + result = + IsValid(symbol) && + IsValid(period) && + source.IsValid(); + if (!result) + { + return result; + } + + // + int index = iBarShift( + symbol, + period, + source.time // + ); + result = bar.Init( + symbol, + period, + index // + ); + if (!result) + { + // + bar.Clean(); + return result; + } + + // + return result; + } + + /** + * Retrieve Specified Bar ... + * + * @param bar: XOHCL instance ... + * @param index: Integer ... + * + * @return ( bool ) + */ + bool GetBar( + XOHCL &bar, + int index = 0 // + ) + { + // + bool result = false; + + // + bar.Clean(); + + // + if (index < 0) + { + index = 0; + } + + // + string symbol = GetSymbol(); + ENUM_TIMEFRAMES period = GetPeriod(); + + // + result = bar.Init( + symbol, + period, + index // + ); + + // + return result; + } + + /** + * Retrieve Specified Bar ... + * + * @param bar: XOHCL instance ... + * @param time: Datetime ... + * + * @return ( bool ) + */ + bool GetBar( + XOHCL &bar, + datetime time = NULL // + ) + { + // + bool result = false; + + // + int index = GetBarIndex(time); + result = GetBar(bar, + index // + ); + + // + return result; + } + + /** + * Retrieve Specified Time Bar Index ... + * + * @param time: DateTime ... + * + * @return ( int ) + */ + int GetBarIndex(datetime time = NULL) + { + // + int result = -1; + + // + time = NormalizeTime(time); + + // + string symbol = GetSymbol(); + ENUM_TIMEFRAMES period = GetPeriod(); + + // + result = iBarShift( + symbol, + period, + time // + ); + + // + return result; + } + + /** + * Retrieve Cycle Conditions ... + * + * @param events: ENUM_X_CYCLE_EVENTS member, Array ... + * @param conditions: X121SMCCycleConditions instance ... + * @param barIndex: Integer ... + * @param loopback: Integer ... + * + * @return ( bool ) + */ + bool GetConditions( + ENUM_X_CYCLE_EVENTS &events[], + ENUM_XPOI_EVENTS &poiEvents[], + X121SMCCycleConditions &conditions, + int barIndex = 0, + int loopback = 7 // + ) + { + // + bool result = false; + + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + if (loopback < 5) + { + loopback = 5; + } + + // + Clean(events); + Clean(poiEvents); + conditions.Clean(); + + // + result = mX121Helper.GetConditions( + conditions.x121Conditions, + barIndex, + loopback // + ); + if (!result) + { + // + conditions.Clean(); + return result; + } + + // + mPOIDetector.Update(poiEvents); + mPOIDetector.GetState(conditions.state); + + // + conditions.symbol = GetSymbol(); + conditions.period = GetPeriod(); + conditions.time = TimeCurrent(); + + // + // Update(); + + // + result = conditions.IsValid(); + + // + return result; + } + + // + bool GeneratePVBox( + XBoxZone &box, + int barIndex = 0 // + ) + { + // + bool result = false; + + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + box.Clean(); + box.symbol = GetSymbol(); + box.period = GetPeriod(); + + // + int index = barIndex; + + // + // Peak ... + datetime peaksSameFrom = NULL; + double peak = mX121Helper.xpvHelper.GetPeak(index); + double prevPeak = mX121Helper.xpvHelper.GetPeak(index + 1); + bool startsByPeak = peak == prevPeak; + + // + // Vale ... + datetime valesSameFrom = NULL; + double vale = mX121Helper.xpvHelper.GetVale(index); + double prevVale = mX121Helper.xpvHelper.GetVale(index + 1); + bool startsByVale = + !startsByPeak && + vale == prevVale; + + // + bool canBreak = false; + while (!canBreak) + { + // + index++; + + // + datetime cTime = iTime( + box.symbol, + box.period, + index // + ); + + // + // Peak ... + double iPeak = mX121Helper.xpvHelper.GetPeak(index); + + // + // Vale ... + double iVale = mX121Helper.xpvHelper.GetVale(index); + + // + // Start By Peak or Value ... + bool isSame = false; + if (startsByPeak) + { + // + isSame = iPeak == peak; + bool canSetVale = vale == 0 + ? true + : iVale > vale; + if (canSetVale) + { + vale = iVale; + } + } + else if (startsByVale) + { + // + isSame = iVale == vale; + bool canSetPeak = peak == 0 + ? true + : iPeak < peak; + if (canSetPeak) + { + peak = iPeak; + } + } + + // + if (isSame) + { + // + box.from = cTime; + box.upper = peak; + box.lower = vale; + } + else if (IsValid(box.from)) + { + // + // Complete Box ... + box.to = iTime( + box.symbol, + box.period, + barIndex // + ); + + // + box.type = "XPVBox"; + box.dir = startsByPeak + ? X_DIRECTION_BEARISH + : startsByVale + ? X_DIRECTION_BULLISH + : X_DIRECTION_NONE; + } + + // + canBreak = !isSame; + } + + // + result = box.IsValid(); + if (!result) + { + box.Clean(); + } + + // + return result; + } + + // + int DetectRejections( + XBoxZone &rejections[], + int barIndex = 0, + bool forceBarType = true, + bool forceFiboPressure = true, + bool forceUnUsedRejections = true, + int maxAllowedLoopback = 587 // + ) + { + // + int result = 0; + + // + // Normalize Args ... + Clean(rejections); + + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + int idx = -1; + bool has = false; + for (int i = barIndex + 1; i < barIndex + maxAllowedLoopback; i++) + { + // + // Init Indexed Bar ... + XOHCL iBar; + XOHCL iCBar; + XOHCL iPBar; + has = GetBar(iBar, i); + has = + has && + iBar.GetPreviousBar(iCBar); + has = + has && + iCBar.GetPreviousBar(iPBar); + if (!has) + { + // + iBar.Clean(); + iCBar.Clean(); + iPBar.Clean(); + break; + } + + // + // Check CBar Bullish Fibo Pressure ... + bool cBarHasBullishFiboPressure = + mBarAnalyser + .HasFiboPressure( + iCBar, + X_DIRECTION_BULLISH, + X_FIBO_LEVEL_382 // + ); + + // + // Check CBar Bearish Fibo Pressure ... + bool cBarHasBearishFiboPressure = + mBarAnalyser + .HasFiboPressure( + iCBar, + X_DIRECTION_BEARISH, + X_FIBO_LEVEL_382 // + ); + + // + // Check Bar is Bullish Rejection Swing ... + bool isBullishRejection = + // + iCBar.low < iBar.low && + iCBar.low < iPBar.low && + // + iCBar.low < iCBar.GetDown() && + iCBar.GetLowShadow() > iCBar.GetBody() && + iCBar.GetLowShadow() > iCBar.GetHighShadow() + // + ; + + // + // Check Bar is Bearish Rejection Swing ... + bool isBearishRejection = + // + iCBar.high > iBar.high && + iCBar.high > iPBar.high && + // + iCBar.high > iCBar.GetUp() && + iCBar.GetHighShadow() > iCBar.GetBody() && + iCBar.GetHighShadow() > iCBar.GetLowShadow() + // + ; + + // + // Apply Fibo Pressure ... + if (forceFiboPressure) + { + // + isBullishRejection = + isBullishRejection && + cBarHasBullishFiboPressure; + + // + isBearishRejection = + isBearishRejection && + cBarHasBearishFiboPressure; + } + + // + // Apply Force Bar Type ... + if (forceBarType) + { + // + isBullishRejection = + isBullishRejection && + iCBar.IsBullish(); + + // + isBearishRejection = + isBearishRejection && + iCBar.IsBearish(); + } + + // + // Summarize Result ... + has = isBullishRejection || + isBearishRejection; + if (has) + { + // + XBoxZone iBox; + + // + iBox.to = iBar.time; + iBox.from = iCBar.time; + iBox.period = iBar.period; + iBox.symbol = iBar.symbol; + + // + iBox.dir = + isBullishRejection + ? X_DIRECTION_BULLISH + : X_DIRECTION_BEARISH; + + // + iBox.upper = + isBullishRejection + ? iCBar.GetDown() + : iCBar.high; + + // + iBox.lower = + isBullishRejection + ? iCBar.low + : iCBar.GetUp(); + + // + iBox.type = + isBullishRejection + ? "XSwingLow" + : "XSwingHigh"; + + // + // Validate Box ... + has = iBox.IsValid(); + if (has) + { + // + // Apply Force Unused Rejections ... + if (forceUnUsedRejections) + { + // + has = !IsBoxBreaked( + iBox, + iCBar.Index() + 1, + barIndex // + ); + } + + // + if (has) + { + // + idx = FindIndex( + iBox, + rejections // + ); + has = !IsValidIndex(idx); + if (has) + { + // + AddRef( + iBox, + rejections // + ); + } + } + } + + // + iBox.Clean(); + } + + // + iBar.Clean(); + iCBar.Clean(); + iPBar.Clean(); + } + + // + result = ArraySize(rejections); + + // + return result; + } + + // + datetime GetNearestCloseOverX3MAFast( + XOHCL &bar, + int maxAllowedBars = 20 // + ) + { + // + datetime result = NULL; + + // + if (!bar.IsValid()) + { + return result; + } + + // + bool has = false; + int idx = bar.Index(); + int start = idx; + int end = start + maxAllowedBars; + bool canContinue = true; + while (canContinue) + { + // + XOHCL iBar; + has = iBar.Init( + bar.symbol, + bar.period, + start // + ); + if (!has) + { + // + iBar.Clean(); + break; + } + + // + double iFast = mX121Helper + .x3maHelper + .GetX3MaFast(start); + + // + has = iBar.close > iFast && + iBar.open < iFast; + if (has) + { + result = iBar.time; + } + + // + canContinue = + start < end && + !IsValid(result); + + // + start++; + + // + iBar.Clean(); + } + + // + return result; + } + + // + datetime GetNearestCloseUnderX3MAFast( + XOHCL &bar, + int maxAllowedBars = 20 // + ) + { + // + datetime result = NULL; + + // + if (!bar.IsValid()) + { + return result; + } + + // + bool has = false; + int idx = bar.Index(); + int start = idx; + int end = start + maxAllowedBars; + bool canContinue = true; + while (canContinue) + { + // + XOHCL iBar; + has = iBar.Init( + bar.symbol, + bar.period, + start // + ); + if (!has) + { + // + iBar.Clean(); + break; + } + + // + double iFast = mX121Helper + .x3maHelper + .GetX3MaFast(start); + + // + has = iBar.close < iFast && + iBar.open > iFast; + if (has) + { + result = iBar.time; + } + + // + canContinue = + start < end && + !IsValid(result); + + // + start++; + + // + iBar.Clean(); + } + + // + return result; + } + + // + // Virtuals ... + + /** + * Set Default Properties Values ... + */ + virtual void Default() + { + } + + // + protected: + // + + // + private: + // + // Props ... + string mSymbol; + ENUM_TIMEFRAMES mPeriod; + + // + // Actions ... + + /** + * Release All Resources ... + */ + void DeInit() + { + // + ZeroMemory(mX121Helper); + ZeroMemory(mPOIDetector); + ZeroMemory(mBarAnalyser); + + // + delete mX121Helper; + delete mPOIDetector; + delete mBarAnalyser; + } + + /** + * Apply Chart Style ... + */ + void ApplyChartStyle() + { + // + // Retrieve Current Chart ID ... + long chartId = ChartID(); + + // + ENUM_CHART_MODE mMode = CHART_CANDLES; // chart's mMode + bool mShowBidLine = true; // show bid line + bool mShowAskLine = true; // show ask line + bool mShowGrid = false; // show grids on chart + bool mShowVolumes = true; // show volumes + bool mShowTradeLevels = true; // Displaying trade levels in the chart (levels of open positions, Stop Loss, Take Profit and pending orders) + bool mAutoScroll = true; // chart autoscroll + bool mQuickNavigation = true; // chart quick navigation state + color mForeGroundColor = clrWhite; // chart's foreground color + color mBackGroundColor = clrBlack; // chart's background color + color mUpColor = clrGreen; // Up Color + color mDownColor = clrRed; // Down Color + color mBullishColor = clrGreen; // Bullish color + color mBearishColor = clrRed; // Bearish color + color mGridColor = clrGray; // grid color + color mBidLineColor = clrGray; // bid line color + color mAskLineColor = clrRed; // ask line color + color mLineColor = clrLime; // line mMode and doji candlestick color + color mStopColor = clrGold; // Color of stop order levels (Stop Loss and Take Profit) + color mVolumesColor = clrGreen; // volumes color + + // + ChartSetInteger(chartId, CHART_SHOW_BID_LINE, mShowBidLine); + ChartSetInteger(chartId, CHART_SHOW_ASK_LINE, mShowAskLine); + ChartSetInteger(chartId, CHART_SHOW_GRID, mShowGrid); + ChartSetInteger(chartId, CHART_SHOW_VOLUMES, mShowVolumes); + ChartSetInteger(chartId, CHART_SHOW_TRADE_LEVELS, mShowTradeLevels); + ChartSetInteger(chartId, CHART_AUTOSCROLL, mAutoScroll); + ChartSetInteger(chartId, CHART_QUICK_NAVIGATION, mQuickNavigation); + ChartSetInteger(chartId, CHART_COLOR_FOREGROUND, mForeGroundColor); + ChartSetInteger(chartId, CHART_COLOR_BACKGROUND, mBackGroundColor); + 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_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); + } + + // +}; + +// +// Signal Provider Data ... +struct X121SMCStrategySignalProviderData +{ + // + // Props ... + + // + // Trigger ... + XPOIState triggerState; + double triggerBullishScore; + double triggerBearishScore; + X121Conditions triggerXConditions; + ENUM_XPOI_EVENTS triggerPoiEvents[]; + XC121SMCCycleHelper *triggerCycleHelper; + ENUM_X_CYCLE_EVENTS triggerCycleEvents[]; + X121SMCCycleConditions triggerConditions; + + // + // Decision ... + XPOIState decisionState; + double decisionBullishScore; + double decisionBearishScore; + X121Conditions decisionXConditions; + ENUM_XPOI_EVENTS decisionPoiEvents[]; + XC121SMCCycleHelper *decisionCycleHelper; + ENUM_X_CYCLE_EVENTS decisionCycleEvents[]; + X121SMCCycleConditions decisionConditions; + + // + // Analyse ... + XPOIState analyseState; + double analyseBullishScore; + double analyseBearishScore; + X121Conditions analyseXConditions; + ENUM_XPOI_EVENTS analysePoiEvents[]; + XC121SMCCycleHelper *analyseCycleHelper; + ENUM_X_CYCLE_EVENTS analyseCycleEvents[]; + X121SMCCycleConditions analyseConditions; + + // + // Verification ... + XPOIState verificationState; + double verificationBullishScore; + double verificationBearishScore; + X121Conditions verificationXConditions; + ENUM_XPOI_EVENTS verificationPoiEvents[]; + XC121SMCCycleHelper *verificationCycleHelper; + ENUM_X_CYCLE_EVENTS verificationCycleEvents[]; + X121SMCCycleConditions verificationConditions; + + // + // Consolidation ... + XPOIState consolidationState; + double consolidationBullishScore; + double consolidationBearishScore; + X121Conditions consolidationXConditions; + ENUM_XPOI_EVENTS consolidationPoiEvents[]; + XC121SMCCycleHelper *consolidationCycleHelper; + ENUM_X_CYCLE_EVENTS consolidationCycleEvents[]; + X121SMCCycleConditions consolidationConditions; + + // + // Vision ... + XPOIState visionState; + double visionBullishScore; + double visionBearishScore; + X121Conditions visionXConditions; + ENUM_XPOI_EVENTS visionPoiEvents[]; + XC121SMCCycleHelper *visionCycleHelper; + ENUM_X_CYCLE_EVENTS visionCycleEvents[]; + X121SMCCycleConditions visionConditions; + + // + // Constructor ... + X121SMCStrategySignalProviderData() + { + Clean(); + } + + // + // Tools ... + + // + // Cleanup ... + void Clean() + { + // + // Trigger ... + triggerState.Clean(); + triggerBullishScore = 0; + triggerBearishScore = 0; + Clean(triggerPoiEvents); + Clean(triggerCycleEvents); + triggerConditions.Clean(); + triggerXConditions.Clean(); + + // + // Decision ... + decisionState.Clean(); + decisionBullishScore = 0; + decisionBearishScore = 0; + Clean(decisionPoiEvents); + Clean(decisionCycleEvents); + decisionConditions.Clean(); + decisionXConditions.Clean(); + + // + // Analyse ... + analyseState.Clean(); + analyseBullishScore = 0; + analyseBearishScore = 0; + Clean(analysePoiEvents); + Clean(analyseCycleEvents); + analyseConditions.Clean(); + analyseXConditions.Clean(); + + // + // Verification ... + verificationState.Clean(); + verificationBullishScore = 0; + verificationBearishScore = 0; + Clean(verificationPoiEvents); + Clean(verificationCycleEvents); + verificationConditions.Clean(); + verificationXConditions.Clean(); + + // + // Consolidation ... + consolidationState.Clean(); + consolidationBullishScore = 0; + consolidationBearishScore = 0; + Clean(consolidationPoiEvents); + Clean(consolidationCycleEvents); + consolidationConditions.Clean(); + consolidationXConditions.Clean(); + + // + // Vision ... + visionState.Clean(); + visionBullishScore = 0; + visionBearishScore = 0; + Clean(visionPoiEvents); + Clean(visionCycleEvents); + visionConditions.Clean(); + visionXConditions.Clean(); + } + + // + void Destroy() + { + // + Clean(); + + // + ZeroMemory(visionCycleHelper); + ZeroMemory(triggerCycleHelper); + ZeroMemory(analyseCycleHelper); + ZeroMemory(decisionCycleHelper); + ZeroMemory(verificationCycleHelper); + ZeroMemory(consolidationCycleHelper); + + // + ZeroMemory(this); + } + + // + bool IsValid() + { + // + bool result = false; + + // + result = + visionCycleHelper != NULL && + triggerCycleHelper != NULL && + analyseCycleHelper != NULL && + decisionCycleHelper != NULL && + verificationCycleHelper != NULL && + consolidationCycleHelper != NULL; + + // + return result; + } + + // + // Initialize ... + bool Init( + XC121SMCCycleHelper *_triggerCycleHelper, + XC121SMCCycleHelper *_decisionCycleHelper, + XC121SMCCycleHelper *_analyseCycleHelper, + XC121SMCCycleHelper *_verificationCycleHelper, + XC121SMCCycleHelper *_consolidationCycleHelper, + XC121SMCCycleHelper *_visionCycleHelper // + ) + { + // + bool result = false; + + // + // Validate Cycle Helpers ... + result = + // + _visionCycleHelper != NULL && + _triggerCycleHelper != NULL && + _analyseCycleHelper != NULL && + _decisionCycleHelper != NULL && + _verificationCycleHelper != NULL && + _consolidationCycleHelper != NULL + // + ; + if (!result) + { + return result; + } + + // + visionCycleHelper = _visionCycleHelper; + triggerCycleHelper = _triggerCycleHelper; + analyseCycleHelper = _analyseCycleHelper; + decisionCycleHelper = _decisionCycleHelper; + verificationCycleHelper = _verificationCycleHelper; + consolidationCycleHelper = _consolidationCycleHelper; + + // + result = IsValid(); + + // + return result; + } + + // + // Prepare all ... + bool Prepare( + int barIndex = 0, + int loopback = 10, + bool trigger = false, + bool decision = true, + bool analyse = true, + bool verification = false, + bool consolidation = true, + bool vision = true // + ) + { + // + bool result = false; + + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + if (loopback < 7) + { + loopback = 7; + } + + // + result = IsValid(); + if (!result) + { + return result; + } + + // + // Trigger ... + if (trigger) + { + // + result = triggerCycleHelper.GetConditions( + triggerCycleEvents, + triggerPoiEvents, + triggerConditions, + barIndex, + loopback // + ); + if (!result) + { + // + Clean(triggerPoiEvents); + Clean(triggerCycleEvents); + + // + triggerConditions.Clean(); + + // + return result; + } + } + + // + // Decision ... + if (decision) + { + // + result = decisionCycleHelper.GetConditions( + decisionCycleEvents, + decisionPoiEvents, + decisionConditions, + barIndex, + loopback // + ); + if (!result) + { + // + Clean(triggerPoiEvents); + Clean(decisionPoiEvents); + Clean(triggerCycleEvents); + triggerConditions.Clean(); + Clean(decisionCycleEvents); + decisionConditions.Clean(); + + // + return result; + } + } + + // + // Analyse ... + if (analyse) + { + // + result = analyseCycleHelper.GetConditions( + analyseCycleEvents, + analysePoiEvents, + analyseConditions, + barIndex, + loopback // + ); + if (!result) + { + // + Clean(triggerPoiEvents); + Clean(analysePoiEvents); + Clean(decisionPoiEvents); + Clean(triggerCycleEvents); + Clean(analyseCycleEvents); + triggerConditions.Clean(); + analyseConditions.Clean(); + Clean(decisionCycleEvents); + decisionConditions.Clean(); + + // + return result; + } + } + + // + // Verification ... + if (verification) + { + // + result = verificationCycleHelper.GetConditions( + verificationCycleEvents, + verificationPoiEvents, + verificationConditions, + barIndex, + loopback // + ); + if (!result) + { + // + Clean(triggerPoiEvents); + Clean(analysePoiEvents); + Clean(decisionPoiEvents); + Clean(triggerCycleEvents); + Clean(analyseCycleEvents); + triggerConditions.Clean(); + analyseConditions.Clean(); + Clean(decisionCycleEvents); + decisionConditions.Clean(); + Clean(verificationPoiEvents); + Clean(verificationCycleEvents); + verificationConditions.Clean(); + + // + return result; + } + } + + // + // Consolidation ... + if (consolidation) + { + // + result = consolidationCycleHelper.GetConditions( + consolidationCycleEvents, + consolidationPoiEvents, + consolidationConditions, + barIndex, + loopback // + ); + if (!result) + { + // + Clean(triggerPoiEvents); + Clean(analysePoiEvents); + Clean(decisionPoiEvents); + Clean(triggerCycleEvents); + Clean(analyseCycleEvents); + triggerConditions.Clean(); + analyseConditions.Clean(); + Clean(decisionCycleEvents); + decisionConditions.Clean(); + Clean(verificationPoiEvents); + Clean(consolidationPoiEvents); + Clean(verificationCycleEvents); + verificationConditions.Clean(); + Clean(consolidationCycleEvents); + consolidationConditions.Clean(); + + // + return result; + } + } + + // + // Vision ... + if (vision) + { + result = visionCycleHelper.GetConditions( + visionCycleEvents, + visionPoiEvents, + visionConditions, + barIndex, + loopback // + ); + if (!result) + { + // + Clean(visionPoiEvents); + Clean(triggerPoiEvents); + Clean(analysePoiEvents); + Clean(visionCycleEvents); + visionConditions.Clean(); + Clean(decisionPoiEvents); + Clean(triggerCycleEvents); + Clean(analyseCycleEvents); + triggerConditions.Clean(); + analyseConditions.Clean(); + Clean(decisionCycleEvents); + decisionConditions.Clean(); + Clean(verificationPoiEvents); + Clean(consolidationPoiEvents); + Clean(verificationCycleEvents); + verificationConditions.Clean(); + Clean(consolidationCycleEvents); + consolidationConditions.Clean(); + + // + return result; + } + } + + // + // Cycles POI States ... + visionState = visionConditions.state; + triggerState = triggerConditions.state; + analyseState = analyseConditions.state; + decisionState = decisionConditions.state; + verificationState = verificationConditions.state; + consolidationState = consolidationConditions.state; + + // + // Cycle X121Conditions ... + visionXConditions = visionConditions.x121Conditions; + triggerXConditions = triggerConditions.x121Conditions; + analyseXConditions = analyseConditions.x121Conditions; + decisionXConditions = decisionConditions.x121Conditions; + verificationXConditions = verificationConditions.x121Conditions; + consolidationXConditions = consolidationConditions.x121Conditions; + + // + // Trigger ... + triggerXConditions.GenerateScore( + triggerBullishScore, + triggerBearishScore // + ); + + // + // Decision ... + decisionXConditions.GenerateScore( + decisionBullishScore, + decisionBearishScore // + ); + + // + // Analyse ... + analyseXConditions.GenerateScore( + analyseBullishScore, + analyseBearishScore // + ); + + // + // Verification ... + verificationXConditions.GenerateScore( + verificationBullishScore, + verificationBearishScore // + ); + + // + // Consolidation ... + consolidationXConditions.GenerateScore( + consolidationBullishScore, + consolidationBearishScore // + ); + + // + // Vision ... + visionXConditions.GenerateScore( + visionBullishScore, + visionBearishScore // + ); + + // + return result; + } + + // + bool SelectCycle( + ENUM_X_CYCLES cycle, + XPOIState &cState, + XPOIStateEvents &cStateEvents, + X121Conditions &cXConditions, + XC121SMCCycleHelper *&cHelper, + X121SMCCycleConditions &cConditions // + ) + { + // + bool result = false; + + // + cState.Clean(); + ZeroMemory(cHelper); + cConditions.Clean(); + cStateEvents.Clean(); + cXConditions.Clean(); + + // + result = cycle != X_CYCLE_NONE; + if (!result) + { + return result; + } + + // + if (cycle == X_CYCLE_TRIGGER) + { + // + cState = triggerState; + cHelper = triggerCycleHelper; + cConditions = triggerConditions; + cXConditions = triggerXConditions; + cStateEvents.Init(triggerPoiEvents); + } + else if (cycle == X_CYCLE_DECISION) + { + // + cState = decisionState; + cHelper = decisionCycleHelper; + cConditions = decisionConditions; + cXConditions = decisionXConditions; + cStateEvents.Init(decisionPoiEvents); + } + else if (cycle == X_CYCLE_ANALYSE) + { + // + cState = analyseState; + cHelper = analyseCycleHelper; + cConditions = analyseConditions; + cXConditions = analyseXConditions; + cStateEvents.Init(analysePoiEvents); + } + else if (cycle == X_CYCLE_VERIFICATION) + { + // + cState = verificationState; + cHelper = verificationCycleHelper; + cConditions = verificationConditions; + cXConditions = verificationXConditions; + cStateEvents.Init(verificationPoiEvents); + } + else if (cycle == X_CYCLE_CONSOLIDATION) + { + // + cState = consolidationState; + cHelper = consolidationCycleHelper; + cConditions = consolidationConditions; + cXConditions = consolidationXConditions; + cStateEvents.Init(consolidationPoiEvents); + } + else if (cycle == X_CYCLE_VISION) + { + // + cState = visionState; + cHelper = visionCycleHelper; + cConditions = visionConditions; + cXConditions = visionXConditions; + cStateEvents.Init(visionPoiEvents); + } + + // + result = cState.IsValid() && + cHelper != NULL; + + // + return result; + } + + // + void MaxRequiredPOIs(int value) + { + // + if (!IsValid()) + { + return; + } + + // + visionCycleHelper.mPOIDetector.MaxRequiredPOIs(value); + analyseCycleHelper.mPOIDetector.MaxRequiredPOIs(value); + decisionCycleHelper.mPOIDetector.MaxRequiredPOIs(value); + consolidationCycleHelper.mPOIDetector.MaxRequiredPOIs(value); + } + + // + void MaxAllowedLoopbackForInit(int value) + { + // + if (!IsValid()) + { + return; + } + + // + visionCycleHelper.mPOIDetector.MaxAllowedLoopbackForInit(value); + analyseCycleHelper.mPOIDetector.MaxAllowedLoopbackForInit(value); + decisionCycleHelper.mPOIDetector.MaxAllowedLoopbackForInit(value); + consolidationCycleHelper.mPOIDetector.MaxAllowedLoopbackForInit(value); + } + + // +}; + +// +// Condition Parser ... +struct X121SMCStrategyConditionParser +{ + // + // Props ... + + // + // XSAR ... + + // + bool isSarBullishOverPeaksGoldenZone; + bool isSarSwitchedToBullishOverPeaksGoldenZone; + bool isSarBearishOverPeaksGoldenZone; + bool isSarSwitchedToBearishOverPeaksGoldenZone; + bool isSarBullishUnderValesGoldenZone; + bool isSarSwitchedToBullishUnderValesGoldenZone; + bool isSarBearishUnderValesGoldenZone; + bool isSarSwitchedToBearishUnderValesGoldenZone; + + // + // XMA ... + + // + bool isX3MaFastUnderValesGoldenZone; + bool isX3MaMidUnderValesGoldenZone; + bool isX3MaSlowUnderValesGoldenZone; + bool isX3MaFastCrossedUnderValesGoldenZone; + + // + bool isX3MaFastOverPeaksGoldenZone; + bool isX3MaMidOverPeaksGoldenZone; + bool isX3MaFastCrossedOverPeaksGoldenZone; + + // + bool isX3MaInsidePeaksGoldenZone; + bool isX3MaCrossedInsidePeaksGoldenZone; + bool isX3MaInsideValesGoldenZone; + bool isX3MaCrossedInsideValesGoldenZone; + + // + bool isX3MaBullishStateOverPeaksGoldenZone; + bool isX3MaBearishStateOverPeaksGoldenZone; + bool isX3MaSwitchedToBullishStateOverPeaksGoldenZone; + bool isX3MaSwitchedToBearishStateOverPeaksGoldenZone; + + // + bool isX3MaBullishOrderedOverPeaksGoldenZone; + bool isX3MaBearishOrderedOverPeaksGoldenZone; + bool isX3MaSwitchedToBullishOrderedOverPeaksGoldenZone; + bool isX3MaSwitchedToBearishOrderedOverPeaksGoldenZone; + + // + bool isX3MaBullishStateUnderValesGoldenZone; + bool isX3MaBearishStateUnderValesGoldenZone; + bool isX3MaSwitchedToBullishStateUnderValesGoldenZone; + bool isX3MaSwitchedToBearishStateUnderValesGoldenZone; + + // + bool isX3MaBullishOrderedUnderValesGoldenZone; + bool isX3MaBearishOrderedUnderValesGoldenZone; + bool isX3MaSwitchedToBullishOrderedUnderValesGoldenZone; + bool isX3MaSwitchedToBearishOrderedUnderValesGoldenZone; + + // + // XVWAP ... + + // + bool isVWapFastUnderValesGoldenZone; + bool isVWapMidUnderValesGoldenZone; + bool isVWapFastCrossedUnderValesGoldenZone; + + // + bool isVWapFastOverPeaksGoldenZone; + bool isVWapMidOverPeaksGoldenZone; + bool isVWapFastCrossedOverPeaksGoldenZone; + + // + bool isVWapInsidePeaksGoldenZone; + bool isVWapCrossedInsidePeaksGoldenZone; + bool isVWapInsideValesGoldenZone; + bool isVWapCrossedInsideValesGoldenZone; + + // + bool isVWapBullishStateOverPeaksGoldenZone; + bool isVWapBearishStateOverPeaksGoldenZone; + bool isVWapSwitchedToBullishStateOverPeaksGoldenZone; + bool isVWapSwitchedToBearishStateOverPeaksGoldenZone; + + // + bool isVWapBullishOrderedOverPeaksGoldenZone; + bool isVWapBearishOrderedOverPeaksGoldenZone; + bool isVWapSwitchedToBullishOrderedOverPeaksGoldenZone; + bool isVWapSwitchedToBearishOrderedOverPeaksGoldenZone; + + // + bool isVWapBullishStateUnderValesGoldenZone; + bool isVWapBearishStateUnderValesGoldenZone; + bool isVWapSwitchedToBullishStateUnderValesGoldenZone; + bool isVWapSwitchedToBearishStateUnderValesGoldenZone; + + // + bool isVWapBullishOrderedUnderValesGoldenZone; + bool isVWapBearishOrderedUnderValesGoldenZone; + bool isVWapSwitchedToBullishOrderedUnderValesGoldenZone; + bool isVWapSwitchedToBearishOrderedUnderValesGoldenZone; + + // + // XHK ... + + // + // XRWHK ... + + // + bool isRawHKBearishOverPeaksGoldenZone; + bool isRawHKSwitchedToBearishOverPeaksGoldenZone; + bool isRawHKBullishUnderValesGoldenZone; + bool isRawHKSwitchedToBullishUnderValesGoldenZone; + + // + // XSMHK ... + + // + bool isSMHKBearishOverPeaksGoldenZone; + bool isSMHKSwitchedToBearishOverPeaksGoldenZone; + bool isSMHKBullishUnderValesGoldenZone; + bool isSMHKSwitchedToBullishUnderValesGoldenZone; + + // + // XATR ... + + // + bool isAtrUpperOverPeaksGoldenZone; + bool isAtrLowerOverPeaksGoldenZone; + bool isAtrOverPeaksGoldenZone; + bool isAtrCrossedOverPeaksGoldenZone; + + // + bool isAtrUpperUnderValesGoldenZone; + bool isAtrLowerUnderValesGoldenZone; + bool isAtrUnderValesGoldenZone; + bool isAtrCrossedUnderValesGoldenZone; + + // + // XSTR ... + + // + bool isStrBullishOverPeaksGoldenZone; + bool isStrBearishOverPeaksGoldenZone; + bool isStrSwitchedToBullishOverPeaksGoldenZone; + bool isStrSwitchedToBearishOverPeaksGoldenZone; + + // + bool isStrBullishUnderValesGoldenZone; + bool isStrBearishUnderValesGoldenZone; + bool isStrSwitchedToBullishUnderValesGoldenZone; + bool isStrSwitchedToBearishUnderValesGoldenZone; + + // + // XCHE ... + + // + bool isCheBullishOverPeaksGoldenZone; + bool isCheBearishOverPeaksGoldenZone; + bool isCheSwitchedBullishOverPeaksGoldenZone; + bool isCheSwitchedBearishOverPeaksGoldenZone; + + // + bool isCheBullishUnderValesGoldenZone; + bool isCheBearishUnderValesGoldenZone; + bool isCheSwitchedBullishUnderValesGoldenZone; + bool isCheSwitchedBearishUnderValesGoldenZone; + + // + // Constructor ... + X121SMCStrategyConditionParser() + { + Clean(); + } + + // + // Tools ... + + // + void Clean() + { + // + // XSAR ... + + // + isSarBullishOverPeaksGoldenZone = false; + isSarSwitchedToBullishOverPeaksGoldenZone = false; + isSarBearishOverPeaksGoldenZone = false; + isSarSwitchedToBearishOverPeaksGoldenZone = false; + isSarBullishUnderValesGoldenZone = false; + isSarSwitchedToBullishUnderValesGoldenZone = false; + isSarBearishUnderValesGoldenZone = false; + isSarSwitchedToBearishUnderValesGoldenZone = false; + + // + // X3MA ... + + // + isX3MaFastUnderValesGoldenZone = false; + isX3MaFastCrossedUnderValesGoldenZone = false; + isX3MaFastOverPeaksGoldenZone = false; + isX3MaFastCrossedOverPeaksGoldenZone = false; + + // + isX3MaInsidePeaksGoldenZone = false; + isX3MaCrossedInsidePeaksGoldenZone = false; + isX3MaInsideValesGoldenZone = false; + isX3MaCrossedInsideValesGoldenZone = false; + + // + isX3MaBullishStateOverPeaksGoldenZone = false; + isX3MaBearishStateOverPeaksGoldenZone = false; + isX3MaSwitchedToBullishStateOverPeaksGoldenZone = false; + isX3MaSwitchedToBearishStateOverPeaksGoldenZone = false; + + // + isX3MaBullishOrderedOverPeaksGoldenZone = false; + isX3MaBearishOrderedOverPeaksGoldenZone = false; + isX3MaSwitchedToBullishOrderedOverPeaksGoldenZone = false; + isX3MaSwitchedToBearishOrderedOverPeaksGoldenZone = false; + + // + isX3MaBullishStateUnderValesGoldenZone = false; + isX3MaBearishStateUnderValesGoldenZone = false; + isX3MaSwitchedToBullishStateUnderValesGoldenZone = false; + isX3MaSwitchedToBearishStateUnderValesGoldenZone = false; + + // + isX3MaBullishOrderedUnderValesGoldenZone = false; + isX3MaBearishOrderedUnderValesGoldenZone = false; + isX3MaSwitchedToBullishOrderedUnderValesGoldenZone = false; + isX3MaSwitchedToBearishOrderedUnderValesGoldenZone = false; + + // + // XVWAP ... + + // + isVWapFastUnderValesGoldenZone = false; + isVWapMidUnderValesGoldenZone = false; + isVWapFastCrossedUnderValesGoldenZone = false; + + // + isVWapFastOverPeaksGoldenZone = false; + isVWapMidOverPeaksGoldenZone = false; + isVWapFastCrossedOverPeaksGoldenZone = false; + + // + isVWapInsidePeaksGoldenZone = false; + isVWapCrossedInsidePeaksGoldenZone = false; + isVWapInsideValesGoldenZone = false; + isVWapCrossedInsideValesGoldenZone = false; + + // + isVWapBullishStateOverPeaksGoldenZone = false; + isVWapBearishStateOverPeaksGoldenZone = false; + isVWapSwitchedToBullishStateOverPeaksGoldenZone = false; + isVWapSwitchedToBearishStateOverPeaksGoldenZone = false; + + // + isVWapBullishOrderedOverPeaksGoldenZone = false; + isVWapBearishOrderedOverPeaksGoldenZone = false; + isVWapSwitchedToBullishOrderedOverPeaksGoldenZone = false; + isVWapSwitchedToBearishOrderedOverPeaksGoldenZone = false; + + // + isVWapBullishStateUnderValesGoldenZone = false; + isVWapBearishStateUnderValesGoldenZone = false; + isVWapSwitchedToBullishStateUnderValesGoldenZone = false; + isVWapSwitchedToBearishStateUnderValesGoldenZone = false; + + // + isVWapBullishOrderedUnderValesGoldenZone = false; + isVWapBearishOrderedUnderValesGoldenZone = false; + isVWapSwitchedToBullishOrderedUnderValesGoldenZone = false; + isVWapSwitchedToBearishOrderedUnderValesGoldenZone = false; + + // + // XHK ... + + // + // XRWHK ... + + // + isRawHKBearishOverPeaksGoldenZone = false; + isRawHKSwitchedToBearishOverPeaksGoldenZone = false; + isRawHKBullishUnderValesGoldenZone = false; + isRawHKSwitchedToBullishUnderValesGoldenZone = false; + + // + // XSMHK ... + + // + isSMHKBearishOverPeaksGoldenZone = false; + isSMHKSwitchedToBearishOverPeaksGoldenZone = false; + isSMHKBullishUnderValesGoldenZone = false; + isSMHKSwitchedToBullishUnderValesGoldenZone = false; + + // + // XATR ... + + // + isAtrUpperOverPeaksGoldenZone = false; + isAtrLowerOverPeaksGoldenZone = false; + isAtrOverPeaksGoldenZone = false; + isAtrCrossedOverPeaksGoldenZone = false; + + // + isAtrUpperUnderValesGoldenZone = false; + isAtrLowerUnderValesGoldenZone = false; + isAtrUnderValesGoldenZone = false; + isAtrCrossedUnderValesGoldenZone = false; + + // + // XSTR ... + + // + isStrBullishOverPeaksGoldenZone = false; + isStrBearishOverPeaksGoldenZone = false; + isStrSwitchedToBullishOverPeaksGoldenZone = false; + isStrSwitchedToBearishOverPeaksGoldenZone = false; + + // + isStrBullishUnderValesGoldenZone = false; + isStrBearishUnderValesGoldenZone = false; + isStrSwitchedToBullishUnderValesGoldenZone = false; + isStrSwitchedToBearishUnderValesGoldenZone = false; + + // + // XCHE ... + + // + isCheBullishOverPeaksGoldenZone = false; + isCheBearishOverPeaksGoldenZone = false; + isCheSwitchedBullishOverPeaksGoldenZone = false; + isCheSwitchedBearishOverPeaksGoldenZone = false; + + // + isCheBullishUnderValesGoldenZone = false; + isCheBearishUnderValesGoldenZone = false; + isCheSwitchedBullishUnderValesGoldenZone = false; + isCheSwitchedBearishUnderValesGoldenZone = false; + + // + ZeroMemory(this); + } + + // + void Parse( + X121Conditions &conditions // + ) + { + // + Clean(); + + // + // + int zIDX = 0; + int cIDX = zIDX + 1; + int pIDX = cIDX + 1; + + // + // XSAR ... + + // + isSarBullishOverPeaksGoldenZone = + conditions.isSarBullish && + conditions.sarBuffer[cIDX] > conditions.peaksGoldenBuffer[cIDX]; + + // + isSarSwitchedToBullishOverPeaksGoldenZone = + conditions.isSarSwitchedToBullish && + conditions.sarBuffer[cIDX] > conditions.peaksGoldenBuffer[cIDX]; + + // + isSarBearishOverPeaksGoldenZone = + conditions.isSarBearish && + conditions.sarBuffer[cIDX] > conditions.peaksGoldenBuffer[cIDX]; + + // + isSarSwitchedToBearishOverPeaksGoldenZone = + conditions.isSarSwitchedToBearish && + conditions.sarBuffer[cIDX] > conditions.peaksGoldenBuffer[cIDX]; + + // + isSarBullishUnderValesGoldenZone = + conditions.isSarBullish && + conditions.sarBuffer[cIDX] < conditions.valesGoldenBuffer[cIDX]; + + // + isSarSwitchedToBullishUnderValesGoldenZone = + conditions.isSarSwitchedToBullish && + conditions.sarBuffer[cIDX] < conditions.valesGoldenBuffer[cIDX]; + + // + isSarBearishUnderValesGoldenZone = + conditions.isSarBearish && + conditions.sarBuffer[cIDX] < conditions.valesGoldenBuffer[cIDX]; + + // + isSarSwitchedToBearishUnderValesGoldenZone = + conditions.isSarSwitchedToBearish && + conditions.sarBuffer[cIDX] < conditions.valesGoldenBuffer[cIDX]; + + // + // X3MA ... + + // + isX3MaFastUnderValesGoldenZone = + conditions.x3maFastBuffer[cIDX] < conditions.valesGoldenBuffer[cIDX]; + + // + isX3MaFastCrossedUnderValesGoldenZone = + isX3MaFastUnderValesGoldenZone && + conditions.x3maFastBuffer[pIDX] >= conditions.valesGoldenBuffer[pIDX]; + + // + isX3MaFastOverPeaksGoldenZone = + conditions.x3maFastBuffer[cIDX] > conditions.peaksGoldenBuffer[cIDX]; + + // + isX3MaFastCrossedOverPeaksGoldenZone = + isX3MaFastOverPeaksGoldenZone && + conditions.x3maFastBuffer[pIDX] <= conditions.peaksGoldenBuffer[pIDX]; + + // + isX3MaInsidePeaksGoldenZone = + // + conditions.x3maMin < conditions.peaksBuffer[cIDX] && + conditions.x3maMin > conditions.peaksGoldenBuffer[cIDX] && + // + conditions.x3maMax < conditions.peaksBuffer[cIDX] && + conditions.x3maMax > conditions.peaksGoldenBuffer[cIDX] + // + ; + + // + isX3MaCrossedInsidePeaksGoldenZone = + isX3MaInsidePeaksGoldenZone && + !( + // + conditions.x3maMin < conditions.peaksBuffer[pIDX] && + conditions.x3maMin > conditions.peaksGoldenBuffer[pIDX] && + // + conditions.x3maMax < conditions.peaksBuffer[pIDX] && + conditions.x3maMax > conditions.peaksGoldenBuffer[pIDX] + // + ); + + // + isX3MaInsideValesGoldenZone = + // + conditions.x3maMin > conditions.valesBuffer[cIDX] && + conditions.x3maMin < conditions.valesGoldenBuffer[cIDX] && + // + conditions.x3maMax > conditions.valesBuffer[cIDX] && + conditions.x3maMax < conditions.valesGoldenBuffer[cIDX] + // + ; + + isX3MaCrossedInsideValesGoldenZone = + isX3MaInsideValesGoldenZone && + !( + // + conditions.x3maMin > conditions.valesBuffer[pIDX] && + conditions.x3maMin < conditions.valesGoldenBuffer[pIDX] && + // + conditions.x3maMax > conditions.valesBuffer[pIDX] && + conditions.x3maMax < conditions.valesGoldenBuffer[pIDX] + // + ); + + // + isX3MaBullishStateOverPeaksGoldenZone = + isX3MaInsidePeaksGoldenZone && + conditions.isX3MaBullishState; + + // + isX3MaBearishStateOverPeaksGoldenZone = + isX3MaInsidePeaksGoldenZone && + conditions.isX3MaBearishState; + + // + isX3MaSwitchedToBullishStateOverPeaksGoldenZone = + isX3MaInsidePeaksGoldenZone && + conditions.isX3MaSwitchedToBullishState; + + // + isX3MaSwitchedToBearishStateOverPeaksGoldenZone = + isX3MaInsidePeaksGoldenZone && + conditions.isX3MaSwitchedToBearishState; + + // + isX3MaBullishOrderedOverPeaksGoldenZone = + isX3MaInsidePeaksGoldenZone && + conditions.isX3MaBullishOrdered; + + // + isX3MaBearishOrderedOverPeaksGoldenZone = + isX3MaInsidePeaksGoldenZone && + conditions.isX3MaBearishOrdered; + + // + isX3MaSwitchedToBullishOrderedOverPeaksGoldenZone = + isX3MaInsidePeaksGoldenZone && + conditions.isX3MaSwitchedToBullishOrdered; + + // + isX3MaSwitchedToBearishOrderedOverPeaksGoldenZone = + isX3MaInsidePeaksGoldenZone && + conditions.isX3MaSwitchedToBearishOrdered; + + // + isX3MaBullishStateUnderValesGoldenZone = + isX3MaInsideValesGoldenZone && + conditions.isX3MaBullishState; + + // + isX3MaBearishStateUnderValesGoldenZone = + isX3MaInsideValesGoldenZone && + conditions.isX3MaBearishState; + + // + isX3MaSwitchedToBullishStateUnderValesGoldenZone = + isX3MaInsideValesGoldenZone && + conditions.isX3MaSwitchedToBullishState; + + // + isX3MaSwitchedToBearishStateUnderValesGoldenZone = + isX3MaInsideValesGoldenZone && + conditions.isX3MaSwitchedToBearishState; + + // + isX3MaBullishOrderedUnderValesGoldenZone = + isX3MaInsideValesGoldenZone && + conditions.isX3MaBullishOrdered; + + // + isX3MaBearishOrderedUnderValesGoldenZone = + isX3MaInsideValesGoldenZone && + conditions.isX3MaBearishOrdered; + + // + isX3MaSwitchedToBullishOrderedUnderValesGoldenZone = + isX3MaInsideValesGoldenZone && + conditions.isX3MaSwitchedToBullishOrdered; + + // + isX3MaSwitchedToBearishOrderedUnderValesGoldenZone = + isX3MaInsideValesGoldenZone && + conditions.isX3MaSwitchedToBearishOrdered; + + // + // XVWAP ... + + // + isVWapFastUnderValesGoldenZone = + conditions.vwapFastBuffer[cIDX] < conditions.valesGoldenBuffer[cIDX]; + + // + isVWapMidUnderValesGoldenZone = + conditions.vwapMidBuffer[cIDX] < conditions.valesGoldenBuffer[cIDX]; + + // + isVWapFastCrossedUnderValesGoldenZone = + isVWapFastUnderValesGoldenZone && + conditions.vwapFastBuffer[pIDX] >= conditions.valesGoldenBuffer[pIDX]; + + // + isVWapFastOverPeaksGoldenZone = + conditions.vwapFastBuffer[cIDX] > conditions.peaksGoldenBuffer[cIDX]; + + // + isVWapMidOverPeaksGoldenZone = + conditions.vwapFastBuffer[cIDX] > conditions.peaksGoldenBuffer[cIDX]; + + // + isVWapFastCrossedOverPeaksGoldenZone = + isVWapFastOverPeaksGoldenZone && + conditions.vwapFastBuffer[pIDX] <= conditions.peaksGoldenBuffer[pIDX]; + + // + isVWapInsidePeaksGoldenZone = + // + conditions.vwapMin < conditions.peaksBuffer[cIDX] && + conditions.vwapMin > conditions.peaksGoldenBuffer[cIDX] && + // + conditions.vwapMax < conditions.peaksBuffer[cIDX] && + conditions.vwapMax > conditions.peaksGoldenBuffer[cIDX] + // + ; + + // + isVWapCrossedInsidePeaksGoldenZone = + isVWapInsidePeaksGoldenZone && + !( + // + conditions.vwapMin < conditions.peaksBuffer[pIDX] && + conditions.vwapMin > conditions.peaksGoldenBuffer[pIDX] && + // + conditions.vwapMax < conditions.peaksBuffer[pIDX] && + conditions.vwapMax > conditions.peaksGoldenBuffer[pIDX] + // + ); + + // + isVWapInsideValesGoldenZone = + // + conditions.vwapMin > conditions.valesBuffer[cIDX] && + conditions.vwapMin < conditions.valesGoldenBuffer[cIDX] && + // + conditions.vwapMax > conditions.valesBuffer[cIDX] && + conditions.vwapMax < conditions.valesGoldenBuffer[cIDX] + // + ; + + // + isVWapCrossedInsideValesGoldenZone = + isVWapInsideValesGoldenZone && + !( + // + conditions.vwapMin > conditions.valesBuffer[pIDX] && + conditions.vwapMin < conditions.valesGoldenBuffer[pIDX] && + // + conditions.vwapMax > conditions.valesBuffer[pIDX] && + conditions.vwapMax < conditions.valesGoldenBuffer[pIDX] + // + ); + + // + isVWapBullishStateOverPeaksGoldenZone = + isVWapInsidePeaksGoldenZone && + conditions.isVWapBullishState; + + // + isVWapBearishStateOverPeaksGoldenZone = + isVWapInsidePeaksGoldenZone && + conditions.isVWapBearishState; + + // + isVWapSwitchedToBullishStateOverPeaksGoldenZone = + isVWapInsidePeaksGoldenZone && + conditions.isVWapSwitchedToBullishState; + + // + isVWapSwitchedToBearishStateOverPeaksGoldenZone = + isVWapInsidePeaksGoldenZone && + conditions.isVWapSwitchedToBearishState; + + // + isVWapBullishOrderedOverPeaksGoldenZone = + isVWapInsidePeaksGoldenZone && + conditions.isVWapBullishOrdered; + + // + isVWapBearishOrderedOverPeaksGoldenZone = + isVWapInsidePeaksGoldenZone && + conditions.isVWapBearishOrdered; + + // + isVWapSwitchedToBullishOrderedOverPeaksGoldenZone = + isVWapInsidePeaksGoldenZone && + conditions.isVWapSwitchedToBullishOrdered; + + // + isVWapSwitchedToBearishOrderedOverPeaksGoldenZone = + isVWapInsidePeaksGoldenZone && + conditions.isVWapSwitchedToBearishOrdered; + + // + isVWapBullishStateUnderValesGoldenZone = + isVWapInsideValesGoldenZone && + conditions.isVWapBullishState; + + // + isVWapBearishStateUnderValesGoldenZone = + isVWapInsideValesGoldenZone && + conditions.isVWapBearishState; + + // + isVWapSwitchedToBullishStateUnderValesGoldenZone = + isVWapInsideValesGoldenZone && + conditions.isVWapSwitchedToBullishState; + + // + isVWapSwitchedToBearishStateUnderValesGoldenZone = + isVWapInsideValesGoldenZone && + conditions.isVWapSwitchedToBearishState; + + // + isVWapBullishOrderedUnderValesGoldenZone = + isVWapInsideValesGoldenZone && + conditions.isVWapBullishOrdered; + + // + isVWapBearishOrderedUnderValesGoldenZone = + isVWapInsideValesGoldenZone && + conditions.isVWapBearishOrdered; + + // + isVWapSwitchedToBullishOrderedUnderValesGoldenZone = + isVWapInsideValesGoldenZone && + conditions.isVWapSwitchedToBullishOrdered; + + // + isVWapSwitchedToBearishOrderedUnderValesGoldenZone = + isVWapInsideValesGoldenZone && + conditions.isVWapSwitchedToBearishOrdered; + + // + // XHK ... + + // + // XRWHK ... + + // + isRawHKBearishOverPeaksGoldenZone = + conditions.isRawHKBearish && + conditions.xhkRawHighBuffer[cIDX] > conditions.peaksGoldenBuffer[cIDX]; + + // + isRawHKSwitchedToBearishOverPeaksGoldenZone = + conditions.isRawHKSwitchedToBearish && + conditions.xhkRawHighBuffer[cIDX] > conditions.peaksGoldenBuffer[cIDX]; + + // + isRawHKBullishUnderValesGoldenZone = + conditions.isRawHKBullish && + conditions.xhkRawLowBuffer[cIDX] < conditions.valesGoldenBuffer[cIDX]; + + // + isRawHKSwitchedToBullishUnderValesGoldenZone = + conditions.isRawHKSwitchedToBullish && + conditions.xhkRawLowBuffer[cIDX] < conditions.valesGoldenBuffer[cIDX]; + + // + // XSMHK ... + + // + isSMHKBearishOverPeaksGoldenZone = + conditions.isSMHKBearish && + conditions.xhkSMHighBuffer[cIDX] > conditions.peaksGoldenBuffer[cIDX]; + + // + isSMHKSwitchedToBearishOverPeaksGoldenZone = + conditions.isSMHKSwitchedToBearish && + conditions.xhkSMHighBuffer[cIDX] > conditions.peaksGoldenBuffer[cIDX]; + + // + isSMHKBullishUnderValesGoldenZone = + conditions.isSMHKBullish && + conditions.xhkSMLowBuffer[cIDX] < conditions.valesGoldenBuffer[cIDX]; + + // + isSMHKSwitchedToBullishUnderValesGoldenZone = + conditions.isSMHKSwitchedToBullish && + conditions.xhkSMLowBuffer[cIDX] < conditions.valesGoldenBuffer[cIDX]; + + // + // XATR ... + + // + isAtrUpperOverPeaksGoldenZone = + conditions.atrUpperBuffer[cIDX] < conditions.peaksBuffer[cIDX] && + conditions.atrUpperBuffer[cIDX] > conditions.peaksGoldenBuffer[cIDX]; + + // + isAtrLowerOverPeaksGoldenZone = + conditions.atrLowerBuffer[cIDX] < conditions.peaksBuffer[cIDX] && + conditions.atrLowerBuffer[cIDX] > conditions.peaksGoldenBuffer[cIDX]; + + // + isAtrOverPeaksGoldenZone = + isAtrUpperOverPeaksGoldenZone && + isAtrLowerOverPeaksGoldenZone; + + // + isAtrCrossedOverPeaksGoldenZone = + isAtrOverPeaksGoldenZone && + !( + // + conditions.atrUpperBuffer[pIDX] < conditions.peaksBuffer[pIDX] && + conditions.atrUpperBuffer[pIDX] > conditions.peaksGoldenBuffer[pIDX] + // + && + // + conditions.atrLowerBuffer[pIDX] < conditions.peaksBuffer[pIDX] && + conditions.atrLowerBuffer[pIDX] > conditions.peaksGoldenBuffer[pIDX] + // + ); + + // + isAtrUpperUnderValesGoldenZone = + conditions.atrUpperBuffer[cIDX] > conditions.valesBuffer[cIDX] && + conditions.atrUpperBuffer[cIDX] < conditions.valesGoldenBuffer[cIDX]; + + // + isAtrLowerUnderValesGoldenZone = + conditions.atrLowerBuffer[cIDX] > conditions.valesBuffer[cIDX] && + conditions.atrLowerBuffer[cIDX] < conditions.valesGoldenBuffer[cIDX]; + + // + isAtrUnderValesGoldenZone = + isAtrUpperUnderValesGoldenZone && + isAtrLowerUnderValesGoldenZone; + + // + isAtrCrossedUnderValesGoldenZone = + isAtrUnderValesGoldenZone && + !( + // + conditions.atrUpperBuffer[pIDX] > conditions.valesBuffer[pIDX] && + conditions.atrUpperBuffer[pIDX] < conditions.valesGoldenBuffer[pIDX] + // + && + // + conditions.atrLowerBuffer[pIDX] > conditions.valesBuffer[pIDX] && + conditions.atrLowerBuffer[pIDX] < conditions.valesGoldenBuffer[pIDX] + // + ); + + // + // XSTR ... + + // + isStrBullishOverPeaksGoldenZone = + conditions.isStrBullish && + conditions.strBuffer[cIDX] < conditions.peaksBuffer[cIDX] && + conditions.strBuffer[cIDX] > conditions.peaksGoldenBuffer[cIDX]; + + // + isStrBearishOverPeaksGoldenZone = + conditions.isStrBearish && + conditions.strBuffer[cIDX] < conditions.peaksBuffer[cIDX] && + conditions.strBuffer[cIDX] > conditions.peaksGoldenBuffer[cIDX]; + + // + isStrSwitchedToBullishOverPeaksGoldenZone = + conditions.isStrSwitchedToBullish && + conditions.strBuffer[cIDX] < conditions.peaksBuffer[cIDX] && + conditions.strBuffer[cIDX] > conditions.peaksGoldenBuffer[cIDX]; + + // + isStrSwitchedToBearishOverPeaksGoldenZone = + conditions.isStrSwitchedToBearish && + conditions.strBuffer[cIDX] < conditions.peaksBuffer[cIDX] && + conditions.strBuffer[cIDX] > conditions.peaksGoldenBuffer[cIDX]; + + // + isStrBullishUnderValesGoldenZone = + conditions.isStrBullish && + conditions.strBuffer[cIDX] > conditions.valesBuffer[cIDX] && + conditions.strBuffer[cIDX] < conditions.valesGoldenBuffer[cIDX]; + + // + isStrBearishUnderValesGoldenZone = + conditions.isStrBearish && + conditions.strBuffer[cIDX] > conditions.valesBuffer[cIDX] && + conditions.strBuffer[cIDX] < conditions.valesGoldenBuffer[cIDX]; + + // + isStrSwitchedToBullishUnderValesGoldenZone = + conditions.isStrSwitchedToBullish && + conditions.strBuffer[cIDX] > conditions.valesBuffer[cIDX] && + conditions.strBuffer[cIDX] < conditions.valesGoldenBuffer[cIDX]; + + // + isStrSwitchedToBearishUnderValesGoldenZone = + conditions.isStrSwitchedToBearish && + conditions.strBuffer[cIDX] > conditions.valesBuffer[cIDX] && + conditions.strBuffer[cIDX] < conditions.valesGoldenBuffer[cIDX]; + + // + // XCHE ... + + // + isCheBullishOverPeaksGoldenZone = + conditions.isCheBullish && + conditions.le1Buffer[cIDX] < conditions.peaksBuffer[cIDX] && + conditions.le1Buffer[cIDX] > conditions.peaksGoldenBuffer[cIDX] && + conditions.le2Buffer[cIDX] < conditions.peaksBuffer[cIDX] && + conditions.le2Buffer[cIDX] > conditions.peaksGoldenBuffer[cIDX]; + + // + isCheBearishOverPeaksGoldenZone = + conditions.isCheSwitchedToBullish && + conditions.se1Buffer[cIDX] < conditions.peaksBuffer[cIDX] && + conditions.se1Buffer[cIDX] > conditions.peaksGoldenBuffer[cIDX] && + conditions.se2Buffer[cIDX] < conditions.peaksBuffer[cIDX] && + conditions.se2Buffer[cIDX] > conditions.peaksGoldenBuffer[cIDX]; + + // + isCheSwitchedBullishOverPeaksGoldenZone = + conditions.isCheSwitchedToBullish && + conditions.le1Buffer[cIDX] < conditions.peaksBuffer[cIDX] && + conditions.le1Buffer[cIDX] > conditions.peaksGoldenBuffer[cIDX] && + conditions.le2Buffer[cIDX] < conditions.peaksBuffer[cIDX] && + conditions.le2Buffer[cIDX] > conditions.peaksGoldenBuffer[cIDX]; + + // + isCheSwitchedBearishOverPeaksGoldenZone = + conditions.isCheSwitchedToBearish && + conditions.se1Buffer[cIDX] < conditions.peaksBuffer[cIDX] && + conditions.se1Buffer[cIDX] > conditions.peaksGoldenBuffer[cIDX] && + conditions.se2Buffer[cIDX] < conditions.peaksBuffer[cIDX] && + conditions.se2Buffer[cIDX] > conditions.peaksGoldenBuffer[cIDX]; + + // + isCheBullishUnderValesGoldenZone = + conditions.isCheBullish && + conditions.cheMin > conditions.valesBuffer[cIDX] && + conditions.cheMin < conditions.valesGoldenBuffer[cIDX] && + conditions.cheMax > conditions.valesBuffer[cIDX] && + conditions.cheMax < conditions.valesGoldenBuffer[cIDX]; + + // + isCheBearishUnderValesGoldenZone = + conditions.isCheBearish && + conditions.cheMin > conditions.valesBuffer[cIDX] && + conditions.cheMin < conditions.valesGoldenBuffer[cIDX] && + conditions.cheMax > conditions.valesBuffer[cIDX] && + conditions.cheMax < conditions.valesGoldenBuffer[cIDX]; + + // + isCheSwitchedBullishUnderValesGoldenZone = + conditions.isCheSwitchedToBullish && + conditions.cheMin > conditions.valesBuffer[cIDX] && + conditions.cheMin < conditions.valesGoldenBuffer[cIDX] && + conditions.cheMax > conditions.valesBuffer[cIDX] && + conditions.cheMax < conditions.valesGoldenBuffer[cIDX]; + + // + isCheSwitchedBearishUnderValesGoldenZone = + conditions.isCheSwitchedToBearish && + conditions.cheMin > conditions.valesBuffer[cIDX] && + conditions.cheMin < conditions.valesGoldenBuffer[cIDX] && + conditions.cheMax > conditions.valesBuffer[cIDX] && + conditions.cheMax < conditions.valesGoldenBuffer[cIDX]; + } + + // + // Rejected Boxes ... + bool HasRejectedBoxConditions( + ENUM_X_CYCLES cycle, + XSignalBox &box, + ENUM_X_DIRECTION &dir, + XSignalBox &waitingBoxes[], + X121SMCStrategySignalProviderData &provider, + int barIndex = 0 // + ) + { + // + bool result = false; + + // + box.Clean(); + dir = X_DIRECTION_NONE; + + // + // Checking Waiting Baoxes Exists ... + result = HasChild(waitingBoxes); + if (!result) + { + return result; + } + + // + // Fil Selected Data ... + XPOIState cState; + X121Conditions cXConditions; + XPOIStateEvents cStateEvents; + XC121SMCCycleHelper *cHelper; + X121SMCCycleConditions cConditions; + result = provider.SelectCycle( + cycle, + cState, + cStateEvents, + cXConditions, + cHelper, + cConditions // + ); + if (!result) + { + // + cState.Clean(); + ZeroMemory(cHelper); + cConditions.Clean(); + cXConditions.Clean(); + cStateEvents.Clean(); + + // + return result; + } + Parse(cXConditions); + + // + // Normalize Args ... + + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + int idx = -1; + int count = 0; + bool has = false; + + // + int zIDX = barIndex; + int cIDX = zIDX + 1; + int pIDX = cIDX + 1; + int ppIDX = pIDX + 1; + + // + bool isBullish = false; + bool isBearish = false; + + // + XOHCL zBar; + XOHCL cBar; + XOHCL pBar; + + // + // Initial Bars ... + result = zBar.Init( + cState.symbol, + cState.period, + barIndex // + ); + result = + result && + zBar.GetPreviousBar(cBar); + result = + result && + cBar.GetPreviousBar(pBar); + if (!result) + { + // + zBar.Clean(); + cBar.Clean(); + pBar.Clean(); + cState.Clean(); + ZeroMemory(cHelper); + cConditions.Clean(); + cXConditions.Clean(); + + // + return result; + } + + // + // Checking Bar Based on Positions State ... + ENUM_X_DIRECTION iBarPosDir; + bool isBarValidForDir = cHelper + .mBarAnalyser + .IsValidForPosition( + cBar, + iBarPosDir // + ); + bool isBarValidForBullish = + isBarValidForDir && + IsBullish(iBarPosDir); + bool isBarValidForBearish = + isBarValidForDir && + IsBearish(iBarPosDir); + + // + // Extract Selected Boxes ... + XBoxZone selectedBox; + XSignalBox iSignalBox; + count = ArraySize(waitingBoxes); + has = IsValidSize(count); + if (has) + { + // + for (int i = 0; i < count; i++) + { + // + XSignalBox iBox = waitingBoxes[i]; + + // + bool isBullish = iBox.ob.IsBullish(); + + // + bool isOBBullishRejected = + // + cBar.low < iBox.ob.upper && + cBar.GetDown() > iBox.ob.upper + // + ; + + // + bool isOBBearishRejected = + // + cBar.high > iBox.ob.lower && + cBar.GetUp() < iBox.ob.lower + // + ; + + // + has = + isBullish + ? isOBBullishRejected + : isOBBearishRejected; + + // + // Force Using OB ... + if (has) + { + // + iSignalBox = iBox; + if (!selectedBox.IsValid()) + { + selectedBox = iBox.ob; + } + iBox.Clean(); + break; + } + + // + iBox.Clean(); + } + } + result = + iSignalBox.IsValid() && + selectedBox.IsValid(); + if (!result) + { + // + zBar.Clean(); + cBar.Clean(); + pBar.Clean(); + cState.Clean(); + iSignalBox.Clean(); + selectedBox.Clean(); + ZeroMemory(cHelper); + cConditions.Clean(); + cXConditions.Clean(); + + // + return result; + } + + // + bool hasSignalBox = iSignalBox.IsValid(); + bool isSignalBoxBullish = IsBullish(iSignalBox.ob.dir); + + // + // Checking Other Conditions ... + bool isVWapSlowPassed = + isSignalBoxBullish + ? cXConditions.isVWapSlowBullish + : cXConditions.isVWapSlowBearish; + + // + // Bullish Conditions ... + isBullish = + // + // Base Condition ... + ( + // + hasSignalBox && + isVWapSlowPassed && + isSignalBoxBullish && + isBarValidForBullish + // + ) + // + ; + + // + // Bearish Conditions ... + isBearish = + // + // Base Condition ... + ( + // + hasSignalBox && + isVWapSlowPassed && + !isSignalBoxBullish && + isBarValidForBearish + // + ) + // + ; + + // + // Filling Requirements ... + result = + isBullish || + isBearish; + if (result) + { + // + dir = + isBullish + ? X_DIRECTION_BULLISH + : X_DIRECTION_BEARISH; + + // + box = iSignalBox; + box.UpdateTo(TimeCurrent()); + } + + // + // Check All Conditions ... + result = + box.IsValid() && + HasDirection(dir) && + (isBullish || + isBearish); + + // + // Cleanup Resources ... + zBar.Clean(); + cBar.Clean(); + pBar.Clean(); + cState.Clean(); + iSignalBox.Clean(); + selectedBox.Clean(); + ZeroMemory(cHelper); + cConditions.Clean(); + cStateEvents.Clean(); + cXConditions.Clean(); + + // + return result; + } + + // + // Activated Boxes ... + bool HasActivatedBoxConditions( + ENUM_X_CYCLES cycle, + XSignalBox &box, + ENUM_X_DIRECTION &dir, + XSignalBox &waitingBoxes[], + X121SMCStrategySignalProviderData &provider, + int barIndex = 0 // + ) + { + // + bool result = false; + + // + box.Clean(); + dir = X_DIRECTION_NONE; + + // + // Checking Waiting Baoxes Exists ... + result = HasChild(waitingBoxes); + if (!result) + { + return result; + } + + // + // Fil Selected Data ... + XPOIState cState; + X121Conditions cXConditions; + XPOIStateEvents cStateEvents; + XC121SMCCycleHelper *cHelper; + X121SMCCycleConditions cConditions; + result = provider.SelectCycle( + cycle, + cState, + cStateEvents, + cXConditions, + cHelper, + cConditions // + ); + if (!result) + { + // + cState.Clean(); + ZeroMemory(cHelper); + cConditions.Clean(); + cXConditions.Clean(); + cStateEvents.Clean(); + + // + return result; + } + Parse(cXConditions); + + // + // Normalize Args ... + + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + int idx = -1; + int count = 0; + bool has = false; + + // + int zIDX = barIndex; + int cIDX = zIDX + 1; + int pIDX = cIDX + 1; + int ppIDX = pIDX + 1; + + // + bool isBullish = false; + bool isBearish = false; + + // + XOHCL zBar; + XOHCL cBar; + XOHCL pBar; + + // + // Initial Bars ... + result = zBar.Init( + cState.symbol, + cState.period, + barIndex // + ); + result = + result && + zBar.GetPreviousBar(cBar); + result = + result && + cBar.GetPreviousBar(pBar); + if (!result) + { + // + zBar.Clean(); + cBar.Clean(); + pBar.Clean(); + cState.Clean(); + ZeroMemory(cHelper); + cConditions.Clean(); + cXConditions.Clean(); + + // + return result; + } + + // + // Checking Bar Based on Positions State ... + ENUM_X_DIRECTION iBarPosDir; + bool isBarValidForDir = cHelper + .mBarAnalyser + .IsValidForPosition( + cBar, + iBarPosDir // + ); + bool isBarValidForBullish = + isBarValidForDir && + IsBullish(iBarPosDir); + bool isBarValidForBearish = + isBarValidForDir && + IsBearish(iBarPosDir); + + // + // Extract Selected Boxes ... + XBoxZone selectedBox; + XSignalBox iSignalBox; + count = ArraySize(waitingBoxes); + has = IsValidSize(count); + if (has) + { + // + for (int i = 0; i < count; i++) + { + // + XSignalBox iBox = waitingBoxes[i]; + + // + bool isBullish = iBox.ob.IsBullish(); + + // + has = cBar.low < iBox.sharp.upper && + cBar.low > iBox.sharp.lower && + cBar.high > iBox.sharp.lower && + cBar.high < iBox.sharp.upper; + + // + // Force Using OB ... + if (has) + { + // + iSignalBox = iBox; + if (!selectedBox.IsValid()) + { + selectedBox = iBox.ob; + } + iBox.Clean(); + break; + } + + // + iBox.Clean(); + } + } + result = + iSignalBox.IsValid() && + selectedBox.IsValid(); + if (!result) + { + // + zBar.Clean(); + cBar.Clean(); + pBar.Clean(); + cState.Clean(); + iSignalBox.Clean(); + selectedBox.Clean(); + ZeroMemory(cHelper); + cConditions.Clean(); + cXConditions.Clean(); + + // + return result; + } + + // + bool hasSignalBox = iSignalBox.IsValid(); + bool isSignalBoxBullish = IsBullish(iSignalBox.ob.dir); + + // + // Checking Other Conditions ... + + // + // XVWAP ... + + // + bool isVWapSlopeBullish = + cXConditions.isVwapFastSlopeBullish && + cXConditions.isVwapMidSlopeBullish && + cXConditions.isVwapSlowSlopeBullish; + + // + bool isVWapSlopeBearish = + cXConditions.isVwapFastSlopeBearish && + cXConditions.isVwapMidSlopeBearish && + cXConditions.isVwapSlowSlopeBearish; + + // + bool isVWapBullishCondition = + (cXConditions.isVWapBullishOrdered && + cXConditions.isVWapSwitchedToBullishState) || + (cXConditions.isVWapBullishState && + cXConditions.isVWapSwitchedToBullishOrdered); + + // + bool isVWapBearishCondition = + (cXConditions.isVWapBearishOrdered && + cXConditions.isVWapSwitchedToBearishState) || + (cXConditions.isVWapBearishState && + cXConditions.isVWapSwitchedToBearishOrdered); + + // + // Bullish Conditions ... + isBullish = + // + // Base Condition ... + ( + // + hasSignalBox && + isSignalBoxBullish && + isVWapSlopeBullish && + isBarValidForBullish && + isVWapBullishCondition + // + ) + // + ; + + // + // Bearish Conditions ... + isBearish = + // + // Base Condition ... + ( + // + hasSignalBox && + isVWapSlopeBearish && + !isSignalBoxBullish && + isBarValidForBearish && + isVWapBearishCondition + // + ) + // + ; + + // + // Filling Requirements ... + result = + isBullish || + isBearish; + if (result) + { + // + dir = + isBullish + ? X_DIRECTION_BULLISH + : X_DIRECTION_BEARISH; + + // + box = iSignalBox; + box.UpdateTo(TimeCurrent()); + + // + // Provide TP/SL ... + + // + box.sl = isBullish + ? cXConditions.vwapMin + : cXConditions.vwapMax; + + // + box.tp = isBullish + ? box.sharp.upper + : box.sharp.lower; + } + + // + // Check All Conditions ... + result = + box.IsValid() && + HasDirection(dir) && + (isBullish || + isBearish); + + // + // Cleanup Resources ... + zBar.Clean(); + cBar.Clean(); + pBar.Clean(); + cState.Clean(); + iSignalBox.Clean(); + selectedBox.Clean(); + ZeroMemory(cHelper); + cConditions.Clean(); + cStateEvents.Clean(); + cXConditions.Clean(); + + // + return result; + } + + // + // Breaked Boxes ... + bool HasBreakedBoxConditions( + ENUM_X_CYCLES cycle, + XSignalBox &box, + ENUM_X_DIRECTION &dir, + XSignalBox &breakedBoxes[], + X121SMCStrategySignalProviderData &provider, + int barIndex = 0 // + ) + { + // + bool result = false; + + // + box.Clean(); + dir = X_DIRECTION_NONE; + + // + // Checking Waiting Baoxes Exists ... + result = HasChild(breakedBoxes); + if (!result) + { + return result; + } + + // + // Fil Selected Data ... + XPOIState cState; + X121Conditions cXConditions; + XPOIStateEvents cStateEvents; + XC121SMCCycleHelper *cHelper; + X121SMCCycleConditions cConditions; + result = provider.SelectCycle( + cycle, + cState, + cStateEvents, + cXConditions, + cHelper, + cConditions // + ); + if (!result) + { + // + cState.Clean(); + ZeroMemory(cHelper); + cConditions.Clean(); + cXConditions.Clean(); + cStateEvents.Clean(); + + // + return result; + } + Parse(cXConditions); + + // + // Normalize Args ... + + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + int idx = -1; + int count = 0; + bool has = false; + + // + int zIDX = barIndex; + int cIDX = zIDX + 1; + int pIDX = cIDX + 1; + int ppIDX = pIDX + 1; + + // + bool isBullish = false; + bool isBearish = false; + + // + XOHCL zBar; + XOHCL cBar; + XOHCL pBar; + + // + // Initial Bars ... + result = zBar.Init( + cState.symbol, + cState.period, + barIndex // + ); + result = + result && + zBar.GetPreviousBar(cBar); + result = + result && + cBar.GetPreviousBar(pBar); + if (!result) + { + // + zBar.Clean(); + cBar.Clean(); + pBar.Clean(); + cState.Clean(); + ZeroMemory(cHelper); + cConditions.Clean(); + cXConditions.Clean(); + + // + return result; + } + + // + // Checking Bar Based on Positions State ... + ENUM_X_DIRECTION iBarPosDir; + bool isBarValidForDir = cHelper + .mBarAnalyser + .IsValidForPosition( + cBar, + iBarPosDir // + ); + bool isBarValidForBullish = + isBarValidForDir && + IsBullish(iBarPosDir); + bool isBarValidForBearish = + isBarValidForDir && + IsBearish(iBarPosDir); + + // + // Extract Selected Boxes ... + XBoxZone selectedBox; + XSignalBox iSignalBox; + count = ArraySize(breakedBoxes); + has = IsValidSize(count); + if (has) + { + // + for (int i = 0; i < count; i++) + { + // + XSignalBox iBox = breakedBoxes[i]; + + // + bool isBullish = iBox.ob.IsBullish(); + + // + has = cBar.low < iBox.sharp.upper && + cBar.low > iBox.sharp.lower && + cBar.high > iBox.sharp.lower && + cBar.high < iBox.sharp.upper; + + // + // Force Using OB ... + if (has) + { + // + iSignalBox = iBox; + if (!selectedBox.IsValid()) + { + selectedBox = iBox.ob; + } + iBox.Clean(); + break; + } + + // + iBox.Clean(); + } + } + result = + iSignalBox.IsValid() && + selectedBox.IsValid(); + if (!result) + { + // + zBar.Clean(); + cBar.Clean(); + pBar.Clean(); + cState.Clean(); + iSignalBox.Clean(); + selectedBox.Clean(); + ZeroMemory(cHelper); + cConditions.Clean(); + cXConditions.Clean(); + + // + return result; + } + + // + bool hasSignalBox = iSignalBox.IsValid(); + bool isSignalBoxBullish = IsBullish(iSignalBox.ob.dir); + + // + // Checking Other Conditions ... + + // + // XVWAP ... + + // + bool isVWapSlopeBullish = + cXConditions.isVwapFastSlopeBullish && + cXConditions.isVwapMidSlopeBullish && + cXConditions.isVwapSlowSlopeBullish; + + // + bool isVWapSlopeBearish = + cXConditions.isVwapFastSlopeBearish && + cXConditions.isVwapMidSlopeBearish && + cXConditions.isVwapSlowSlopeBearish; + + // + bool isVWapBullishCondition = + (cXConditions.isVWapBullishOrdered && + cXConditions.isVWapSwitchedToBullishState) || + (cXConditions.isVWapBullishState && + cXConditions.isVWapSwitchedToBullishOrdered); + + // + bool isVWapBearishCondition = + (cXConditions.isVWapBearishOrdered && + cXConditions.isVWapSwitchedToBearishState) || + (cXConditions.isVWapBearishState && + cXConditions.isVWapSwitchedToBearishOrdered); + + // + // Bullish Conditions ... + isBullish = + // + // Base Condition ... + ( + // + hasSignalBox && + isSignalBoxBullish && + isVWapSlopeBullish && + isBarValidForBullish && + isVWapBullishCondition + // + ) + // + ; + + // + // Bearish Conditions ... + isBearish = + // + // Base Condition ... + ( + // + hasSignalBox && + isVWapSlopeBearish && + !isSignalBoxBullish && + isBarValidForBearish && + isVWapBearishCondition + // + ) + // + ; + + // + // Filling Requirements ... + result = + isBullish || + isBearish; + if (result) + { + // + dir = + isBullish + ? X_DIRECTION_BULLISH + : X_DIRECTION_BEARISH; + + // + box = iSignalBox; + box.UpdateTo(TimeCurrent()); + + // + // Provide TP/SL ... + + // + box.sl = isBullish + ? cXConditions.vwapMin + : cXConditions.vwapMax; + + // + box.tp = isBullish + ? box.sharp.upper + : box.sharp.lower; + } + + // + // Check All Conditions ... + result = + box.IsValid() && + HasDirection(dir) && + (isBullish || + isBearish); + + // + // Cleanup Resources ... + zBar.Clean(); + cBar.Clean(); + pBar.Clean(); + cState.Clean(); + iSignalBox.Clean(); + selectedBox.Clean(); + ZeroMemory(cHelper); + cConditions.Clean(); + cStateEvents.Clean(); + cXConditions.Clean(); + + // + return result; + } + + // + // XFVGMA ... + bool HasXFVGMAConditions( + ENUM_X_CYCLES cycle, + XSignalBox &box, + ENUM_X_DIRECTION &dir, + XSignalBox &waitingBoxes[], + X121SMCStrategySignalProviderData &provider, + int barIndex = 0 // + ) + { + // + bool result = false; + + // + box.Clean(); + dir = X_DIRECTION_NONE; + + // + result = HasChild(waitingBoxes); + if (!result) + { + return result; + } + + // + // Fil Selected Data ... + XPOIState cState; + X121Conditions cXConditions; + XPOIStateEvents cStateEvents; + XC121SMCCycleHelper *cHelper; + X121SMCCycleConditions cConditions; + result = provider.SelectCycle( + cycle, + cState, + cStateEvents, + cXConditions, + cHelper, + cConditions // + ); + if (!result) + { + // + cState.Clean(); + ZeroMemory(cHelper); + cConditions.Clean(); + cXConditions.Clean(); + cStateEvents.Clean(); + + // + return result; + } + Parse(cXConditions); + + // + // Normalize Args ... + + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + int idx = -1; + int count = 0; + bool has = false; + + // + int zIDX = barIndex; + int cIDX = zIDX + 1; + int pIDX = cIDX + 1; + int ppIDX = pIDX + 1; + + // + bool isBullish = false; + bool isBearish = false; + + // + XOHCL zBar; + XOHCL cBar; + XOHCL pBar; + + // + // Initial Bars ... + result = zBar.Init( + cState.symbol, + cState.period, + barIndex // + ); + result = + result && + zBar.GetPreviousBar(cBar); + result = + result && + cBar.GetPreviousBar(pBar); + if (!result) + { + // + zBar.Clean(); + cBar.Clean(); + pBar.Clean(); + cState.Clean(); + ZeroMemory(cHelper); + cConditions.Clean(); + cXConditions.Clean(); + + // + return result; + } + + // + // Select Waiting Box ... + XBoxZone selectedBox; + XSignalBox selectedSignalBox; + count = ArraySize(waitingBoxes); + for (int i = 0; i < count; i++) + { + // + XSignalBox iSBox = waitingBoxes[i]; + bool isBullish = iSBox.ob.IsBullish(); + + // + bool isInsidePassed = + isBullish + ? cBar.low < iSBox.ob.upper && + cBar.low > iSBox.ob.lower + : cBar.high > iSBox.ob.lower && + cBar.high < iSBox.ob.upper; + + // + bool isTypePassed = iSBox.sharp.type == "XSHPOBX"; + + // + has = isTypePassed && + isInsidePassed; + if (has) + { + // + selectedBox = iSBox.ob; + selectedSignalBox = iSBox; + break; + } + } + result = selectedBox.IsValid() && + selectedSignalBox.IsValid(); + if (!result) + { + // + zBar.Clean(); + cBar.Clean(); + pBar.Clean(); + cState.Clean(); + ZeroMemory(cHelper); + cConditions.Clean(); + selectedBox.Clean(); + cXConditions.Clean(); + selectedSignalBox.Clean(); + + // + return result; + } + + // + bool isSignalBoxBullish = selectedBox.IsBullish(); + + // + // Checking Other Conditions ... + + // + // Checking Bar Based on Positions State ... + ENUM_X_DIRECTION iBarPosDir; + bool isBarValidForDir = cHelper + .mBarAnalyser + .IsValidForPosition( + cBar, + iBarPosDir // + ); + bool isBarValidForBullish = + isBarValidForDir && + IsBullish(iBarPosDir); + bool isBarValidForBearish = + isBarValidForDir && + IsBearish(iBarPosDir); + + // + // Bullish Conditions ... + isBullish = + // + // Base Condition ... + ( + // + isSignalBoxBullish && + isBarValidForBullish + // + ) + // + ; + + // + // Bearish Conditions ... + isBearish = + // + // Base Condition ... + ( + // + !isSignalBoxBullish && + isBarValidForBearish + // + ) + // + ; + + // + // Filling Requirements ... + result = + isBullish || + isBearish; + if (result) + { + // + dir = + isBullish + ? X_DIRECTION_BULLISH + : X_DIRECTION_BEARISH; + + // + box = selectedSignalBox; + box.ob.to = TimeCurrent(); + } + + // + // Check All Conditions ... + result = + box.IsValid() && + HasDirection(dir) && + (isBullish || + isBearish); + + // + // Cleanup Resources ... + zBar.Clean(); + cBar.Clean(); + pBar.Clean(); + cState.Clean(); + selectedBox.Clean(); + ZeroMemory(cHelper); + cConditions.Clean(); + cStateEvents.Clean(); + cXConditions.Clean(); + selectedSignalBox.Clean(); + + // + return result; + } + + // + // XWPVZ ... + bool HasXWPVZConditions( + ENUM_X_CYCLES cycle, + XSignalBox &box, + ENUM_X_DIRECTION &dir, + X121SMCStrategySignalProviderData &provider, + int barIndex = 0 // + ) + { + // + bool result = false; + + // + box.Clean(); + dir = X_DIRECTION_NONE; + + // + // Fil Selected Data ... + XPOIState cState; + X121Conditions cXConditions; + XPOIStateEvents cStateEvents; + XC121SMCCycleHelper *cHelper; + X121SMCCycleConditions cConditions; + result = provider.SelectCycle( + cycle, + cState, + cStateEvents, + cXConditions, + cHelper, + cConditions // + ); + if (!result) + { + // + cState.Clean(); + ZeroMemory(cHelper); + cConditions.Clean(); + cXConditions.Clean(); + cStateEvents.Clean(); + + // + return result; + } + Parse(cXConditions); + + // + // Normalize Args ... + + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + int idx = -1; + int count = 0; + bool has = false; + + // + int zIDX = barIndex; + int cIDX = zIDX + 1; + int pIDX = cIDX + 1; + int ppIDX = pIDX + 1; + + // + bool isBullish = false; + bool isBearish = false; + + // + XOHCL zBar; + XOHCL cBar; + XOHCL pBar; + + // + // Initial Bars ... + result = zBar.Init( + cState.symbol, + cState.period, + barIndex // + ); + result = + result && + zBar.GetPreviousBar(cBar); + result = + result && + cBar.GetPreviousBar(pBar); + if (!result) + { + // + zBar.Clean(); + cBar.Clean(); + pBar.Clean(); + cState.Clean(); + ZeroMemory(cHelper); + cConditions.Clean(); + cXConditions.Clean(); + + // + return result; + } + + // + // Checking Other Conditions ... + + // + // Checking Bar Based on Positions State ... + ENUM_X_DIRECTION iBarPosDir; + bool isBarValidForDir = cHelper + .mBarAnalyser + .IsValidForPosition( + cBar, + iBarPosDir // + ); + bool isBarValidForBullish = + isBarValidForDir && + IsBullish(iBarPosDir); + bool isBarValidForBearish = + isBarValidForDir && + IsBearish(iBarPosDir); + + // + XCPOIDrawer *drawer = provider.visionCycleHelper.mPOIDrawer; + + if (result) + { + // + result = false; + Print("Salam"); + } + + // + // Bullish Conditions ... + isBullish = + // + // Base Condition ... + ( + // + false + // + ) + // + ; + + // + // Bearish Conditions ... + isBearish = + // + // Base Condition ... + ( + // + false + // + ) + // + ; + + // + // Filling Requirements ... + result = + isBullish || + isBearish; + if (result) + { + // + dir = + isBullish + ? X_DIRECTION_BULLISH + : X_DIRECTION_BEARISH; + + // + } + + // + // Check All Conditions ... + result = + box.IsValid() && + HasDirection(dir) && + (isBullish || + isBearish); + + // + // Cleanup Resources ... + zBar.Clean(); + cBar.Clean(); + pBar.Clean(); + cState.Clean(); + ZeroMemory(cHelper); + cConditions.Clean(); + cStateEvents.Clean(); + cXConditions.Clean(); + + // + return result; + } + + // +}; diff --git a/Helpers/x-saherelm.x121.helper.mq5 b/Helpers/x-saherelm.x121.helper.mq5 index 85624ce8..19f2286c 100644 --- a/Helpers/x-saherelm.x121.helper.mq5 +++ b/Helpers/x-saherelm.x121.helper.mq5 @@ -140,8 +140,8 @@ struct X121Inputs // int xpvMax = xpvInputs.Max(); - int xhkMax = xpvInputs.Max(); - int xmasMax = xpvInputs.Max(); + int xhkMax = xhkInputs.Max(); + int xmasMax = xmasInputs.Max(); int xatrMax = xatrInputs.Max(); int xstrMax = xstrInputs.Max(); int xcheMax = xcheInputs.Max(); diff --git a/Helpers/x-saherelm.x121.xstr.helper.mq5 b/Helpers/x-saherelm.x121.xstr.helper.mq5 index 31bf24f9..acfdaa14 100644 --- a/Helpers/x-saherelm.x121.xstr.helper.mq5 +++ b/Helpers/x-saherelm.x121.xstr.helper.mq5 @@ -92,7 +92,7 @@ struct X121XSTRInputs // strLength = 14; strMultiplier = 3.0; - strAppliedTo = PRICE_MEDIAN; + strAppliedTo = PRICE_CLOSE; // showStr = true; 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 ab2d1aac..1f69586e 100644 --- a/X121SMCEA/Classes/x-121.smc.market.cycle.helper.class.mq5 +++ b/X121SMCEA/Classes/x-121.smc.market.cycle.helper.class.mq5 @@ -1709,162 +1709,83 @@ struct X121SMCStrategyConditionParser // // Props ... - // - // XSAR ... - - // - bool isSarBullishOverPeaksGoldenZone; - bool isSarSwitchedToBullishOverPeaksGoldenZone; - bool isSarBearishOverPeaksGoldenZone; - bool isSarSwitchedToBearishOverPeaksGoldenZone; - bool isSarBullishUnderValesGoldenZone; - bool isSarSwitchedToBullishUnderValesGoldenZone; - bool isSarBearishUnderValesGoldenZone; - bool isSarSwitchedToBearishUnderValesGoldenZone; - // // XMA ... // bool isX3MaFastUnderValesGoldenZone; + bool isX3MaMidUnderValesGoldenZone; + bool isX3MaSlowUnderValesGoldenZone; + + // bool isX3MaFastCrossedUnderValesGoldenZone; + bool isX3MaMidCrossedUnderValesGoldenZone; + bool isX3MaSlowCrossedUnderValesGoldenZone; + + // bool isX3MaFastOverPeaksGoldenZone; + bool isX3MaMidOverPeaksGoldenZone; + bool isX3MaSlowOverPeaksGoldenZone; + + // bool isX3MaFastCrossedOverPeaksGoldenZone; - - // - bool isX3MaInsidePeaksGoldenZone; - bool isX3MaCrossedInsidePeaksGoldenZone; - bool isX3MaInsideValesGoldenZone; - bool isX3MaCrossedInsideValesGoldenZone; - - // - bool isX3MaBullishStateOverPeaksGoldenZone; - bool isX3MaBearishStateOverPeaksGoldenZone; - bool isX3MaSwitchedToBullishStateOverPeaksGoldenZone; - bool isX3MaSwitchedToBearishStateOverPeaksGoldenZone; - - // - bool isX3MaBullishOrderedOverPeaksGoldenZone; - bool isX3MaBearishOrderedOverPeaksGoldenZone; - bool isX3MaSwitchedToBullishOrderedOverPeaksGoldenZone; - bool isX3MaSwitchedToBearishOrderedOverPeaksGoldenZone; - - // - bool isX3MaBullishStateUnderValesGoldenZone; - bool isX3MaBearishStateUnderValesGoldenZone; - bool isX3MaSwitchedToBullishStateUnderValesGoldenZone; - bool isX3MaSwitchedToBearishStateUnderValesGoldenZone; - - // - bool isX3MaBullishOrderedUnderValesGoldenZone; - bool isX3MaBearishOrderedUnderValesGoldenZone; - bool isX3MaSwitchedToBullishOrderedUnderValesGoldenZone; - bool isX3MaSwitchedToBearishOrderedUnderValesGoldenZone; + bool isX3MaMidCrossedOverPeaksGoldenZone; + bool isX3MaSlowCrossedOverPeaksGoldenZone; // // XVWAP ... // bool isVWapFastUnderValesGoldenZone; + bool isVWapMidUnderValesGoldenZone; + bool isVWapSlowUnderValesGoldenZone; + + // bool isVWapFastCrossedUnderValesGoldenZone; + bool isVWapMidCrossedUnderValesGoldenZone; + bool isVWapSlowCrossedUnderValesGoldenZone; + + // bool isVWapFastOverPeaksGoldenZone; + bool isVWapMidOverPeaksGoldenZone; + bool isVWapSlowOverPeaksGoldenZone; + + // bool isVWapFastCrossedOverPeaksGoldenZone; - - // - bool isVWapInsidePeaksGoldenZone; - bool isVWapCrossedInsidePeaksGoldenZone; - bool isVWapInsideValesGoldenZone; - bool isVWapCrossedInsideValesGoldenZone; - - // - bool isVWapBullishStateOverPeaksGoldenZone; - bool isVWapBearishStateOverPeaksGoldenZone; - bool isVWapSwitchedToBullishStateOverPeaksGoldenZone; - bool isVWapSwitchedToBearishStateOverPeaksGoldenZone; - - // - bool isVWapBullishOrderedOverPeaksGoldenZone; - bool isVWapBearishOrderedOverPeaksGoldenZone; - bool isVWapSwitchedToBullishOrderedOverPeaksGoldenZone; - bool isVWapSwitchedToBearishOrderedOverPeaksGoldenZone; - - // - bool isVWapBullishStateUnderValesGoldenZone; - bool isVWapBearishStateUnderValesGoldenZone; - bool isVWapSwitchedToBullishStateUnderValesGoldenZone; - bool isVWapSwitchedToBearishStateUnderValesGoldenZone; - - // - bool isVWapBullishOrderedUnderValesGoldenZone; - bool isVWapBearishOrderedUnderValesGoldenZone; - bool isVWapSwitchedToBullishOrderedUnderValesGoldenZone; - bool isVWapSwitchedToBearishOrderedUnderValesGoldenZone; + bool isVWapMidCrossedOverPeaksGoldenZone; + bool isVWapSlowCrossedOverPeaksGoldenZone; // // XHK ... // - // XRWHK ... + bool isSMHKUnderValesGoldenZone; + bool isRawHKUnderValesGoldenZone; // - bool isRawHKBearishOverPeaksGoldenZone; - bool isRawHKSwitchedToBearishOverPeaksGoldenZone; - bool isRawHKBullishUnderValesGoldenZone; - bool isRawHKSwitchedToBullishUnderValesGoldenZone; + bool isSMHKCrossedUnderValesGoldenZone; + bool isRawHKCrossedUnderValesGoldenZone; // - // XSMHK ... + bool isSMHKOverPeaksGoldenZone; + bool isRawHKOverPeaksGoldenZone; // - bool isSMHKBearishOverPeaksGoldenZone; - bool isSMHKSwitchedToBearishOverPeaksGoldenZone; - bool isSMHKBullishUnderValesGoldenZone; - bool isSMHKSwitchedToBullishUnderValesGoldenZone; - - // - // XATR ... - - // - bool isAtrUpperOverPeaksGoldenZone; - bool isAtrLowerOverPeaksGoldenZone; - bool isAtrOverPeaksGoldenZone; - bool isAtrCrossedOverPeaksGoldenZone; - - // - bool isAtrUpperUnderValesGoldenZone; - bool isAtrLowerUnderValesGoldenZone; - bool isAtrUnderValesGoldenZone; - bool isAtrCrossedUnderValesGoldenZone; + bool isSMHKCrossedOverPeaksGoldenZone; + bool isRawHKCrossedOverPeaksGoldenZone; // // XSTR ... // - bool isStrBullishOverPeaksGoldenZone; - bool isStrBearishOverPeaksGoldenZone; - bool isStrSwitchedToBullishOverPeaksGoldenZone; - bool isStrSwitchedToBearishOverPeaksGoldenZone; + bool isStrUnderValesGoldenZone; + bool isStrCrossedUnderValesGoldenZone; // - bool isStrBullishUnderValesGoldenZone; - bool isStrBearishUnderValesGoldenZone; - bool isStrSwitchedToBullishUnderValesGoldenZone; - bool isStrSwitchedToBearishUnderValesGoldenZone; + bool isStrOverPeaksGoldenZone; + bool isStrCrossedOverPeaksGoldenZone; // - // XCHE ... - - // - bool isCheBullishOverPeaksGoldenZone; - bool isCheBearishOverPeaksGoldenZone; - bool isCheSwitchedBullishOverPeaksGoldenZone; - bool isCheSwitchedBearishOverPeaksGoldenZone; - - // - bool isCheBullishUnderValesGoldenZone; - bool isCheBearishUnderValesGoldenZone; - bool isCheSwitchedBullishUnderValesGoldenZone; - bool isCheSwitchedBearishUnderValesGoldenZone; // // Constructor ... @@ -1879,162 +1800,77 @@ struct X121SMCStrategyConditionParser // void Clean() { - // - // XSAR ... - - // - isSarBullishOverPeaksGoldenZone = false; - isSarSwitchedToBullishOverPeaksGoldenZone = false; - isSarBearishOverPeaksGoldenZone = false; - isSarSwitchedToBearishOverPeaksGoldenZone = false; - isSarBullishUnderValesGoldenZone = false; - isSarSwitchedToBullishUnderValesGoldenZone = false; - isSarBearishUnderValesGoldenZone = false; - isSarSwitchedToBearishUnderValesGoldenZone = false; - - // - // X3MA ... - // isX3MaFastUnderValesGoldenZone = false; isX3MaFastCrossedUnderValesGoldenZone = false; + + // + isX3MaMidUnderValesGoldenZone = false; + isX3MaMidCrossedUnderValesGoldenZone = false; + + // + isX3MaSlowUnderValesGoldenZone = false; + isX3MaSlowCrossedUnderValesGoldenZone = false; + + // isX3MaFastOverPeaksGoldenZone = false; isX3MaFastCrossedOverPeaksGoldenZone = false; // - isX3MaInsidePeaksGoldenZone = false; - isX3MaCrossedInsidePeaksGoldenZone = false; - isX3MaInsideValesGoldenZone = false; - isX3MaCrossedInsideValesGoldenZone = false; + isX3MaMidOverPeaksGoldenZone = false; + isX3MaMidCrossedOverPeaksGoldenZone = false; // - isX3MaBullishStateOverPeaksGoldenZone = false; - isX3MaBearishStateOverPeaksGoldenZone = false; - isX3MaSwitchedToBullishStateOverPeaksGoldenZone = false; - isX3MaSwitchedToBearishStateOverPeaksGoldenZone = false; - - // - isX3MaBullishOrderedOverPeaksGoldenZone = false; - isX3MaBearishOrderedOverPeaksGoldenZone = false; - isX3MaSwitchedToBullishOrderedOverPeaksGoldenZone = false; - isX3MaSwitchedToBearishOrderedOverPeaksGoldenZone = false; - - // - isX3MaBullishStateUnderValesGoldenZone = false; - isX3MaBearishStateUnderValesGoldenZone = false; - isX3MaSwitchedToBullishStateUnderValesGoldenZone = false; - isX3MaSwitchedToBearishStateUnderValesGoldenZone = false; - - // - isX3MaBullishOrderedUnderValesGoldenZone = false; - isX3MaBearishOrderedUnderValesGoldenZone = false; - isX3MaSwitchedToBullishOrderedUnderValesGoldenZone = false; - isX3MaSwitchedToBearishOrderedUnderValesGoldenZone = false; - - // - // XVWAP ... + isX3MaSlowOverPeaksGoldenZone = false; + isX3MaSlowCrossedOverPeaksGoldenZone = false; // isVWapFastUnderValesGoldenZone = false; isVWapFastCrossedUnderValesGoldenZone = false; + + // + isVWapMidUnderValesGoldenZone = false; + isVWapMidCrossedUnderValesGoldenZone = false; + + // + isVWapSlowUnderValesGoldenZone = false; + isVWapSlowCrossedUnderValesGoldenZone = false; + + // isVWapFastOverPeaksGoldenZone = false; isVWapFastCrossedOverPeaksGoldenZone = false; // - isVWapInsidePeaksGoldenZone = false; - isVWapCrossedInsidePeaksGoldenZone = false; - isVWapInsideValesGoldenZone = false; - isVWapCrossedInsideValesGoldenZone = false; + isVWapMidOverPeaksGoldenZone = false; + isVWapMidCrossedOverPeaksGoldenZone = false; // - isVWapBullishStateOverPeaksGoldenZone = false; - isVWapBearishStateOverPeaksGoldenZone = false; - isVWapSwitchedToBullishStateOverPeaksGoldenZone = false; - isVWapSwitchedToBearishStateOverPeaksGoldenZone = false; + isVWapSlowOverPeaksGoldenZone = false; + isVWapSlowCrossedOverPeaksGoldenZone = false; // - isVWapBullishOrderedOverPeaksGoldenZone = false; - isVWapBearishOrderedOverPeaksGoldenZone = false; - isVWapSwitchedToBullishOrderedOverPeaksGoldenZone = false; - isVWapSwitchedToBearishOrderedOverPeaksGoldenZone = false; + isSMHKUnderValesGoldenZone = false; + isSMHKCrossedUnderValesGoldenZone = false; // - isVWapBullishStateUnderValesGoldenZone = false; - isVWapBearishStateUnderValesGoldenZone = false; - isVWapSwitchedToBullishStateUnderValesGoldenZone = false; - isVWapSwitchedToBearishStateUnderValesGoldenZone = false; + isRawHKUnderValesGoldenZone = false; + isRawHKCrossedUnderValesGoldenZone = false; // - isVWapBullishOrderedUnderValesGoldenZone = false; - isVWapBearishOrderedUnderValesGoldenZone = false; - isVWapSwitchedToBullishOrderedUnderValesGoldenZone = false; - isVWapSwitchedToBearishOrderedUnderValesGoldenZone = false; + isSMHKOverPeaksGoldenZone = false; + isSMHKCrossedOverPeaksGoldenZone = false; // - // XHK ... + isRawHKOverPeaksGoldenZone = false; + isRawHKCrossedOverPeaksGoldenZone = false; // - // XRWHK ... + isStrUnderValesGoldenZone = false; + isStrCrossedUnderValesGoldenZone = false; // - isRawHKBearishOverPeaksGoldenZone = false; - isRawHKSwitchedToBearishOverPeaksGoldenZone = false; - isRawHKBullishUnderValesGoldenZone = false; - isRawHKSwitchedToBullishUnderValesGoldenZone = false; - - // - // XSMHK ... - - // - isSMHKBearishOverPeaksGoldenZone = false; - isSMHKSwitchedToBearishOverPeaksGoldenZone = false; - isSMHKBullishUnderValesGoldenZone = false; - isSMHKSwitchedToBullishUnderValesGoldenZone = false; - - // - // XATR ... - - // - isAtrUpperOverPeaksGoldenZone = false; - isAtrLowerOverPeaksGoldenZone = false; - isAtrOverPeaksGoldenZone = false; - isAtrCrossedOverPeaksGoldenZone = false; - - // - isAtrUpperUnderValesGoldenZone = false; - isAtrLowerUnderValesGoldenZone = false; - isAtrUnderValesGoldenZone = false; - isAtrCrossedUnderValesGoldenZone = false; - - // - // XSTR ... - - // - isStrBullishOverPeaksGoldenZone = false; - isStrBearishOverPeaksGoldenZone = false; - isStrSwitchedToBullishOverPeaksGoldenZone = false; - isStrSwitchedToBearishOverPeaksGoldenZone = false; - - // - isStrBullishUnderValesGoldenZone = false; - isStrBearishUnderValesGoldenZone = false; - isStrSwitchedToBullishUnderValesGoldenZone = false; - isStrSwitchedToBearishUnderValesGoldenZone = false; - - // - // XCHE ... - - // - isCheBullishOverPeaksGoldenZone = false; - isCheBearishOverPeaksGoldenZone = false; - isCheSwitchedBullishOverPeaksGoldenZone = false; - isCheSwitchedBearishOverPeaksGoldenZone = false; - - // - isCheBullishUnderValesGoldenZone = false; - isCheBearishUnderValesGoldenZone = false; - isCheSwitchedBullishUnderValesGoldenZone = false; - isCheSwitchedBearishUnderValesGoldenZone = false; + isStrOverPeaksGoldenZone = false; + isStrCrossedOverPeaksGoldenZone = false; // ZeroMemory(this); @@ -2055,574 +1891,431 @@ struct X121SMCStrategyConditionParser int pIDX = cIDX + 1; // - // XSAR ... + // Reading Required Materials ... // - isSarBullishOverPeaksGoldenZone = - conditions.isSarBullish && - conditions.sarBuffer[cIDX] > conditions.peaksGoldenBuffer[cIDX]; + // // - isSarSwitchedToBullishOverPeaksGoldenZone = - conditions.isSarSwitchedToBullish && - conditions.sarBuffer[cIDX] > conditions.peaksGoldenBuffer[cIDX]; + double peak = conditions.peaksBuffer[cIDX]; + double vale = conditions.valesBuffer[cIDX]; // - isSarBearishOverPeaksGoldenZone = - conditions.isSarBearish && - conditions.sarBuffer[cIDX] > conditions.peaksGoldenBuffer[cIDX]; + double peakP = conditions.peaksBuffer[pIDX]; + double valeP = conditions.valesBuffer[pIDX]; // - isSarSwitchedToBearishOverPeaksGoldenZone = - conditions.isSarSwitchedToBearish && - conditions.sarBuffer[cIDX] > conditions.peaksGoldenBuffer[cIDX]; + // // - isSarBullishUnderValesGoldenZone = - conditions.isSarBullish && - conditions.sarBuffer[cIDX] < conditions.valesGoldenBuffer[cIDX]; + double str = conditions.strBuffer[cIDX]; + double strP = conditions.strBuffer[pIDX]; // - isSarSwitchedToBullishUnderValesGoldenZone = - conditions.isSarSwitchedToBullish && - conditions.sarBuffer[cIDX] < conditions.valesGoldenBuffer[cIDX]; + // // - isSarBearishUnderValesGoldenZone = - conditions.isSarBearish && - conditions.sarBuffer[cIDX] < conditions.valesGoldenBuffer[cIDX]; + double smhkO = conditions.xhkSMOpenBuffer[cIDX]; + double smhkC = conditions.xhkSMCloseBuffer[cIDX]; // - isSarSwitchedToBearishUnderValesGoldenZone = - conditions.isSarSwitchedToBearish && - conditions.sarBuffer[cIDX] < conditions.valesGoldenBuffer[cIDX]; + double smhkMax = MathMax(smhkO, smhkC); + double smhkMin = MathMin(smhkO, smhkC); + + // + double smhkOP = conditions.xhkSMOpenBuffer[pIDX]; + double smhkCP = conditions.xhkSMCloseBuffer[pIDX]; + + // + double smhkMaxP = MathMax(smhkOP, smhkCP); + double smhkMinP = MathMin(smhkOP, smhkCP); + + // + double rawhkO = conditions.xhkRawOpenBuffer[cIDX]; + double rawhkH = conditions.xhkRawHighBuffer[cIDX]; + double rawhkC = conditions.xhkRawCloseBuffer[cIDX]; + double rawhkL = conditions.xhkRawLowBuffer[cIDX]; + + // + double rawhkOP = conditions.xhkRawOpenBuffer[pIDX]; + double rawhkHP = conditions.xhkRawHighBuffer[pIDX]; + double rawhkCP = conditions.xhkRawCloseBuffer[pIDX]; + double rawhkLP = conditions.xhkRawLowBuffer[pIDX]; + + // + // + + // + double support = conditions.supportsBuffer[cIDX]; + double resistance = conditions.resistancesBuffer[cIDX]; + + // + double supportP = conditions.supportsBuffer[pIDX]; + double resistanceP = conditions.resistancesBuffer[pIDX]; + + // + double peakGolden = conditions.peaksGoldenBuffer[cIDX]; + double valeGolden = conditions.valesGoldenBuffer[cIDX]; + + // + double peakGoldenP = conditions.peaksGoldenBuffer[pIDX]; + double valeGoldenP = conditions.valesGoldenBuffer[pIDX]; + + // + // + + // + double x3maFast = conditions.x3maFastBuffer[cIDX]; + double x3maMid = conditions.x3maMidBuffer[cIDX]; + double x3maSlow = conditions.x3maSlowBuffer[cIDX]; + + // + double x3maFastP = conditions.x3maFastBuffer[pIDX]; + double x3maMidP = conditions.x3maMidBuffer[pIDX]; + double x3maSlowP = conditions.x3maSlowBuffer[pIDX]; + + // + double vwapFast = conditions.vwapFastBuffer[cIDX]; + double vwapMid = conditions.vwapMidBuffer[cIDX]; + double vwapSlow = conditions.vwapSlowBuffer[cIDX]; + + // + double vwapFastP = conditions.vwapFastBuffer[pIDX]; + double vwapMidP = conditions.vwapMidBuffer[pIDX]; + double vwapSlowP = conditions.vwapSlowBuffer[pIDX]; // // X3MA ... // isX3MaFastUnderValesGoldenZone = - conditions.x3maFastBuffer[cIDX] < conditions.valesGoldenBuffer[cIDX]; + x3maFast >= vale && + x3maFast <= valeGolden; + + // + bool isX3MaFastUnderValesGoldenZoneP = + x3maFastP >= valeP && + x3maFastP <= valeGoldenP; // isX3MaFastCrossedUnderValesGoldenZone = isX3MaFastUnderValesGoldenZone && - conditions.x3maFastBuffer[pIDX] >= conditions.valesGoldenBuffer[pIDX]; + !isX3MaFastUnderValesGoldenZoneP; + + // + // + + // + isX3MaMidUnderValesGoldenZone = + x3maMid >= vale && + x3maMid <= valeGolden; + + // + bool isX3MaMidUnderValesGoldenZoneP = + x3maMidP >= valeP && + x3maMidP <= valeGoldenP; + + // + isX3MaMidCrossedUnderValesGoldenZone = + isX3MaMidUnderValesGoldenZone && + !isX3MaMidUnderValesGoldenZoneP; + + // + // + + // + isX3MaSlowUnderValesGoldenZone = + x3maSlow >= vale && + x3maSlow <= valeGolden; + + // + bool isX3MaSlowUnderValesGoldenZoneP = + x3maSlowP >= valeP && + x3maSlowP <= valeGoldenP; + + // + isX3MaSlowCrossedUnderValesGoldenZone = + isX3MaSlowUnderValesGoldenZone && + !isX3MaSlowUnderValesGoldenZoneP; + + // + // // isX3MaFastOverPeaksGoldenZone = - conditions.x3maFastBuffer[cIDX] > conditions.peaksGoldenBuffer[cIDX]; + x3maFast <= peak && + x3maFast >= peakGolden; + + // + bool isX3MaFastOverPeaksGoldenZoneP = + x3maFastP <= peakP && + x3maFastP >= peakGoldenP; // isX3MaFastCrossedOverPeaksGoldenZone = isX3MaFastOverPeaksGoldenZone && - conditions.x3maFastBuffer[pIDX] <= conditions.peaksGoldenBuffer[pIDX]; + !isX3MaFastOverPeaksGoldenZoneP; // - isX3MaInsidePeaksGoldenZone = - // - conditions.x3maMin < conditions.peaksBuffer[cIDX] && - conditions.x3maMin > conditions.peaksGoldenBuffer[cIDX] && - // - conditions.x3maMax < conditions.peaksBuffer[cIDX] && - conditions.x3maMax > conditions.peaksGoldenBuffer[cIDX] - // - ; + // // - isX3MaCrossedInsidePeaksGoldenZone = - isX3MaInsidePeaksGoldenZone && - !( - // - conditions.x3maMin < conditions.peaksBuffer[pIDX] && - conditions.x3maMin > conditions.peaksGoldenBuffer[pIDX] && - // - conditions.x3maMax < conditions.peaksBuffer[pIDX] && - conditions.x3maMax > conditions.peaksGoldenBuffer[pIDX] - // - ); + isX3MaMidOverPeaksGoldenZone = + x3maMid <= peak && + x3maMid >= peakGolden; // - isX3MaInsideValesGoldenZone = - // - conditions.x3maMin > conditions.valesBuffer[cIDX] && - conditions.x3maMin < conditions.valesGoldenBuffer[cIDX] && - // - conditions.x3maMax > conditions.valesBuffer[cIDX] && - conditions.x3maMax < conditions.valesGoldenBuffer[cIDX] - // - ; - - isX3MaCrossedInsideValesGoldenZone = - isX3MaInsideValesGoldenZone && - !( - // - conditions.x3maMin > conditions.valesBuffer[pIDX] && - conditions.x3maMin < conditions.valesGoldenBuffer[pIDX] && - // - conditions.x3maMax > conditions.valesBuffer[pIDX] && - conditions.x3maMax < conditions.valesGoldenBuffer[pIDX] - // - ); + bool isX3MaMidOverPeaksGoldenZoneP = + x3maMidP <= peakP && + x3maMidP >= peakGoldenP; // - isX3MaBullishStateOverPeaksGoldenZone = - isX3MaInsidePeaksGoldenZone && - conditions.isX3MaBullishState; + isX3MaMidCrossedOverPeaksGoldenZone = + isX3MaMidOverPeaksGoldenZone && + !isX3MaMidOverPeaksGoldenZoneP; // - isX3MaBearishStateOverPeaksGoldenZone = - isX3MaInsidePeaksGoldenZone && - conditions.isX3MaBearishState; + // // - isX3MaSwitchedToBullishStateOverPeaksGoldenZone = - isX3MaInsidePeaksGoldenZone && - conditions.isX3MaSwitchedToBullishState; + isX3MaSlowOverPeaksGoldenZone = + x3maSlow <= peak && + x3maSlow >= peakGolden; // - isX3MaSwitchedToBearishStateOverPeaksGoldenZone = - isX3MaInsidePeaksGoldenZone && - conditions.isX3MaSwitchedToBearishState; + bool isX3MaSlowOverPeaksGoldenZoneP = + x3maSlowP <= peakP && + x3maSlowP >= peakGoldenP; // - isX3MaBullishOrderedOverPeaksGoldenZone = - isX3MaInsidePeaksGoldenZone && - conditions.isX3MaBullishOrdered; - - // - isX3MaBearishOrderedOverPeaksGoldenZone = - isX3MaInsidePeaksGoldenZone && - conditions.isX3MaBearishOrdered; - - // - isX3MaSwitchedToBullishOrderedOverPeaksGoldenZone = - isX3MaInsidePeaksGoldenZone && - conditions.isX3MaSwitchedToBullishOrdered; - - // - isX3MaSwitchedToBearishOrderedOverPeaksGoldenZone = - isX3MaInsidePeaksGoldenZone && - conditions.isX3MaSwitchedToBearishOrdered; - - // - isX3MaBullishStateUnderValesGoldenZone = - isX3MaInsideValesGoldenZone && - conditions.isX3MaBullishState; - - // - isX3MaBearishStateUnderValesGoldenZone = - isX3MaInsideValesGoldenZone && - conditions.isX3MaBearishState; - - // - isX3MaSwitchedToBullishStateUnderValesGoldenZone = - isX3MaInsideValesGoldenZone && - conditions.isX3MaSwitchedToBullishState; - - // - isX3MaSwitchedToBearishStateUnderValesGoldenZone = - isX3MaInsideValesGoldenZone && - conditions.isX3MaSwitchedToBearishState; - - // - isX3MaBullishOrderedUnderValesGoldenZone = - isX3MaInsideValesGoldenZone && - conditions.isX3MaBullishOrdered; - - // - isX3MaBearishOrderedUnderValesGoldenZone = - isX3MaInsideValesGoldenZone && - conditions.isX3MaBearishOrdered; - - // - isX3MaSwitchedToBullishOrderedUnderValesGoldenZone = - isX3MaInsideValesGoldenZone && - conditions.isX3MaSwitchedToBullishOrdered; - - // - isX3MaSwitchedToBearishOrderedUnderValesGoldenZone = - isX3MaInsideValesGoldenZone && - conditions.isX3MaSwitchedToBearishOrdered; + isX3MaSlowCrossedOverPeaksGoldenZone = + isX3MaSlowOverPeaksGoldenZone && + !isX3MaSlowOverPeaksGoldenZoneP; // // XVWAP ... + // + // + // isVWapFastUnderValesGoldenZone = - conditions.vwapFastBuffer[cIDX] < conditions.valesGoldenBuffer[cIDX]; + vwapFast >= vale && + vwapFast <= valeGolden; + + // + bool isVWapFastUnderValesGoldenZoneP = + vwapFastP >= valeP && + vwapFastP <= valeGoldenP; // isVWapFastCrossedUnderValesGoldenZone = isVWapFastUnderValesGoldenZone && - conditions.vwapFastBuffer[pIDX] >= conditions.valesGoldenBuffer[pIDX]; + !isVWapFastUnderValesGoldenZoneP; + + // + // + + // + isVWapMidUnderValesGoldenZone = + vwapMid >= vale && + vwapMid <= valeGolden; + + // + bool isVWapMidUnderValesGoldenZoneP = + vwapMidP >= valeP && + vwapMidP <= valeGoldenP; + + // + isVWapMidCrossedUnderValesGoldenZone = + isVWapMidUnderValesGoldenZone && + !isVWapMidUnderValesGoldenZoneP; + + // + // + + // + isVWapSlowUnderValesGoldenZone = + vwapSlow >= vale && + vwapSlow <= valeGolden; + + // + bool isVWapSlowUnderValesGoldenZoneP = + vwapSlowP >= valeP && + vwapSlowP <= valeGoldenP; + + // + isVWapSlowCrossedUnderValesGoldenZone = + isVWapSlowUnderValesGoldenZone && + !isVWapSlowUnderValesGoldenZoneP; + + // + // // isVWapFastOverPeaksGoldenZone = - conditions.vwapFastBuffer[cIDX] > conditions.peaksGoldenBuffer[cIDX]; + vwapFast <= peak && + vwapFast >= peakGolden; + + // + bool isVWapFastOverPeaksGoldenZoneP = + vwapFastP <= peakP && + vwapFastP >= peakGoldenP; // isVWapFastCrossedOverPeaksGoldenZone = isVWapFastOverPeaksGoldenZone && - conditions.vwapFastBuffer[pIDX] <= conditions.peaksGoldenBuffer[pIDX]; + !isVWapFastOverPeaksGoldenZoneP; // - isVWapInsidePeaksGoldenZone = - // - conditions.vwapMin < conditions.peaksBuffer[cIDX] && - conditions.vwapMin > conditions.peaksGoldenBuffer[cIDX] && - // - conditions.vwapMax < conditions.peaksBuffer[cIDX] && - conditions.vwapMax > conditions.peaksGoldenBuffer[cIDX] - // - ; + // // - isVWapCrossedInsidePeaksGoldenZone = - isVWapInsidePeaksGoldenZone && - !( - // - conditions.vwapMin < conditions.peaksBuffer[pIDX] && - conditions.vwapMin > conditions.peaksGoldenBuffer[pIDX] && - // - conditions.vwapMax < conditions.peaksBuffer[pIDX] && - conditions.vwapMax > conditions.peaksGoldenBuffer[pIDX] - // - ); + isVWapMidOverPeaksGoldenZone = + vwapMid <= peak && + vwapMid >= peakGolden; // - isVWapInsideValesGoldenZone = - // - conditions.vwapMin > conditions.valesBuffer[cIDX] && - conditions.vwapMin < conditions.valesGoldenBuffer[cIDX] && - // - conditions.vwapMax > conditions.valesBuffer[cIDX] && - conditions.vwapMax < conditions.valesGoldenBuffer[cIDX] - // - ; + bool isVWapMidOverPeaksGoldenZoneP = + vwapMidP <= peakP && + vwapMidP >= peakGoldenP; // - isVWapCrossedInsideValesGoldenZone = - isVWapInsideValesGoldenZone && - !( - // - conditions.vwapMin > conditions.valesBuffer[pIDX] && - conditions.vwapMin < conditions.valesGoldenBuffer[pIDX] && - // - conditions.vwapMax > conditions.valesBuffer[pIDX] && - conditions.vwapMax < conditions.valesGoldenBuffer[pIDX] - // - ); + isVWapMidCrossedOverPeaksGoldenZone = + isVWapMidOverPeaksGoldenZone && + !isVWapMidOverPeaksGoldenZoneP; // - isVWapBullishStateOverPeaksGoldenZone = - isVWapInsidePeaksGoldenZone && - conditions.isVWapBullishState; + // // - isVWapBearishStateOverPeaksGoldenZone = - isVWapInsidePeaksGoldenZone && - conditions.isVWapBearishState; + isVWapSlowOverPeaksGoldenZone = + vwapSlow <= peak && + vwapSlow >= peakGolden; // - isVWapSwitchedToBullishStateOverPeaksGoldenZone = - isVWapInsidePeaksGoldenZone && - conditions.isVWapSwitchedToBullishState; + bool isVWapSlowOverPeaksGoldenZoneP = + vwapSlowP <= peakP && + vwapSlowP >= peakGoldenP; // - isVWapSwitchedToBearishStateOverPeaksGoldenZone = - isVWapInsidePeaksGoldenZone && - conditions.isVWapSwitchedToBearishState; - - // - isVWapBullishOrderedOverPeaksGoldenZone = - isVWapInsidePeaksGoldenZone && - conditions.isVWapBullishOrdered; - - // - isVWapBearishOrderedOverPeaksGoldenZone = - isVWapInsidePeaksGoldenZone && - conditions.isVWapBearishOrdered; - - // - isVWapSwitchedToBullishOrderedOverPeaksGoldenZone = - isVWapInsidePeaksGoldenZone && - conditions.isVWapSwitchedToBullishOrdered; - - // - isVWapSwitchedToBearishOrderedOverPeaksGoldenZone = - isVWapInsidePeaksGoldenZone && - conditions.isVWapSwitchedToBearishOrdered; - - // - isVWapBullishStateUnderValesGoldenZone = - isVWapInsideValesGoldenZone && - conditions.isVWapBullishState; - - // - isVWapBearishStateUnderValesGoldenZone = - isVWapInsideValesGoldenZone && - conditions.isVWapBearishState; - - // - isVWapSwitchedToBullishStateUnderValesGoldenZone = - isVWapInsideValesGoldenZone && - conditions.isVWapSwitchedToBullishState; - - // - isVWapSwitchedToBearishStateUnderValesGoldenZone = - isVWapInsideValesGoldenZone && - conditions.isVWapSwitchedToBearishState; - - // - isVWapBullishOrderedUnderValesGoldenZone = - isVWapInsideValesGoldenZone && - conditions.isVWapBullishOrdered; - - // - isVWapBearishOrderedUnderValesGoldenZone = - isVWapInsideValesGoldenZone && - conditions.isVWapBearishOrdered; - - // - isVWapSwitchedToBullishOrderedUnderValesGoldenZone = - isVWapInsideValesGoldenZone && - conditions.isVWapSwitchedToBullishOrdered; - - // - isVWapSwitchedToBearishOrderedUnderValesGoldenZone = - isVWapInsideValesGoldenZone && - conditions.isVWapSwitchedToBearishOrdered; + isVWapSlowCrossedOverPeaksGoldenZone = + isVWapSlowOverPeaksGoldenZone && + !isVWapSlowOverPeaksGoldenZoneP; // // XHK ... // - // XRWHK ... + // // - isRawHKBearishOverPeaksGoldenZone = - conditions.isRawHKBearish && - conditions.xhkRawHighBuffer[cIDX] > conditions.peaksGoldenBuffer[cIDX]; + isSMHKUnderValesGoldenZone = + smhkMax >= vale && + smhkMax <= valeGolden; // - isRawHKSwitchedToBearishOverPeaksGoldenZone = - conditions.isRawHKSwitchedToBearish && - conditions.xhkRawHighBuffer[cIDX] > conditions.peaksGoldenBuffer[cIDX]; + bool isSMHKUnderValesGoldenZoneP = + smhkMaxP >= valeP && + smhkMaxP <= valeGoldenP; // - isRawHKBullishUnderValesGoldenZone = - conditions.isRawHKBullish && - conditions.xhkRawLowBuffer[cIDX] < conditions.valesGoldenBuffer[cIDX]; + isSMHKCrossedUnderValesGoldenZone = + isSMHKUnderValesGoldenZone && + !isSMHKUnderValesGoldenZoneP; // - isRawHKSwitchedToBullishUnderValesGoldenZone = - conditions.isRawHKSwitchedToBullish && - conditions.xhkRawLowBuffer[cIDX] < conditions.valesGoldenBuffer[cIDX]; + // // - // XSMHK ... + isRawHKUnderValesGoldenZone = + rawhkH >= vale && + rawhkH <= valeGolden; // - isSMHKBearishOverPeaksGoldenZone = - conditions.isSMHKBearish && - conditions.xhkSMHighBuffer[cIDX] > conditions.peaksGoldenBuffer[cIDX]; + bool isRawHKUnderValesGoldenZoneP = + rawhkHP >= valeP && + rawhkHP <= valeGoldenP; // - isSMHKSwitchedToBearishOverPeaksGoldenZone = - conditions.isSMHKSwitchedToBearish && - conditions.xhkSMHighBuffer[cIDX] > conditions.peaksGoldenBuffer[cIDX]; + isRawHKCrossedUnderValesGoldenZone = + isRawHKUnderValesGoldenZone && + !isRawHKUnderValesGoldenZoneP; // - isSMHKBullishUnderValesGoldenZone = - conditions.isSMHKBullish && - conditions.xhkSMLowBuffer[cIDX] < conditions.valesGoldenBuffer[cIDX]; + // // - isSMHKSwitchedToBullishUnderValesGoldenZone = - conditions.isSMHKSwitchedToBullish && - conditions.xhkSMLowBuffer[cIDX] < conditions.valesGoldenBuffer[cIDX]; + isSMHKOverPeaksGoldenZone = + smhkMin <= peak && + smhkMin >= peakGolden; // - // XATR ... + bool isSMHKOverPeaksGoldenZoneP = + smhkMinP <= peakP && + smhkMinP >= peakGoldenP; // - isAtrUpperOverPeaksGoldenZone = - conditions.atrUpperBuffer[cIDX] < conditions.peaksBuffer[cIDX] && - conditions.atrUpperBuffer[cIDX] > conditions.peaksGoldenBuffer[cIDX]; + isSMHKCrossedOverPeaksGoldenZone = + isSMHKOverPeaksGoldenZone && + !isSMHKOverPeaksGoldenZoneP; // - isAtrLowerOverPeaksGoldenZone = - conditions.atrLowerBuffer[cIDX] < conditions.peaksBuffer[cIDX] && - conditions.atrLowerBuffer[cIDX] > conditions.peaksGoldenBuffer[cIDX]; + // // - isAtrOverPeaksGoldenZone = - isAtrUpperOverPeaksGoldenZone && - isAtrLowerOverPeaksGoldenZone; + isRawHKOverPeaksGoldenZone = + rawhkL <= peak && + rawhkL >= peakGolden; // - isAtrCrossedOverPeaksGoldenZone = - isAtrOverPeaksGoldenZone && - !( - // - conditions.atrUpperBuffer[pIDX] < conditions.peaksBuffer[pIDX] && - conditions.atrUpperBuffer[pIDX] > conditions.peaksGoldenBuffer[pIDX] - // - && - // - conditions.atrLowerBuffer[pIDX] < conditions.peaksBuffer[pIDX] && - conditions.atrLowerBuffer[pIDX] > conditions.peaksGoldenBuffer[pIDX] - // - ); + bool isRawHKOverPeaksGoldenZoneP = + rawhkLP <= peakP && + rawhkLP >= peakGoldenP; // - isAtrUpperUnderValesGoldenZone = - conditions.atrUpperBuffer[cIDX] > conditions.valesBuffer[cIDX] && - conditions.atrUpperBuffer[cIDX] < conditions.valesGoldenBuffer[cIDX]; - - // - isAtrLowerUnderValesGoldenZone = - conditions.atrLowerBuffer[cIDX] > conditions.valesBuffer[cIDX] && - conditions.atrLowerBuffer[cIDX] < conditions.valesGoldenBuffer[cIDX]; - - // - isAtrUnderValesGoldenZone = - isAtrUpperUnderValesGoldenZone && - isAtrLowerUnderValesGoldenZone; - - // - isAtrCrossedUnderValesGoldenZone = - isAtrUnderValesGoldenZone && - !( - // - conditions.atrUpperBuffer[pIDX] > conditions.valesBuffer[pIDX] && - conditions.atrUpperBuffer[pIDX] < conditions.valesGoldenBuffer[pIDX] - // - && - // - conditions.atrLowerBuffer[pIDX] > conditions.valesBuffer[pIDX] && - conditions.atrLowerBuffer[pIDX] < conditions.valesGoldenBuffer[pIDX] - // - ); + isRawHKCrossedOverPeaksGoldenZone = + isRawHKOverPeaksGoldenZone && + !isRawHKOverPeaksGoldenZoneP; // // XSTR ... // - isStrBullishOverPeaksGoldenZone = - conditions.isStrBullish && - conditions.strBuffer[cIDX] < conditions.peaksBuffer[cIDX] && - conditions.strBuffer[cIDX] > conditions.peaksGoldenBuffer[cIDX]; + // // - isStrBearishOverPeaksGoldenZone = - conditions.isStrBearish && - conditions.strBuffer[cIDX] < conditions.peaksBuffer[cIDX] && - conditions.strBuffer[cIDX] > conditions.peaksGoldenBuffer[cIDX]; + isStrUnderValesGoldenZone = + str >= vale && + str <= valeGolden; // - isStrSwitchedToBullishOverPeaksGoldenZone = - conditions.isStrSwitchedToBullish && - conditions.strBuffer[cIDX] < conditions.peaksBuffer[cIDX] && - conditions.strBuffer[cIDX] > conditions.peaksGoldenBuffer[cIDX]; + bool isStrUnderValesGoldenZoneP = + strP >= valeP && + strP <= valeGoldenP; // - isStrSwitchedToBearishOverPeaksGoldenZone = - conditions.isStrSwitchedToBearish && - conditions.strBuffer[cIDX] < conditions.peaksBuffer[cIDX] && - conditions.strBuffer[cIDX] > conditions.peaksGoldenBuffer[cIDX]; + isStrCrossedUnderValesGoldenZone = + isStrUnderValesGoldenZone && + !isStrUnderValesGoldenZoneP; // - isStrBullishUnderValesGoldenZone = - conditions.isStrBullish && - conditions.strBuffer[cIDX] > conditions.valesBuffer[cIDX] && - conditions.strBuffer[cIDX] < conditions.valesGoldenBuffer[cIDX]; + // // - isStrBearishUnderValesGoldenZone = - conditions.isStrBearish && - conditions.strBuffer[cIDX] > conditions.valesBuffer[cIDX] && - conditions.strBuffer[cIDX] < conditions.valesGoldenBuffer[cIDX]; + isStrOverPeaksGoldenZone = + str <= peak && + str >= peakGolden; // - isStrSwitchedToBullishUnderValesGoldenZone = - conditions.isStrSwitchedToBullish && - conditions.strBuffer[cIDX] > conditions.valesBuffer[cIDX] && - conditions.strBuffer[cIDX] < conditions.valesGoldenBuffer[cIDX]; + bool isStrOverPeaksGoldenZoneP = + strP <= peakP && + strP >= peakGoldenP; // - isStrSwitchedToBearishUnderValesGoldenZone = - conditions.isStrSwitchedToBearish && - conditions.strBuffer[cIDX] > conditions.valesBuffer[cIDX] && - conditions.strBuffer[cIDX] < conditions.valesGoldenBuffer[cIDX]; - - // - // XCHE ... - - // - isCheBullishOverPeaksGoldenZone = - conditions.isCheBullish && - conditions.le1Buffer[cIDX] < conditions.peaksBuffer[cIDX] && - conditions.le1Buffer[cIDX] > conditions.peaksGoldenBuffer[cIDX] && - conditions.le2Buffer[cIDX] < conditions.peaksBuffer[cIDX] && - conditions.le2Buffer[cIDX] > conditions.peaksGoldenBuffer[cIDX]; - - // - isCheBearishOverPeaksGoldenZone = - conditions.isCheSwitchedToBullish && - conditions.se1Buffer[cIDX] < conditions.peaksBuffer[cIDX] && - conditions.se1Buffer[cIDX] > conditions.peaksGoldenBuffer[cIDX] && - conditions.se2Buffer[cIDX] < conditions.peaksBuffer[cIDX] && - conditions.se2Buffer[cIDX] > conditions.peaksGoldenBuffer[cIDX]; - - // - isCheSwitchedBullishOverPeaksGoldenZone = - conditions.isCheSwitchedToBullish && - conditions.le1Buffer[cIDX] < conditions.peaksBuffer[cIDX] && - conditions.le1Buffer[cIDX] > conditions.peaksGoldenBuffer[cIDX] && - conditions.le2Buffer[cIDX] < conditions.peaksBuffer[cIDX] && - conditions.le2Buffer[cIDX] > conditions.peaksGoldenBuffer[cIDX]; - - // - isCheSwitchedBearishOverPeaksGoldenZone = - conditions.isCheSwitchedToBearish && - conditions.se1Buffer[cIDX] < conditions.peaksBuffer[cIDX] && - conditions.se1Buffer[cIDX] > conditions.peaksGoldenBuffer[cIDX] && - conditions.se2Buffer[cIDX] < conditions.peaksBuffer[cIDX] && - conditions.se2Buffer[cIDX] > conditions.peaksGoldenBuffer[cIDX]; - - // - isCheBullishUnderValesGoldenZone = - conditions.isCheBullish && - conditions.cheMin > conditions.valesBuffer[cIDX] && - conditions.cheMin < conditions.valesGoldenBuffer[cIDX] && - conditions.cheMax > conditions.valesBuffer[cIDX] && - conditions.cheMax < conditions.valesGoldenBuffer[cIDX]; - - // - isCheBearishUnderValesGoldenZone = - conditions.isCheBearish && - conditions.cheMin > conditions.valesBuffer[cIDX] && - conditions.cheMin < conditions.valesGoldenBuffer[cIDX] && - conditions.cheMax > conditions.valesBuffer[cIDX] && - conditions.cheMax < conditions.valesGoldenBuffer[cIDX]; - - // - isCheSwitchedBullishUnderValesGoldenZone = - conditions.isCheSwitchedToBullish && - conditions.cheMin > conditions.valesBuffer[cIDX] && - conditions.cheMin < conditions.valesGoldenBuffer[cIDX] && - conditions.cheMax > conditions.valesBuffer[cIDX] && - conditions.cheMax < conditions.valesGoldenBuffer[cIDX]; - - // - isCheSwitchedBearishUnderValesGoldenZone = - conditions.isCheSwitchedToBearish && - conditions.cheMin > conditions.valesBuffer[cIDX] && - conditions.cheMin < conditions.valesGoldenBuffer[cIDX] && - conditions.cheMax > conditions.valesBuffer[cIDX] && - conditions.cheMax < conditions.valesGoldenBuffer[cIDX]; + isStrCrossedOverPeaksGoldenZone = + isStrOverPeaksGoldenZone && + !isStrOverPeaksGoldenZoneP; } // @@ -3240,7 +2933,8 @@ struct X121SMCStrategyConditionParser XSignalBox &breakedBoxes[], X121SMCStrategySignalProviderData &provider, int barIndex = 0 // - ) { + ) + { // bool result = false; @@ -3425,7 +3119,7 @@ struct X121SMCStrategyConditionParser // // Checking Other Conditions ... - + // // XVWAP ... @@ -3801,5 +3495,181 @@ struct X121SMCStrategyConditionParser return result; } + // + // XWPVZ ... + bool HasXWPVZConditions( + ENUM_X_CYCLES cycle, + XSignalBox &box, + ENUM_X_DIRECTION &dir, + X121SMCStrategySignalProviderData &provider, + int barIndex = 0 // + ) + { + // + bool result = false; + + // + box.Clean(); + dir = X_DIRECTION_NONE; + + // + // Fil Selected Data ... + XPOIState cState; + X121Conditions cXConditions; + XPOIStateEvents cStateEvents; + XC121SMCCycleHelper *cHelper; + X121SMCCycleConditions cConditions; + result = provider.SelectCycle( + cycle, + cState, + cStateEvents, + cXConditions, + cHelper, + cConditions // + ); + if (!result) + { + // + cState.Clean(); + ZeroMemory(cHelper); + cConditions.Clean(); + cXConditions.Clean(); + cStateEvents.Clean(); + + // + return result; + } + Parse(cXConditions); + + // + // Normalize Args ... + + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + int idx = -1; + int count = 0; + bool has = false; + + // + int zIDX = barIndex; + int cIDX = zIDX + 1; + int pIDX = cIDX + 1; + int ppIDX = pIDX + 1; + + // + bool isBullish = false; + bool isBearish = false; + + // + XOHCL zBar; + XOHCL cBar; + XOHCL pBar; + + // + // Initial Bars ... + result = zBar.Init( + cState.symbol, + cState.period, + barIndex // + ); + result = + result && + zBar.GetPreviousBar(cBar); + result = + result && + cBar.GetPreviousBar(pBar); + if (!result) + { + // + zBar.Clean(); + cBar.Clean(); + pBar.Clean(); + cState.Clean(); + ZeroMemory(cHelper); + cConditions.Clean(); + cXConditions.Clean(); + + // + return result; + } + + // + XCPOIDrawer *drawer = provider.visionCycleHelper.mPOIDrawer; + + // + // Checking Other Conditions ... + + // + // Bullish Conditions ... + isBullish = + // + // Base Condition ... + ( + // + false + // + ) + // + ; + + // + // Bearish Conditions ... + isBearish = + // + // Base Condition ... + ( + // + false + // + ) + // + ; + + // + // Filling Requirements ... + result = + isBullish || + isBearish; + if (result) + { + // + dir = + isBullish + ? X_DIRECTION_BULLISH + : X_DIRECTION_BEARISH; + + // + result = false; + Print("Signal ..."); + } + + // + // Check All Conditions ... + result = + box.IsValid() && + HasDirection(dir) && + (isBullish || + isBearish); + + // + // Cleanup Resources ... + zBar.Clean(); + cBar.Clean(); + pBar.Clean(); + cState.Clean(); + ZeroMemory(cHelper); + cConditions.Clean(); + cStateEvents.Clean(); + cXConditions.Clean(); + + // + return result; + } + // }; diff --git a/X121SMCEA/Signals/x-121.smc.xwz.signal.class.mq5 b/X121SMCEA/Signals/x-121.smc.xwz.signal.class.mq5 index 583c7fe5..9dabc372 100644 --- a/X121SMCEA/Signals/x-121.smc.xwz.signal.class.mq5 +++ b/X121SMCEA/Signals/x-121.smc.xwz.signal.class.mq5 @@ -190,87 +190,87 @@ class XCX121SMCXWZSignalDetector : public XCBase // // First We Have to Has Working Zone ... - bool hasWorkingZone = workingZone.IsValid(); - if (!hasWorkingZone) - { - // - hasWorkingZone = workingZone.Init( - symbol, - period, - zIndex, - provider // - ); - } + // bool hasWorkingZone = workingZone.IsValid(); + // if (!hasWorkingZone) + // { + // // + // hasWorkingZone = workingZone.Init( + // symbol, + // period, + // zIndex, + // provider // + // ); + // } - // - // Update Working Zone ... - if (hasWorkingZone) - { - // - // Reset POI Detector Required POI(s) ... - provider.MaxRequiredPOIs(50); + // // + // // Update Working Zone ... + // if (hasWorkingZone) + // { + // // + // // Reset POI Detector Required POI(s) ... + // provider.MaxRequiredPOIs(50); - // - // Reset POI Detector Allowed Loopback ... - provider.MaxAllowedLoopbackForInit(578); + // // + // // Reset POI Detector Allowed Loopback ... + // provider.MaxAllowedLoopbackForInit(578); - // - // Check Working Zone Has Trend ... - hasTrend = workingZone.DetectTreand( - X_CYCLE_CONSOLIDATION, - trend, - provider, - zIndex // - ); + // // + // // Check Working Zone Has Trend ... + // hasTrend = workingZone.DetectTreand( + // X_CYCLE_CONSOLIDATION, + // trend, + // provider, + // zIndex // + // ); - // - // Detectiong Signal Boxes ... - hasWaitingBoxes = workingZone - .DetectWaitingBoxes( - X_CYCLE_ANALYSE, - X_CYCLE_DECISION, - provider, - zIndex // - ); - if (hasWaitingBoxes) - { - // - // Validate Working Zone Waiting Boxes ... - workingZone.ValidateWaitingBoxes(zIndex); + // // + // // Detectiong Signal Boxes ... + // // hasWaitingBoxes = workingZone + // // .DetectWaitingBoxes( + // // X_CYCLE_ANALYSE, + // // X_CYCLE_DECISION, + // // provider, + // // zIndex // + // // ); + // if (hasWaitingBoxes) + // { + // // + // // Validate Working Zone Waiting Boxes ... + // workingZone.ValidateWaitingBoxes(zIndex); - // - // Double Check Has Waiting Boxes or not ... - hasWaitingBoxes = workingZone.HasWaitingBoxes(); - } + // // + // // Double Check Has Waiting Boxes or not ... + // hasWaitingBoxes = workingZone.HasWaitingBoxes(); + // } - // - // Checking Working Zone Destory or not ... - bool isWorkingZoneDestroyed = workingZone.IsDestroyed( - zIndex, - period // - ); + // // + // // Checking Working Zone Destory or not ... + // bool isWorkingZoneDestroyed = workingZone.IsDestroyed( + // zIndex, + // period // + // ); - // - // Cleanup WorkingZone and ignore all conditions ... - if (isWorkingZoneDestroyed) - { - // - result = false; - workingZone.Clean(); - hasWorkingZone = false; + // // + // // Cleanup WorkingZone and ignore all conditions ... + // if (isWorkingZoneDestroyed) + // { + // // + // result = false; + // workingZone.Clean(); + // hasWorkingZone = false; - // - // Cleanup Resources ... - provider.Clean(); + // // + // // Cleanup Resources ... + // provider.Clean(); - // - mConditions.Clean(); - consolidationZBar.Clean(); + // // + // mConditions.Clean(); + // consolidationZBar.Clean(); - // - return result; - } - } + // // + // return result; + // } + // } // // Update Models To Time ... @@ -290,7 +290,7 @@ class XCX121SMCXWZSignalDetector : public XCBase // // Detect Signal Box ... hasSignalBox = - hasWorkingZone && + // hasWorkingZone && workingZone.DetectSignalConditions( signalBox, signalBoxDir, @@ -377,25 +377,25 @@ class XCX121SMCXWZSignalDetector : public XCBase // // Check Priority Exists ... - hasPriority = - hasWorkingZone && - workingZone - .DetectPriority( - priority, - signalBoxDir, - zIndex, - period // - ); + // hasPriority = + // hasWorkingZone && + // workingZone + // .DetectPriority( + // priority, + // signalBoxDir, + // zIndex, + // period // + // ); // // Check Price Reward and Amount Exists ... - hasRewardAmount = - hasWorkingZone && - CalculateRiskReward( - priority, - reward, - amountPercent // - ); + // hasRewardAmount = + // hasWorkingZone && + // CalculateRiskReward( + // priority, + // reward, + // amountPercent // + // ); // // Check Signal Conditions ... @@ -839,9 +839,10 @@ class XCX121SMCXWZSignalDetector : public XCBase // // Summarize Results ... - result = hasPriority && - hasSignalBox && - hasRewardAmount; + // result = hasPriority && + // hasSignalBox && + // hasRewardAmount; + result = hasSignalBox; // if (result) diff --git a/X121SMCEA/Signals/x-121.smc.xwz.signal.lib.mq5 b/X121SMCEA/Signals/x-121.smc.xwz.signal.lib.mq5 index ce9163d5..be3bf839 100644 --- a/X121SMCEA/Signals/x-121.smc.xwz.signal.lib.mq5 +++ b/X121SMCEA/Signals/x-121.smc.xwz.signal.lib.mq5 @@ -31,6 +31,7 @@ enum ENUM_X121SMC_XWZ_PROVIDERS { X121SMC_XWZ_PROVIDER_NONE, + X121SMC_XWZ_PROVIDER_XWPVZ, X121SMC_XWZ_PROVIDER_XFVGMA, X121SMC_XWZ_PROVIDER_XBREAKED_BOX, X121SMC_XWZ_PROVIDER_XREJECTED_BOX, @@ -1929,7 +1930,7 @@ struct X121SMCStrategyXWZWorkingZone // --------------------------------------------- // Rejected Box ... // --------------------------------------------- - bool useSenario1 = true; + bool useSenario1 = false; bool isSenario1Happend = false; bool isSenario1Bullish = false; bool isSenario1Bearish = false; @@ -1967,7 +1968,7 @@ struct X121SMCStrategyXWZWorkingZone // --------------------------------------------------- // Activated Box ... // --------------------------------------------------- - bool useSenario2 = true; + bool useSenario2 = false; bool isSenario2Happend = false; bool isSenario2Bullish = false; bool isSenario2Bearish = false; @@ -2006,7 +2007,7 @@ struct X121SMCStrategyXWZWorkingZone // --------------------------------------------------- // Breaked Box ... // --------------------------------------------------- - bool useSenario3 = true; + bool useSenario3 = false; bool isSenario3Happend = false; bool isSenario3Bullish = false; bool isSenario3Bearish = false; @@ -2046,7 +2047,7 @@ struct X121SMCStrategyXWZWorkingZone // ----------------------------------------------- // Detect Signal Box Based On FVG Conditions ... // ----------------------------------------------- - bool useSenario4 = true; + bool useSenario4 = false; bool isSenario4Happend = false; bool isSenario4Bullish = false; bool isSenario4Bearish = false; @@ -2085,8 +2086,9 @@ struct X121SMCStrategyXWZWorkingZone // // Senario 5: // --------------------------------------------- + // XWPVZ ... // --------------------------------------------- - bool useSenario5 = false; + bool useSenario5 = true; bool isSenario5Happend = false; bool isSenario5Bullish = false; bool isSenario5Bearish = false; @@ -2096,6 +2098,30 @@ struct X121SMCStrategyXWZWorkingZone !isSenario4Happend && useSenario5) { + // + isSenario5Happend = cParser.HasXWPVZConditions( + X_CYCLE_DECISION, + box, + dir, + provider, + barIndex // + ); + + // + isSenario5Bullish = + isSenario5Happend && + IsBullish(dir); + + // + isSenario5Bearish = + isSenario5Happend && + IsBearish(dir); + + // + if (isSenario5Happend) + { + signalProvider = X121SMC_XWZ_PROVIDER_XWPVZ; + } } // diff --git a/X121SMCEA/Strategy/x-121.smc.strategy.class.mq5 b/X121SMCEA/Strategy/x-121.smc.strategy.class.mq5 index f1047088..b1132fa9 100644 --- a/X121SMCEA/Strategy/x-121.smc.strategy.class.mq5 +++ b/X121SMCEA/Strategy/x-121.smc.strategy.class.mq5 @@ -755,7 +755,7 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy // x121Inputs.xatrInputs.atrMultiplier = 1.5; - x121Inputs.xatrInputs.atrSmoothingMode = X_MA_MODE_NONE; + x121Inputs.xatrInputs.atrSmoothingMode = X_MA_MODE_EMA; x121Inputs.xpvInputs.goldenZoneLevel = X_FIBO_LEVEL_236; // @@ -768,6 +768,16 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy x121Inputs.x3maInputs.x3maMidMALength = 50; x121Inputs.x3maInputs.x3maSlowMALength = 200; + // + // x121Inputs.xcheInputs.cheLength = 14; + // x121Inputs.xcheInputs.cheLoopback = 7; + // x121Inputs.xcheInputs.cheMultiplier1 = 1.5; + // x121Inputs.xcheInputs.cheMultiplier2 = 2; + + // + // x121Inputs.xstrInputs.strLength = 14; + // x121Inputs.xstrInputs.strMultiplier = 1.5; + // // x121Inputs.xccInputs.upColor = clrLime; // x121Inputs.xccInputs.downColor = clrRed; @@ -786,12 +796,12 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy // // XPV ... - x121Inputs.xpvInputs.showSar = showAll || false; - x121Inputs.xpvInputs.showPeaks = showAll || false; - x121Inputs.xpvInputs.showVales = showAll || false; + x121Inputs.xpvInputs.showSar = showAll || true; + x121Inputs.xpvInputs.showPeaks = showAll || true; + x121Inputs.xpvInputs.showVales = showAll || true; x121Inputs.xpvInputs.showSupports = showAll || false; x121Inputs.xpvInputs.showResistances = showAll || false; - x121Inputs.xpvInputs.showGoldenZones = showAll || false; + x121Inputs.xpvInputs.showGoldenZones = showAll || true; // // XHK ... @@ -804,9 +814,9 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy // XMAS ... // - x121Inputs.xmasInputs.showUpper = showAll || false; - x121Inputs.xmasInputs.showMid = showAll || false; - x121Inputs.xmasInputs.showLower = showAll || false; + x121Inputs.xmasInputs.showUpper = showAll || true; + x121Inputs.xmasInputs.showMid = showAll || true; + x121Inputs.xmasInputs.showLower = showAll || true; // // XATR ... @@ -835,9 +845,9 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy // // XVWAP ... - x121Inputs.xvwapInputs.showVWapFast = showAll || true; - x121Inputs.xvwapInputs.showVWapMedium = showAll || true; - x121Inputs.xvwapInputs.showVWapSlow = showAll || true; + x121Inputs.xvwapInputs.showVWapFast = showAll || false; + x121Inputs.xvwapInputs.showVWapMedium = showAll || false; + x121Inputs.xvwapInputs.showVWapSlow = showAll || false; // // X3MA ...