From a21799a9aa528532d28fe55869f6a8e95e4d8598 Mon Sep 17 00:00:00 2001 From: Hadi Khazaee Asl Date: Thu, 24 Apr 2025 02:26:21 +0330 Subject: [PATCH] implement valeSupSWL Pivots ... --- Documents/BKP/xcaea.signaller.class.mq5 | 878 ++ Documents/BKP/xcaea.x-poi.detector.class.mq5 | 7691 ++++++++++++++++++ Documents/BKP/xcaea.x-poi.drawer.class.mq5 | 2424 ++++++ Helpers/x-saherelm.x121.xca.helper.mq5 | 147 + XCAEA/Classes/xcaea.x-poi.detector.class.mq5 | 6819 +--------------- XCAEA/Classes/xcaea.x-poi.drawer.class.mq5 | 2555 +----- XCAEA/Helpers/xcaea.helper.mq5 | 92 +- XCAEA/Libraries/xcaea.signaller.lib.mq5 | 146 +- XCAEA/Signals/xcaea.signaller.class.mq5 | 209 +- 9 files changed, 12259 insertions(+), 8702 deletions(-) create mode 100644 Documents/BKP/xcaea.signaller.class.mq5 create mode 100644 Documents/BKP/xcaea.x-poi.detector.class.mq5 create mode 100644 Documents/BKP/xcaea.x-poi.drawer.class.mq5 diff --git a/Documents/BKP/xcaea.signaller.class.mq5 b/Documents/BKP/xcaea.signaller.class.mq5 new file mode 100644 index 00000000..e240ea00 --- /dev/null +++ b/Documents/BKP/xcaea.signaller.class.mq5 @@ -0,0 +1,878 @@ +/////////////////////////////////////////////////////// +// +// SaherElm IT Center MQL5 Indicator +// ------------------------------------------------- +// Name: XCXCAEASignaller ... +// Description: Class for XCAEA Signaller ... +// +// +// Maintainer: +// ------------ +// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com) +// +////////////////////////////////////////////////////// +// +// Global Properties ... +#property library +#property copyright "Copyright 2023, SaherElm IT Center" +#property link "https://saherelm.ir" +#property version "1.00" +#property description "SaherElm Class for XCAEA Signaller" +#property strict + +// +// Imports ... +#include "../../Classes/x-saherelm.base.class.mq5" +#include "../../Classes/x-saherelm.x-cobject.class.mq5" +#include "../Classes/xcaea.x-poi.detector.class.mq5" +#include "../Classes/xcaea.x-poi.drawer.class.mq5" +#include "../Helpers/xcaea.helper.mq5" +#include "../Libraries/xcaea.signaller.lib.mq5" + +// +// Definitions ... + +class XCXCAEASignaller : XCBase +{ + // + // Public ... + public: + // + // Props ... + bool useGuards; + XCAEAInputs inputs; + XBarTracker barTraker; + XCXCAEAHelper *helper; + XCXCAEAPOIDrawer *drawer; + bool continuesRFTillTarget; + XBoxZone unAvailableBoxes[]; + XCXCAEAPOIDetector *detector; + XCAEAStrategyConditions mConditions; + XCAEAStrategyConditions mConditionsCollection[]; + + // + // Constructor ... + XCXCAEASignaller( + string _symbol, + ENUM_TIMEFRAMES _period // + ) + { + // + symbol = _symbol; + period = _period; + + // + Init(); + } + + // + // Deconstructor ... + ~XCXCAEASignaller() + { + DeInit(); + } + + // + // Properties ... + + string GetSymbol() + { + return symbol; + } + + ENUM_TIMEFRAMES GetPeriod() + { + return period; + } + + // + // Signaller Tools ... + + /** + * Detect Setup Conditions based on Signalling ... + * + * @param maxAllowedSLDistanceInPoint: int, Max Allowed SL Distance in Points (if Bigger thn Zero Provided) ... + * + * @return ( bool ) + */ + bool DetectSignalSetup( + double tpReward = 3, + double maxAllowedSLDistanceInPoint = 100 // + ) + { + // + bool result = false; + + // + // Check Bar Processing ... + if (!barTraker.CanProcessBar()) + { + return result; + } + + // + bool isBullish = false; + bool isBearish = false; + + // + int zIndex = 0; + int cIndex = zIndex + 1; + int pIndex = cIndex + 1; + int ppIndex = pIndex + 1; + + // + int loopback = 10; + + // + int idx = -1; + int count = 0; + bool has = false; + + // + double ask = GetAsk(symbol); + double bid = GetBid(symbol); + datetime cTime = TimeCurrent(); + double points = GetPoints(symbol); + + // + XOHCL zBar; + XOHCL cBar; + XOHCL pBar; + XOHCL pPBar; + result = zBar.Init( + symbol, + period, + zIndex // + ); + result = + result && + zBar.GetPreviousBar(cBar); + result = + result && + cBar.GetPreviousBar(pBar); + result = + result && + pBar.GetPreviousBar(pPBar); + if (!result) + { + // + zBar.Clean(); + cBar.Clean(); + pBar.Clean(); + pPBar.Clean(); + + // + return result; + } + + // + // Setup Conditions ... + XBoxZone boxes[]; + XBoxZone pivotBox; + XBoxZone signalBox; + double additionalSL = 0; + XBoxZone bullishBoxes[]; + XBoxZone bearishBoxes[]; + bool hasSignalBox = false; + XCAEAConditions conditions; + ENUM_X_DIRECTION signalBoxDir = X_DIRECTION_NONE; + + // + // Detecting Pivots ... + detector.Update( + zIndex // + ); + + // + // Validate Pivots ... + detector.Validate( + unAvailableBoxes, + zIndex // + ); + + // + // Draw Founded Pivots ... + drawer.Draw(cTime); + + // + // Retrieve Valid Boxes ... + + // + // Bullish ... + int bullishBoxesCount = + detector + .FillBullishBoxes(bullishBoxes); + + // + // Bearish ... + int bearishBoxesCount = + detector + .FillBearishBoxes(bearishBoxes); + + // + Copy( + bullishBoxes, + boxes, + false // + ); + Copy( + bearishBoxes, + boxes, + false // + ); + int boxesCount = ArraySize(boxes); + bool hasBoxes = IsValidSize(boxesCount); + + // + // Filter UnAvailable Boxes ... + if (hasBoxes) + { + // + // Remove UnAvailable Boxes ... + has = HasChild(unAvailableBoxes); + if (has) + { + // + count = ArraySize(unAvailableBoxes); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox = unAvailableBoxes[i]; + + // + has = FindBoxIndex( + idx, + iBox, + boxes // + ); + if (has) + { + // + ArrayRemove( + boxes, + idx, + 1 // + ); + } + } + } + + // + hasBoxes = HasChild(boxes); + boxesCount = ArraySize(boxes); + } + + // + // + // + + // + // if (hasBoxes) + // { + // } + + // + // Detect Sinal Box ... + hasSignalBox = DetectXCAEAConditions( + boxes, + conditions, + pivotBox, + signalBox, + additionalSL, + signalBoxDir, + helper, + zIndex, + loopback // + ); + + // + // Make Pivot Box UnAvailable ... + if (pivotBox.IsValid()) + { + // + AddRef( + pivotBox, + unAvailableBoxes // + ); + } + + // + isBullish = hasSignalBox && + IsBullish(signalBoxDir); + + // + isBearish = hasSignalBox && + IsBearish(signalBoxDir); + + // + result = isBullish || + isBearish; + if (result) + { + // + // Do What we Want ... + barTraker.Waits(); + + // + // Draw Signal Box ... + XCBoxObject *iObj; + bool isCreated = helper.poiDrawer.DrawBox( + signalBox, + iObj // + ); + if (isCreated) + { + // + mObjects.Add(iObj); + ZeroMemory(iObj); + + // + Print("Signal Box ..."); + } + + // + // Prepare Conditions ... + mConditions.symbol = symbol; + mConditions.period = period; + + // + double spread = GetSpread(symbol); + + // + double entry = + isBullish + ? signalBox.upper + : signalBox.lower; + + // + double sl = + isBullish + ? signalBox.lower + : signalBox.upper; + if (additionalSL > 0) + { + // + sl = + isBullish + ? sl - additionalSL + : sl + additionalSL; + } + + // + double risk = + isBullish + ? entry - sl + : sl - entry; + risk += spread; + if (risk >= maxAllowedSLDistanceInPoint * points) + { + // + // Fix Risk in Big Distances ... + double hh5 = zBar.FindHighest(5, MODE_HIGH); + double ll5 = zBar.FindLowest(5, MODE_LOW); + + // + double hhll5Delta = hh5 - ll5; + double riskDelta = hhll5Delta / 2; + risk = riskDelta; + } + + // + double rewardTP = risk * tpReward; + + // + double tp = + isBullish + ? entry + rewardTP + : entry - rewardTP; + + // + // Filling ... + mConditions.sl = sl; + mConditions.tp = tp; + mConditions.pivot = + isBullish + ? sl + : entry; + mConditions.point = + isBullish + ? entry + : sl; + mConditions.dir = signalBoxDir; + mConditions.provider = "XCAEA"; + mConditions.signalBox = signalBox; + mConditions.setupTime = zBar.time; + mConditions.conditions = conditions; + + // + // Select RF Rewards ... + if (continuesRFTillTarget) + { + // + double rfReward = 1; + while (rfReward < tpReward) + { + // + double rewardRF = risk * rfReward; + double rfTP = + isBullish + ? entry + rewardRF + : entry - rewardRF; + + // + Add( + rfTP, + mConditions.targets // + ); + + // + rfReward++; + } + } + else + { + // + double rfReward = 1; + + // + double rewardRF = risk * rfReward; + double rfTP = + isBullish + ? entry + rewardRF + : entry - rewardRF; + + // + Add( + rfTP, + mConditions.targets // + ); + } + } + + // + // Cleanup Resource ... + + // + Clean(boxes); + Clean(bullishBoxes); + Clean(bearishBoxes); + + // + zBar.Clean(); + cBar.Clean(); + pBar.Clean(); + pPBar.Clean(); + + // + pivotBox.Clean(); + signalBox.Clean(); + conditions.Clean(); + + // + return result; + } + + /** + * Detect Trigger Conditions for Specified Signal ... + * + * @param conditions: XCAEAStrategyConditions instance Reference, Specified Signal Conditions ... + * @param maxAllowedSetupAge: specified Setup Age for Expiration (if bigger than Zero) ... + * + * @return ( bool ) + */ + bool DetectSignalTrigger( + XCAEAStrategyConditions &conditions, + int maxAllowedSetupAge = 60 // + ) + { + // + bool result = false; + + // + result = conditions.IsSetuped(); + if (!result) + { + return result; + } + + // + datetime setupTime = conditions.setupTime; + ENUM_X_DIRECTION setupDir = conditions.dir; + + // + bool isBullish = IsBullish(setupDir); + bool isBearish = IsBearish(setupDir); + + // + int zIndex = 0; + int cIndex = zIndex + 1; + int pIndex = cIndex + 1; + int ppIndex = pIndex + 1; + + // + int loopback = 10; + + // + double ask = GetAsk(symbol); + double bid = GetBid(symbol); + datetime cTime = TimeCurrent(); + double points = GetPoints(symbol); + + // + // Check Signal Validation ... + // IMPORTANT: since all Validations done in SetUp Process ... + // here we only Execute Signal ... + + // + result = isBullish || + isBearish; + + // + if (result) + { + // + conditions.triggerTime = cTime; + conditions.type = isBullish + ? X_POSITION_TYPE_LONG + : X_POSITION_TYPE_SHORT; + + // + } + + // + // Cleanup ... + + // + return result; + } + + /** + * Detect Guards bsed on Signalling Class ... + * + * @param guards: XCAEAGuard instance Collection, Holds Provided Guards ... + * @param positions: XPosition instance Collection, Provides Signalling Based Positions for Apply Guards on them ... + * @param provider: X121SMCStrategySignalProviderData instance Reference, Specified Data for Cycles ... + * + * @return ( bool ) + */ + bool DetectGuards( + XCAEAGuard &guards[], + const XPosition &positions[] // + ) + { + // + bool result = false; + + // + return result; + } + + /** + * Add Conditions to Conditions Collection if not Exists ... + * + * @param maxAllowed: int, Specified Max Allowed Holding Conditions ... + * + * @return ( int ) + */ + int AddConditionsIfNotExists( + int maxAllowed = 10 // + ) + { + // + int result = 0; + + // + bool isSetuped = IsValid(mConditions.setupTime) && + HasDirection(mConditions.dir); + if (!isSetuped) + { + return result; + } + + // + int count = ArraySize(mConditionsCollection); + if (IsValidSize(count)) + { + // + // Copy Original Items ... + XCAEAStrategyConditions tmpItems[]; + Copy( + mConditionsCollection, + tmpItems // + ); + + // + // Prese Item Data ... + bool isBullish = IsBullish(mConditions.dir); + + // + for (int i = 0; i < count; i++) + { + // + XCAEAStrategyConditions iItem = tmpItems[i]; + + // + bool canRemove = mConditions.dir == iItem.dir && + mConditions.pivot == iItem.pivot; + if (canRemove) + { + // + ArrayRemove( + mConditionsCollection, + i, + 1 // + ); + } + } + + // + Clean(tmpItems); + } + + // + AddRef( + mConditions, + mConditionsCollection // + ); + + // + // Remove Olds ... + CleanupArray( + mConditionsCollection, + maxAllowed // + ); + + // + result = ArraySize(mConditionsCollection); + + // + return result; + } + + // + // Protected ... + protected: + // + + // + // Private ... + private: + // + // Props ... + string symbol; + ENUM_TIMEFRAMES period; + CArrayObj mObjects; + CArrayObj mBarObjects; + + /** + * Initialize ... + */ + void Init() + { + // + useGuards = false; + continuesRFTillTarget = true; + + // + barTraker.Init( + symbol, + period // + ); + + // + inputs.Default(); + + // + // Configure Indicators ... + + // + // XCC ... + inputs.ccInputs.showCandles = true; + + // + // XCT ... + inputs.ctInputs.showCandleTime = true; + + // + // XCA ... + + // + inputs.caInputs.supResSmoothingLength = 7; + inputs.caInputs.supResSmoothingMode = X_MA_MODE_NONE; + + // + inputs.caInputs.showKI = true; + inputs.caInputs.showTKI = false; + inputs.caInputs.showSar = false; + inputs.caInputs.showVidya = true; + inputs.caInputs.showTrend = false; + inputs.caInputs.showSwings = false; + inputs.caInputs.showLongCycle = false; + inputs.caInputs.showHindCycle = false; + inputs.caInputs.showFiboLevel1 = false; + inputs.caInputs.showFiboLevel2 = false; + inputs.caInputs.showFiboLevel3 = false; + inputs.caInputs.showShortCycle = false; + inputs.caInputs.showMediumCycle = false; + inputs.caInputs.showPeaksAndVales = true; + inputs.caInputs.showPeakAndValeGolden = false; + inputs.caInputs.showSupportAndResistance = false; + + // + // XOSCS ... + // inputs.oscsInputs.rsiLength = 5; + // inputs.oscsInputs.cciLength = 5; + // inputs.oscsInputs.mfiLength = 5; + // inputs.oscsInputs.rviLength = 5; + + // + // Oscillators Views ... + inputs.showCCI = false; + inputs.showRSI = false; + inputs.showMFI = false; + inputs.showRVI = false; + inputs.showADX = false; + inputs.showMACD = false; + + // + // XCAEA Helper ... + helper = new XCXCAEAHelper(); + helper.Init( + symbol, + period, + inputs // + ); + + // + // Initialize and Configure Detector ... + detector = new XCXCAEAPOIDetector(helper); + + // + detector.detectSWHPivot = false; + detector.detectSWLPivot = false; + detector.detectPeakPivot = false; + detector.detectValePivot = false; + detector.detectRSIPeakPivot = true; + detector.detectRSIValePivot = true; + detector.detectCCIPeakPivot = true; + detector.detectCCIValePivot = true; + detector.detectKIBullishPivot = false; + detector.detectKIBearishPivot = false; + detector.detectFVGBullishPivot = true; + detector.detectFVGBearishPivot = true; + detector.detectPeakSWHResPivot = true; + detector.detectValeSWLSupPivot = true; + detector.detectTKIBullishPivot = false; + detector.detectCycleSameLLPivot = false; + detector.detectCycleSameHHPivot = false; + detector.detectTKIBearishPivot = false; + detector.detectTrendBullishPivot = false; + detector.detectTrendBearishPivot = false; + detector.detectTKITRNDBullishPivot = false; + detector.detectTKITRNDBearishPivot = false; + detector.detectRSICrossedOverOSPivot = false; + detector.detectRSICrossedUnderOBPivot = false; + detector.detectCCICrossedOverOSPivot = false; + detector.detectCCICrossedUnderOBPivot = false; + + // + // Initialize and Configure Drawer ... + drawer = new XCXCAEAPOIDrawer(detector); + + // + // UnActive Pivots ... + drawer.drawSWHPivots = false; + drawer.drawSWLPivots = false; + drawer.drawPeakPivots = false; + drawer.drawValePivots = false; + drawer.drawRSIPeakPivots = true; // true; + drawer.drawRSIValePivots = true; // true; + drawer.drawCCIPeakPivots = false; // true; + drawer.drawCCIValePivots = false; // true; + drawer.drawKIBullishPivots = false; + drawer.drawKIBearishPivots = false; + drawer.drawFVGBullishPivots = false; + drawer.drawFVGBearishPivots = false; + drawer.drawPeakSWHResPivots = false; // true; + drawer.drawValeSWLSupPivots = false; // true; + drawer.drawTKIBullishPivots = false; + drawer.drawTKIBearishPivots = false; + drawer.drawPVFVGBullishPivots = false; // true; + drawer.drawPVFVGBearishPivots = false; // true; + drawer.drawCycleSameLLPivots = false; + drawer.drawCycleSameHHPivots = false; + drawer.drawTrendBullishPivots = false; + drawer.drawTrendBearishPivots = false; + drawer.drawTKITRNDBullishPivots = false; + drawer.drawTKITRNDBearishPivots = false; + drawer.drawRSICrossedOverOSPivots = false; + drawer.drawRSICrossedUnderOBPivots = false; + drawer.drawCCICrossedOverOSPivots = false; + drawer.drawCCICrossedUnderOBPivots = false; + + // + drawer.drawTicks = false; + + // + // Configure Width ... + drawer.peakPivotWidth = 1; + drawer.valePivotWidth = 1; + drawer.ticksBullishWidth = 2; + drawer.ticksBearishWidth = 2; + drawer.fvgBullishPivotWidth = 1; + drawer.fvgBearishPivotWidth = 1; + drawer.oscsBullishPivotWidth = 2; + drawer.oscsBearishPivotWidth = 2; + + // + // Configure Colors ... + drawer.peakPivotColor = clrMagenta; + drawer.valePivotColor = clrAqua; + drawer.ticksBullishColor = clrYellow; + drawer.ticksBearishColor = clrOrange; + drawer.fvgBullishPivotColor = clrLime; + drawer.fvgBearishPivotColor = clrRed; + drawer.oscsBullishPivotColor = clrAqua; + drawer.oscsBearishPivotColor = clrMagenta; + + // + // Configure Style ... + drawer.peakPivotStyle = STYLE_SOLID; + drawer.valePivotStyle = STYLE_SOLID; + drawer.ticksBullishStyle = STYLE_DOT; + drawer.ticksBearishStyle = STYLE_DOT; + drawer.fvgBullishPivotStyle = STYLE_DASH; + drawer.fvgBearishPivotStyle = STYLE_DASH; + drawer.oscsBullishPivotStyle = STYLE_SOLID; + drawer.oscsBearishPivotStyle = STYLE_SOLID; + } + + /** + * DeInitialize ... + */ + void DeInit() + { + // + inputs.Clean(); + + // + ZeroMemory(drawer); + ZeroMemory(helper); + ZeroMemory(detector); + + // + mConditions.Clean(); + Clean(mConditionsCollection); + + // + mObjects.Clear(); + mBarObjects.Clear(); + + // + barTraker.Clean(); + } + + // +}; + +// \ No newline at end of file diff --git a/Documents/BKP/xcaea.x-poi.detector.class.mq5 b/Documents/BKP/xcaea.x-poi.detector.class.mq5 new file mode 100644 index 00000000..a3d3a6e8 --- /dev/null +++ b/Documents/BKP/xcaea.x-poi.detector.class.mq5 @@ -0,0 +1,7691 @@ +/////////////////////////////////////////////////////// +// +// SaherElm IT Center MQL5 Indicator +// ------------------------------------------------- +// Name: XCXCAEAPOIDetector ... +// Description: Class for XCAEA POI Detector ... +// +// +// Maintainer: +// ------------ +// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com) +// +////////////////////////////////////////////////////// +// +// Global Properties ... +#property library +#property copyright "Copyright 2023, SaherElm IT Center" +#property link "https://saherelm.ir" +#property version "1.00" +#property description "SaherElm Class for XCAEA POI Detector" +#property strict + +// +// Imports ... +#include "../../Classes/x-saherelm.x-bar.analyser.class.mq5" +#include "../../Classes/x-saherelm.x-poi.drawer.class.mq5" +#include "../Helpers/xcaea.helper.mq5" + +// +// Definitions ... + +// +enum ENUM_XCA_PIVOTS +{ + XCA_NONE, // None + XCA_LL, // LowestLow + XCA_HH, // HighestHigh + XCA_KI, // KI + XCA_SWL, // SWL + XCA_SWH, // SWH + XCA_VALE, // VALE + XCA_PEAK, // PEAK + XCA_FVG_BULL, // FVGBull + XCA_FVG_BEAR, // FVGBear + XCA_RSI_COOS, // RSICOOS + XCA_RSI_CUOB, // RSICUOB + XCA_RSI_PEAK, // RSIPeak + XCA_RSI_VALE, // RSIVale + XCA_CCI_COOS, // CCICOOS + XCA_CCI_CUOB, // CCICUOB + XCA_CCI_PEAK, // CCIPeak + XCA_CCI_VALE, // CCIVale + XCA_KI_BULL, // KIBull + XCA_KI_BEAR, // KIBear + XCA_TKI_BULL, // TKIBull + XCA_TKI_BEAR, // TKIBear + XCA_PEAKSWHRES, // PeakSWHRes + XCA_VALESWLSUP, // ValeSWLSup + XCA_TREND_BULL, // TrendBull + XCA_TREND_BEAR, // TrendBear + XCA_TKITRND_BULL, // TKITRNDBull + XCA_TKITRND_BEAR, // TKITRNDBear +}; + +// +bool IsValid(ENUM_XCA_PIVOTS value) +{ + // + bool result = false; + + // + result = value != XCA_NONE; + + // + return result; +} + +// +string ToString(ENUM_XCA_PIVOTS value) +{ + // + string result = NULL; + + // + result = EnumToString(value); + + // + return result; +} + +// +struct XCAPivot +{ + // + // Props ... + datetime to; + double value; + string symbol; + datetime from; + double reserve; + ENUM_XCA_PIVOTS type; + ENUM_TIMEFRAMES period; + + // + double values[]; + + // + // Constructor ... + XCAPivot() + { + Clean(); + } + + // + // Tools ... + + /** + * Cleanup ... + */ + void Clean() + { + // + value = 0; + to = NULL; + reserve = 0; + from = NULL; + symbol = NULL; + period = NULL; + type = XCA_NONE; + + // + Clean(values); + + // + ZeroMemory(this); + } + + /** + * Validate ... + * + * @return ( bool ) + */ + bool IsValid() + { + // + bool result = false; + + // + result = + from < to && + value != 0 && + IsValid(to) && + IsValid(from) && + IsValid(type) && + IsValid(symbol) && + IsValid(period); + + // + return result; + } + + /** + * Check a Model is Same as this or not ... + * + * @param pivot: XCAPivot ... + * + * @return ( bool ) + */ + bool IsSameAs(XCAPivot &pivot) + { + // + bool result = false; + + // + result = + IsValid() && + pivot.IsValid(); + if (!result) + { + return result; + } + + // + result = + to == pivot.to && + from == pivot.from && + type == pivot.type && + value == pivot.value && + symbol == pivot.symbol && + period == pivot.period; + + // + return result; + } + + /** + * Retrieve To Index ... + * + * @param forPeriod: ENUM_TIMEFRAMES, Specified Period ... + * + * @return ( int ) + */ + int ToIndex( + ENUM_TIMEFRAMES forPeriod = NULL // + ) + { + // + int result = -1; + + // + if (!IsValid()) + { + return result; + } + + // + if (!IsValid(forPeriod)) + { + forPeriod = period; + } + + // + result = GetBarIndex( + symbol, + forPeriod, + to // + ); + + // + return result; + } + + /** + * Retrieve From Index ... + * + * @param forPeriod: ENUM_TIMEFRAMES, Specified Period ... + * + * @return ( int ) + */ + int FromIndex( + ENUM_TIMEFRAMES forPeriod = NULL // + ) + { + // + int result = -1; + + // + if (!IsValid()) + { + return result; + } + + // + if (!IsValid(forPeriod)) + { + forPeriod = period; + } + + // + result = GetBarIndex( + symbol, + forPeriod, + from // + ); + + // + return result; + } + + /** + * Retrieve Age of Pivot ... + * + * @param forPeriod: ENUM_TIMEFRAMES, Specified Period ... + * + * @return ( int ) + */ + int GetAge( + ENUM_TIMEFRAMES forPeriod = NULL // + ) + { + // + int result = 0; + + // + if (!IsValid()) + { + return result; + } + + // + if (!IsValid(forPeriod)) + { + forPeriod = period; + } + + // + int toIDX = ToIndex(forPeriod); + int fromIDX = FromIndex(forPeriod); + + // + result = fromIDX - toIDX; + + // + return result; + } + + /** + * Converts Pivot to Box ... + * + * @param box: XBoxZone instance reference ... + * + * @return ( bool ) + */ + bool AsBox( + XBoxZone &box // + ) + { + // + bool result = false; + + // + box.Clean(); + + // + result = IsValid(); + if (!result) + { + return result; + } + + // + ENUM_X_DIRECTION iDir = X_DIRECTION_NONE; + switch (type) + { + // + case XCA_LL: + case XCA_SWL: + case XCA_VALE: + case XCA_KI_BULL: + case XCA_FVG_BULL: + case XCA_RSI_COOS: + case XCA_RSI_VALE: + case XCA_CCI_COOS: + case XCA_CCI_VALE: + case XCA_TKI_BULL: + case XCA_TREND_BULL: + case XCA_VALESWLSUP: + case XCA_TKITRND_BULL: + iDir = X_DIRECTION_BULLISH; + break; + + // + case XCA_HH: + case XCA_SWH: + case XCA_PEAK: + case XCA_KI_BEAR: + case XCA_FVG_BEAR: + case XCA_RSI_CUOB: + case XCA_RSI_PEAK: + case XCA_CCI_CUOB: + case XCA_CCI_PEAK: + case XCA_TKI_BEAR: + case XCA_TREND_BEAR: + case XCA_PEAKSWHRES: + case XCA_TKITRND_BEAR: + iDir = X_DIRECTION_BEARISH; + break; + } + + // + result = HasDirection(iDir); + if (!result) + { + return result; + } + + // + bool isBullish = + IsBullish(iDir) && + value < reserve; + + // + bool isBearish = + IsBearish(iDir) && + value > reserve; + + // + result = isBullish || + isBearish; + if (!result) + { + return result; + } + + // + box.to = to; + box.dir = iDir; + box.from = from; + box.symbol = symbol; + box.period = period; + + // + string typeStr = ToString(type); + if (type == XCA_KI_BULL || + type == XCA_KI_BEAR) + { + // + typeStr = "XCA_KI"; + } + else if (type == XCA_FVG_BULL || + type == XCA_FVG_BEAR) + { + // + typeStr = "XCA_FVG"; + } + else if (type == XCA_RSI_COOS || + type == XCA_RSI_CUOB) + { + // + typeStr = "XCA_RSI"; + } + else if (type == XCA_CCI_COOS || + type == XCA_CCI_CUOB) + { + // + typeStr = "XCA_CCI"; + } + else if (type == XCA_TKI_BULL || + type == XCA_TKI_BEAR) + { + // + typeStr = "XCA_TKI"; + } + else if (type == XCA_TREND_BULL || + type == XCA_TREND_BEAR) + { + // + typeStr = "XCA_TREND"; + } + else if (type == XCA_TKITRND_BULL || + type == XCA_TKITRND_BEAR) + { + // + typeStr = "XCA_TKITRND"; + } + box.type = typeStr; + + // + box.upper = + isBullish + ? reserve + : value; + box.lower = + isBullish + ? value + : reserve; + + // + result = box.IsValid(); + if (!result) + { + box.Clean(); + } + + // + return result; + } + + // +}; + +// +struct XCAPVPivot +{ + // + // Props ... + double value; + XCAPivot pivots[]; + ENUM_X_DIRECTION dir; + + // + // Constructor ... + XCAPVPivot() + { + Clean(); + } + + // + // Tools ... + + // + void Clean() + { + // + value = 0; + Clean(pivots); + dir = X_DIRECTION_NONE; + + // + ZeroMemory(this); + } + + // + bool IsValid() + { + // + bool result = false; + + // + result = value != 0 && + HasDirection(dir); + + // + return result; + } + + // + void AddPivot(XCAPivot &pivot) + { + // + if (!IsValid() || + !pivot.IsValid()) + { + return; + } + + // + int idx = -1; + bool has = FindPivotIndex( + idx, + pivot, + pivots // + ); + if (has) + { + return; + } + + // + AddRef( + pivot, + pivots // + ); + } + + // + int GetPivots(XBoxZone &pivotBoxes[]) + { + // + int result = 0; + + // + Clean(pivotBoxes); + + // + bool has = false; + + // + has = IsValid() && + HasChild(pivots); + if (!has) + { + return result; + } + + // + int count = ArraySize(pivots); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = pivots[i].AsBox(iBox); + if (has) + { + // + AddRef( + iBox, + pivotBoxes // + ); + } + + // + iBox.Clean(); + } + + // + result = ArraySize(pivotBoxes); + + // + return result; + } +}; + +// +struct XCAPVTick +{ + // + XCAPivot pivot; + XCTicksZone *zone; + + // + XCAPVTick() + { + Clean(); + } + + // + // Tools ... + + // + void Clean() + { + // + pivot.Clean(); + + // + ZeroMemory(zone); + ZeroMemory(this); + } + + // + bool IsValid() + { + // + bool result = false; + + // + result = pivot.IsValid() && + zone != NULL; + + // + return result; + } + + // + bool Init(XCAPivot &_pivot) + { + // + bool result = false; + + // + result = _pivot.IsValid(); + if (!result) + { + return result; + } + + // + int toIDX = _pivot.ToIndex(); + int fromIDX = _pivot.FromIndex(); + int rangeLength = fromIDX - toIDX; + result = IsValidIndex(fromIDX) && + IsValidIndex(toIDX); + if (!result) + { + // + Clean(); + return result; + } + + // + XOHCL toBar; + XOHCL fromBar; + result = toBar.Init( + _pivot.symbol, + _pivot.period, + toIDX // + ); + result = result && + fromBar.Init( + _pivot.symbol, + _pivot.period, + fromIDX // + ); + if (!result) + { + // + toBar.Clean(); + fromBar.Clean(); + + // + Clean(); + + // + return result; + } + + // + double rangeDivider = 10 * GetPoints(_pivot.symbol); + double rangeL = toBar.FindLowest(rangeLength, MODE_LOW); + double rangeH = toBar.FindHighest(rangeLength, MODE_HIGH); + double rangeDiff = (rangeH - rangeL); + int zoneLevels = (int)(rangeDiff / rangeDivider); + + // + XCTicksZone *_zone; + _zone = new XCTicksZone(); + _zone.Levels(zoneLevels); + result = _zone.Init( + fromBar, + toBar // + ); + if (!result) + { + // + toBar.Clean(); + fromBar.Clean(); + ZeroMemory(_zone); + + // + Clean(); + + // + return result; + } + + // + pivot = _pivot; + zone = _zone; + + // + result = IsValid(); + if (!result) + { + Clean(); + } + + // + toBar.Clean(); + fromBar.Clean(); + ZeroMemory(_zone); + + // + return result; + } + + // + bool GetMaxVolumeBox(XBoxZone &box) + { + // + bool result = false; + + // + box.Clean(); + + // + result = IsValid(); + if (!result) + { + return result; + } + + // + // Select MAX Volume Zone ... + XCTickZone *selectedZone = NULL; + int zonesCount = zone.Count(); + for (int j = 0; j < zonesCount; j++) + { + // + XCTickZone *jZone = zone.GetZone(j); + + // + bool canSet = + selectedZone == NULL + ? true + : selectedZone.volume < jZone.volume; + if (canSet) + { + selectedZone = jZone; + } + + // + ZeroMemory(jZone); + } + + // + result = selectedZone != NULL; + if (!result) + { + // + box.Clean(); + ZeroMemory(selectedZone); + + // + return result; + } + + // + result = pivot.AsBox(box); + if (!result) + { + // + box.Clean(); + + // + return result; + } + box.upper = selectedZone.high; + box.lower = selectedZone.low; + box.type = + pivot.type == XCA_PEAKSWHRES + ? "PEAKTICK" + : pivot.type == XCA_VALESWLSUP + ? "VALETICK" + : box.type; + + // + return result; + } + + // +}; + +/** + * Find Specified Pivot Index inside a Collection of Pivots ... + * + * @param pivot: XCAPivot instance Reference ... + * @param pivots: XCAPivot instance Reference Collection ... + * + * @return ( int ) + */ +bool FindPivotIndex( + int &index, + XCAPivot &pivot, + XCAPivot &pivots[] // +) +{ + // + bool result = false; + + // + index = -1; + + // + int count = ArraySize(pivots); + result = pivot.IsValid() && + IsValidSize(count); + if (!result) + { + return result; + } + + // + for (int i = 0; i < count; i++) + { + // + XCAPivot iPivot = pivots[i]; + + // + bool isSame = pivot.IsSameAs(iPivot); + if (isSame) + { + // + index = i; + break; + } + } + + // + result = IsValidIndex(index); + + // + return result; +} + +/** + * Add or Update Specified Pivot to Specified Collection ... + * + * @param pivot: XCAPivot instance reference, Specified Item ... + * @param pivots: XCAPivot instance reference Collection ... + * @param maxAllowedPivots: int, Max Allowed Pivots number of Collection ... + */ +void AddPivot( + XCAPivot &pivot, + XCAPivot &pivots[], + int maxAllowedPivots = 50 // +) +{ + // + bool has = pivot.IsValid(); + if (!has) + { + return; + } + + // + int idx = -1; + has = FindPivotIndex( + idx, + pivot, + pivots // + ); + if (has) + { + return; + } + + // + int updateIDX = -1; + int count = ArraySize(pivots); + for (int i = 0; i < count; i++) + { + // + XCAPivot iPivot = pivots[i]; + + // + has = + iPivot.to > pivot.to && + iPivot.from == pivot.from && + iPivot.value == pivot.value && + iPivot.symbol == pivot.symbol && + iPivot.period == pivot.period; + if (has) + { + // + updateIDX = i; + break; + } + } + + // + has = IsValidIndex(updateIDX); + if (!has) + { + // + AddRef( + pivot, + pivots // + ); + } + else + { + pivots[updateIDX].to = pivot.to; + } + + // + // Apply Max Allowed ... + CleanupArray( + pivots, + maxAllowedPivots // + ); +} + +/** + * Add or Update PV FVG item to Specified Collection ... + * + * @param value: double, Peak or Vale Value ... + * @param fvg: XCAPivot instance reference, Specified Pivot ... + * @param collection: XCAPVPivot instance Collection ... + */ +void AddOrUpdatePVFVG( + double value, + XCAPivot &fvg, + XCAPVPivot &collection[] // +) +{ + // + // Validate Args ... + if (value < 0 && + !fvg.IsValid() && + (fvg.type == XCA_FVG_BULL || + fvg.type == XCA_FVG_BEAR)) + { + return; + } + + // + // Check Pivot is Exists or not ... + ENUM_X_DIRECTION dir = + fvg.type == XCA_FVG_BULL + ? X_DIRECTION_BULLISH + : X_DIRECTION_BEARISH; + + // + bool isBullish = IsBullish(dir); + bool isBearish = IsBearish(dir); + + // + // Try to Findout Pivot Value in Collection ... + int idx = -1; + int count = ArraySize(collection); + for (int i = 0; i < count; i++) + { + // + XCAPVPivot iTem = collection[i]; + + // + bool isSameValue = iTem.value == value; + bool isSameDirection = iTem.dir == dir; + + // + bool isValid = isSameValue && + isSameDirection; + if (isValid) + { + // + idx = i; + iTem.Clean(); + break; + } + + // + iTem.Clean(); + } + + // + // Try to Add Or Update Pivots ... + bool hasIndex = IsValidIndex(idx); + if (!hasIndex) + { + // + // New Item ... + XCAPVPivot iPVFVG; + + // + iPVFVG.dir = dir; + iPVFVG.value = value; + + // + AddRef( + fvg, + iPVFVG.pivots // + ); + + // + AddRef( + iPVFVG, + collection // + ); + } + else + { + // + // Add Pivot to Existing Item ... + collection[idx].AddPivot(fvg); + } + + // +} + +/** + * Add Specified PVTick to Collection ... + * + * @param pvTick: XCAPVTick instance Reference ... + * @param pvTicks: XCAPVTickinstance Reference Collection ... + */ +void AddPVTick( + XCAPVTick &pvTick, + XCAPVTick &pvTicks[] // +) +{ + // + bool has = pvTick.IsValid(); + if (!has) + { + return; + } + + // + has = false; + int count = ArraySize(pvTicks); + for (int i = 0; i < count; i++) + { + // + has = pvTicks[i].pivot.IsSameAs(pvTick.pivot); + if (has) + { + break; + } + } + + // + if (has) + { + return; + } + + // + AddRef( + pvTick, + pvTicks // + ); +} + +// +// Implementations ... +class XCXCAEAPOIDetector : public XCBase +{ + // + // Public ... + public: + // + // Props ... + + // + // Pivot Verifications and Max Allowed Holding Items ... + int pivotVerifications; // Pivots Verifications ... + int maxAllowedPivots; // Max Allowed Holding Pibots ... + + // + // Detector Pivots State Properties ... + + // + // PEAK / VALES ... + bool detectPeakPivot; + bool detectValePivot; + + // + // PEAK SWH RES / VALE SWL SUP ... + bool detectPeakSWHResPivot; + bool detectValeSWLSupPivot; + + // + // SWING HIGH / LOW ... + bool detectSWHPivot; + bool detectSWLPivot; + + // + // KI ... + bool detectKIBullishPivot; + bool detectKIBearishPivot; + + // + // TKI ... + bool detectTKIBullishPivot; + bool detectTKIBearishPivot; + + // + // FVG ... + bool detectFVGBullishPivot; + bool detectFVGBearishPivot; + + // + // SAME Cycles HH / LL ... + bool detectCycleSameLLPivot; + bool detectCycleSameHHPivot; + + // + // TREND ... + bool detectTrendBullishPivot; + bool detectTrendBearishPivot; + + // + // TKITRND ... + bool detectTKITRNDBullishPivot; + bool detectTKITRNDBearishPivot; + + // + // OSCS ... + + // + // RSI ... + bool detectRSIPeakPivot; + bool detectRSIValePivot; + bool detectRSICrossedOverOSPivot; + bool detectRSICrossedUnderOBPivot; + + // + // CCI ... + bool detectCCIPeakPivot; + bool detectCCIValePivot; + bool detectCCICrossedOverOSPivot; + bool detectCCICrossedUnderOBPivot; + + // + // Active Pivots ... + XCAPivot swhPivot; + XCAPivot swlPivot; + XCAPivot peakPivot; + XCAPivot valePivot; + XCAPivot sSameHHPivot; + XCAPivot mSameHHPivot; + XCAPivot lSameHHPivot; + XCAPivot hSameHHPivot; + XCAPivot sSameLLPivot; + XCAPivot mSameLLPivot; + XCAPivot lSameLLPivot; + XCAPivot hSameLLPivot; + XCAPivot kiBullishPivot; + XCAPivot kiBearishPivot; + XCAPivot tkiBullishPivot; + XCAPivot tkiBearishPivot; + XCAPivot peakSWHResPivot; + XCAPivot valeSWLSupPivot; + XCAPivot trendBullishPivot; + XCAPivot trendBearishPivot; + XCAPivot tkitrndBullishPivot; + XCAPivot tkitrndBearishPivot; + + // + // UnActive Pivots ... + XCAPivot swhPivots[]; + XCAPivot swlPivots[]; + XCAPivot peakPivots[]; + XCAPivot valePivots[]; + XCAPivot rsiPeakPivots[]; + XCAPivot rsiValePivots[]; + XCAPivot cciPeakPivots[]; + XCAPivot cciValePivots[]; + XCAPivot sSameHHPivots[]; + XCAPivot mSameHHPivots[]; + XCAPivot lSameHHPivots[]; + XCAPivot hSameHHPivots[]; + XCAPivot sSameLLPivots[]; + XCAPivot mSameLLPivots[]; + XCAPivot lSameLLPivots[]; + XCAPivot hSameLLPivots[]; + XCAPivot kiBullishPivots[]; + XCAPivot kiBearishPivots[]; + XCAPivot fvgBullishPivots[]; + XCAPivot fvgBearishPivots[]; + XCAPivot tkiBullishPivots[]; + XCAPivot tkiBearishPivots[]; + XCAPivot peakSWHResPivots[]; + XCAPivot valeSWLSupPivots[]; + XCAPivot trendBullishPivots[]; + XCAPivot trendBearishPivots[]; + XCAPivot tkitrndBullishPivots[]; + XCAPivot tkitrndBearishPivots[]; + XCAPivot rsiCrossedOverOSPivots[]; + XCAPivot cciCrossedOverOSPivots[]; + XCAPivot rsiCrossedUnderOBPivots[]; + XCAPivot cciCrossedUnderOBPivots[]; + + // + XCAPVTick peakTicks[]; + XCAPVTick valeTicks[]; + + // + XCAPVPivot pvFVGBullishPivots[]; + XCAPVPivot pvFVGBearishPivots[]; + + // + // Constructors ... + XCXCAEAPOIDetector( + XCXCAEAHelper *_helper // + ) + { + // + helper = _helper; + drawer = new XCPOIDrawer(); + barAnalyser = new XCBarAnalyser(); + + // + Default(); + } + + // + // De Constructors ... + ~XCXCAEAPOIDetector() + { + // + swhPivot.Clean(); + swlPivot.Clean(); + peakPivot.Clean(); + valePivot.Clean(); + sSameHHPivot.Clean(); + mSameHHPivot.Clean(); + lSameHHPivot.Clean(); + hSameHHPivot.Clean(); + sSameLLPivot.Clean(); + mSameLLPivot.Clean(); + lSameLLPivot.Clean(); + hSameLLPivot.Clean(); + kiBullishPivot.Clean(); + kiBearishPivot.Clean(); + tkiBullishPivot.Clean(); + tkiBearishPivot.Clean(); + peakSWHResPivot.Clean(); + valeSWLSupPivot.Clean(); + trendBullishPivot.Clean(); + trendBearishPivot.Clean(); + tkitrndBullishPivot.Clean(); + tkitrndBearishPivot.Clean(); + + // + Clean(swhPivots); + Clean(swlPivots); + Clean(peakPivots); + Clean(valePivots); + Clean(rsiPeakPivots); + Clean(rsiValePivots); + Clean(cciPeakPivots); + Clean(cciValePivots); + Clean(sSameHHPivots); + Clean(mSameHHPivots); + Clean(lSameHHPivots); + Clean(hSameHHPivots); + Clean(sSameLLPivots); + Clean(mSameLLPivots); + Clean(lSameLLPivots); + Clean(hSameLLPivots); + Clean(kiBullishPivots); + Clean(kiBearishPivots); + Clean(fvgBullishPivots); + Clean(fvgBearishPivots); + Clean(tkiBullishPivots); + Clean(tkiBearishPivots); + Clean(peakSWHResPivots); + Clean(valeSWLSupPivots); + Clean(trendBullishPivots); + Clean(trendBearishPivots); + Clean(tkitrndBullishPivots); + Clean(tkitrndBearishPivots); + Clean(rsiCrossedOverOSPivots); + Clean(cciCrossedOverOSPivots); + Clean(rsiCrossedUnderOBPivots); + Clean(cciCrossedUnderOBPivots); + + // + ZeroMemory(helper); + ZeroMemory(drawer); + ZeroMemory(barAnalyser); + } + + // + // Properties ... + + // + // Tools ... + + // + virtual void Default() + { + // + maxAllowedPivots = 50; + pivotVerifications = 5; + + // + detectSWHPivot = true; + detectSWLPivot = true; + detectPeakPivot = true; + detectValePivot = true; + detectRSIPeakPivot = true; + detectRSIValePivot = true; + detectCCIPeakPivot = true; + detectCCIValePivot = true; + detectKIBullishPivot = true; + detectKIBearishPivot = true; + detectFVGBullishPivot = true; + detectFVGBearishPivot = true; + detectTKIBullishPivot = true; + detectTKIBearishPivot = true; + detectPeakSWHResPivot = true; + detectValeSWLSupPivot = true; + detectCycleSameLLPivot = true; + detectCycleSameHHPivot = true; + detectTrendBullishPivot = true; + detectTrendBearishPivot = true; + detectTKITRNDBullishPivot = true; + detectTKITRNDBearishPivot = true; + detectCCICrossedOverOSPivot = true; + detectCCICrossedUnderOBPivot = true; + } + + // + void Update( + int barIndex = 0, + int loopback = 400 // + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + loopback = NormalizeInt(loopback, 400); + + // + int count = 0; + bool has = false; + + // + int zIDX = 0; + int cIDX = zIDX + 1; + int pIDX = cIDX + 1; + int p2IDX = pIDX + 1; + int p3IDX = p2IDX + 1; + + // + int index = barIndex; + int start = index; + int end = index + loopback; + while (start < end) + { + // + // Retrieve Conditions ... + XCAEAConditions iConditions; + has = helper.GetConditions( + iConditions, + start, + 5 // + ); + + // + // Retrieve Bars ... + XOHCL zBar; + XOHCL cBar; + XOHCL pBar; + XOHCL p2Bar; + has = zBar.Init( + iConditions.symbol, + iConditions.period, + start // + ); + has = + has && + zBar.GetPreviousBar(cBar); + has = + has && + cBar.GetPreviousBar(pBar); + has = + has && + pBar.GetPreviousBar(p2Bar); + if (!has) + { + // + zBar.Clean(); + cBar.Clean(); + pBar.Clean(); + p2Bar.Clean(); + iConditions.Clean(); + + // + continue; + } + + // + XBoxZone fvgBox; + bool isFVG = barAnalyser.IsFVG( + cBar, + fvgBox // + ); + + // + bool isBullishFVG = + isFVG && + fvgBox.IsBullish(); + + // + bool isBearishFVG = + isFVG && + fvgBox.IsBearish(); + + // + // Provide Some Conditions ... + + // + double points = GetPoints(zBar.symbol); + + // + // PEAK ... + + // + double cPeak = iConditions.peakBuffer[cIDX]; + double pPeak = iConditions.peakBuffer[pIDX]; + double p2Peak = iConditions.peakBuffer[p2IDX]; + + // + bool isPeakStartSameLast = + cPeak == pPeak && + pPeak != p2Peak; + + // + bool isPeakFinishedSameLast = + cPeak != pPeak && + pPeak == p2Peak; + + // + // VALE ... + + // + double cVale = iConditions.valeBuffer[cIDX]; + double pVale = iConditions.valeBuffer[pIDX]; + double p2Vale = iConditions.valeBuffer[p2IDX]; + + // + bool isValeStartSameLast = + cVale == pVale && + pVale != p2Vale; + + // + bool isValeFinishedSameLast = + cVale != pVale && + pVale == p2Vale; + + // + // SWH ... + + // + double cSWH = iConditions.swingHighBuffer[cIDX]; + double pSWH = iConditions.swingHighBuffer[pIDX]; + double p2SWH = iConditions.swingHighBuffer[p2IDX]; + + // + bool isSWHStartSameLast = + cSWH == pSWH && + pSWH != p2SWH; + + // + bool isSWHFinishedSameLast = + cSWH != pSWH && + pSWH == p2SWH; + + // + // SWL ... + + // + double pSWL = iConditions.swingLowBuffer[pIDX]; + double cSWL = iConditions.swingLowBuffer[cIDX]; + double p2SWL = iConditions.swingLowBuffer[p2IDX]; + + // + bool isSWLStartSameLast = + cSWL == pSWL && + pSWL != p2SWL; + + // + bool isSWLFinishedSameLast = + cSWL != pSWL && + pSWL == p2SWL; + + // + // SUPPORT ... + + // + double cSupport = iConditions.supportBuffer[cIDX]; + double pSupport = iConditions.supportBuffer[pIDX]; + double p2Support = iConditions.supportBuffer[p2IDX]; + + // + bool isSupportStartSameLast = + cSupport == pSupport && + pSupport != p2Support; + + // + bool isSupportFinishedSameLast = + cSupport != pSupport && + pSupport == p2Support; + + // + // RESISTANCE ... + + // + double pResistance = iConditions.resistanceBuffer[pIDX]; + double cResistance = iConditions.resistanceBuffer[cIDX]; + double p2Resistance = iConditions.resistanceBuffer[p2IDX]; + + // + bool isResistanceStartSameLast = + cResistance == pResistance && + pResistance != p2Resistance; + + // + bool isResistanceFinishedSameLast = + cResistance != pResistance && + pResistance == p2Resistance; + + // + // PEAK SWH RES ... + + // + bool isCPeakIsPivot = + cPeak == cSWH && + cSWH == cResistance; + + // + bool isPPeakIsPivot = + pPeak == pSWH && + pSWH == pResistance; + + // + bool isStartPeakIsPivot = + isCPeakIsPivot && + !isPPeakIsPivot; + + // + bool isFinishedPeakIsPivot = + !isCPeakIsPivot && + isPPeakIsPivot; + + // + // VALE SWL SUP ... + + // + bool isCValeIsPivot = + cVale == cSWL && + cSWL == cSupport; + + // + bool isPValeIsPivot = + pVale == pSWL && + pSWL == pSupport; + + // + bool isStartValeIsPivot = + isCValeIsPivot && + !isPValeIsPivot; + + // + bool isFinishedValeIsPivot = + !isCValeIsPivot && + isPValeIsPivot; + + // + // TKITRND ... + + // + double cKI = iConditions.kiBuffer[cIDX]; + double pKI = iConditions.kiBuffer[pIDX]; + double p2KI = iConditions.kiBuffer[p2IDX]; + + // + double cKIState = iConditions.kiStateBuffer[cIDX]; + double pKIState = iConditions.kiStateBuffer[pIDX]; + double p2KIState = iConditions.kiStateBuffer[p2IDX]; + + // + double cTKI = iConditions.tkiBuffer[cIDX]; + double pTKI = iConditions.tkiBuffer[pIDX]; + double p2TKI = iConditions.tkiBuffer[p2IDX]; + + // + double cTKIState = iConditions.tkiStateBuffer[cIDX]; + double pTKIState = iConditions.tkiStateBuffer[pIDX]; + double p2TKIState = iConditions.tkiStateBuffer[p2IDX]; + + // + double cTrend = iConditions.trendBuffer[cIDX]; + double pTrend = iConditions.trendBuffer[pIDX]; + double p2Trend = iConditions.trendBuffer[p2IDX]; + + // + double cTrendState = iConditions.trendStateBuffer[cIDX]; + double pTrendState = iConditions.trendStateBuffer[pIDX]; + double p2TrendState = iConditions.trendStateBuffer[p2IDX]; + + // + double cTKITRNDs[] = { + cKI, + cTKI, + cTrend // + }; + + // + double cTKITRNDMin = GetMin(cTKITRNDs); + double cTKITRNDMax = GetMax(cTKITRNDs); + + // + double pTKITRNDs[] = { + pKI, + pTKI, + pTrend // + }; + + // + double pTKITRNDMin = GetMin(pTKITRNDs); + double pTKITRNDMax = GetMax(pTKITRNDs); + + // + bool isCTKITRNDBullish = + cKIState > 0 && + cTKIState > 0 && + cTrendState > 0; + + // + bool isPTKITRNDBullish = + pKIState > 0 && + pTKIState > 0 && + pTrendState > 0; + + // + bool isTKITRNDSwitchedBullish = + isCTKITRNDBullish && + !isPTKITRNDBullish; + + // + bool isCTKITRNDBearish = + cKIState < 0 && + cTKIState < 0 && + cTrendState < 0; + + // + bool isPTKITRNDBearish = + pKIState < 0 && + pTKIState < 0 && + pTrendState < 0; + + // + bool isTKITRNDSwitchedBearish = + isCTKITRNDBearish && + !isPTKITRNDBearish; + + // + // CYCLES ... + + // + double cSLL = iConditions.sLLBuffer[cIDX]; + double pSLL = iConditions.sLLBuffer[pIDX]; + double p2SLL = iConditions.sLLBuffer[p2IDX]; + + // + double cSHH = iConditions.sHHBuffer[cIDX]; + double pSHH = iConditions.sHHBuffer[pIDX]; + double p2SHH = iConditions.sHHBuffer[p2IDX]; + + // + double cMLL = iConditions.mLLBuffer[cIDX]; + double pMLL = iConditions.mLLBuffer[pIDX]; + double p2MLL = iConditions.mLLBuffer[p2IDX]; + + // + double cMHH = iConditions.mHHBuffer[cIDX]; + double pMHH = iConditions.mHHBuffer[pIDX]; + double p2MHH = iConditions.mHHBuffer[p2IDX]; + + // + double cLLL = iConditions.lLLBuffer[cIDX]; + double pLLL = iConditions.lLLBuffer[pIDX]; + double p2LLL = iConditions.lLLBuffer[p2IDX]; + + // + double cLHH = iConditions.lHHBuffer[cIDX]; + double pLHH = iConditions.lHHBuffer[pIDX]; + double p2LHH = iConditions.lHHBuffer[p2IDX]; + + // + double cHLL = iConditions.hLLBuffer[cIDX]; + double pHLL = iConditions.hLLBuffer[pIDX]; + double p2HLL = iConditions.hLLBuffer[p2IDX]; + + // + double cHHH = iConditions.hHHBuffer[cIDX]; + double pHHH = iConditions.hHHBuffer[pIDX]; + double p2HHH = iConditions.hHHBuffer[p2IDX]; + + // + // Short Cycle ... + + // + // LL ... + + // + bool isCSLLSame = + cSLL == pSLL; + + // + bool isPSLLSame = + pSLL == p2SLL; + + // + bool isSLLStartSame = + isCSLLSame && + !isPSLLSame; + + // + bool isSLLFinishedSame = + !isCSLLSame && + isPSLLSame; + + // + // HH ... + + // + bool isCSHHSame = + cSHH == pSHH; + + // + bool isPSHHSame = + pSHH == p2SHH; + + // + bool isSHHStartSame = + isCSHHSame && + !isPSHHSame; + + // + bool isSHHFinishedSame = + !isCSHHSame && + isPSHHSame; + + // + // Mediu Cycle ... + + // + // LL ... + + // + bool isCMLLSame = + cMLL == pMLL; + + // + bool isPMLLSame = + pMLL == p2MLL; + + // + bool isMLLStartSame = + isCMLLSame && + !isPMLLSame; + + // + bool isMLLFinishedSame = + !isCMLLSame && + isPMLLSame; + + // + // HH ... + + // + bool isCMHHSame = + cMHH == pMHH; + + // + bool isPMHHSame = + pMHH == p2MHH; + + // + bool isMHHStartSame = + isCMHHSame && + !isPMHHSame; + + // + bool isMHHFinishedSame = + !isCMHHSame && + isPMHHSame; + + // + // Long Cycle ... + + // + // LL ... + + // + bool isCLLLSame = + cLLL == pLLL; + + // + bool isPLLLSame = + pLLL == p2LLL; + + // + bool isLLLStartSame = + isCLLLSame && + !isPLLLSame; + + // + bool isLLLFinishedSame = + !isCLLLSame && + isPLLLSame; + + // + // HH ... + + // + bool isCLHHSame = + cLHH == pLHH; + + // + bool isPLHHSame = + pLHH == p2LHH; + + // + bool isLHHStartSame = + isCLHHSame && + !isPLHHSame; + + // + bool isLHHFinishedSame = + !isCLHHSame && + isPLHHSame; + + // + // Hind Cycle ... + + // + // LL ... + + // + bool isCHLLSame = + cHLL == pHLL; + + // + bool isPHLLSame = + pHLL == p2HLL; + + // + bool isHLLStartSame = + isCHLLSame && + !isPHLLSame; + + // + bool isHLLFinishedSame = + !isCHLLSame && + isPHLLSame; + + // + // HH ... + + // + bool isCHHHSame = + cHHH == pHHH; + + // + bool isPHHHSame = + pHHH == p2HHH; + + // + bool isHHHStartSame = + isCHHHSame && + !isPHHHSame; + + // + bool isHHHFinishedSame = + !isCHHHSame && + isPHHHSame; + + // + // KI ... + + // + bool isCKISame = + cKI == pKI; + + // + bool isPKISame = + pKI == p2KI; + + // + bool isKIStartSame = + isCKISame && + !isPKISame; + + // + bool isKIFinishedSame = + !isCKISame && + isPKISame; + + // + // RSI ... + + // + double zRSI = iConditions.rsiBuffer[zIDX]; + double cRSI = iConditions.rsiBuffer[cIDX]; + double pRSI = iConditions.rsiBuffer[pIDX]; + double p2RSI = iConditions.rsiBuffer[p2IDX]; + + // + bool isRSIPeak = + pRSI > cRSI && + pRSI > p2RSI && + pRSI > zRSI; + + // + bool isRSIVale = + pRSI < cRSI && + pRSI < p2RSI && + pRSI < zRSI; + + // + bool isRSIBullishVPattern = + cRSI > pRSI && + p2RSI > pRSI && + cRSI > iConditions.rsiOSLevel && + pRSI < iConditions.rsiOSLevel; + + // + bool isRSIBearishVPattern = + cRSI < pRSI && + p2RSI < pRSI && + cRSI < iConditions.rsiOBLevel && + pRSI > iConditions.rsiOBLevel; + + // + // CCI ... + + // + double zCCI = iConditions.cciBuffer[zIDX]; + double cCCI = iConditions.cciBuffer[cIDX]; + double pCCI = iConditions.cciBuffer[pIDX]; + double p2CCI = iConditions.cciBuffer[p2IDX]; + + // + bool isCCIPeak = + pCCI > cCCI && + pCCI > p2CCI && + pCCI > zCCI; + + // + bool isCCIVale = + pCCI < cCCI && + pCCI < p2CCI && + pCCI < zCCI; + + // + bool isCCIBullishVPattern = + cCCI > pCCI && + p2CCI > pCCI && + cCCI > iConditions.cciOSLevel && + pCCI < iConditions.cciOSLevel; + + // + bool isCCIBearishVPattern = + cCCI < pCCI && + p2CCI < pCCI && + cCCI < iConditions.cciOBLevel && + pCCI > iConditions.cciOBLevel; + + // + // Checking Pivots ... + + // + // Peak Pivot ... + if (detectPeakPivot) + { + // + if (!peakPivot.IsValid()) + { + // + peakPivot.type = XCA_PEAK; + peakPivot.symbol = iConditions.symbol; + peakPivot.period = iConditions.period; + + // + if (isPeakFinishedSameLast) + { + // + peakPivot.Clean(); + + // + peakPivot.type = XCA_PEAK; + peakPivot.symbol = iConditions.symbol; + peakPivot.period = iConditions.period; + + // + peakPivot.to = pBar.time; + peakPivot.from = pBar.time; + peakPivot.value = iConditions.peakBuffer[pIDX]; + peakPivot.reserve = iConditions.peakGoldenBuffer[pIDX]; + } + } + + // + if (iConditions.isPeakSameLast) + { + // + peakPivot.from = pBar.time; + + // + peakPivot.reserve = + peakPivot.reserve == 0 + ? iConditions.peakGoldenBuffer[cIDX] + : MathMax(peakPivot.reserve, iConditions.peakGoldenBuffer[cIDX]); + } + + // + if (isPeakStartSameLast) + { + // + has = + peakPivot.IsValid() && + peakPivot.GetAge() >= pivotVerifications; + if (has) + { + // + AddPivot( + peakPivot, + peakPivots, + maxAllowedPivots // + ); + } + + // + peakPivot.Clean(); + } + } + + // + // Vale Pivot ... + if (detectValePivot) + { + // + if (!valePivot.IsValid()) + { + // + valePivot.type = XCA_VALE; + valePivot.symbol = iConditions.symbol; + valePivot.period = iConditions.period; + + // + if (isValeFinishedSameLast) + { + // + valePivot.Clean(); + + // + valePivot.type = XCA_VALE; + valePivot.symbol = iConditions.symbol; + valePivot.period = iConditions.period; + + // + valePivot.to = pBar.time; + valePivot.from = pBar.time; + valePivot.value = iConditions.valeBuffer[pIDX]; + valePivot.reserve = iConditions.valeGoldenBuffer[pIDX]; + } + } + + // + if (iConditions.isValeSameLast) + { + // + valePivot.from = pBar.time; + + // + valePivot.reserve = + valePivot.reserve == 0 + ? iConditions.valeGoldenBuffer[cIDX] + : MathMin(valePivot.reserve, iConditions.valeGoldenBuffer[cIDX]); + } + + // + if (isValeStartSameLast) + { + // + has = valePivot.IsValid() && + valePivot.GetAge() >= pivotVerifications; + if (has) + { + // + AddPivot( + valePivot, + valePivots, + maxAllowedPivots // + ); + } + + // + valePivot.Clean(); + } + } + + // + // SWH Pivot ... + if (detectSWHPivot) + { + // + if (!swhPivot.IsValid()) + { + // + swhPivot.type = XCA_SWH; + swhPivot.symbol = iConditions.symbol; + swhPivot.period = iConditions.period; + + // + if (isSWHFinishedSameLast) + { + // + swhPivot.Clean(); + + // + swhPivot.type = XCA_SWH; + swhPivot.symbol = iConditions.symbol; + swhPivot.period = iConditions.period; + + // + swhPivot.to = pBar.time; + swhPivot.from = pBar.time; + swhPivot.value = iConditions.swingHighBuffer[pIDX]; + } + } + + // + if (iConditions.isSwingHighSameLast) + { + // + swhPivot.from = pBar.time; + + // + double reserve = swhPivot.reserve; + if (pBar.high == pSWH) + { + // + reserve = + reserve == 0 + ? pBar.GetUp() + : MathMin(reserve, pBar.GetUp()); + } + swhPivot.reserve = reserve; + } + + // + if (isSWHStartSameLast) + { + // + double reserve = swhPivot.reserve; + if (cBar.high == cSWH) + { + // + reserve = + reserve == 0 + ? cBar.GetUp() + : MathMin(reserve, cBar.GetUp()); + } + if (pBar.high == pSWH) + { + // + reserve = + reserve == 0 + ? pBar.GetUp() + : MathMin(reserve, pBar.GetUp()); + } + if (reserve == 0 || reserve == swhPivot.value) + { + reserve = swhPivot.value - (5 * points); + } + swhPivot.reserve = reserve; + + // + has = + swhPivot.IsValid() && + swhPivot.GetAge() >= pivotVerifications; + if (has) + { + // + AddPivot( + swhPivot, + swhPivots, + maxAllowedPivots // + ); + } + + // + swhPivot.Clean(); + } + } + + // + // SWL Pivot ... + if (detectSWLPivot) + { + // + if (!swlPivot.IsValid()) + { + // + swlPivot.type = XCA_SWL; + swlPivot.symbol = iConditions.symbol; + swlPivot.period = iConditions.period; + + // + if (isSWLFinishedSameLast) + { + // + swlPivot.Clean(); + + // + swlPivot.type = XCA_SWL; + swlPivot.symbol = iConditions.symbol; + swlPivot.period = iConditions.period; + + // + swlPivot.to = cBar.time; + swlPivot.from = pBar.time; + swlPivot.value = iConditions.swingLowBuffer[cIDX]; + } + } + + // + if (iConditions.isSwingLowSameLast) + { + // + swlPivot.from = pBar.time; + + // + double reserve = swlPivot.reserve; + if (pBar.low == pSWL) + { + // + reserve = + reserve == 0 + ? pBar.GetDown() + : MathMax(reserve, pBar.GetDown()); + } + swlPivot.reserve = reserve; + } + + // + if (isSWLStartSameLast) + { + // + double reserve = swlPivot.reserve; + if (cBar.low == cSWL) + { + // + reserve = + reserve == 0 + ? cBar.GetDown() + : MathMax(reserve, cBar.GetDown()); + } + if (pBar.low == pSWL) + { + // + reserve = + reserve == 0 + ? pBar.GetDown() + : MathMax(reserve, pBar.GetDown()); + } + if (reserve == 0 || reserve == swlPivot.value) + { + reserve = swlPivot.value + (5 * points); + } + swlPivot.reserve = reserve; + + // + has = + swlPivot.IsValid() && + swlPivot.GetAge() >= pivotVerifications; + if (has) + { + // + AddPivot( + swlPivot, + swlPivots, + maxAllowedPivots // + ); + } + + // + swlPivot.Clean(); + } + } + + // + // Peak SWH Res Pivot ... + if (detectPeakSWHResPivot) + { + // + if (!peakSWHResPivot.IsValid()) + { + // + peakSWHResPivot.type = XCA_PEAKSWHRES; + peakSWHResPivot.symbol = iConditions.symbol; + peakSWHResPivot.period = iConditions.period; + + // + if (isFinishedPeakIsPivot) + { + // + peakSWHResPivot.Clean(); + + // + peakSWHResPivot.type = XCA_PEAKSWHRES; + peakSWHResPivot.symbol = iConditions.symbol; + peakSWHResPivot.period = iConditions.period; + + // + peakSWHResPivot.to = pBar.time; + peakSWHResPivot.from = pBar.time; + peakSWHResPivot.value = iConditions.peakBuffer[pIDX]; + peakSWHResPivot.reserve = iConditions.peakGoldenBuffer[pIDX]; + } + } + + // + if (iConditions.isPeakIsPivot) + { + // + peakSWHResPivot.from = pBar.time; + + // + peakSWHResPivot.reserve = + peakSWHResPivot.reserve == 0 + ? iConditions.peakGoldenBuffer[pIDX] + : MathMax(peakSWHResPivot.reserve, iConditions.peakGoldenBuffer[pIDX]); + } + + // + if (isStartPeakIsPivot) + { + // + has = peakSWHResPivot.IsValid() && + peakSWHResPivot.GetAge() >= pivotVerifications; + if (has) + { + // + AddPivot( + peakSWHResPivot, + peakSWHResPivots, + maxAllowedPivots // + ); + + // + XCAPVTick peakTick; + has = peakTick.Init(peakSWHResPivot); + if (has) + { + // + AddPVTick( + peakTick, + peakTicks // + ); + } + + // + peakTick.Clean(); + } + + // + peakSWHResPivot.Clean(); + } + } + + // + // Vale SWL Sup Pivot ... + if (detectValeSWLSupPivot) + { + // + if (!valeSWLSupPivot.IsValid()) + { + // + valeSWLSupPivot.type = XCA_VALESWLSUP; + valeSWLSupPivot.symbol = iConditions.symbol; + valeSWLSupPivot.period = iConditions.period; + + // + if (isFinishedValeIsPivot) + { + // + valeSWLSupPivot.Clean(); + + // + valeSWLSupPivot.type = XCA_VALESWLSUP; + valeSWLSupPivot.symbol = iConditions.symbol; + valeSWLSupPivot.period = iConditions.period; + + // + valeSWLSupPivot.to = pBar.time; + valeSWLSupPivot.from = pBar.time; + valeSWLSupPivot.value = iConditions.valeBuffer[pIDX]; + valeSWLSupPivot.reserve = iConditions.valeGoldenBuffer[pIDX]; + } + } + + // + if (iConditions.isValeIsPivot) + { + // + valeSWLSupPivot.from = pBar.time; + + // + valeSWLSupPivot.reserve = + valeSWLSupPivot.reserve == 0 + ? iConditions.valeGoldenBuffer[pIDX] + : MathMin(valeSWLSupPivot.reserve, iConditions.valeGoldenBuffer[pIDX]); + } + + // + if (isStartValeIsPivot) + { + // + has = valeSWLSupPivot.IsValid() && + valeSWLSupPivot.GetAge() >= pivotVerifications; + if (has) + { + // + AddPivot( + valeSWLSupPivot, + valeSWLSupPivots, + maxAllowedPivots // + ); + + // + XCAPVTick valeTick; + has = valeTick.Init(valeSWLSupPivot); + if (has) + { + // + AddPVTick( + valeTick, + valeTicks // + ); + } + + // + valeTick.Clean(); + } + + // + valeSWLSupPivot.Clean(); + } + } + + // + // KI Bullish ... + if (detectKIBullishPivot) + { + // + if (!kiBullishPivot.IsValid()) + { + // + kiBullishPivot.type = XCA_KI_BULL; + kiBullishPivot.symbol = iConditions.symbol; + kiBullishPivot.period = iConditions.period; + + // + if (iConditions.isKISwitchedToBearish) + { + // + kiBullishPivot.Clean(); + + // + kiBullishPivot.type = XCA_KI_BULL; + kiBullishPivot.symbol = iConditions.symbol; + kiBullishPivot.period = iConditions.period; + + // + kiBullishPivot.to = pBar.time; + kiBullishPivot.from = pBar.time; + kiBullishPivot.value = iConditions.kiBuffer[pIDX]; + kiBullishPivot.reserve = iConditions.kiBuffer[pIDX]; + } + } + + // + if (iConditions.isKIBullish) + { + // + kiBullishPivot.from = cBar.time; + + // + Add( + iConditions.kiBuffer[cIDX], + kiBullishPivot.values // + ); + + // + kiBullishPivot.value = + kiBullishPivot.value == 0 + ? iConditions.kiBuffer[cIDX] + : MathMin(iConditions.kiBuffer[cIDX], kiBullishPivot.value); + + // + kiBullishPivot.reserve = + kiBullishPivot.reserve == 0 + ? iConditions.kiBuffer[cIDX] + : MathMax(iConditions.kiBuffer[cIDX], kiBullishPivot.reserve); + } + + // + if (iConditions.isKISwitchedToBullish) + { + // + has = + kiBullishPivot.IsValid() && + kiBullishPivot.GetAge() >= pivotVerifications; + if (has) + { + // + AddPivot( + kiBullishPivot, + kiBullishPivots, + maxAllowedPivots // + ); + } + + // + kiBullishPivot.Clean(); + } + } + + // + // KI Bearish ... + if (detectKIBearishPivot) + { + // + if (!kiBearishPivot.IsValid()) + { + // + kiBearishPivot.type = XCA_KI_BEAR; + kiBearishPivot.symbol = iConditions.symbol; + kiBearishPivot.period = iConditions.period; + + // + if (iConditions.isKISwitchedToBullish) + { + // + kiBearishPivot.Clean(); + + // + kiBearishPivot.type = XCA_KI_BEAR; + kiBearishPivot.symbol = iConditions.symbol; + kiBearishPivot.period = iConditions.period; + + // + kiBearishPivot.to = pBar.time; + kiBearishPivot.from = pBar.time; + kiBearishPivot.value = iConditions.kiBuffer[pIDX]; + kiBearishPivot.reserve = iConditions.kiBuffer[pIDX]; + } + } + + // + if (iConditions.isKIBearish) + { + // + kiBearishPivot.from = cBar.time; + + // + Add( + iConditions.kiBuffer[cIDX], + kiBearishPivot.values // + ); + + // + kiBearishPivot.value = + kiBearishPivot.value == 0 + ? iConditions.kiBuffer[cIDX] + : MathMax(iConditions.kiBuffer[cIDX], kiBearishPivot.value); + + // + kiBearishPivot.reserve = + kiBearishPivot.reserve == 0 + ? iConditions.kiBuffer[cIDX] + : MathMin(iConditions.kiBuffer[cIDX], kiBearishPivot.reserve); + } + + // + if (iConditions.isKISwitchedToBearish) + { + // + has = + kiBearishPivot.IsValid() && + kiBearishPivot.GetAge() >= pivotVerifications; + if (has) + { + // + AddPivot( + kiBearishPivot, + kiBearishPivots, + maxAllowedPivots // + ); + } + + // + kiBearishPivot.Clean(); + } + } + + // + // FVG Bullish ... + if (detectFVGBullishPivot) + { + // + if (isBullishFVG) + { + // + XCAPivot iPivot; + + // + iPivot.to = fvgBox.to; + iPivot.from = fvgBox.from; + iPivot.type = XCA_FVG_BULL; + iPivot.value = fvgBox.lower; + iPivot.reserve = fvgBox.upper; + iPivot.symbol = fvgBox.symbol; + iPivot.period = fvgBox.period; + + // + AddPivot( + iPivot, + fvgBullishPivots, + maxAllowedPivots // + ); + + // + double fValue = + fvgBox.IsBullish() + ? cVale + : cPeak; + + // + // XPVFVG Handling ... + AddOrUpdatePVFVG( + fValue, + iPivot, + pvFVGBullishPivots // + ); + + // + iPivot.Clean(); + } + } + + // + // FVG Bearish ... + if (detectFVGBearishPivot) + { + // + if (isBearishFVG) + { + // + XCAPivot iPivot; + + // + iPivot.to = fvgBox.to; + iPivot.from = fvgBox.from; + iPivot.type = XCA_FVG_BEAR; + iPivot.value = fvgBox.upper; + iPivot.reserve = fvgBox.lower; + iPivot.symbol = fvgBox.symbol; + iPivot.period = fvgBox.period; + + // + AddPivot( + iPivot, + fvgBearishPivots, + maxAllowedPivots // + ); + + // + double fValue = + fvgBox.IsBullish() + ? cVale + : cPeak; + + // + // XPVFVG Handling ... + AddOrUpdatePVFVG( + fValue, + iPivot, + pvFVGBearishPivots // + ); + + // + iPivot.Clean(); + } + } + + // + // TKI Bullish ... + if (detectTKIBullishPivot) + { + // + if (!tkiBullishPivot.IsValid()) + { + // + tkiBullishPivot.type = XCA_TKI_BULL; + tkiBullishPivot.symbol = iConditions.symbol; + tkiBullishPivot.period = iConditions.period; + + // + if (iConditions.isTKISwitchedToBearish) + { + // + tkiBullishPivot.Clean(); + + // + tkiBullishPivot.type = XCA_TKI_BULL; + tkiBullishPivot.symbol = iConditions.symbol; + tkiBullishPivot.period = iConditions.period; + + // + tkiBullishPivot.to = pBar.time; + tkiBullishPivot.from = pBar.time; + tkiBullishPivot.value = iConditions.tkiBuffer[pIDX]; + tkiBullishPivot.reserve = iConditions.tkiBuffer[pIDX]; + } + } + + // + if (iConditions.isTKIBullish) + { + // + tkiBullishPivot.from = cBar.time; + + // + Add( + iConditions.tkiBuffer[cIDX], + tkiBullishPivot.values // + ); + + // + tkiBullishPivot.value = + tkiBullishPivot.value == 0 + ? iConditions.tkiBuffer[cIDX] + : MathMin(iConditions.tkiBuffer[cIDX], tkiBullishPivot.value); + + // + tkiBullishPivot.reserve = + tkiBullishPivot.reserve == 0 + ? iConditions.tkiBuffer[cIDX] + : MathMax(iConditions.tkiBuffer[cIDX], tkiBullishPivot.reserve); + } + + // + if (iConditions.isTKISwitchedToBullish) + { + // + has = + tkiBullishPivot.IsValid() && + tkiBullishPivot.GetAge() >= pivotVerifications; + if (has) + { + // + AddPivot( + tkiBullishPivot, + tkiBullishPivots, + maxAllowedPivots // + ); + } + + // + tkiBullishPivot.Clean(); + } + } + + // + // TKI Bearish ... + if (detectTKIBearishPivot) + { + // + if (!tkiBearishPivot.IsValid()) + { + // + tkiBearishPivot.type = XCA_TKI_BEAR; + tkiBearishPivot.symbol = iConditions.symbol; + tkiBearishPivot.period = iConditions.period; + + // + if (iConditions.isTKISwitchedToBullish) + { + // + tkiBearishPivot.Clean(); + + // + tkiBearishPivot.type = XCA_TKI_BEAR; + tkiBearishPivot.symbol = iConditions.symbol; + tkiBearishPivot.period = iConditions.period; + + // + tkiBearishPivot.to = pBar.time; + tkiBearishPivot.from = pBar.time; + tkiBearishPivot.value = iConditions.tkiBuffer[pIDX]; + tkiBearishPivot.reserve = iConditions.tkiBuffer[pIDX]; + } + } + + // + if (iConditions.isTKIBearish) + { + // + tkiBearishPivot.from = cBar.time; + + // + Add( + iConditions.tkiBuffer[cIDX], + tkiBearishPivot.values // + ); + + // + tkiBearishPivot.value = + tkiBearishPivot.value == 0 + ? iConditions.tkiBuffer[cIDX] + : MathMax(iConditions.tkiBuffer[cIDX], tkiBearishPivot.value); + + // + tkiBearishPivot.reserve = + tkiBearishPivot.reserve == 0 + ? iConditions.tkiBuffer[cIDX] + : MathMin(iConditions.tkiBuffer[cIDX], tkiBearishPivot.reserve); + } + + // + if (iConditions.isTKISwitchedToBearish) + { + // + has = + tkiBearishPivot.IsValid() && + tkiBearishPivot.GetAge() >= pivotVerifications; + if (has) + { + // + AddPivot( + tkiBearishPivot, + tkiBearishPivots, + maxAllowedPivots // + ); + } + + // + tkiBearishPivot.Clean(); + } + } + + // + // TREND Bullish ... + if (detectTrendBullishPivot) + { + // + if (!trendBullishPivot.IsValid()) + { + // + trendBullishPivot.type = XCA_TREND_BULL; + trendBullishPivot.symbol = iConditions.symbol; + trendBullishPivot.period = iConditions.period; + + // + if (iConditions.isTrendSwitchedToBearish) + { + // + trendBullishPivot.Clean(); + + // + trendBullishPivot.type = XCA_TREND_BULL; + trendBullishPivot.symbol = iConditions.symbol; + trendBullishPivot.period = iConditions.period; + + // + trendBullishPivot.to = pBar.time; + trendBullishPivot.from = pBar.time; + trendBullishPivot.value = iConditions.trendBuffer[pIDX]; + trendBullishPivot.reserve = iConditions.trendBuffer[pIDX]; + } + } + + // + if (iConditions.isTrendBullish) + { + // + trendBullishPivot.from = cBar.time; + + // + Add( + iConditions.trendBuffer[cIDX], + trendBullishPivot.values // + ); + + // + trendBullishPivot.value = + trendBullishPivot.value == 0 + ? iConditions.trendBuffer[cIDX] + : MathMin(iConditions.trendBuffer[cIDX], trendBullishPivot.value); + + // + trendBullishPivot.reserve = + trendBullishPivot.reserve == 0 + ? iConditions.trendBuffer[cIDX] + : MathMax(iConditions.trendBuffer[cIDX], trendBullishPivot.reserve); + } + + // + if (iConditions.isTrendSwitchedToBullish) + { + // + has = + trendBullishPivot.IsValid() && + trendBullishPivot.GetAge() >= pivotVerifications; + if (has) + { + // + AddPivot( + trendBullishPivot, + trendBullishPivots, + maxAllowedPivots // + ); + } + + // + trendBullishPivot.Clean(); + } + } + + // + // TREND Bearish ... + if (detectTrendBearishPivot) + { + // + if (!trendBearishPivot.IsValid()) + { + // + trendBearishPivot.type = XCA_TREND_BEAR; + trendBearishPivot.symbol = iConditions.symbol; + trendBearishPivot.period = iConditions.period; + + // + if (iConditions.isTrendSwitchedToBullish) + { + // + trendBearishPivot.Clean(); + + // + trendBearishPivot.type = XCA_TREND_BEAR; + trendBearishPivot.symbol = iConditions.symbol; + trendBearishPivot.period = iConditions.period; + + // + trendBearishPivot.to = pBar.time; + trendBearishPivot.from = pBar.time; + trendBearishPivot.value = iConditions.trendBuffer[pIDX]; + trendBearishPivot.reserve = iConditions.trendBuffer[pIDX]; + } + } + + // + if (iConditions.isTrendBearish) + { + // + trendBearishPivot.from = cBar.time; + + // + Add( + iConditions.trendBuffer[cIDX], + trendBearishPivot.values // + ); + + // + trendBearishPivot.value = + trendBearishPivot.value == 0 + ? iConditions.trendBuffer[cIDX] + : MathMax(iConditions.trendBuffer[cIDX], trendBearishPivot.value); + + // + trendBearishPivot.reserve = + trendBearishPivot.reserve == 0 + ? iConditions.trendBuffer[cIDX] + : MathMin(iConditions.trendBuffer[cIDX], trendBearishPivot.reserve); + } + + // + if (iConditions.isTrendSwitchedToBearish) + { + // + has = + trendBearishPivot.IsValid() && + trendBearishPivot.GetAge() >= pivotVerifications; + if (has) + { + // + AddPivot( + trendBearishPivot, + trendBearishPivots, + maxAllowedPivots // + ); + } + + // + trendBearishPivot.Clean(); + } + } + + // + // TKITRND Bullish ... + if (detectTKITRNDBullishPivot) + { + // + if (!tkitrndBullishPivot.IsValid()) + { + // + tkitrndBullishPivot.type = XCA_TKITRND_BULL; + tkitrndBullishPivot.symbol = iConditions.symbol; + tkitrndBullishPivot.period = iConditions.period; + + // + if (!isCTKITRNDBullish && isPTKITRNDBullish) + { + // + tkitrndBullishPivot.Clean(); + + // + tkitrndBullishPivot.type = XCA_TKITRND_BULL; + tkitrndBullishPivot.symbol = iConditions.symbol; + tkitrndBullishPivot.period = iConditions.period; + + // + tkitrndBullishPivot.to = pBar.time; + tkitrndBullishPivot.from = pBar.time; + tkitrndBullishPivot.value = pTKITRNDMin; + tkitrndBullishPivot.reserve = pTKITRNDMax; + } + } + + // + if (isCTKITRNDBullish) + { + // + tkitrndBullishPivot.from = cBar.time; + + // + Add( + cTKITRNDMin, + tkitrndBullishPivot.values // + ); + + // + Add( + cTKITRNDMax, + tkitrndBullishPivot.values // + ); + + // + tkitrndBullishPivot.value = + tkitrndBullishPivot.value == 0 + ? cTKITRNDMin + : MathMin(cTKITRNDMin, tkitrndBullishPivot.value); + + // + tkitrndBullishPivot.reserve = + tkitrndBullishPivot.reserve == 0 + ? cTKITRNDMax + : MathMax(cTKITRNDMax, tkitrndBullishPivot.reserve); + } + + // + if (!isCTKITRNDBullish) + { + // + has = + tkitrndBullishPivot.IsValid() && + tkitrndBullishPivot.GetAge() >= pivotVerifications; + if (has) + { + // + AddPivot( + tkitrndBullishPivot, + tkitrndBullishPivots, + maxAllowedPivots // + ); + } + + // + trendBullishPivot.Clean(); + } + } + + // + // TKITRND Bearish ... + if (detectTKITRNDBearishPivot) + { + // + if (!tkitrndBearishPivot.IsValid()) + { + // + tkitrndBearishPivot.type = XCA_TKITRND_BEAR; + tkitrndBearishPivot.symbol = iConditions.symbol; + tkitrndBearishPivot.period = iConditions.period; + + // + if (!isCTKITRNDBearish && isPTKITRNDBearish) + { + // + tkitrndBearishPivot.Clean(); + + // + tkitrndBearishPivot.type = XCA_TKITRND_BEAR; + tkitrndBearishPivot.symbol = iConditions.symbol; + tkitrndBearishPivot.period = iConditions.period; + + // + tkitrndBearishPivot.to = pBar.time; + tkitrndBearishPivot.from = pBar.time; + tkitrndBearishPivot.value = pTKITRNDMax; + tkitrndBearishPivot.reserve = pTKITRNDMin; + } + } + + // + if (isCTKITRNDBearish) + { + // + tkitrndBearishPivot.from = cBar.time; + + // + Add( + cTKITRNDMin, + tkitrndBearishPivot.values // + ); + + // + Add( + cTKITRNDMax, + tkitrndBearishPivot.values // + ); + + // + tkitrndBearishPivot.value = + tkitrndBearishPivot.value == 0 + ? cTKITRNDMax + : MathMax(cTKITRNDMax, tkitrndBearishPivot.value); + + // + tkitrndBearishPivot.reserve = + tkitrndBearishPivot.reserve == 0 + ? cTKITRNDMin + : MathMin(cTKITRNDMin, tkitrndBearishPivot.reserve); + } + + // + if (!isCTKITRNDBearish) + { + // + has = + tkitrndBearishPivot.IsValid() && + tkitrndBearishPivot.GetAge() >= pivotVerifications; + if (has) + { + // + AddPivot( + tkitrndBearishPivot, + tkitrndBearishPivots, + maxAllowedPivots // + ); + } + + // + trendBearishPivot.Clean(); + } + } + + // + // Cycles LL ... + if (detectCycleSameLLPivot) + { + // + // Short Cycle ... + if (!sSameLLPivot.IsValid()) + { + // + sSameLLPivot.type = XCA_LL; + sSameLLPivot.symbol = iConditions.symbol; + sSameLLPivot.period = iConditions.period; + + // + if (isSLLFinishedSame) + { + // + sSameLLPivot.Clean(); + + // + sSameLLPivot.type = XCA_LL; + sSameLLPivot.symbol = iConditions.symbol; + sSameLLPivot.period = iConditions.period; + + // + sSameLLPivot.to = pBar.time; + sSameLLPivot.from = pBar.time; + sSameLLPivot.value = pSLL; + sSameLLPivot.reserve = pSLL; + } + } + + // + if (isCSLLSame) + { + // + sSameLLPivot.from = pBar.time; + + // + double reserve = sSameLLPivot.reserve; + if (pBar.low == pSLL) + { + // + reserve = + reserve == 0 + ? pBar.GetDown() + : MathMax(reserve, pBar.GetDown()); + } + sSameLLPivot.reserve = reserve; + } + + // + if (isSLLStartSame) + { + // + double reserve = sSameLLPivot.reserve; + if (cBar.low == cSLL) + { + // + reserve = + reserve == 0 + ? cBar.GetDown() + : MathMax(reserve, cBar.GetDown()); + } + if (pBar.low == pSLL) + { + // + reserve = + reserve == 0 + ? pBar.GetDown() + : MathMax(reserve, pBar.GetDown()); + } + if (reserve == 0 || reserve == sSameLLPivot.value) + { + reserve = sSameLLPivot.value + (5 * points); + } + sSameLLPivot.reserve = reserve; + + // + has = + sSameLLPivot.IsValid() && + sSameLLPivot.GetAge() >= pivotVerifications; + if (has) + { + // + AddPivot( + sSameLLPivot, + sSameLLPivots, + maxAllowedPivots // + ); + } + + // + sSameLLPivot.Clean(); + } + + // + // Medium Cycle ... + if (!mSameLLPivot.IsValid()) + { + // + mSameLLPivot.type = XCA_LL; + mSameLLPivot.symbol = iConditions.symbol; + mSameLLPivot.period = iConditions.period; + + // + if (isMLLFinishedSame) + { + // + mSameLLPivot.Clean(); + + // + mSameLLPivot.type = XCA_LL; + mSameLLPivot.symbol = iConditions.symbol; + mSameLLPivot.period = iConditions.period; + + // + mSameLLPivot.to = pBar.time; + mSameLLPivot.from = pBar.time; + mSameLLPivot.value = pMLL; + mSameLLPivot.reserve = pMLL; + } + } + + // + if (isCMLLSame) + { + // + mSameLLPivot.from = pBar.time; + + // + double reserve = mSameLLPivot.reserve; + if (pBar.low == pMLL) + { + // + reserve = + reserve == 0 + ? pBar.GetDown() + : MathMax(reserve, pBar.GetDown()); + } + mSameLLPivot.reserve = reserve; + } + + // + if (isMLLStartSame) + { + // + double reserve = mSameLLPivot.reserve; + if (cBar.low == cMLL) + { + // + reserve = + reserve == 0 + ? cBar.GetDown() + : MathMax(reserve, cBar.GetDown()); + } + if (pBar.low == pMLL) + { + // + reserve = + reserve == 0 + ? pBar.GetDown() + : MathMax(reserve, pBar.GetDown()); + } + if (reserve == 0 || reserve == mSameLLPivot.value) + { + reserve = mSameLLPivot.value + (5 * points); + } + mSameLLPivot.reserve = reserve; + + // + has = + mSameLLPivot.IsValid() && + mSameLLPivot.GetAge() >= pivotVerifications; + if (has) + { + // + AddPivot( + mSameLLPivot, + mSameLLPivots, + maxAllowedPivots // + ); + } + + // + mSameLLPivot.Clean(); + } + + // + // Long Cycle ... + if (!lSameLLPivot.IsValid()) + { + // + lSameLLPivot.type = XCA_LL; + lSameLLPivot.symbol = iConditions.symbol; + lSameLLPivot.period = iConditions.period; + + // + if (isLLLFinishedSame) + { + // + lSameLLPivot.Clean(); + + // + lSameLLPivot.type = XCA_LL; + lSameLLPivot.symbol = iConditions.symbol; + lSameLLPivot.period = iConditions.period; + + // + lSameLLPivot.to = pBar.time; + lSameLLPivot.from = pBar.time; + lSameLLPivot.value = pLLL; + lSameLLPivot.reserve = pLLL; + } + } + + // + if (isCLLLSame) + { + // + lSameLLPivot.from = pBar.time; + + // + double reserve = lSameLLPivot.reserve; + if (pBar.low == pLLL) + { + // + reserve = + reserve == 0 + ? pBar.GetDown() + : MathMax(reserve, pBar.GetDown()); + } + lSameLLPivot.reserve = reserve; + } + + // + if (isLLLStartSame) + { + // + double reserve = lSameLLPivot.reserve; + if (cBar.low == cLLL) + { + // + reserve = + reserve == 0 + ? cBar.GetDown() + : MathMax(reserve, cBar.GetDown()); + } + if (pBar.low == pLLL) + { + // + reserve = + reserve == 0 + ? pBar.GetDown() + : MathMax(reserve, pBar.GetDown()); + } + if (reserve == 0 || reserve == lSameLLPivot.value) + { + reserve = lSameLLPivot.value + (5 * points); + } + lSameLLPivot.reserve = reserve; + + // + has = + lSameLLPivot.IsValid() && + lSameLLPivot.GetAge() >= pivotVerifications; + if (has) + { + // + AddPivot( + lSameLLPivot, + lSameLLPivots, + maxAllowedPivots // + ); + } + + // + lSameLLPivot.Clean(); + } + + // + // Hind Cycle ... + if (!hSameLLPivot.IsValid()) + { + // + hSameLLPivot.type = XCA_LL; + hSameLLPivot.symbol = iConditions.symbol; + hSameLLPivot.period = iConditions.period; + + // + if (isHLLFinishedSame) + { + // + hSameLLPivot.Clean(); + + // + hSameLLPivot.type = XCA_LL; + hSameLLPivot.symbol = iConditions.symbol; + hSameLLPivot.period = iConditions.period; + + // + hSameLLPivot.to = pBar.time; + hSameLLPivot.from = pBar.time; + hSameLLPivot.value = pHLL; + hSameLLPivot.reserve = pHLL; + } + } + + // + if (isCHLLSame) + { + // + hSameLLPivot.from = pBar.time; + + // + double reserve = hSameLLPivot.reserve; + if (pBar.low == pHLL) + { + // + reserve = + reserve == 0 + ? pBar.GetDown() + : MathMax(reserve, pBar.GetDown()); + } + hSameLLPivot.reserve = reserve; + } + + // + if (isHLLStartSame) + { + // + double reserve = hSameLLPivot.reserve; + if (cBar.low == cHLL) + { + // + reserve = + reserve == 0 + ? cBar.GetDown() + : MathMax(reserve, cBar.GetDown()); + } + if (pBar.low == pHLL) + { + // + reserve = + reserve == 0 + ? pBar.GetDown() + : MathMax(reserve, pBar.GetDown()); + } + if (reserve == 0 || reserve == hSameLLPivot.value) + { + reserve = hSameLLPivot.value + (5 * points); + } + hSameLLPivot.reserve = reserve; + + // + has = + hSameLLPivot.IsValid() && + hSameLLPivot.GetAge() >= pivotVerifications; + if (has) + { + // + AddPivot( + hSameLLPivot, + hSameLLPivots, + maxAllowedPivots // + ); + } + + // + hSameLLPivot.Clean(); + } + } + + // + // Cycles HH ... + if (detectCycleSameHHPivot) + { + // + // Short Cycle ... + if (!sSameHHPivot.IsValid()) + { + // + sSameHHPivot.type = XCA_HH; + sSameHHPivot.symbol = iConditions.symbol; + sSameHHPivot.period = iConditions.period; + + // + if (isSHHFinishedSame) + { + // + sSameHHPivot.Clean(); + + // + sSameHHPivot.type = XCA_HH; + sSameHHPivot.symbol = iConditions.symbol; + sSameHHPivot.period = iConditions.period; + + // + sSameHHPivot.to = pBar.time; + sSameHHPivot.from = pBar.time; + sSameHHPivot.value = pSHH; + sSameHHPivot.reserve = pSHH; + } + } + + // + if (isCSHHSame) + { + // + sSameHHPivot.from = pBar.time; + + // + double reserve = sSameHHPivot.reserve; + if (pBar.high == pSHH) + { + // + reserve = + reserve == 0 + ? pBar.GetUp() + : MathMin(reserve, pBar.GetUp()); + } + sSameHHPivot.reserve = reserve; + } + + // + if (isSHHStartSame) + { + // + double reserve = sSameHHPivot.reserve; + if (cBar.high == cSHH) + { + // + reserve = + reserve == 0 + ? cBar.GetUp() + : MathMin(reserve, cBar.GetUp()); + } + if (pBar.high == pSHH) + { + // + reserve = + reserve == 0 + ? pBar.GetUp() + : MathMin(reserve, pBar.GetUp()); + } + if (reserve == 0 || reserve == sSameHHPivot.value) + { + reserve = sSameHHPivot.value + (5 * points); + } + sSameHHPivot.reserve = reserve; + + // + has = + sSameHHPivot.IsValid() && + sSameHHPivot.GetAge() >= pivotVerifications; + if (has) + { + // + AddPivot( + sSameHHPivot, + sSameHHPivots, + maxAllowedPivots // + ); + } + + // + sSameHHPivot.Clean(); + } + + // + // Medium Cycle ... + if (!mSameHHPivot.IsValid()) + { + // + mSameHHPivot.type = XCA_HH; + mSameHHPivot.symbol = iConditions.symbol; + mSameHHPivot.period = iConditions.period; + + // + if (isMHHFinishedSame) + { + // + mSameHHPivot.Clean(); + + // + mSameHHPivot.type = XCA_HH; + mSameHHPivot.symbol = iConditions.symbol; + mSameHHPivot.period = iConditions.period; + + // + mSameHHPivot.to = pBar.time; + mSameHHPivot.from = pBar.time; + mSameHHPivot.value = pMHH; + mSameHHPivot.reserve = pMHH; + } + } + + // + if (isCMHHSame) + { + // + mSameHHPivot.from = pBar.time; + + // + double reserve = mSameHHPivot.reserve; + if (pBar.high == pMHH) + { + // + reserve = + reserve == 0 + ? pBar.GetUp() + : MathMin(reserve, pBar.GetUp()); + } + mSameHHPivot.reserve = reserve; + } + + // + if (isMHHStartSame) + { + // + double reserve = mSameHHPivot.reserve; + if (cBar.high == cMHH) + { + // + reserve = + reserve == 0 + ? cBar.GetUp() + : MathMin(reserve, cBar.GetUp()); + } + if (pBar.high == pMHH) + { + // + reserve = + reserve == 0 + ? pBar.GetUp() + : MathMin(reserve, pBar.GetUp()); + } + if (reserve == 0 || reserve == mSameHHPivot.value) + { + reserve = mSameHHPivot.value + (5 * points); + } + mSameHHPivot.reserve = reserve; + + // + has = + mSameHHPivot.IsValid() && + mSameHHPivot.GetAge() >= pivotVerifications; + if (has) + { + // + AddPivot( + mSameHHPivot, + mSameHHPivots, + maxAllowedPivots // + ); + } + + // + mSameHHPivot.Clean(); + } + + // + // Long Cycle ... + if (!lSameHHPivot.IsValid()) + { + // + lSameHHPivot.type = XCA_HH; + lSameHHPivot.symbol = iConditions.symbol; + lSameHHPivot.period = iConditions.period; + + // + if (isLHHFinishedSame) + { + // + lSameHHPivot.Clean(); + + // + lSameHHPivot.type = XCA_HH; + lSameHHPivot.symbol = iConditions.symbol; + lSameHHPivot.period = iConditions.period; + + // + lSameHHPivot.to = pBar.time; + lSameHHPivot.from = pBar.time; + lSameHHPivot.value = pLHH; + lSameHHPivot.reserve = pLHH; + } + } + + // + if (isCLHHSame) + { + // + lSameHHPivot.from = pBar.time; + + // + double reserve = lSameHHPivot.reserve; + if (pBar.high == pLHH) + { + // + reserve = + reserve == 0 + ? pBar.GetUp() + : MathMin(reserve, pBar.GetUp()); + } + lSameHHPivot.reserve = reserve; + } + + // + if (isLHHStartSame) + { + // + double reserve = lSameHHPivot.reserve; + if (cBar.high == cLHH) + { + // + reserve = + reserve == 0 + ? cBar.GetUp() + : MathMin(reserve, cBar.GetUp()); + } + if (pBar.high == pLHH) + { + // + reserve = + reserve == 0 + ? pBar.GetUp() + : MathMin(reserve, pBar.GetUp()); + } + if (reserve == 0 || reserve == lSameHHPivot.value) + { + reserve = lSameHHPivot.value + (5 * points); + } + lSameHHPivot.reserve = reserve; + + // + has = + lSameHHPivot.IsValid() && + lSameHHPivot.GetAge() >= pivotVerifications; + if (has) + { + // + AddPivot( + lSameHHPivot, + lSameHHPivots, + maxAllowedPivots // + ); + } + + // + lSameHHPivot.Clean(); + } + + // + // Hind Cycle ... + if (!hSameHHPivot.IsValid()) + { + // + hSameHHPivot.type = XCA_HH; + hSameHHPivot.symbol = iConditions.symbol; + hSameHHPivot.period = iConditions.period; + + // + if (isHHHFinishedSame) + { + // + hSameHHPivot.Clean(); + + // + hSameHHPivot.type = XCA_HH; + hSameHHPivot.symbol = iConditions.symbol; + hSameHHPivot.period = iConditions.period; + + // + hSameHHPivot.to = pBar.time; + hSameHHPivot.from = pBar.time; + hSameHHPivot.value = pHHH; + hSameHHPivot.reserve = pHHH; + } + } + + // + if (isCHHHSame) + { + // + hSameHHPivot.from = pBar.time; + + // + double reserve = hSameHHPivot.reserve; + if (pBar.high == pHHH) + { + // + reserve = + reserve == 0 + ? pBar.GetUp() + : MathMin(reserve, pBar.GetUp()); + } + hSameHHPivot.reserve = reserve; + } + + // + if (isHHHStartSame) + { + // + double reserve = hSameHHPivot.reserve; + if (cBar.high == cHHH) + { + // + reserve = + reserve == 0 + ? cBar.GetUp() + : MathMin(reserve, cBar.GetUp()); + } + if (pBar.high == pHHH) + { + // + reserve = + reserve == 0 + ? pBar.GetUp() + : MathMin(reserve, pBar.GetUp()); + } + if (reserve == 0 || reserve == hSameHHPivot.value) + { + reserve = hSameHHPivot.value + (5 * points); + } + hSameHHPivot.reserve = reserve; + + // + has = + hSameHHPivot.IsValid() && + hSameHHPivot.GetAge() >= pivotVerifications; + if (has) + { + // + AddPivot( + hSameHHPivot, + hSameHHPivots, + maxAllowedPivots // + ); + } + + // + hSameHHPivot.Clean(); + } + } + + // + // RSI Peak ... + if (detectRSIPeakPivot) + { + // + if (isRSIPeak) + { + // + XCAPivot iPivot; + + // + iPivot.to = cBar.time; + iPivot.from = p2Bar.time; + iPivot.value = pBar.high; + iPivot.type = XCA_RSI_PEAK; + iPivot.symbol = cBar.symbol; + iPivot.period = cBar.period; + + // + Add( + cBar.high, + iPivot.values // + ); + Add( + pBar.high, + iPivot.values // + ); + Add( + p2Bar.high, + iPivot.values // + ); + Add( + cBar.close, + iPivot.values // + ); + Add( + pBar.close, + iPivot.values // + ); + Add( + p2Bar.close, + iPivot.values // + ); + + // + iPivot.reserve = GetMin(iPivot.values); + + // + AddPivot( + iPivot, + rsiPeakPivots, + maxAllowedPivots // + ); + + // + iPivot.Clean(); + } + } + + // + // RSI Vale ... + if (detectRSIValePivot) + { + // + if (isRSIVale) + { + // + XCAPivot iPivot; + + // + iPivot.to = cBar.time; + iPivot.from = p2Bar.time; + iPivot.value = pBar.low; + iPivot.type = XCA_RSI_VALE; + iPivot.symbol = cBar.symbol; + iPivot.period = cBar.period; + + // + Add( + cBar.low, + iPivot.values // + ); + Add( + pBar.low, + iPivot.values // + ); + Add( + p2Bar.low, + iPivot.values // + ); + Add( + cBar.close, + iPivot.values // + ); + Add( + pBar.close, + iPivot.values // + ); + Add( + p2Bar.close, + iPivot.values // + ); + + // + iPivot.reserve = GetMax(iPivot.values); + + // + AddPivot( + iPivot, + rsiValePivots, + maxAllowedPivots // + ); + + // + iPivot.Clean(); + } + } + + // + // RSI Crossed Over OS ... + if (detectRSICrossedOverOSPivot) + { + // + if (isRSIBullishVPattern) + { + // + XCAPivot iPivot; + + // + iPivot.to = cBar.time; + iPivot.from = p2Bar.time; + iPivot.value = pBar.low; + iPivot.type = XCA_RSI_COOS; + iPivot.symbol = cBar.symbol; + iPivot.period = cBar.period; + + // + Add( + cBar.low, + iPivot.values // + ); + Add( + pBar.low, + iPivot.values // + ); + Add( + p2Bar.low, + iPivot.values // + ); + Add( + cBar.close, + iPivot.values // + ); + Add( + pBar.close, + iPivot.values // + ); + Add( + p2Bar.close, + iPivot.values // + ); + + // + iPivot.reserve = GetMax(iPivot.values); + + // + AddPivot( + iPivot, + rsiCrossedOverOSPivots, + maxAllowedPivots // + ); + + // + iPivot.Clean(); + } + } + + // + // RSI Crossed Under OS ... + if (detectRSICrossedUnderOBPivot) + { + // + if (isRSIBearishVPattern) + { + // + XCAPivot iPivot; + + // + iPivot.to = cBar.time; + iPivot.from = p2Bar.time; + iPivot.value = pBar.high; + iPivot.type = XCA_RSI_CUOB; + iPivot.symbol = cBar.symbol; + iPivot.period = cBar.period; + + // + Add( + cBar.high, + iPivot.values // + ); + Add( + pBar.high, + iPivot.values // + ); + Add( + p2Bar.high, + iPivot.values // + ); + Add( + cBar.close, + iPivot.values // + ); + Add( + pBar.close, + iPivot.values // + ); + Add( + p2Bar.close, + iPivot.values // + ); + + // + iPivot.reserve = GetMin(iPivot.values); + + // + AddPivot( + iPivot, + rsiCrossedUnderOBPivots, + maxAllowedPivots // + ); + + // + iPivot.Clean(); + } + } + + // + // CCI Peak ... + if (detectCCIPeakPivot) + { + // + if (isCCIPeak) + { + // + XCAPivot iPivot; + + // + iPivot.to = cBar.time; + iPivot.from = p2Bar.time; + iPivot.value = pBar.high; + iPivot.type = XCA_CCI_PEAK; + iPivot.symbol = cBar.symbol; + iPivot.period = cBar.period; + + // + Add( + cBar.high, + iPivot.values // + ); + Add( + pBar.high, + iPivot.values // + ); + Add( + p2Bar.high, + iPivot.values // + ); + Add( + cBar.close, + iPivot.values // + ); + Add( + pBar.close, + iPivot.values // + ); + Add( + p2Bar.close, + iPivot.values // + ); + + // + iPivot.reserve = GetMin(iPivot.values); + + // + AddPivot( + iPivot, + cciPeakPivots, + maxAllowedPivots // + ); + + // + iPivot.Clean(); + } + } + + // + // CCI Vale ... + if (detectCCIValePivot) + { + // + if (isCCIVale) + { + // + XCAPivot iPivot; + + // + iPivot.to = cBar.time; + iPivot.from = p2Bar.time; + iPivot.value = pBar.low; + iPivot.type = XCA_CCI_VALE; + iPivot.symbol = cBar.symbol; + iPivot.period = cBar.period; + + // + Add( + cBar.low, + iPivot.values // + ); + Add( + pBar.low, + iPivot.values // + ); + Add( + p2Bar.low, + iPivot.values // + ); + Add( + cBar.close, + iPivot.values // + ); + Add( + pBar.close, + iPivot.values // + ); + Add( + p2Bar.close, + iPivot.values // + ); + + // + iPivot.reserve = GetMax(iPivot.values); + + // + AddPivot( + iPivot, + cciValePivots, + maxAllowedPivots // + ); + + // + iPivot.Clean(); + } + } + + // + // CCI Crossed Over OS ... + if (detectCCICrossedOverOSPivot) + { + // + if (isCCIBullishVPattern) + { + // + XCAPivot iPivot; + + // + iPivot.to = cBar.time; + iPivot.from = p2Bar.time; + iPivot.value = pBar.low; + iPivot.type = XCA_CCI_COOS; + iPivot.symbol = cBar.symbol; + iPivot.period = cBar.period; + + // + Add( + cBar.low, + iPivot.values // + ); + Add( + pBar.low, + iPivot.values // + ); + Add( + p2Bar.low, + iPivot.values // + ); + Add( + cBar.close, + iPivot.values // + ); + Add( + pBar.close, + iPivot.values // + ); + Add( + p2Bar.close, + iPivot.values // + ); + + // + iPivot.reserve = GetMax(iPivot.values); + + // + AddPivot( + iPivot, + cciCrossedOverOSPivots, + maxAllowedPivots // + ); + + // + iPivot.Clean(); + } + } + + // + // CCI Crossed Under OS ... + if (detectCCICrossedUnderOBPivot) + { + // + if (isCCIBearishVPattern) + { + // + XCAPivot iPivot; + + // + iPivot.to = cBar.time; + iPivot.from = p2Bar.time; + iPivot.value = pBar.high; + iPivot.type = XCA_CCI_CUOB; + iPivot.symbol = cBar.symbol; + iPivot.period = cBar.period; + + // + Add( + cBar.high, + iPivot.values // + ); + Add( + pBar.high, + iPivot.values // + ); + Add( + p2Bar.high, + iPivot.values // + ); + Add( + cBar.close, + iPivot.values // + ); + Add( + pBar.close, + iPivot.values // + ); + Add( + p2Bar.close, + iPivot.values // + ); + + // + iPivot.reserve = GetMin(iPivot.values); + + // + AddPivot( + iPivot, + cciCrossedUnderOBPivots, + maxAllowedPivots // + ); + + // + iPivot.Clean(); + } + } + + // + start++; + + // + zBar.Clean(); + cBar.Clean(); + pBar.Clean(); + p2Bar.Clean(); + fvgBox.Clean(); + iConditions.Clean(); + } + + // + } + + // + void Validate( + XBoxZone &unAvailableBoxes[], + int barIndex = 0 // + ) + { + // + // Do All Pivots Validation ... + + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + XCAPivot tmp[]; + bool has = false; + + // + int zIDX = 0; + int cIDX = zIDX + 1; + int pIDX = cIDX + 1; + int p2IDX = pIDX + 1; + + // + // Implement Validation Senarios ... + + // + // PEAKS ... + + // + has = HasPeakPivots(); + if (has) + { + // + Copy( + peakPivots, + tmp // + ); + Clean(peakPivots); + while (HasChild(tmp)) + { + // + XCAPivot iPivot = tmp[0]; + ArrayRemove( + tmp, + 0, + 1 // + ); + + // + has = IsPivotBreaked( + iPivot, + unAvailableBoxes, + barIndex // + ); + if (!has) + { + // + AddRef( + iPivot, + peakPivots // + ); + } + } + Clean(tmp); + } + + // + // VALES ... + + // + has = HasValePivots(); + if (has) + { + // + Copy( + valePivots, + tmp // + ); + Clean(valePivots); + while (HasChild(tmp)) + { + // + XCAPivot iPivot = tmp[0]; + ArrayRemove( + tmp, + 0, + 1 // + ); + + // + has = IsPivotBreaked( + iPivot, + unAvailableBoxes, + barIndex // + ); + if (!has) + { + // + AddRef( + iPivot, + valePivots // + ); + } + } + Clean(tmp); + } + + // + // PEAK SWH RES ... + + // + has = HasPeakSWHResPivots(); + if (has) + { + // + Copy( + peakSWHResPivots, + tmp // + ); + Clean(peakSWHResPivots); + while (HasChild(tmp)) + { + // + XCAPivot iPivot = tmp[0]; + ArrayRemove( + tmp, + 0, + 1 // + ); + + // + has = IsPivotBreaked( + iPivot, + unAvailableBoxes, + barIndex // + ); + if (!has) + { + // + AddRef( + iPivot, + peakSWHResPivots // + ); + } + } + Clean(tmp); + } + + // + // VALE SWL SUP ... + + // + has = HasValeSWLSupPivots(); + if (has) + { + // + Copy( + valeSWLSupPivots, + tmp // + ); + Clean(valeSWLSupPivots); + while (HasChild(tmp)) + { + // + XCAPivot iPivot = tmp[0]; + ArrayRemove( + tmp, + 0, + 1 // + ); + + // + has = IsPivotBreaked( + iPivot, + unAvailableBoxes, + barIndex // + ); + if (!has) + { + // + AddRef( + iPivot, + valeSWLSupPivots // + ); + } + } + Clean(tmp); + } + + // + // SWING HIGH ... + + // + has = HasSWHPivots(); + if (has) + { + // + Copy( + swhPivots, + tmp // + ); + Clean(swhPivots); + while (HasChild(tmp)) + { + // + XCAPivot iPivot = tmp[0]; + ArrayRemove( + tmp, + 0, + 1 // + ); + + // + has = IsPivotBreaked( + iPivot, + unAvailableBoxes, + barIndex // + ); + if (!has) + { + // + AddRef( + iPivot, + swhPivots // + ); + } + } + Clean(tmp); + } + + // + // SWING LOW ... + + // + has = HasSWLPivots(); + if (has) + { + // + Copy( + swlPivots, + tmp // + ); + Clean(swlPivots); + while (HasChild(tmp)) + { + // + XCAPivot iPivot = tmp[0]; + ArrayRemove( + tmp, + 0, + 1 // + ); + + // + has = IsPivotBreaked( + iPivot, + unAvailableBoxes, + barIndex // + ); + if (!has) + { + // + AddRef( + iPivot, + swlPivots // + ); + } + } + Clean(tmp); + } + + // + // KI ... + + // + has = HasKIBullishPivots(); + if (has) + { + // + Copy( + kiBullishPivots, + tmp // + ); + Clean(kiBullishPivots); + while (HasChild(tmp)) + { + // + XCAPivot iPivot = tmp[0]; + ArrayRemove( + tmp, + 0, + 1 // + ); + + // + has = IsPivotBreaked( + iPivot, + unAvailableBoxes, + barIndex // + ); + if (!has) + { + // + AddRef( + iPivot, + kiBullishPivots // + ); + } + } + Clean(tmp); + } + + // + has = HasKIBearishPivots(); + if (has) + { + // + Copy( + kiBearishPivots, + tmp // + ); + Clean(kiBearishPivots); + while (HasChild(tmp)) + { + // + XCAPivot iPivot = tmp[0]; + ArrayRemove( + tmp, + 0, + 1 // + ); + + // + has = IsPivotBreaked( + iPivot, + unAvailableBoxes, + barIndex // + ); + if (!has) + { + // + AddRef( + iPivot, + kiBearishPivots // + ); + } + } + Clean(tmp); + } + + // + // TKI ... + + // + has = HasTKIBullishPivots(); + if (has) + { + // + Copy( + tkiBullishPivots, + tmp // + ); + Clean(tkiBullishPivots); + while (HasChild(tmp)) + { + // + XCAPivot iPivot = tmp[0]; + ArrayRemove( + tmp, + 0, + 1 // + ); + + // + has = IsPivotBreaked( + iPivot, + unAvailableBoxes, + barIndex // + ); + if (!has) + { + // + AddRef( + iPivot, + tkiBullishPivots // + ); + } + } + Clean(tmp); + } + + // + has = HasTKIBearishPivots(); + if (has) + { + // + Copy( + tkiBearishPivots, + tmp // + ); + Clean(tkiBearishPivots); + while (HasChild(tmp)) + { + // + XCAPivot iPivot = tmp[0]; + ArrayRemove( + tmp, + 0, + 1 // + ); + + // + has = IsPivotBreaked( + iPivot, + unAvailableBoxes, + barIndex // + ); + if (!has) + { + // + AddRef( + iPivot, + tkiBearishPivots // + ); + } + } + Clean(tmp); + } + + // + // FVG ... + + // + has = HasFVGBullishPivots(); + if (has) + { + // + Copy( + fvgBullishPivots, + tmp // + ); + Clean(fvgBullishPivots); + while (HasChild(tmp)) + { + // + XCAPivot iPivot = tmp[0]; + ArrayRemove( + tmp, + 0, + 1 // + ); + + // + has = IsPivotBreaked( + iPivot, + unAvailableBoxes, + barIndex // + ); + if (!has) + { + // + AddRef( + iPivot, + fvgBullishPivots // + ); + } + } + Clean(tmp); + } + + // + has = HasFVGBearishPivots(); + if (has) + { + // + Copy( + fvgBearishPivots, + tmp // + ); + Clean(fvgBearishPivots); + while (HasChild(tmp)) + { + // + XCAPivot iPivot = tmp[0]; + ArrayRemove( + tmp, + 0, + 1 // + ); + + // + has = IsPivotBreaked( + iPivot, + unAvailableBoxes, + barIndex // + ); + if (!has) + { + // + AddRef( + iPivot, + fvgBearishPivots // + ); + } + } + Clean(tmp); + } + + // + // PVFVG ... + XCAPVPivot tmpPVFVG[]; + + // + has = HasPVFVGBullishPivots(); + if (has) + { + // + Copy( + pvFVGBullishPivots, + tmpPVFVG // + ); + Clean(pvFVGBullishPivots); + while (HasChild(tmpPVFVG)) + { + // + XCAPVPivot iPVFVG = tmpPVFVG[0]; + ArrayRemove( + tmpPVFVG, + 0, + 1 // + ); + + // + XCAPivot tmpFVGs[]; + Copy( + iPVFVG.pivots, + tmpFVGs // + ); + Clean(iPVFVG.pivots); + while (HasChild(tmpFVGs)) + { + // + XCAPivot iPivot = tmpFVGs[0]; + ArrayRemove( + tmpFVGs, + 0, + 1 // + ); + + // + has = IsPivotBreaked( + iPivot, + unAvailableBoxes, + barIndex // + ); + if (!has) + { + // + AddRef( + iPivot, + iPVFVG.pivots // + ); + } + } + Clean(tmpFVGs); + + // + if (HasChild(iPVFVG.pivots)) + { + // + AddRef( + iPVFVG, + pvFVGBullishPivots // + ); + } + } + Clean(tmp); + Clean(tmpPVFVG); + } + + // + has = HasPVFVGBearishPivots(); + if (has) + { + // + Copy( + pvFVGBearishPivots, + tmpPVFVG // + ); + Clean(pvFVGBearishPivots); + while (HasChild(tmpPVFVG)) + { + // + XCAPVPivot iPVFVG = tmpPVFVG[0]; + ArrayRemove( + tmpPVFVG, + 0, + 1 // + ); + + // + XCAPivot tmpFVGs[]; + Copy( + iPVFVG.pivots, + tmpFVGs // + ); + Clean(iPVFVG.pivots); + while (HasChild(tmpFVGs)) + { + // + XCAPivot iPivot = tmpFVGs[0]; + ArrayRemove( + tmpFVGs, + 0, + 1 // + ); + + // + has = IsPivotBreaked( + iPivot, + unAvailableBoxes, + barIndex // + ); + if (!has) + { + // + AddRef( + iPivot, + iPVFVG.pivots // + ); + } + } + Clean(tmpFVGs); + + // + if (HasChild(iPVFVG.pivots)) + { + // + AddRef( + iPVFVG, + pvFVGBearishPivots // + ); + } + } + Clean(tmp); + Clean(tmpPVFVG); + } + + // + // TREND ... + + // + has = HasTrendBullishPivots(); + if (has) + { + // + Copy( + trendBullishPivots, + tmp // + ); + Clean(trendBullishPivots); + while (HasChild(tmp)) + { + // + XCAPivot iPivot = tmp[0]; + ArrayRemove( + tmp, + 0, + 1 // + ); + + // + has = IsPivotBreaked( + iPivot, + unAvailableBoxes, + barIndex // + ); + if (!has) + { + // + AddRef( + iPivot, + trendBullishPivots // + ); + } + } + Clean(tmp); + } + + // + has = HasTrendBearishPivots(); + if (has) + { + // + Copy( + trendBearishPivots, + tmp // + ); + Clean(trendBearishPivots); + while (HasChild(tmp)) + { + // + XCAPivot iPivot = tmp[0]; + ArrayRemove( + tmp, + 0, + 1 // + ); + + // + has = IsPivotBreaked( + iPivot, + unAvailableBoxes, + barIndex // + ); + if (!has) + { + // + AddRef( + iPivot, + trendBearishPivots // + ); + } + } + Clean(tmp); + } + + // + // TKITRND ... + + // + has = HasTKITRNDBullishPivots(); + if (has) + { + // + Copy( + tkitrndBullishPivots, + tmp // + ); + Clean(tkitrndBullishPivots); + while (HasChild(tmp)) + { + // + XCAPivot iPivot = tmp[0]; + ArrayRemove( + tmp, + 0, + 1 // + ); + + // + has = IsPivotBreaked( + iPivot, + unAvailableBoxes, + barIndex // + ); + if (!has) + { + // + AddRef( + iPivot, + tkitrndBullishPivots // + ); + } + } + Clean(tmp); + } + + // + has = HasTKITRNDBearishPivots(); + if (has) + { + // + Copy( + tkitrndBearishPivots, + tmp // + ); + Clean(tkitrndBearishPivots); + while (HasChild(tmp)) + { + // + XCAPivot iPivot = tmp[0]; + ArrayRemove( + tmp, + 0, + 1 // + ); + + // + has = IsPivotBreaked( + iPivot, + unAvailableBoxes, + barIndex // + ); + if (!has) + { + // + AddRef( + iPivot, + tkitrndBearishPivots // + ); + } + } + Clean(tmp); + } + + // + // SAME CYCLES HH / LL ... + + // + has = HasSSameLLPivots(); + if (has) + { + // + Copy( + sSameLLPivots, + tmp // + ); + Clean(sSameLLPivots); + while (HasChild(tmp)) + { + // + XCAPivot iPivot = tmp[0]; + ArrayRemove( + tmp, + 0, + 1 // + ); + + // + has = IsPivotBreaked( + iPivot, + unAvailableBoxes, + barIndex // + ); + if (!has) + { + // + AddRef( + iPivot, + sSameLLPivots // + ); + } + } + Clean(tmp); + } + + // + has = HasSSameHHPivots(); + if (has) + { + // + Copy( + sSameHHPivots, + tmp // + ); + Clean(sSameHHPivots); + while (HasChild(tmp)) + { + // + XCAPivot iPivot = tmp[0]; + ArrayRemove( + tmp, + 0, + 1 // + ); + + // + has = IsPivotBreaked( + iPivot, + unAvailableBoxes, + barIndex // + ); + if (!has) + { + // + AddRef( + iPivot, + sSameHHPivots // + ); + } + } + Clean(tmp); + } + + // + has = HasMSameLLPivots(); + if (has) + { + // + Copy( + mSameLLPivots, + tmp // + ); + Clean(mSameLLPivots); + while (HasChild(tmp)) + { + // + XCAPivot iPivot = tmp[0]; + ArrayRemove( + tmp, + 0, + 1 // + ); + + // + has = IsPivotBreaked( + iPivot, + unAvailableBoxes, + barIndex // + ); + if (!has) + { + // + AddRef( + iPivot, + mSameLLPivots // + ); + } + } + Clean(tmp); + } + + // + has = HasMSameHHPivots(); + if (has) + { + // + Copy( + mSameHHPivots, + tmp // + ); + Clean(mSameHHPivots); + while (HasChild(tmp)) + { + // + XCAPivot iPivot = tmp[0]; + ArrayRemove( + tmp, + 0, + 1 // + ); + + // + has = IsPivotBreaked( + iPivot, + unAvailableBoxes, + barIndex // + ); + if (!has) + { + // + AddRef( + iPivot, + mSameHHPivots // + ); + } + } + Clean(tmp); + } + + // + has = HasLSameLLPivots(); + if (has) + { + // + Copy( + lSameLLPivots, + tmp // + ); + Clean(lSameLLPivots); + while (HasChild(tmp)) + { + // + XCAPivot iPivot = tmp[0]; + ArrayRemove( + tmp, + 0, + 1 // + ); + + // + has = IsPivotBreaked( + iPivot, + unAvailableBoxes, + barIndex // + ); + if (!has) + { + // + AddRef( + iPivot, + lSameLLPivots // + ); + } + } + Clean(tmp); + } + + // + has = HasLSameHHPivots(); + if (has) + { + // + Copy( + lSameHHPivots, + tmp // + ); + Clean(lSameHHPivots); + while (HasChild(tmp)) + { + // + XCAPivot iPivot = tmp[0]; + ArrayRemove( + tmp, + 0, + 1 // + ); + + // + has = IsPivotBreaked( + iPivot, + unAvailableBoxes, + barIndex // + ); + if (!has) + { + // + AddRef( + iPivot, + lSameHHPivots // + ); + } + } + Clean(tmp); + } + + // + has = HasHSameLLPivots(); + if (has) + { + // + Copy( + hSameLLPivots, + tmp // + ); + Clean(hSameLLPivots); + while (HasChild(tmp)) + { + // + XCAPivot iPivot = tmp[0]; + ArrayRemove( + tmp, + 0, + 1 // + ); + + // + has = IsPivotBreaked( + iPivot, + unAvailableBoxes, + barIndex // + ); + if (!has) + { + // + AddRef( + iPivot, + hSameLLPivots // + ); + } + } + Clean(tmp); + } + + // + has = HasHSameHHPivots(); + if (has) + { + // + Copy( + hSameHHPivots, + tmp // + ); + Clean(hSameHHPivots); + while (HasChild(tmp)) + { + // + XCAPivot iPivot = tmp[0]; + ArrayRemove( + tmp, + 0, + 1 // + ); + + // + has = IsPivotBreaked( + iPivot, + unAvailableBoxes, + barIndex // + ); + if (!has) + { + // + AddRef( + iPivot, + hSameHHPivots // + ); + } + } + Clean(tmp); + } + + // + // OSCS ... + + // + // RSI ... + + // + has = HasRSIPeakPivots(); + if (has) + { + // + Copy( + rsiPeakPivots, + tmp // + ); + Clean(rsiPeakPivots); + while (HasChild(tmp)) + { + // + XCAPivot iPivot = tmp[0]; + ArrayRemove( + tmp, + 0, + 1 // + ); + + // + has = IsPivotBreaked( + iPivot, + unAvailableBoxes, + barIndex // + ); + if (!has) + { + // + AddRef( + iPivot, + rsiPeakPivots // + ); + } + } + Clean(tmp); + } + + // + has = HasRSIValePivots(); + if (has) + { + // + Copy( + rsiValePivots, + tmp // + ); + Clean(rsiValePivots); + while (HasChild(tmp)) + { + // + XCAPivot iPivot = tmp[0]; + ArrayRemove( + tmp, + 0, + 1 // + ); + + // + has = IsPivotBreaked( + iPivot, + unAvailableBoxes, + barIndex // + ); + if (!has) + { + // + AddRef( + iPivot, + rsiValePivots // + ); + } + } + Clean(tmp); + } + + // + has = HasRSICrossedOverOSPivots(); + if (has) + { + // + Copy( + rsiCrossedOverOSPivots, + tmp // + ); + Clean(rsiCrossedOverOSPivots); + while (HasChild(tmp)) + { + // + XCAPivot iPivot = tmp[0]; + ArrayRemove( + tmp, + 0, + 1 // + ); + + // + has = IsPivotBreaked( + iPivot, + unAvailableBoxes, + barIndex // + ); + if (!has) + { + // + AddRef( + iPivot, + rsiCrossedOverOSPivots // + ); + } + } + Clean(tmp); + } + + // + has = HasRSICrossedUnderOBPivots(); + if (has) + { + // + Copy( + rsiCrossedUnderOBPivots, + tmp // + ); + Clean(rsiCrossedUnderOBPivots); + while (HasChild(tmp)) + { + // + XCAPivot iPivot = tmp[0]; + ArrayRemove( + tmp, + 0, + 1 // + ); + + // + has = IsPivotBreaked( + iPivot, + unAvailableBoxes, + barIndex // + ); + if (!has) + { + // + AddRef( + iPivot, + rsiCrossedUnderOBPivots // + ); + } + } + Clean(tmp); + } + + // + // CCI ... + + // + has = HasCCIPeakPivots(); + if (has) + { + // + Copy( + cciPeakPivots, + tmp // + ); + Clean(cciPeakPivots); + while (HasChild(tmp)) + { + // + XCAPivot iPivot = tmp[0]; + ArrayRemove( + tmp, + 0, + 1 // + ); + + // + has = IsPivotBreaked( + iPivot, + unAvailableBoxes, + barIndex // + ); + if (!has) + { + // + AddRef( + iPivot, + cciPeakPivots // + ); + } + } + Clean(tmp); + } + + // + has = HasCCIValePivots(); + if (has) + { + // + Copy( + cciValePivots, + tmp // + ); + Clean(cciValePivots); + while (HasChild(tmp)) + { + // + XCAPivot iPivot = tmp[0]; + ArrayRemove( + tmp, + 0, + 1 // + ); + + // + has = IsPivotBreaked( + iPivot, + unAvailableBoxes, + barIndex // + ); + if (!has) + { + // + AddRef( + iPivot, + cciValePivots // + ); + } + } + Clean(tmp); + } + + // + has = HasCCICrossedOverOSPivots(); + if (has) + { + // + Copy( + cciCrossedOverOSPivots, + tmp // + ); + Clean(cciCrossedOverOSPivots); + while (HasChild(tmp)) + { + // + XCAPivot iPivot = tmp[0]; + ArrayRemove( + tmp, + 0, + 1 // + ); + + // + has = IsPivotBreaked( + iPivot, + unAvailableBoxes, + barIndex // + ); + if (!has) + { + // + AddRef( + iPivot, + cciCrossedOverOSPivots // + ); + } + } + Clean(tmp); + } + + // + has = HasCCICrossedUnderOBPivots(); + if (has) + { + // + Copy( + cciCrossedUnderOBPivots, + tmp // + ); + Clean(cciCrossedUnderOBPivots); + while (HasChild(tmp)) + { + // + XCAPivot iPivot = tmp[0]; + ArrayRemove( + tmp, + 0, + 1 // + ); + + // + has = IsPivotBreaked( + iPivot, + unAvailableBoxes, + barIndex // + ); + if (!has) + { + // + AddRef( + iPivot, + cciCrossedUnderOBPivots // + ); + } + } + Clean(tmp); + } + + // + // PVTICKS ... + + // + XCAPVTick tmpTicks[]; + + // + has = HasPeakTicks(); + if (has) + { + // + Copy( + peakTicks, + tmpTicks // + ); + Clean(peakTicks); + while (HasChild(tmpTicks)) + { + // + XCAPVTick iPVTick = tmpTicks[0]; + ArrayRemove( + tmpTicks, + 0, + 1 // + ); + + // + XBoxZone iBox; + bool isBoxBreaked = false; + has = iPVTick.GetMaxVolumeBox(iBox); + if (has) + { + // + isBoxBreaked = IsBoxBreaked( + iBox, + unAvailableBoxes, + barIndex // + ); + } + + // + has = IsPivotBreaked( + iPVTick.pivot, + unAvailableBoxes, + barIndex // + ); + if (!has && !isBoxBreaked) + { + // + AddRef( + iPVTick, + peakTicks // + ); + } + } + Clean(tmpTicks); + } + + // + has = HasValeTicks(); + if (has) + { + // + Copy( + valeTicks, + tmpTicks // + ); + Clean(valeTicks); + while (HasChild(tmpTicks)) + { + // + XCAPVTick iPVTick = tmpTicks[0]; + ArrayRemove( + tmpTicks, + 0, + 1 // + ); + + // + XBoxZone iBox; + bool isBoxBreaked = false; + has = iPVTick.GetMaxVolumeBox(iBox); + if (has) + { + // + isBoxBreaked = IsBoxBreaked( + iBox, + unAvailableBoxes, + barIndex // + ); + } + + // + has = IsPivotBreaked( + iPVTick.pivot, + unAvailableBoxes, + barIndex // + ); + if (!has && !isBoxBreaked) + { + // + AddRef( + iPVTick, + valeTicks // + ); + } + } + Clean(tmpTicks); + } + + // + Clean(tmp); + Clean(tmpPVFVG); + Clean(tmpTicks); + } + + // + int FillBullishBoxes( + XBoxZone &boxes[] // + ) + { + // + int result = 0; + + // + int count = 0; + bool has = false; + + // + Clean(boxes); + + // + has = HasSWLPivots(); + if (has) + { + // + count = CountSWLPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = swlPivots[i].AsBox(iBox); + if (has) + { + // + AddRef( + iBox, + boxes // + ); + } + + // + iBox.Clean(); + } + } + + // + has = HasValePivots(); + if (has) + { + // + count = CountValePivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = valePivots[i].AsBox(iBox); + if (has) + { + // + AddRef( + iBox, + boxes // + ); + } + + // + iBox.Clean(); + } + } + + // + has = HasSSameLLPivots(); + if (has) + { + // + count = CountSSameLLPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = sSameLLPivots[i].AsBox(iBox); + if (has) + { + // + AddRef( + iBox, + boxes // + ); + } + + // + iBox.Clean(); + } + } + + // + has = HasMSameLLPivots(); + if (has) + { + // + count = CountMSameLLPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = mSameLLPivots[i].AsBox(iBox); + if (has) + { + // + AddRef( + iBox, + boxes // + ); + } + + // + iBox.Clean(); + } + } + + // + has = HasLSameLLPivots(); + if (has) + { + // + count = CountLSameLLPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = lSameLLPivots[i].AsBox(iBox); + if (has) + { + // + AddRef( + iBox, + boxes // + ); + } + + // + iBox.Clean(); + } + } + + // + has = HasHSameLLPivots(); + if (has) + { + // + count = CountHSameLLPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = hSameLLPivots[i].AsBox(iBox); + if (has) + { + // + AddRef( + iBox, + boxes // + ); + } + + // + iBox.Clean(); + } + } + + // + has = HasKIBullishPivots(); + if (has) + { + // + count = CountKIBullishPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = kiBullishPivots[i].AsBox(iBox); + if (has) + { + // + AddRef( + iBox, + boxes // + ); + } + + // + iBox.Clean(); + } + } + + // + has = HasFVGBullishPivots(); + if (has) + { + // + count = CountFVGBullishPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = fvgBullishPivots[i].AsBox(iBox); + if (has) + { + // + AddRef( + iBox, + boxes // + ); + } + + // + iBox.Clean(); + } + } + + // + has = HasValeSWLSupPivots(); + if (has) + { + // + count = CountValeSWLSupPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = valeSWLSupPivots[i].AsBox(iBox); + if (has) + { + // + AddRef( + iBox, + boxes // + ); + } + + // + iBox.Clean(); + } + } + + // + has = HasTKIBullishPivots(); + if (has) + { + // + count = CountTKIBullishPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = tkiBullishPivots[i].AsBox(iBox); + if (has) + { + // + AddRef( + iBox, + boxes // + ); + } + + // + iBox.Clean(); + } + } + + // + has = HasTrendBullishPivots(); + if (has) + { + // + count = CountTrendBullishPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = trendBullishPivots[i].AsBox(iBox); + if (has) + { + // + AddRef( + iBox, + boxes // + ); + } + + // + iBox.Clean(); + } + } + + // + has = HasTKITRNDBullishPivots(); + if (has) + { + // + count = CountTKITRNDBullishPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = tkitrndBullishPivots[i].AsBox(iBox); + if (has) + { + // + AddRef( + iBox, + boxes // + ); + } + + // + iBox.Clean(); + } + } + + // + has = HasRSIValePivots(); + if (has) + { + // + count = CountRSIValePivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = rsiValePivots[i].AsBox(iBox); + if (has) + { + // + AddRef( + iBox, + boxes // + ); + } + + // + iBox.Clean(); + } + } + + // + has = HasRSICrossedOverOSPivots(); + if (has) + { + // + count = CountRSICrossedOverOSPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = rsiCrossedOverOSPivots[i].AsBox(iBox); + if (has) + { + // + AddRef( + iBox, + boxes // + ); + } + + // + iBox.Clean(); + } + } + + // + has = HasCCIValePivots(); + if (has) + { + // + count = CountCCIValePivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = cciValePivots[i].AsBox(iBox); + if (has) + { + // + AddRef( + iBox, + boxes // + ); + } + + // + iBox.Clean(); + } + } + + // + has = HasCCICrossedOverOSPivots(); + if (has) + { + // + count = CountCCICrossedOverOSPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = cciCrossedOverOSPivots[i].AsBox(iBox); + if (has) + { + // + AddRef( + iBox, + boxes // + ); + } + + // + iBox.Clean(); + } + } + + // + result = ArraySize(boxes); + + // + return result; + } + + // + int FillBearishBoxes( + XBoxZone &boxes[] // + ) + { + // + int result = 0; + + // + int count = 0; + bool has = false; + + // + Clean(boxes); + + // + has = HasSWHPivots(); + if (has) + { + // + count = CountSWHPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = swhPivots[i].AsBox(iBox); + if (has) + { + // + AddRef( + iBox, + boxes // + ); + } + + // + iBox.Clean(); + } + } + + // + has = HasPeakPivots(); + if (has) + { + // + count = CountPeakPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = peakPivots[i].AsBox(iBox); + if (has) + { + // + AddRef( + iBox, + boxes // + ); + } + + // + iBox.Clean(); + } + } + + // + has = HasSSameHHPivots(); + if (has) + { + // + count = CountSSameHHPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = sSameHHPivots[i].AsBox(iBox); + if (has) + { + // + AddRef( + iBox, + boxes // + ); + } + + // + iBox.Clean(); + } + } + + // + has = HasMSameHHPivots(); + if (has) + { + // + count = CountMSameHHPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = mSameHHPivots[i].AsBox(iBox); + if (has) + { + // + AddRef( + iBox, + boxes // + ); + } + + // + iBox.Clean(); + } + } + + // + has = HasLSameHHPivots(); + if (has) + { + // + count = CountLSameHHPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = lSameHHPivots[i].AsBox(iBox); + if (has) + { + // + AddRef( + iBox, + boxes // + ); + } + + // + iBox.Clean(); + } + } + + // + has = HasHSameHHPivots(); + if (has) + { + // + count = CountHSameHHPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = hSameHHPivots[i].AsBox(iBox); + if (has) + { + // + AddRef( + iBox, + boxes // + ); + } + + // + iBox.Clean(); + } + } + + // + has = HasKIBearishPivots(); + if (has) + { + // + count = CountKIBearishPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = kiBearishPivots[i].AsBox(iBox); + if (has) + { + // + AddRef( + iBox, + boxes // + ); + } + + // + iBox.Clean(); + } + } + + // + has = HasFVGBearishPivots(); + if (has) + { + // + count = CountFVGBearishPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = fvgBearishPivots[i].AsBox(iBox); + if (has) + { + // + AddRef( + iBox, + boxes // + ); + } + + // + iBox.Clean(); + } + } + + // + has = HasPeakSWHResPivots(); + if (has) + { + // + count = CountPeakSWHResPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = peakSWHResPivots[i].AsBox(iBox); + if (has) + { + // + AddRef( + iBox, + boxes // + ); + } + + // + iBox.Clean(); + } + } + + // + has = HasTKIBearishPivots(); + if (has) + { + // + count = CountTKIBearishPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = tkiBearishPivots[i].AsBox(iBox); + if (has) + { + // + AddRef( + iBox, + boxes // + ); + } + + // + iBox.Clean(); + } + } + + // + has = HasTrendBearishPivots(); + if (has) + { + // + count = CountTrendBearishPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = trendBearishPivots[i].AsBox(iBox); + if (has) + { + // + AddRef( + iBox, + boxes // + ); + } + + // + iBox.Clean(); + } + } + + // + has = HasTKITRNDBearishPivots(); + if (has) + { + // + count = CountTKITRNDBearishPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = tkitrndBearishPivots[i].AsBox(iBox); + if (has) + { + // + AddRef( + iBox, + boxes // + ); + } + + // + iBox.Clean(); + } + } + + // + has = HasRSIPeakPivots(); + if (has) + { + // + count = CountRSIPeakPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = rsiPeakPivots[i].AsBox(iBox); + if (has) + { + // + AddRef( + iBox, + boxes // + ); + } + + // + iBox.Clean(); + } + } + + // + has = HasRSICrossedUnderOBPivots(); + if (has) + { + // + count = CountRSICrossedUnderOBPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = rsiCrossedUnderOBPivots[i].AsBox(iBox); + if (has) + { + // + AddRef( + iBox, + boxes // + ); + } + + // + iBox.Clean(); + } + } + + // + has = HasCCIPeakPivots(); + if (has) + { + // + count = CountCCIPeakPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = cciPeakPivots[i].AsBox(iBox); + if (has) + { + // + AddRef( + iBox, + boxes // + ); + } + + // + iBox.Clean(); + } + } + + // + has = HasCCICrossedUnderOBPivots(); + if (has) + { + // + count = CountCCICrossedUnderOBPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = cciCrossedUnderOBPivots[i].AsBox(iBox); + if (has) + { + // + AddRef( + iBox, + boxes // + ); + } + + // + iBox.Clean(); + } + } + + // + result = ArraySize(boxes); + + // + return result; + } + + // + // POI Handlers ... + + // + // PEAK ... + + // + bool HasPeakPivots() + { + return HasChild(peakPivots); + } + + // + int CountPeakPivots() + { + return ArraySize(peakPivots); + } + + // + // VALE ... + + // + bool HasValePivots() + { + return HasChild(valePivots); + } + + // + int CountValePivots() + { + return ArraySize(valePivots); + } + + // + // PEAK SWH Res ... + + // + bool HasPeakSWHResPivots() + { + return HasChild(peakSWHResPivots); + } + + // + int CountPeakSWHResPivots() + { + return ArraySize(peakSWHResPivots); + } + + // + // VALE SWL Sup ... + + // + bool HasValeSWLSupPivots() + { + return HasChild(valeSWLSupPivots); + } + + // + int CountValeSWLSupPivots() + { + return ArraySize(valeSWLSupPivots); + } + + // + // SWING High ... + + // + bool HasSWHPivots() + { + return HasChild(swhPivots); + } + + // + int CountSWHPivots() + { + return ArraySize(swhPivots); + } + + // + // SWING Low ... + + // + bool HasSWLPivots() + { + return HasChild(swlPivots); + } + + // + int CountSWLPivots() + { + return ArraySize(swlPivots); + } + + // + // KI ... + + // + bool HasKIBullishPivots() + { + return HasChild(kiBullishPivots); + } + + // + int CountKIBullishPivots() + { + return ArraySize(kiBullishPivots); + } + + // + bool HasKIBearishPivots() + { + return HasChild(kiBearishPivots); + } + + // + int CountKIBearishPivots() + { + return ArraySize(kiBearishPivots); + } + + // + // TKI ... + + // + bool HasTKIBullishPivots() + { + return HasChild(tkiBullishPivots); + } + + // + int CountTKIBullishPivots() + { + return ArraySize(tkiBullishPivots); + } + + // + bool HasTKIBearishPivots() + { + return HasChild(tkiBearishPivots); + } + + // + int CountTKIBearishPivots() + { + return ArraySize(tkiBearishPivots); + } + + // + // FVG ... + + // + bool HasFVGBullishPivots() + { + return HasChild(fvgBullishPivots); + } + + // + int CountFVGBullishPivots() + { + return ArraySize(fvgBullishPivots); + } + + // + bool HasFVGBearishPivots() + { + return HasChild(fvgBearishPivots); + } + + // + int CountFVGBearishPivots() + { + return ArraySize(fvgBearishPivots); + } + + // + // PVFVG ... + + // + bool HasPVFVGBullishPivots() + { + return HasChild(pvFVGBullishPivots); + } + + // + int CountPVFVGBullishPivots() + { + return ArraySize(pvFVGBullishPivots); + } + + // + bool HasPVFVGBearishPivots() + { + return HasChild(pvFVGBearishPivots); + } + + // + int CountPVFVGBearishPivots() + { + return ArraySize(pvFVGBearishPivots); + } + + // + // TREND ... + + // + bool HasTrendBullishPivots() + { + return HasChild(trendBullishPivots); + } + + // + int CountTrendBullishPivots() + { + return ArraySize(trendBullishPivots); + } + + // + bool HasTrendBearishPivots() + { + return HasChild(trendBearishPivots); + } + + // + int CountTrendBearishPivots() + { + return ArraySize(trendBearishPivots); + } + + // + // TKITRND ... + + // + bool HasTKITRNDBullishPivots() + { + return HasChild(tkitrndBullishPivots); + } + + // + int CountTKITRNDBullishPivots() + { + return ArraySize(tkitrndBullishPivots); + } + + // + bool HasTKITRNDBearishPivots() + { + return HasChild(tkitrndBearishPivots); + } + + // + int CountTKITRNDBearishPivots() + { + return ArraySize(tkitrndBearishPivots); + } + + // + // SAME CYCLES HH / LL ... + + // + bool HasSSameLLPivots() + { + return HasChild(sSameLLPivots); + } + + // + int CountSSameLLPivots() + { + return ArraySize(sSameLLPivots); + } + + // + bool HasMSameLLPivots() + { + return HasChild(mSameLLPivots); + } + + // + int CountMSameLLPivots() + { + return ArraySize(mSameLLPivots); + } + + // + bool HasLSameLLPivots() + { + return HasChild(lSameLLPivots); + } + + // + int CountLSameLLPivots() + { + return ArraySize(lSameLLPivots); + } + + // + bool HasHSameLLPivots() + { + return HasChild(hSameLLPivots); + } + + // + int CountHSameLLPivots() + { + return ArraySize(hSameLLPivots); + } + + // + bool HasSSameHHPivots() + { + return HasChild(sSameHHPivots); + } + + // + int CountSSameHHPivots() + { + return ArraySize(sSameHHPivots); + } + + // + bool HasMSameHHPivots() + { + return HasChild(mSameHHPivots); + } + + // + int CountMSameHHPivots() + { + return ArraySize(mSameHHPivots); + } + + // + bool HasLSameHHPivots() + { + return HasChild(lSameHHPivots); + } + + // + int CountLSameHHPivots() + { + return ArraySize(lSameHHPivots); + } + + // + bool HasHSameHHPivots() + { + return HasChild(hSameHHPivots); + } + + // + int CountHSameHHPivots() + { + return ArraySize(hSameHHPivots); + } + + // + // OSCS ... + + // + // RSI ... + + // + bool HasRSIPeakPivots() + { + return HasChild(rsiPeakPivots); + } + + // + int CountRSIPeakPivots() + { + return ArraySize(rsiPeakPivots); + } + + // + bool HasRSIValePivots() + { + return HasChild(rsiValePivots); + } + + // + int CountRSIValePivots() + { + return ArraySize(rsiValePivots); + } + + // + bool HasRSICrossedOverOSPivots() + { + return HasChild(rsiCrossedOverOSPivots); + } + + // + int CountRSICrossedOverOSPivots() + { + return ArraySize(rsiCrossedOverOSPivots); + } + + // + bool HasRSICrossedUnderOBPivots() + { + return HasChild(rsiCrossedUnderOBPivots); + } + + // + int CountRSICrossedUnderOBPivots() + { + return ArraySize(rsiCrossedUnderOBPivots); + } + + // + // CCI ... + + // + bool HasCCIPeakPivots() + { + return HasChild(cciPeakPivots); + } + + // + int CountCCIPeakPivots() + { + return ArraySize(cciPeakPivots); + } + + // + bool HasCCIValePivots() + { + return HasChild(cciValePivots); + } + + // + int CountCCIValePivots() + { + return ArraySize(cciValePivots); + } + + // + bool HasCCICrossedOverOSPivots() + { + return HasChild(cciCrossedOverOSPivots); + } + + // + int CountCCICrossedOverOSPivots() + { + return ArraySize(cciCrossedOverOSPivots); + } + + // + bool HasCCICrossedUnderOBPivots() + { + return HasChild(cciCrossedUnderOBPivots); + } + + // + int CountCCICrossedUnderOBPivots() + { + return ArraySize(cciCrossedUnderOBPivots); + } + + // + // PVTICKS ... + + // + bool HasPeakTicks() + { + return HasChild(peakTicks); + } + + // + int CountPeakTicks() + { + return ArraySize(peakTicks); + } + + // + bool HasValeTicks() + { + return HasChild(valeTicks); + } + + // + int CountValeTicks() + { + return ArraySize(valeTicks); + } + + // + // Protected ... + protected: + // + // Props ... + + // + // Prrivate ... + private: + // + // Props ... + + // + XCPOIDrawer *drawer; + XCXCAEAHelper *helper; + XCBarAnalyser *barAnalyser; + + // + bool CheckPivotCommons( + XCAPivot &pivot, + XBoxZone &box, + XBoxZone &unAvailableBoxes[], + int barIndex = 0 // + ) + { + // + bool result = false; + + // + box.Clean(); + + // + barIndex = NormalizeInt(barIndex, 0); + + // + result = pivot.IsValid(); + if (!result) + { + return result; + } + + // + int pivotToIDX = pivot.ToIndex(); + + // + result = pivotToIDX > barIndex; + if (!result) + { + return result; + } + + // + result = pivot.AsBox(box); + if (!result) + { + // + box.Clean(); + return result; + } + + // + return result; + } + + // + bool CheckPivotIsAvailable( + XBoxZone &pivotBox, + XBoxZone &unAvailableBoxes[] // + ) + { + // + bool result = false; + + // + result = pivotBox.IsValid(); + if (!result) + { + return result; + } + + // + int idx = -1; + bool isExists = FindBoxIndex( + idx, + pivotBox, + unAvailableBoxes // + ); + result = !isExists; + + // + return result; + } + + // + bool IsPivotBreaked( + XCAPivot &pivot, + XBoxZone &unAvailableBoxes[], + int barIndex = 0 // + ) + { + // + bool result = false; + + // + XBoxZone iBox; + result = CheckPivotCommons( + pivot, + iBox, + unAvailableBoxes, + barIndex // + ); + if (!result) + { + // + iBox.Clean(); + return result; + } + + // + // Check Box is Available Or Not ... + bool isAvailable = CheckPivotIsAvailable( + iBox, + unAvailableBoxes // + ); + if (!isAvailable) + { + // + iBox.Clean(); + + // + // Assume UnAvailable Boes as Breaked ... + result = true; + return result; + } + + // + bool isBullish = iBox.IsBullish(); + double boundary = + isBullish + ? iBox.lower + : iBox.upper; + + // + int toIDX = iBox.ToIndex(); + + // + // for validating Box Break we have to wait At Least 3 Bars Close + // out of Box Boundary ... + int barsLength = 3; + + // + int startCheckBreaktionBarIndex = toIDX - barsLength; + result = startCheckBreaktionBarIndex > 0 && + barIndex < startCheckBreaktionBarIndex; + if (!result) + { + // + iBox.Clean(); + return result; + } + + // + XOHCL cBar; + XOHCL pBar; + XOHCL p2Bar; + for (int i = barIndex; i < startCheckBreaktionBarIndex; i++) + { + // + result = cBar.Init( + iBox.symbol, + iBox.period, + i + 1 // + ); + result = + result && + cBar.GetPreviousBar(pBar); + result = + result && + pBar.GetPreviousBar(p2Bar); + if (!result) + { + // + iBox.Clean(); + cBar.Clean(); + pBar.Clean(); + p2Bar.Clean(); + + // + break; + } + + // + bool isBullishBreaked = + isBullish && + cBar.close < boundary && + pBar.close < boundary && + p2Bar.close < boundary; + + // + bool isBearishBreaked = + !isBullish && + cBar.close > boundary && + pBar.close > boundary && + p2Bar.close > boundary; + + // + result = isBullishBreaked || + isBearishBreaked; + if (result) + { + break; + } + + // + cBar.Clean(); + pBar.Clean(); + p2Bar.Clean(); + } + + // + iBox.Clean(); + cBar.Clean(); + pBar.Clean(); + p2Bar.Clean(); + + // + return result; + } + + // + bool IsBoxBreaked( + XBoxZone &box, + XBoxZone &unAvailableBoxes[], + int barIndex = 0 // + ) + { + // + bool result = false; + + // + barIndex = NormalizeInt(barIndex, 0); + + // + result = box.IsValid(); + if (!result) + { + // + // Assume Invalid Boxes as Broken ... + return true; + } + + // + int idx = -1; + result = FindBoxIndex( + idx, + box, + unAvailableBoxes // + ); + if (result) + { + // + // Assume UnAvailable Boxes as Broken ... + return result; + } + + // + int toIDX = box.ToIndex(); + result = toIDX > barIndex; + if (!result) + { + return result; + } + + // + bool isBullish = box.IsBullish(); + double boundary = + isBullish + ? box.lower + : box.upper; + + // + // for validating Box Break we have to wait At Least 3 Bars Close + // out of Box Boundary ... + int barsLength = 3; + + // + int startCheckBreaktionBarIndex = toIDX - barsLength; + result = startCheckBreaktionBarIndex > 0 && + barIndex < startCheckBreaktionBarIndex; + if (!result) + { + return result; + } + + // + XOHCL cBar; + XOHCL pBar; + XOHCL p2Bar; + for (int i = barIndex; i < startCheckBreaktionBarIndex; i++) + { + // + result = cBar.Init( + box.symbol, + box.period, + i + 1 // + ); + result = + result && + cBar.GetPreviousBar(pBar); + result = + result && + pBar.GetPreviousBar(p2Bar); + if (!result) + { + // + cBar.Clean(); + pBar.Clean(); + p2Bar.Clean(); + + // + break; + } + + // + bool isBullishBreaked = + isBullish && + cBar.close < boundary && + pBar.close < boundary && + p2Bar.close < boundary; + + // + bool isBearishBreaked = + !isBullish && + cBar.close > boundary && + pBar.close > boundary && + p2Bar.close > boundary; + + // + result = isBullishBreaked || + isBearishBreaked; + if (result) + { + break; + } + + // + cBar.Clean(); + pBar.Clean(); + p2Bar.Clean(); + } + + // + cBar.Clean(); + pBar.Clean(); + p2Bar.Clean(); + + // + return result; + } + + // +}; + +// \ No newline at end of file diff --git a/Documents/BKP/xcaea.x-poi.drawer.class.mq5 b/Documents/BKP/xcaea.x-poi.drawer.class.mq5 new file mode 100644 index 00000000..14d0bfd0 --- /dev/null +++ b/Documents/BKP/xcaea.x-poi.drawer.class.mq5 @@ -0,0 +1,2424 @@ +/////////////////////////////////////////////////////// +// +// SaherElm IT Center MQL5 Indicator +// ------------------------------------------------- +// Name: XCXCAEAPOIDrawer ... +// Description: Class for XCAEA POI Drawer ... +// +// +// Maintainer: +// ------------ +// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com) +// +////////////////////////////////////////////////////// +// +// Global Properties ... +#property library +#property copyright "Copyright 2023, SaherElm IT Center" +#property link "https://saherelm.ir" +#property version "1.00" +#property description "SaherElm Class for XCAEA POI Drawer" +#property strict + +// +// Imports ... +#include "../../Classes/x-saherelm.x-poi.drawer.class.mq5" +#include "../Classes/xcaea.x-poi.detector.class.mq5" + +// +// Definitions ... + +// +// Implementations ... +class XCXCAEAPOIDrawer : public XCBase +{ + // + // Public ... + public: + // + // Props ... + bool drawSWHPivots; + bool drawSWLPivots; + bool drawPeakPivots; + bool drawValePivots; + bool drawRSIPeakPivots; + bool drawRSIValePivots; + bool drawCCIPeakPivots; + bool drawCCIValePivots; + bool drawKIBullishPivots; + bool drawKIBearishPivots; + bool drawFVGBullishPivots; + bool drawFVGBearishPivots; + bool drawPeakSWHResPivots; + bool drawValeSWLSupPivots; + bool drawTKIBullishPivots; + bool drawTKIBearishPivots; + bool drawCycleSameLLPivots; + bool drawCycleSameHHPivots; + bool drawTrendBullishPivots; + bool drawTrendBearishPivots; + bool drawPVFVGBullishPivots; + bool drawPVFVGBearishPivots; + bool drawTKITRNDBullishPivots; + bool drawTKITRNDBearishPivots; + bool drawRSICrossedOverOSPivots; + bool drawRSICrossedUnderOBPivots; + bool drawCCICrossedOverOSPivots; + bool drawCCICrossedUnderOBPivots; + + // + bool drawTicks; + + // + // Colorize Props ... + + // + color peakPivotColor; + color valePivotColor; + color sameHHPivotColor; + color sameLLPivotColor; + color ticksBullishColor; + color ticksBearishColor; + color kiBullishPivotColor; + color kiBearishPivotColor; + color fvgBullishPivotColor; + color fvgBearishPivotColor; + color defBullishPivotColor; + color defBearishPivotColor; + color oscsBullishPivotColor; + color oscsBearishPivotColor; + color trendBullishPivotColor; + color trendBearishPivotColor; + + // + // Width Props ... + + // + int peakPivotWidth; + int valePivotWidth; + int sameHHPivotWidth; + int sameLLPivotWidth; + int ticksBullishWidth; + int ticksBearishWidth; + int kiBullishPivotWidth; + int kiBearishPivotWidth; + int fvgBullishPivotWidth; + int fvgBearishPivotWidth; + int defBullishPivotWidth; + int defBearishPivotWidth; + int oscsBullishPivotWidth; + int oscsBearishPivotWidth; + int trendBullishPivotWidth; + int trendBearishPivotWidth; + + // + // Style Props ... + + // + ENUM_LINE_STYLE peakPivotStyle; + ENUM_LINE_STYLE valePivotStyle; + ENUM_LINE_STYLE sameHHPivotStyle; + ENUM_LINE_STYLE sameLLPivotStyle; + ENUM_LINE_STYLE ticksBullishStyle; + ENUM_LINE_STYLE ticksBearishStyle; + ENUM_LINE_STYLE kiBullishPivotStyle; + ENUM_LINE_STYLE kiBearishPivotStyle; + ENUM_LINE_STYLE fvgBullishPivotStyle; + ENUM_LINE_STYLE fvgBearishPivotStyle; + ENUM_LINE_STYLE defBullishPivotStyle; + ENUM_LINE_STYLE defBearishPivotStyle; + ENUM_LINE_STYLE oscsBullishPivotStyle; + ENUM_LINE_STYLE oscsBearishPivotStyle; + ENUM_LINE_STYLE trendBullishPivotStyle; + ENUM_LINE_STYLE trendBearishPivotStyle; + // + // Constructors ... + XCXCAEAPOIDrawer( + XCXCAEAPOIDetector *_detector // + ) + { + // + detector = _detector; + drawer = new XCPOIDrawer(); + + // + Default(); + } + + // + // De Constructors ... + ~XCXCAEAPOIDrawer() + { + // + mSWHPivotObjects.Clear(); + mSWLPivotObjects.Clear(); + mPeakPivotObjects.Clear(); + mValePivotObjects.Clear(); + mRSIPeakPivotObjects.Clear(); + mRSIValePivotObjects.Clear(); + mCCIPeakPivotObjects.Clear(); + mCCIValePivotObjects.Clear(); + mKIBullishPivotObjects.Clear(); + mKIBearishPivotObjects.Clear(); + mFVGBullishPivotObjects.Clear(); + mFVGBearishPivotObjects.Clear(); + mPeakSWHResPivotObjects.Clear(); + mValeSWLSupPivotObjects.Clear(); + mTKIBullishPivotObjects.Clear(); + mTKIBearishPivotObjects.Clear(); + mTrendBullishPivotObjects.Clear(); + mTrendBearishPivotObjects.Clear(); + mCycleSameLLPivotObjects.Clear(); + mCycleSameHHPivotObjects.Clear(); + mTKITRNDBullishPivotObjects.Clear(); + mTKITRNDBearishPivotObjects.Clear(); + mRSICrossedOverOSPivotObjects.Clear(); + mRSICrossedUnderOBPivotObjects.Clear(); + mCCICrossedOverOSPivotObjects.Clear(); + mCCICrossedUnderOBPivotObjects.Clear(); + + // + ZeroMemory(drawer); + ZeroMemory(detector); + } + + // + // Properties ... + + // + // Tools ... + + // + virtual void Default() + { + // + drawSWHPivots = false; + drawSWLPivots = false; + drawPeakPivots = false; + drawValePivots = false; + drawRSIPeakPivots = false; + drawRSIValePivots = false; + drawCCIPeakPivots = false; + drawCCIValePivots = false; + drawKIBullishPivots = false; + drawKIBearishPivots = false; + drawFVGBullishPivots = false; + drawFVGBearishPivots = false; + drawPeakSWHResPivots = false; + drawValeSWLSupPivots = false; + drawTKIBullishPivots = false; + drawTKIBearishPivots = false; + drawCycleSameLLPivots = false; + drawCycleSameHHPivots = false; + drawPVFVGBullishPivots = false; + drawPVFVGBearishPivots = false; + drawTrendBullishPivots = false; + drawTrendBearishPivots = false; + drawTKITRNDBullishPivots = false; + drawTKITRNDBearishPivots = false; + drawRSICrossedOverOSPivots = false; + drawRSICrossedUnderOBPivots = false; + drawCCICrossedOverOSPivots = false; + drawCCICrossedUnderOBPivots = false; + + // + drawTicks = false; + + // + // Color ... + defBullishPivotColor = clrLime; + defBearishPivotColor = clrRed; + + // + peakPivotColor = defBearishPivotColor; + valePivotColor = defBullishPivotColor; + sameHHPivotColor = defBearishPivotColor; + sameLLPivotColor = defBullishPivotColor; + ticksBullishColor = defBearishPivotColor; + ticksBearishColor = defBullishPivotColor; + kiBullishPivotColor = defBullishPivotColor; + kiBearishPivotColor = defBearishPivotColor; + fvgBullishPivotColor = defBullishPivotColor; + fvgBearishPivotColor = defBearishPivotColor; + oscsBullishPivotColor = defBullishPivotColor; + oscsBearishPivotColor = defBearishPivotColor; + trendBullishPivotColor = defBullishPivotColor; + trendBearishPivotColor = defBearishPivotColor; + + // + // Width ... + defBullishPivotWidth = 1; + defBearishPivotWidth = 1; + + // + peakPivotWidth = defBearishPivotWidth; + valePivotWidth = defBullishPivotWidth; + sameHHPivotWidth = defBearishPivotWidth; + sameLLPivotWidth = defBullishPivotWidth; + ticksBullishWidth = defBearishPivotWidth; + ticksBearishWidth = defBullishPivotWidth; + kiBullishPivotWidth = defBullishPivotWidth; + kiBearishPivotWidth = defBearishPivotWidth; + fvgBullishPivotWidth = defBullishPivotWidth; + fvgBearishPivotWidth = defBearishPivotWidth; + oscsBullishPivotWidth = defBullishPivotWidth; + oscsBearishPivotWidth = defBearishPivotWidth; + trendBullishPivotWidth = defBullishPivotWidth; + trendBearishPivotWidth = defBearishPivotWidth; + + // + // Style ... + defBullishPivotStyle = STYLE_DOT; + defBearishPivotStyle = STYLE_DOT; + + // + peakPivotStyle = defBearishPivotStyle; + valePivotStyle = defBullishPivotStyle; + sameHHPivotStyle = defBearishPivotStyle; + sameLLPivotStyle = defBullishPivotStyle; + ticksBullishStyle = defBearishPivotStyle; + ticksBearishStyle = defBullishPivotStyle; + kiBullishPivotStyle = defBullishPivotStyle; + kiBearishPivotStyle = defBearishPivotStyle; + fvgBullishPivotStyle = defBullishPivotStyle; + fvgBearishPivotStyle = defBearishPivotStyle; + oscsBullishPivotStyle = defBullishPivotStyle; + oscsBearishPivotStyle = defBearishPivotStyle; + trendBullishPivotStyle = defBullishPivotStyle; + trendBearishPivotStyle = defBearishPivotStyle; + } + + // + void Draw(datetime to = NULL) + { + // + DrawTicks(to); + DrawSWHPivots(to); + DrawSWLPivots(to); + DrawPeakPivots(to); + DrawValePivots(to); + DrawRSIPeakPivots(to); + DrawRSIValePivots(to); + DrawCCIPeakPivots(to); + DrawCCIValePivots(to); + DrawKIBullishPivots(to); + DrawKIBearishPivots(to); + DrawFVGBullishPivots(to); + DrawFVGBearishPivots(to); + DrawPeakSWHResPivots(to); + DrawValeSWLSupPivots(to); + DrawTKIBullishPivots(to); + DrawTKIBearishPivots(to); + DrawCycleSameLLPivots(to); + DrawCycleSameHHPivots(to); + DrawTrendBullishPivots(to); + DrawTrendBearishPivots(to); + DrawTKITRNDBullishPivots(to); + DrawTKITRNDBearishPivots(to); + DrawRSICrossedOverOSPivots(to); + DrawRSICrossedUnderOBPivots(to); + DrawCCICrossedOverOSPivots(to); + DrawCCICrossedUnderOBPivots(to); + } + + // + // + // + + // + void DrawTicks(datetime to = NULL) + { + // + if (!drawTicks) + { + return; + } + + // + bool canUpdateTo = IsValid(to); + + // + // PEAK TICKS ... + bool has = detector.HasPeakTicks(); + if (has) + { + // + int count = detector.CountPeakTicks(); + for (int i = 0; i < count; i++) + { + // + XCAPVTick iPVTick = detector.peakTicks[i]; + + // + // Converts Zone to Box ... + XBoxZone iBox; + has = iPVTick.GetMaxVolumeBox(iBox); + if (!has) + { + // + iBox.Clean(); + iPVTick.Clean(); + + // + continue; + } + if (canUpdateTo) + { + iBox.to = to; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + iBox, + iObj // + ); + if (has) + { + // + iObj.BoxColor(ticksBearishColor); + iObj.BoxWidth(ticksBearishWidth); + iObj.BoxStyle(ticksBearishStyle); + + // + mPeakSWHResPivotObjects.Add(iObj); + } + + // + iBox.Clean(); + iPVTick.Clean(); + ZeroMemory(iObj); + } + } + + // + // VALE TICKS ... + has = detector.HasValeTicks(); + if (has) + { + // + int count = detector.CountValeTicks(); + for (int i = 0; i < count; i++) + { + // + XCAPVTick iPVTick = detector.valeTicks[i]; + + // + // Converts Zone to Box ... + XBoxZone iBox; + has = iPVTick.GetMaxVolumeBox(iBox); + if (!has) + { + // + iBox.Clean(); + iPVTick.Clean(); + + // + continue; + } + if (canUpdateTo) + { + iBox.to = to; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + iBox, + iObj // + ); + if (has) + { + // + iObj.BoxColor(ticksBullishColor); + iObj.BoxWidth(ticksBullishWidth); + iObj.BoxStyle(ticksBullishStyle); + + // + mValeSWLSupPivotObjects.Add(iObj); + } + + // + iBox.Clean(); + iPVTick.Clean(); + ZeroMemory(iObj); + } + } + } + + // + void DrawSWHPivots(datetime to = NULL) + { + // + if (!drawSWHPivots) + { + return; + } + + // + bool canUpdateTo = IsValid(to); + + // + bool has = detector.HasSWHPivots(); + if (!has) + { + return; + } + + // + int count = detector.CountSWHPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = detector.swhPivots[i].AsBox(iBox); + if (!has) + { + continue; + } + + // + if (canUpdateTo) + { + iBox.to = to; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + iBox, + iObj // + ); + if (has) + { + // + iObj.BoxColor(peakPivotColor); + iObj.BoxWidth(peakPivotWidth); + iObj.BoxStyle(peakPivotStyle); + + // + mSWHPivotObjects.Add(iObj); + } + + // + iBox.Clean(); + } + } + + // + void DrawSWLPivots(datetime to = NULL) + { + // + if (!drawSWLPivots) + { + return; + } + + // + bool canUpdateTo = IsValid(to); + + // + bool has = detector.HasSWLPivots(); + if (!has) + { + return; + } + + // + int count = detector.CountSWLPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = detector.swlPivots[i].AsBox(iBox); + if (!has) + { + continue; + } + + // + if (canUpdateTo) + { + iBox.to = to; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + iBox, + iObj // + ); + if (has) + { + // + iObj.BoxColor(valePivotColor); + iObj.BoxWidth(valePivotWidth); + iObj.BoxStyle(valePivotStyle); + + // + mSWLPivotObjects.Add(iObj); + } + + // + iBox.Clean(); + } + } + + // + void DrawPeakPivots(datetime to = NULL) + { + // + if (!drawPeakPivots) + { + return; + } + + // + bool canUpdateTo = IsValid(to); + + // + bool has = detector.HasPeakPivots(); + if (!has) + { + return; + } + + // + int count = detector.CountPeakPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = detector.peakPivots[i].AsBox(iBox); + if (!has) + { + continue; + } + + // + if (canUpdateTo) + { + iBox.to = to; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + iBox, + iObj // + ); + if (has) + { + // + iObj.BoxColor(peakPivotColor); + iObj.BoxWidth(peakPivotWidth); + iObj.BoxStyle(peakPivotStyle); + + // + mPeakPivotObjects.Add(iObj); + } + + // + iBox.Clean(); + } + } + + // + void DrawValePivots(datetime to = NULL) + { + // + if (!drawValePivots) + { + return; + } + + // + bool canUpdateTo = IsValid(to); + + // + bool has = detector.HasValePivots(); + if (!has) + { + return; + } + + // + int count = detector.CountValePivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = detector.valePivots[i].AsBox(iBox); + if (!has) + { + continue; + } + + // + if (canUpdateTo) + { + iBox.to = to; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + iBox, + iObj // + ); + if (has) + { + // + iObj.BoxColor(valePivotColor); + iObj.BoxWidth(valePivotWidth); + iObj.BoxStyle(valePivotStyle); + + // + mValePivotObjects.Add(iObj); + } + + // + iBox.Clean(); + } + } + + // + void DrawKIBullishPivots(datetime to = NULL) + { + // + if (!drawKIBullishPivots) + { + return; + } + + // + bool canUpdateTo = IsValid(to); + + // + bool has = detector.HasKIBullishPivots(); + if (!has) + { + return; + } + + // + int count = detector.CountKIBullishPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = detector.kiBullishPivots[i].AsBox(iBox); + if (!has) + { + continue; + } + + // + if (canUpdateTo) + { + iBox.to = to; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + iBox, + iObj // + ); + if (has) + { + // + iObj.BoxColor(kiBullishPivotColor); + iObj.BoxWidth(kiBullishPivotWidth); + iObj.BoxStyle(kiBullishPivotStyle); + + // + mKIBullishPivotObjects.Add(iObj); + } + + // + iBox.Clean(); + } + } + + // + void DrawKIBearishPivots(datetime to = NULL) + { + // + if (!drawKIBearishPivots) + { + return; + } + + // + bool canUpdateTo = IsValid(to); + + // + bool has = detector.HasKIBearishPivots(); + if (!has) + { + return; + } + + // + int count = detector.CountKIBearishPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = detector.kiBearishPivots[i].AsBox(iBox); + if (!has) + { + continue; + } + + // + if (canUpdateTo) + { + iBox.to = to; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + iBox, + iObj // + ); + if (has) + { + // + iObj.BoxColor(kiBearishPivotColor); + iObj.BoxWidth(kiBearishPivotWidth); + iObj.BoxStyle(kiBearishPivotStyle); + + // + mKIBearishPivotObjects.Add(iObj); + } + + // + iBox.Clean(); + } + } + + // + void DrawFVGBullishPivots(datetime to = NULL) + { + // + bool canUpdateTo = IsValid(to); + + // + if (drawFVGBullishPivots) + { + // + bool has = detector.HasFVGBullishPivots(); + if (has) + { + // + int count = detector.CountFVGBullishPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = detector.fvgBullishPivots[i].AsBox(iBox); + if (!has) + { + // + iBox.Clean(); + continue; + } + + // + if (canUpdateTo) + { + iBox.to = to; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + iBox, + iObj // + ); + if (has) + { + // + iObj.BoxColor(fvgBullishPivotColor); + iObj.BoxWidth(fvgBullishPivotWidth); + iObj.BoxStyle(fvgBullishPivotStyle); + + // + mFVGBullishPivotObjects.Add(iObj); + } + } + } + } + + // + if (drawPVFVGBullishPivots) + { + // + bool has = detector.HasPVFVGBullishPivots(); + if (has) + { + // + int count = detector.CountPVFVGBullishPivots(); + for (int i = 0; i < count; i++) + { + // + XCAPVPivot iPVFVG = detector.pvFVGBullishPivots[i]; + + // + XBoxZone fvgBoxes[]; + int fvgBoxesCount = iPVFVG.GetPivots(fvgBoxes); + has = IsValidSize(fvgBoxesCount); + if (has) + { + // + int idx = GetLowest(fvgBoxes); + if (IsValidIndex(idx)) + { + // + XBoxZone iBox = fvgBoxes[idx]; + + // + if (canUpdateTo) + { + iBox.to = to; + } + + // + XCBoxObject *iObj; + + // + has = drawer.DrawBox( + iBox, + iObj // + ); + if (has) + { + // + iObj.BoxColor(fvgBullishPivotColor); + iObj.BoxWidth(fvgBullishPivotWidth); + iObj.BoxStyle(fvgBullishPivotStyle); + + // + mFVGBullishPivotObjects.Add(iObj); + } + + // + iBox.Clean(); + ZeroMemory(iObj); + } + } + } + } + } + } + + // + void DrawFVGBearishPivots(datetime to = NULL) + { + // + bool canUpdateTo = IsValid(to); + + // + if (drawFVGBearishPivots) + { + // + bool has = detector.HasFVGBearishPivots(); + if (has) + { + // + int count = detector.CountFVGBearishPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = detector.fvgBearishPivots[i].AsBox(iBox); + if (!has) + { + // + iBox.Clean(); + continue; + } + + // + if (canUpdateTo) + { + iBox.to = to; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + iBox, + iObj // + ); + if (has) + { + // + iObj.BoxColor(fvgBearishPivotColor); + iObj.BoxWidth(fvgBearishPivotWidth); + iObj.BoxStyle(fvgBearishPivotStyle); + + // + mFVGBearishPivotObjects.Add(iObj); + } + } + } + } + + // + if (drawPVFVGBullishPivots) + { + // + bool has = detector.HasPVFVGBearishPivots(); + if (has) + { + // + int count = detector.CountPVFVGBearishPivots(); + for (int i = 0; i < count; i++) + { + // + XCAPVPivot iPVFVG = detector.pvFVGBearishPivots[i]; + + // + XBoxZone fvgBoxes[]; + int fvgBoxesCount = iPVFVG.GetPivots(fvgBoxes); + has = IsValidSize(fvgBoxesCount); + if (has) + { + // + int idx = GetHighest(fvgBoxes); + if (IsValidIndex(idx)) + { + // + XBoxZone iBox = fvgBoxes[idx]; + + // + if (canUpdateTo) + { + iBox.to = to; + } + + // + XCBoxObject *iObj; + + // + has = drawer.DrawBox( + iBox, + iObj // + ); + if (has) + { + // + iObj.BoxColor(fvgBearishPivotColor); + iObj.BoxWidth(fvgBearishPivotWidth); + iObj.BoxStyle(fvgBearishPivotStyle); + + // + mFVGBearishPivotObjects.Add(iObj); + } + + // + iBox.Clean(); + ZeroMemory(iObj); + } + } + } + } + } + } + + // + void DrawPeakSWHResPivots(datetime to = NULL) + { + // + if (!drawPeakSWHResPivots) + { + return; + } + + // + bool canUpdateTo = IsValid(to); + + // + bool has = detector.HasPeakSWHResPivots(); + if (!has) + { + return; + } + + // + int count = detector.CountPeakSWHResPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = detector.peakSWHResPivots[i].AsBox(iBox); + if (!has) + { + continue; + } + + // + if (canUpdateTo) + { + iBox.to = to; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + iBox, + iObj // + ); + if (has) + { + // + iObj.BoxColor(peakPivotColor); + iObj.BoxWidth(peakPivotWidth); + iObj.BoxStyle(peakPivotStyle); + + // + mPeakSWHResPivotObjects.Add(iObj); + } + + // + iBox.Clean(); + } + } + + // + void DrawValeSWLSupPivots(datetime to = NULL) + { + // + if (!drawValeSWLSupPivots) + { + return; + } + + // + bool canUpdateTo = IsValid(to); + + // + bool has = detector.HasValeSWLSupPivots(); + if (!has) + { + return; + } + + // + int count = detector.CountValeSWLSupPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = detector.valeSWLSupPivots[i].AsBox(iBox); + if (!has) + { + continue; + } + + // + if (canUpdateTo) + { + iBox.to = to; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + iBox, + iObj // + ); + if (has) + { + // + iObj.BoxColor(valePivotColor); + iObj.BoxWidth(valePivotWidth); + iObj.BoxStyle(valePivotStyle); + + // + mValeSWLSupPivotObjects.Add(iObj); + } + + // + iBox.Clean(); + } + } + + // + void DrawTKIBullishPivots(datetime to = NULL) + { + // + if (!drawTKIBullishPivots) + { + return; + } + + // + bool canUpdateTo = IsValid(to); + + // + bool has = detector.HasTKIBullishPivots(); + if (!has) + { + return; + } + + // + int count = detector.CountTKIBullishPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = detector.tkiBullishPivots[i].AsBox(iBox); + if (!has) + { + continue; + } + + // + if (canUpdateTo) + { + iBox.to = to; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + iBox, + iObj // + ); + if (has) + { + // + iObj.BoxColor(kiBullishPivotColor); + iObj.BoxWidth(kiBullishPivotWidth); + iObj.BoxStyle(kiBullishPivotStyle); + + // + mTKIBullishPivotObjects.Add(iObj); + } + + // + iBox.Clean(); + } + } + + // + void DrawTKIBearishPivots(datetime to = NULL) + { + // + if (!drawTKIBearishPivots) + { + return; + } + + // + bool canUpdateTo = IsValid(to); + + // + bool has = detector.HasTKIBearishPivots(); + if (!has) + { + return; + } + + // + int count = detector.CountTKIBearishPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = detector.tkiBearishPivots[i].AsBox(iBox); + if (!has) + { + continue; + } + + // + if (canUpdateTo) + { + iBox.to = to; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + iBox, + iObj // + ); + if (has) + { + // + iObj.BoxColor(kiBearishPivotColor); + iObj.BoxWidth(kiBearishPivotWidth); + iObj.BoxStyle(kiBearishPivotStyle); + + // + mTKIBearishPivotObjects.Add(iObj); + } + + // + iBox.Clean(); + } + } + + // + void DrawTrendBullishPivots(datetime to = NULL) + { + // + if (!drawTrendBullishPivots) + { + return; + } + + // + bool canUpdateTo = IsValid(to); + + // + bool has = detector.HasTrendBullishPivots(); + if (!has) + { + return; + } + + // + int count = detector.CountTrendBullishPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = detector.trendBullishPivots[i].AsBox(iBox); + if (!has) + { + continue; + } + + // + if (canUpdateTo) + { + iBox.to = to; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + iBox, + iObj // + ); + if (has) + { + // + iObj.BoxColor(trendBullishPivotColor); + iObj.BoxWidth(trendBullishPivotWidth); + iObj.BoxStyle(trendBullishPivotStyle); + + // + mTrendBullishPivotObjects.Add(iObj); + } + + // + iBox.Clean(); + } + } + + // + void DrawTrendBearishPivots(datetime to = NULL) + { + // + if (!drawTrendBearishPivots) + { + return; + } + + // + bool canUpdateTo = IsValid(to); + + // + bool has = detector.HasTrendBearishPivots(); + if (!has) + { + return; + } + + // + int count = detector.CountTrendBearishPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = detector.trendBearishPivots[i].AsBox(iBox); + if (!has) + { + continue; + } + + // + if (canUpdateTo) + { + iBox.to = to; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + iBox, + iObj // + ); + if (has) + { + // + iObj.BoxColor(trendBearishPivotColor); + iObj.BoxWidth(trendBearishPivotWidth); + iObj.BoxStyle(trendBearishPivotStyle); + + // + mTrendBearishPivotObjects.Add(iObj); + } + + // + iBox.Clean(); + } + } + + // + void DrawTKITRNDBullishPivots(datetime to = NULL) + { + // + if (!drawTKITRNDBullishPivots) + { + return; + } + + // + bool canUpdateTo = IsValid(to); + + // + bool has = detector.HasTKITRNDBullishPivots(); + if (!has) + { + return; + } + + // + int count = detector.CountTKITRNDBullishPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = detector.tkitrndBullishPivots[i].AsBox(iBox); + if (!has) + { + continue; + } + + // + if (canUpdateTo) + { + iBox.to = to; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + iBox, + iObj // + ); + if (has) + { + // + iObj.BoxColor(trendBullishPivotColor); + iObj.BoxWidth(trendBullishPivotWidth); + iObj.BoxStyle(trendBullishPivotStyle); + + // + mTKITRNDBullishPivotObjects.Add(iObj); + } + + // + iBox.Clean(); + } + } + + // + void DrawTKITRNDBearishPivots(datetime to = NULL) + { + // + if (!drawTKITRNDBearishPivots) + { + return; + } + + // + bool canUpdateTo = IsValid(to); + + // + bool has = detector.HasTKITRNDBearishPivots(); + if (!has) + { + return; + } + + // + int count = detector.CountTKITRNDBearishPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = detector.tkitrndBearishPivots[i].AsBox(iBox); + if (!has) + { + continue; + } + + // + if (canUpdateTo) + { + iBox.to = to; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + iBox, + iObj // + ); + if (has) + { + // + iObj.BoxColor(trendBearishPivotColor); + iObj.BoxWidth(trendBearishPivotWidth); + iObj.BoxStyle(trendBearishPivotStyle); + + // + mTKITRNDBearishPivotObjects.Add(iObj); + } + + // + iBox.Clean(); + } + } + + // + void DrawCycleSameLLPivots(datetime to = NULL) + { + // + if (!drawCycleSameLLPivots) + { + return; + } + + // + bool canUpdateTo = IsValid(to); + + // + int count = 0; + + // + // SHORT ... + bool has = detector.HasSSameLLPivots(); + if (has) + { + // + count = detector.CountSSameLLPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = detector.sSameLLPivots[i].AsBox(iBox); + if (!has) + { + continue; + } + + // + if (canUpdateTo) + { + iBox.to = to; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + iBox, + iObj // + ); + if (has) + { + // + iObj.BoxColor(sameLLPivotColor); + iObj.BoxWidth(sameLLPivotWidth); + iObj.BoxStyle(sameLLPivotStyle); + + // + mCycleSameLLPivotObjects.Add(iObj); + } + + // + iBox.Clean(); + } + } + + // + // MEDIUM ... + has = detector.HasMSameLLPivots(); + if (has) + { + // + count = detector.CountMSameLLPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = detector.mSameLLPivots[i].AsBox(iBox); + if (!has) + { + continue; + } + + // + if (canUpdateTo) + { + iBox.to = to; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + iBox, + iObj // + ); + if (has) + { + // + iObj.BoxColor(sameLLPivotColor); + iObj.BoxWidth(sameLLPivotWidth); + iObj.BoxStyle(sameLLPivotStyle); + + // + mCycleSameLLPivotObjects.Add(iObj); + } + + // + iBox.Clean(); + } + } + + // + // LONG ... + has = detector.HasLSameLLPivots(); + if (has) + { + // + count = detector.CountLSameLLPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = detector.lSameLLPivots[i].AsBox(iBox); + if (!has) + { + continue; + } + + // + if (canUpdateTo) + { + iBox.to = to; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + iBox, + iObj // + ); + if (has) + { + // + iObj.BoxColor(sameLLPivotColor); + iObj.BoxWidth(sameLLPivotWidth); + iObj.BoxStyle(sameLLPivotStyle); + + // + mCycleSameLLPivotObjects.Add(iObj); + } + + // + iBox.Clean(); + } + } + + // + // HIND ... + has = detector.HasHSameLLPivots(); + if (has) + { + // + count = detector.CountHSameLLPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = detector.hSameLLPivots[i].AsBox(iBox); + if (!has) + { + continue; + } + + // + if (canUpdateTo) + { + iBox.to = to; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + iBox, + iObj // + ); + if (has) + { + // + iObj.BoxColor(sameLLPivotColor); + iObj.BoxWidth(sameLLPivotWidth); + iObj.BoxStyle(sameLLPivotStyle); + + // + mCycleSameLLPivotObjects.Add(iObj); + } + + // + iBox.Clean(); + } + } + } + + // + void DrawCycleSameHHPivots(datetime to = NULL) + { + // + if (!drawCycleSameHHPivots) + { + return; + } + + // + bool canUpdateTo = IsValid(to); + + // + int count = 0; + + // + // SHORT ... + bool has = detector.HasSSameHHPivots(); + if (has) + { + // + count = detector.CountSSameHHPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = detector.sSameHHPivots[i].AsBox(iBox); + if (!has) + { + continue; + } + + // + if (canUpdateTo) + { + iBox.to = to; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + iBox, + iObj // + ); + if (has) + { + // + iObj.BoxColor(sameHHPivotColor); + iObj.BoxWidth(sameHHPivotWidth); + iObj.BoxStyle(sameHHPivotStyle); + + // + mCycleSameHHPivotObjects.Add(iObj); + } + + // + iBox.Clean(); + } + } + + // + // MEDIUM ... + has = detector.HasMSameHHPivots(); + if (has) + { + // + count = detector.CountMSameHHPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = detector.mSameHHPivots[i].AsBox(iBox); + if (!has) + { + continue; + } + + // + if (canUpdateTo) + { + iBox.to = to; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + iBox, + iObj // + ); + if (has) + { + // + iObj.BoxColor(sameHHPivotColor); + iObj.BoxWidth(sameHHPivotWidth); + iObj.BoxStyle(sameHHPivotStyle); + + // + mCycleSameHHPivotObjects.Add(iObj); + } + + // + iBox.Clean(); + } + } + + // + // LONG ... + has = detector.HasLSameHHPivots(); + if (has) + { + // + count = detector.CountLSameHHPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = detector.lSameHHPivots[i].AsBox(iBox); + if (!has) + { + continue; + } + + // + if (canUpdateTo) + { + iBox.to = to; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + iBox, + iObj // + ); + if (has) + { + // + iObj.BoxColor(sameHHPivotColor); + iObj.BoxWidth(sameHHPivotWidth); + iObj.BoxStyle(sameHHPivotStyle); + + // + mCycleSameHHPivotObjects.Add(iObj); + } + + // + iBox.Clean(); + } + } + + // + // HIND ... + has = detector.HasHSameHHPivots(); + if (has) + { + // + count = detector.CountHSameHHPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = detector.hSameHHPivots[i].AsBox(iBox); + if (!has) + { + continue; + } + + // + if (canUpdateTo) + { + iBox.to = to; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + iBox, + iObj // + ); + if (has) + { + // + iObj.BoxColor(sameHHPivotColor); + iObj.BoxWidth(sameHHPivotWidth); + iObj.BoxStyle(sameHHPivotStyle); + + // + mCycleSameHHPivotObjects.Add(iObj); + } + + // + iBox.Clean(); + } + } + } + + // + void DrawRSIPeakPivots(datetime to = NULL) + { + // + if (!drawRSIPeakPivots) + { + return; + } + + // + to = NULL; + bool canUpdateTo = IsValid(to); + + // + int count = 0; + bool has = detector.HasRSIPeakPivots(); + if (has) + { + // + count = detector.CountRSIPeakPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = detector.rsiPeakPivots[i].AsBox(iBox); + if (!has) + { + // + iBox.Clean(); + continue; + } + + // + if (canUpdateTo) + { + iBox.to = to; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + iBox, + iObj // + ); + if (has) + { + // + iObj.BoxColor(oscsBearishPivotColor); + iObj.BoxWidth(oscsBearishPivotWidth); + iObj.BoxStyle(oscsBearishPivotStyle); + + // + mRSIPeakPivotObjects.Add(iObj); + } + + // + iBox.Clean(); + } + } + } + + // + void DrawRSIValePivots(datetime to = NULL) + { + // + if (!drawRSIValePivots) + { + return; + } + + // + to = NULL; + bool canUpdateTo = IsValid(to); + + // + int count = 0; + bool has = detector.HasRSIValePivots(); + if (has) + { + // + count = detector.CountRSIValePivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = detector.rsiValePivots[i].AsBox(iBox); + if (!has) + { + // + iBox.Clean(); + continue; + } + + // + if (canUpdateTo) + { + iBox.to = to; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + iBox, + iObj // + ); + if (has) + { + // + iObj.BoxColor(oscsBullishPivotColor); + iObj.BoxWidth(oscsBullishPivotWidth); + iObj.BoxStyle(oscsBullishPivotStyle); + + // + mRSIValePivotObjects.Add(iObj); + } + + // + iBox.Clean(); + } + } + } + + // + void DrawRSICrossedOverOSPivots(datetime to = NULL) + { + // + if (!drawRSICrossedOverOSPivots) + { + return; + } + + // + to = NULL; + bool canUpdateTo = IsValid(to); + + // + int count = 0; + bool has = detector.HasRSICrossedOverOSPivots(); + if (has) + { + // + count = detector.CountRSICrossedOverOSPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = detector.rsiCrossedOverOSPivots[i].AsBox(iBox); + if (!has) + { + continue; + } + + // + if (canUpdateTo) + { + iBox.to = to; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + iBox, + iObj // + ); + if (has) + { + // + iObj.BoxColor(oscsBullishPivotColor); + iObj.BoxWidth(oscsBullishPivotWidth); + iObj.BoxStyle(oscsBullishPivotStyle); + + // + mRSICrossedOverOSPivotObjects.Add(iObj); + } + + // + iBox.Clean(); + } + } + } + + // + void DrawRSICrossedUnderOBPivots(datetime to = NULL) + { + // + if (!drawRSICrossedUnderOBPivots) + { + return; + } + + // + to = NULL; + bool canUpdateTo = IsValid(to); + + // + int count = 0; + bool has = detector.HasRSICrossedUnderOBPivots(); + if (has) + { + // + count = detector.CountRSICrossedUnderOBPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = detector.rsiCrossedUnderOBPivots[i].AsBox(iBox); + if (!has) + { + continue; + } + + // + if (canUpdateTo) + { + iBox.to = to; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + iBox, + iObj // + ); + if (has) + { + // + iObj.BoxColor(oscsBearishPivotColor); + iObj.BoxWidth(oscsBearishPivotWidth); + iObj.BoxStyle(oscsBearishPivotStyle); + + // + mRSICrossedUnderOBPivotObjects.Add(iObj); + } + + // + iBox.Clean(); + } + } + } + + // + void DrawCCIPeakPivots(datetime to = NULL) + { + // + if (!drawCCIPeakPivots) + { + return; + } + + // + to = NULL; + bool canUpdateTo = IsValid(to); + + // + int count = 0; + bool has = detector.HasCCIPeakPivots(); + if (has) + { + // + count = detector.CountCCIPeakPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = detector.cciPeakPivots[i].AsBox(iBox); + if (!has) + { + // + iBox.Clean(); + continue; + } + + // + if (canUpdateTo) + { + iBox.to = to; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + iBox, + iObj // + ); + if (has) + { + // + iObj.BoxColor(oscsBearishPivotColor); + iObj.BoxWidth(oscsBearishPivotWidth); + iObj.BoxStyle(oscsBearishPivotStyle); + + // + mCCIPeakPivotObjects.Add(iObj); + } + + // + iBox.Clean(); + } + } + } + + // + void DrawCCIValePivots(datetime to = NULL) + { + // + if (!drawCCIValePivots) + { + return; + } + + // + to = NULL; + bool canUpdateTo = IsValid(to); + + // + int count = 0; + bool has = detector.HasCCIValePivots(); + if (has) + { + // + count = detector.CountCCIValePivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = detector.cciValePivots[i].AsBox(iBox); + if (!has) + { + // + iBox.Clean(); + continue; + } + + // + if (canUpdateTo) + { + iBox.to = to; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + iBox, + iObj // + ); + if (has) + { + // + iObj.BoxColor(oscsBullishPivotColor); + iObj.BoxWidth(oscsBullishPivotWidth); + iObj.BoxStyle(oscsBullishPivotStyle); + + // + mCCIValePivotObjects.Add(iObj); + } + + // + iBox.Clean(); + } + } + } + + // + void DrawCCICrossedOverOSPivots(datetime to = NULL) + { + // + if (!drawCCICrossedOverOSPivots) + { + return; + } + + // + to = NULL; + bool canUpdateTo = IsValid(to); + + // + int count = 0; + bool has = detector.HasCCICrossedOverOSPivots(); + if (has) + { + // + count = detector.CountCCICrossedOverOSPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = detector.cciCrossedOverOSPivots[i].AsBox(iBox); + if (!has) + { + continue; + } + + // + if (canUpdateTo) + { + iBox.to = to; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + iBox, + iObj // + ); + if (has) + { + // + iObj.BoxColor(oscsBullishPivotColor); + iObj.BoxWidth(oscsBullishPivotWidth); + iObj.BoxStyle(oscsBullishPivotStyle); + + // + mCCICrossedOverOSPivotObjects.Add(iObj); + } + + // + iBox.Clean(); + } + } + } + + // + void DrawCCICrossedUnderOBPivots(datetime to = NULL) + { + // + if (!drawCCICrossedUnderOBPivots) + { + return; + } + + // + to = NULL; + bool canUpdateTo = IsValid(to); + + // + int count = 0; + bool has = detector.HasCCICrossedUnderOBPivots(); + if (has) + { + // + count = detector.CountCCICrossedUnderOBPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = detector.cciCrossedUnderOBPivots[i].AsBox(iBox); + if (!has) + { + continue; + } + + // + if (canUpdateTo) + { + iBox.to = to; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + iBox, + iObj // + ); + if (has) + { + // + iObj.BoxColor(oscsBearishPivotColor); + iObj.BoxWidth(oscsBearishPivotWidth); + iObj.BoxStyle(oscsBearishPivotStyle); + + // + mCCICrossedUnderOBPivotObjects.Add(iObj); + } + + // + iBox.Clean(); + } + } + } + + // + // Protected ... + protected: + // + // Props ... + + // + // Prrivate ... + private: + // + // Props ... + + // + XCPOIDrawer *drawer; + XCXCAEAPOIDetector *detector; + + // + CArrayObj mSWHPivotObjects; + CArrayObj mSWLPivotObjects; + CArrayObj mPeakPivotObjects; + CArrayObj mValePivotObjects; + CArrayObj mRSIPeakPivotObjects; + CArrayObj mRSIValePivotObjects; + CArrayObj mCCIPeakPivotObjects; + CArrayObj mCCIValePivotObjects; + CArrayObj mKIBullishPivotObjects; + CArrayObj mKIBearishPivotObjects; + CArrayObj mFVGBullishPivotObjects; + CArrayObj mFVGBearishPivotObjects; + CArrayObj mPeakSWHResPivotObjects; + CArrayObj mValeSWLSupPivotObjects; + CArrayObj mTKIBullishPivotObjects; + CArrayObj mTKIBearishPivotObjects; + CArrayObj mCycleSameLLPivotObjects; + CArrayObj mCycleSameHHPivotObjects; + CArrayObj mTrendBullishPivotObjects; + CArrayObj mTrendBearishPivotObjects; + CArrayObj mTKITRNDBullishPivotObjects; + CArrayObj mTKITRNDBearishPivotObjects; + CArrayObj mRSICrossedOverOSPivotObjects; + CArrayObj mRSICrossedUnderOBPivotObjects; + CArrayObj mCCICrossedOverOSPivotObjects; + CArrayObj mCCICrossedUnderOBPivotObjects; + + // +}; + +// \ No newline at end of file diff --git a/Helpers/x-saherelm.x121.xca.helper.mq5 b/Helpers/x-saherelm.x121.xca.helper.mq5 index ccc33f1b..d70cb78c 100644 --- a/Helpers/x-saherelm.x121.xca.helper.mq5 +++ b/Helpers/x-saherelm.x121.xca.helper.mq5 @@ -463,6 +463,10 @@ struct X121XCAConditions bool isKISwitchedToBullish; bool isKISwitchedToBearish; + // + bool isKIFinishedFromBullish; + bool isKIFinishedFromBearish; + // // TKI ... @@ -478,6 +482,10 @@ struct X121XCAConditions bool isTKISwitchedToBullish; bool isTKISwitchedToBearish; + // + bool isTKIFinishedFromBullish; + bool isTKIFinishedFromBearish; + // // VIDYA ... @@ -493,6 +501,10 @@ struct X121XCAConditions bool isVidyaSwitchedToBullish; bool isVidyaSwitchedToBearish; + // + bool isVidyaFinishedFromBullish; + bool isVidyaFinishedFromBearish; + // // SAR ... @@ -504,6 +516,10 @@ struct X121XCAConditions bool isSarSwitchedToBullish; bool isSarSwitchedToBearish; + // + bool isSarFinishedFromBullish; + bool isSarFinishedFromBearish; + // // PEAK ... @@ -535,6 +551,10 @@ struct X121XCAConditions bool isTrendSwitchedToBullish; bool isTrendSwitchedToBearish; + // + bool isTrendFinishedFromBullish; + bool isTrendFinishedFromBearish; + // // SUPPORT ... @@ -590,6 +610,14 @@ struct X121XCAConditions bool isPeakIsPivot; bool isValeIsPivot; + // + bool isPeakSwitchedToPivot; + bool isValeSwitchedToPivot; + + // + bool isPeakFinishedFromPivot; + bool isValeFinishedFromPivot; + // bool isSwingLowSameAsVale; bool isSwingHighSameAsPeak; @@ -704,6 +732,10 @@ struct X121XCAConditions isKISwitchedToBullish = false; isKISwitchedToBearish = false; + // + isKIFinishedFromBullish = false; + isKIFinishedFromBearish = false; + // // TKI ... @@ -719,6 +751,10 @@ struct X121XCAConditions isTKISwitchedToBullish = false; isTKISwitchedToBearish = false; + // + isTKIFinishedFromBullish = false; + isTKIFinishedFromBearish = false; + // // VIDYA ... @@ -734,6 +770,10 @@ struct X121XCAConditions isVidyaSwitchedToBullish = false; isVidyaSwitchedToBearish = false; + // + isVidyaFinishedFromBullish = false; + isVidyaFinishedFromBearish = false; + // // SAR ... @@ -745,6 +785,10 @@ struct X121XCAConditions isSarSwitchedToBullish = false; isSarSwitchedToBearish = false; + // + isSarFinishedFromBullish = false; + isSarFinishedFromBearish = false; + // // PEAK ... @@ -776,6 +820,10 @@ struct X121XCAConditions isTrendSwitchedToBullish = false; isTrendSwitchedToBearish = false; + // + isTrendFinishedFromBullish = false; + isTrendFinishedFromBearish = false; + // // SUPPORT ... @@ -831,6 +879,14 @@ struct X121XCAConditions isPeakIsPivot = false; isValeIsPivot = false; + // + isPeakSwitchedToPivot = false; + isValeSwitchedToPivot = false; + + // + isPeakFinishedFromPivot = false; + isValeFinishedFromPivot = false; + // isSwingLowSameAsVale = false; isSwingHighSameAsPeak = false; @@ -1223,23 +1279,31 @@ struct X121XCAConditions ToString("isKIBullish", isKIBullish, ignoreFalseConditions, separator) + ToString("isKIBearish", isKIBearish, ignoreFalseConditions, separator) + ToString("isKISwitchedToBullish", isKISwitchedToBullish, ignoreFalseConditions, separator) + + ToString("isKIFinishedFromBullish", isKIFinishedFromBullish, ignoreFalseConditions, separator) + ToString("isKISwitchedToBearish", isKISwitchedToBearish, ignoreFalseConditions, separator) + + ToString("isKIFinishedFromBearish", isKIFinishedFromBearish, ignoreFalseConditions, separator) + ToString("isTKIRejectUp", isTKIRejectUp, ignoreFalseConditions, separator) + ToString("isTKIRejectDown", isTKIRejectDown, ignoreFalseConditions, separator) + ToString("isTKIBullish", isTKIBullish, ignoreFalseConditions, separator) + ToString("isTKIBearish", isTKIBearish, ignoreFalseConditions, separator) + ToString("isTKISwitchedToBullish", isTKISwitchedToBullish, ignoreFalseConditions, separator) + + ToString("isTKIFinishedFromBullish", isTKIFinishedFromBullish, ignoreFalseConditions, separator) + ToString("isTKISwitchedToBearish", isTKISwitchedToBearish, ignoreFalseConditions, separator) + + ToString("isTKIFinishedFromBearish", isTKIFinishedFromBearish, ignoreFalseConditions, separator) + ToString("isVidyaRejectUp", isVidyaRejectUp, ignoreFalseConditions, separator) + ToString("isVidyaRejectDown", isVidyaRejectDown, ignoreFalseConditions, separator) + ToString("isVidyaBullish", isVidyaBullish, ignoreFalseConditions, separator) + ToString("isVidyaBearish", isVidyaBearish, ignoreFalseConditions, separator) + ToString("isVidyaSwitchedToBullish", isVidyaSwitchedToBullish, ignoreFalseConditions, separator) + + ToString("isVidyaFinishedFromBullish", isVidyaFinishedFromBullish, ignoreFalseConditions, separator) + ToString("isVidyaSwitchedToBearish", isVidyaSwitchedToBearish, ignoreFalseConditions, separator) + + ToString("isVidyaFinishedFromBearish", isVidyaFinishedFromBearish, ignoreFalseConditions, separator) + ToString("isSarBullish", isSarBullish, ignoreFalseConditions, separator) + ToString("isSarBearish", isSarBearish, ignoreFalseConditions, separator) + ToString("isSarSwitchedToBullish", isSarSwitchedToBullish, ignoreFalseConditions, separator) + + ToString("isSarFinishedFromBullish", isSarFinishedFromBullish, ignoreFalseConditions, separator) + ToString("isSarSwitchedToBearish", isSarSwitchedToBearish, ignoreFalseConditions, separator) + + ToString("isSarFinishedFromBearish", isSarFinishedFromBearish, ignoreFalseConditions, separator) + ToString("isPeakSameLast", isPeakSameLast, ignoreFalseConditions, separator) + ToString("isPeakOverLast", isPeakOverLast, ignoreFalseConditions, separator) + ToString("isPeakUnderLast", isPeakUnderLast, ignoreFalseConditions, separator) + @@ -1251,7 +1315,9 @@ struct X121XCAConditions ToString("isTrendBullish", isTrendBullish, ignoreFalseConditions, separator) + ToString("isTrendBearish", isTrendBearish, ignoreFalseConditions, separator) + ToString("isTrendSwitchedToBullish", isTrendSwitchedToBullish, ignoreFalseConditions, separator) + + ToString("isTrendFinishedFromBullish", isTrendFinishedFromBullish, ignoreFalseConditions, separator) + ToString("isTrendSwitchedToBearish", isTrendSwitchedToBearish, ignoreFalseConditions, separator) + + ToString("isTrendFinishedFromBearish", isTrendFinishedFromBearish, ignoreFalseConditions, separator) + ToString("isSupportSameLast", isSupportSameLast, ignoreFalseConditions, separator) + ToString("isSupportOverLast", isSupportOverLast, ignoreFalseConditions, separator) + ToString("isSupportUnderLast", isSupportUnderLast, ignoreFalseConditions, separator) + @@ -1274,6 +1340,10 @@ struct X121XCAConditions ToString("isLastSwingHighRejected", isLastSwingHighRejected, ignoreFalseConditions, separator) + ToString("isPeakIsPivot", isPeakIsPivot, ignoreFalseConditions, separator) + ToString("isValeIsPivot", isValeIsPivot, ignoreFalseConditions, separator) + + ToString("isPeakSwitchedToPivot", isPeakSwitchedToPivot, ignoreFalseConditions, separator) + + ToString("isPeakFinishedFromPivot", isPeakFinishedFromPivot, ignoreFalseConditions, separator) + + ToString("isValeSwitchedToPivot", isValeSwitchedToPivot, ignoreFalseConditions, separator) + + ToString("isValeFinishedFromPivot", isValeFinishedFromPivot, ignoreFalseConditions, separator) + ToString("isSwingLowSameAsVale", isSwingLowSameAsVale, ignoreFalseConditions, separator) + ToString("isSwingHighSameAsPeak", isSwingHighSameAsPeak, ignoreFalseConditions, separator) + ToString("isSupportSameAsVale", isSupportSameAsVale, ignoreFalseConditions, separator) + @@ -3322,8 +3392,14 @@ class XCX121XCAHelper : public XCBaseHelper // bool isKISwitchedToBullish = isKIBullish && !isKIBullishPrev; + bool isKIFinishedFromBullish = !isKIBullish && + isKIBullishPrev; + + // bool isKISwitchedToBearish = isKIBearish && !isKIBearishPrev; + bool isKIFinishedFromBearish = !isKIBearish && + isKIBearishPrev; // // TKI ... @@ -3363,8 +3439,14 @@ class XCX121XCAHelper : public XCBaseHelper // bool isTKISwitchedToBullish = isTKIBullish && !isTKIBullishPrev; + bool isTKIFinishedFromBullish = !isTKIBullish && + isTKIBullishPrev; + + // bool isTKISwitchedToBearish = isTKIBearish && !isTKIBearishPrev; + bool isTKIFinishedFromBearish = !isTKIBearish && + isTKIBearishPrev; // // VIDYA ... @@ -3404,8 +3486,14 @@ class XCX121XCAHelper : public XCBaseHelper // bool isVidyaSwitchedToBullish = isVidyaBullish && !isVidyaBullishPrev; + bool isVidyaFinishedFromBullish = !isVidyaBullish && + isVidyaBullishPrev; + + // bool isVidyaSwitchedToBearish = isVidyaBearish && !isVidyaBearishPrev; + bool isVidyaFinishedFromBearish = !isVidyaBearish && + isVidyaBearishPrev; // // SAR ... @@ -3425,8 +3513,14 @@ class XCX121XCAHelper : public XCBaseHelper // bool isSarSwitchedToBullish = isSarBullish && !isSarBullishPrev; + bool isSarFinishedFromBullish = !isSarBullish && + isSarBullishPrev; + + // bool isSarSwitchedToBearish = isSarBearish && !isSarBearishPrev; + bool isSarFinishedFromBearish = !isSarBearish && + isSarBearishPrev; // // PEAK ... @@ -3488,8 +3582,14 @@ class XCX121XCAHelper : public XCBaseHelper // bool isTrendSwitchedToBullish = isTrendBullish && !isTrendBullishPrev; + bool isTrendFinishedFromBullish = !isTrendBullish && + isTrendBullishPrev; + + // bool isTrendSwitchedToBearish = isTrendBearish && !isTrendBearishPrev; + bool isTrendFinishedFromBearish = !isTrendBearish && + isTrendBearishPrev; // // SUPPORT ... @@ -3592,25 +3692,58 @@ class XCX121XCAHelper : public XCBaseHelper // bool isSwingLowSameAsVale = cSwingLow == cVale; + bool isSwingLowSameAsValePrev = pSwingLow == pVale; + + // bool isSwingHighSameAsPeak = cSwingHigh == cPeak; + bool isSwingHighSameAsPeakPrev = pSwingHigh == pPeak; // bool isSupportSameAsVale = cSupport == cVale; + bool isSupportSameAsValePrev = pSupport == pVale; + + // bool isResistanceSameAsPeak = cResistance == cPeak; + bool isResistanceSameAsPeakPrev = pResistance == pPeak; // bool isSupportSameAsSwingLow = cSupport == cSwingLow; + bool isSupportSameAsSwingLowPrev = pSupport == pSwingLow; + + // bool isResistanceSameAsSwingHigh = cResistance == cSwingHigh; + bool isResistanceSameAsSwingHighPrev = pResistance == pSwingHigh; // bool isPeakIsPivot = isSwingHighSameAsPeak && isResistanceSameAsPeak && isResistanceSameAsSwingHigh; + bool isPeakIsPivotPrev = isSwingHighSameAsPeakPrev && + isResistanceSameAsPeakPrev && + isResistanceSameAsSwingHighPrev; + + // + bool isPeakSwitchedToPivot = isPeakIsPivot && + !isPeakIsPivotPrev; + + // + bool isPeakFinishedFromPivot = !isPeakIsPivot && + isPeakIsPivotPrev; + + // bool isValeIsPivot = isSwingLowSameAsVale && isSupportSameAsVale && isSupportSameAsSwingLow; + bool isValeIsPivotPrev = isSwingLowSameAsValePrev && + isSupportSameAsValePrev && + isSupportSameAsSwingLowPrev; // + bool isValeSwitchedToPivot = isValeIsPivot && + !isValeIsPivotPrev; + bool isValeFinishedFromPivot = !isValeIsPivot && + isValeIsPivotPrev; + // // Attached ... // @@ -3658,6 +3791,8 @@ class XCX121XCAHelper : public XCBaseHelper conditions.isKISwitchedToBearish = isKISwitchedToBearish; conditions.isLastSwingLowBreaked = isLastSwingLowBreaked; conditions.isSwingHighSameAsPeak = isSwingHighSameAsPeak; + conditions.isPeakSwitchedToPivot = isPeakSwitchedToPivot; + conditions.isValeSwitchedToPivot = isValeSwitchedToPivot; conditions.isTKISwitchedToBullish = isTKISwitchedToBullish; conditions.isTKISwitchedToBearish = isTKISwitchedToBearish; conditions.isLastSwingLowRejected = isLastSwingLowRejected; @@ -3665,14 +3800,26 @@ class XCX121XCAHelper : public XCBaseHelper conditions.isSarSwitchedToBearish = isSarSwitchedToBearish; conditions.isLastSwingHighBreaked = isLastSwingHighBreaked; conditions.isResistanceSameAsPeak = isResistanceSameAsPeak; + conditions.isPeakFinishedFromPivot = isPeakFinishedFromPivot; + conditions.isValeFinishedFromPivot = isValeFinishedFromPivot; conditions.isLastSwingHighRejected = isLastSwingHighRejected; conditions.isLastResistanceBreaked = isLastResistanceBreaked; conditions.isSupportSameAsSwingLow = isSupportSameAsSwingLow; + conditions.isKIFinishedFromBullish = isKIFinishedFromBullish; + conditions.isKIFinishedFromBearish = isKIFinishedFromBearish; + conditions.isTKIFinishedFromBullish = isTKIFinishedFromBullish; + conditions.isTKIFinishedFromBearish = isTKIFinishedFromBearish; + conditions.isSarFinishedFromBullish = isSarFinishedFromBullish; + conditions.isSarFinishedFromBearish = isSarFinishedFromBearish; conditions.isVidyaSwitchedToBullish = isVidyaSwitchedToBullish; conditions.isVidyaSwitchedToBearish = isVidyaSwitchedToBearish; conditions.isLastResistanceRejected = isLastResistanceRejected; conditions.isTrendSwitchedToBullish = isTrendSwitchedToBullish; conditions.isTrendSwitchedToBearish = isTrendSwitchedToBearish; + conditions.isVidyaFinishedFromBullish = isVidyaFinishedFromBullish; + conditions.isVidyaFinishedFromBearish = isVidyaFinishedFromBearish; + conditions.isTrendFinishedFromBullish = isTrendFinishedFromBullish; + conditions.isTrendFinishedFromBearish = isTrendFinishedFromBearish; conditions.isResistanceSameAsSwingHigh = isResistanceSameAsSwingHigh; // diff --git a/XCAEA/Classes/xcaea.x-poi.detector.class.mq5 b/XCAEA/Classes/xcaea.x-poi.detector.class.mq5 index a3d3a6e8..a74ddeb1 100644 --- a/XCAEA/Classes/xcaea.x-poi.detector.class.mq5 +++ b/XCAEA/Classes/xcaea.x-poi.detector.class.mq5 @@ -469,619 +469,6 @@ struct XCAPivot // }; -// -struct XCAPVPivot -{ - // - // Props ... - double value; - XCAPivot pivots[]; - ENUM_X_DIRECTION dir; - - // - // Constructor ... - XCAPVPivot() - { - Clean(); - } - - // - // Tools ... - - // - void Clean() - { - // - value = 0; - Clean(pivots); - dir = X_DIRECTION_NONE; - - // - ZeroMemory(this); - } - - // - bool IsValid() - { - // - bool result = false; - - // - result = value != 0 && - HasDirection(dir); - - // - return result; - } - - // - void AddPivot(XCAPivot &pivot) - { - // - if (!IsValid() || - !pivot.IsValid()) - { - return; - } - - // - int idx = -1; - bool has = FindPivotIndex( - idx, - pivot, - pivots // - ); - if (has) - { - return; - } - - // - AddRef( - pivot, - pivots // - ); - } - - // - int GetPivots(XBoxZone &pivotBoxes[]) - { - // - int result = 0; - - // - Clean(pivotBoxes); - - // - bool has = false; - - // - has = IsValid() && - HasChild(pivots); - if (!has) - { - return result; - } - - // - int count = ArraySize(pivots); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox; - has = pivots[i].AsBox(iBox); - if (has) - { - // - AddRef( - iBox, - pivotBoxes // - ); - } - - // - iBox.Clean(); - } - - // - result = ArraySize(pivotBoxes); - - // - return result; - } -}; - -// -struct XCAPVTick -{ - // - XCAPivot pivot; - XCTicksZone *zone; - - // - XCAPVTick() - { - Clean(); - } - - // - // Tools ... - - // - void Clean() - { - // - pivot.Clean(); - - // - ZeroMemory(zone); - ZeroMemory(this); - } - - // - bool IsValid() - { - // - bool result = false; - - // - result = pivot.IsValid() && - zone != NULL; - - // - return result; - } - - // - bool Init(XCAPivot &_pivot) - { - // - bool result = false; - - // - result = _pivot.IsValid(); - if (!result) - { - return result; - } - - // - int toIDX = _pivot.ToIndex(); - int fromIDX = _pivot.FromIndex(); - int rangeLength = fromIDX - toIDX; - result = IsValidIndex(fromIDX) && - IsValidIndex(toIDX); - if (!result) - { - // - Clean(); - return result; - } - - // - XOHCL toBar; - XOHCL fromBar; - result = toBar.Init( - _pivot.symbol, - _pivot.period, - toIDX // - ); - result = result && - fromBar.Init( - _pivot.symbol, - _pivot.period, - fromIDX // - ); - if (!result) - { - // - toBar.Clean(); - fromBar.Clean(); - - // - Clean(); - - // - return result; - } - - // - double rangeDivider = 10 * GetPoints(_pivot.symbol); - double rangeL = toBar.FindLowest(rangeLength, MODE_LOW); - double rangeH = toBar.FindHighest(rangeLength, MODE_HIGH); - double rangeDiff = (rangeH - rangeL); - int zoneLevels = (int)(rangeDiff / rangeDivider); - - // - XCTicksZone *_zone; - _zone = new XCTicksZone(); - _zone.Levels(zoneLevels); - result = _zone.Init( - fromBar, - toBar // - ); - if (!result) - { - // - toBar.Clean(); - fromBar.Clean(); - ZeroMemory(_zone); - - // - Clean(); - - // - return result; - } - - // - pivot = _pivot; - zone = _zone; - - // - result = IsValid(); - if (!result) - { - Clean(); - } - - // - toBar.Clean(); - fromBar.Clean(); - ZeroMemory(_zone); - - // - return result; - } - - // - bool GetMaxVolumeBox(XBoxZone &box) - { - // - bool result = false; - - // - box.Clean(); - - // - result = IsValid(); - if (!result) - { - return result; - } - - // - // Select MAX Volume Zone ... - XCTickZone *selectedZone = NULL; - int zonesCount = zone.Count(); - for (int j = 0; j < zonesCount; j++) - { - // - XCTickZone *jZone = zone.GetZone(j); - - // - bool canSet = - selectedZone == NULL - ? true - : selectedZone.volume < jZone.volume; - if (canSet) - { - selectedZone = jZone; - } - - // - ZeroMemory(jZone); - } - - // - result = selectedZone != NULL; - if (!result) - { - // - box.Clean(); - ZeroMemory(selectedZone); - - // - return result; - } - - // - result = pivot.AsBox(box); - if (!result) - { - // - box.Clean(); - - // - return result; - } - box.upper = selectedZone.high; - box.lower = selectedZone.low; - box.type = - pivot.type == XCA_PEAKSWHRES - ? "PEAKTICK" - : pivot.type == XCA_VALESWLSUP - ? "VALETICK" - : box.type; - - // - return result; - } - - // -}; - -/** - * Find Specified Pivot Index inside a Collection of Pivots ... - * - * @param pivot: XCAPivot instance Reference ... - * @param pivots: XCAPivot instance Reference Collection ... - * - * @return ( int ) - */ -bool FindPivotIndex( - int &index, - XCAPivot &pivot, - XCAPivot &pivots[] // -) -{ - // - bool result = false; - - // - index = -1; - - // - int count = ArraySize(pivots); - result = pivot.IsValid() && - IsValidSize(count); - if (!result) - { - return result; - } - - // - for (int i = 0; i < count; i++) - { - // - XCAPivot iPivot = pivots[i]; - - // - bool isSame = pivot.IsSameAs(iPivot); - if (isSame) - { - // - index = i; - break; - } - } - - // - result = IsValidIndex(index); - - // - return result; -} - -/** - * Add or Update Specified Pivot to Specified Collection ... - * - * @param pivot: XCAPivot instance reference, Specified Item ... - * @param pivots: XCAPivot instance reference Collection ... - * @param maxAllowedPivots: int, Max Allowed Pivots number of Collection ... - */ -void AddPivot( - XCAPivot &pivot, - XCAPivot &pivots[], - int maxAllowedPivots = 50 // -) -{ - // - bool has = pivot.IsValid(); - if (!has) - { - return; - } - - // - int idx = -1; - has = FindPivotIndex( - idx, - pivot, - pivots // - ); - if (has) - { - return; - } - - // - int updateIDX = -1; - int count = ArraySize(pivots); - for (int i = 0; i < count; i++) - { - // - XCAPivot iPivot = pivots[i]; - - // - has = - iPivot.to > pivot.to && - iPivot.from == pivot.from && - iPivot.value == pivot.value && - iPivot.symbol == pivot.symbol && - iPivot.period == pivot.period; - if (has) - { - // - updateIDX = i; - break; - } - } - - // - has = IsValidIndex(updateIDX); - if (!has) - { - // - AddRef( - pivot, - pivots // - ); - } - else - { - pivots[updateIDX].to = pivot.to; - } - - // - // Apply Max Allowed ... - CleanupArray( - pivots, - maxAllowedPivots // - ); -} - -/** - * Add or Update PV FVG item to Specified Collection ... - * - * @param value: double, Peak or Vale Value ... - * @param fvg: XCAPivot instance reference, Specified Pivot ... - * @param collection: XCAPVPivot instance Collection ... - */ -void AddOrUpdatePVFVG( - double value, - XCAPivot &fvg, - XCAPVPivot &collection[] // -) -{ - // - // Validate Args ... - if (value < 0 && - !fvg.IsValid() && - (fvg.type == XCA_FVG_BULL || - fvg.type == XCA_FVG_BEAR)) - { - return; - } - - // - // Check Pivot is Exists or not ... - ENUM_X_DIRECTION dir = - fvg.type == XCA_FVG_BULL - ? X_DIRECTION_BULLISH - : X_DIRECTION_BEARISH; - - // - bool isBullish = IsBullish(dir); - bool isBearish = IsBearish(dir); - - // - // Try to Findout Pivot Value in Collection ... - int idx = -1; - int count = ArraySize(collection); - for (int i = 0; i < count; i++) - { - // - XCAPVPivot iTem = collection[i]; - - // - bool isSameValue = iTem.value == value; - bool isSameDirection = iTem.dir == dir; - - // - bool isValid = isSameValue && - isSameDirection; - if (isValid) - { - // - idx = i; - iTem.Clean(); - break; - } - - // - iTem.Clean(); - } - - // - // Try to Add Or Update Pivots ... - bool hasIndex = IsValidIndex(idx); - if (!hasIndex) - { - // - // New Item ... - XCAPVPivot iPVFVG; - - // - iPVFVG.dir = dir; - iPVFVG.value = value; - - // - AddRef( - fvg, - iPVFVG.pivots // - ); - - // - AddRef( - iPVFVG, - collection // - ); - } - else - { - // - // Add Pivot to Existing Item ... - collection[idx].AddPivot(fvg); - } - - // -} - -/** - * Add Specified PVTick to Collection ... - * - * @param pvTick: XCAPVTick instance Reference ... - * @param pvTicks: XCAPVTickinstance Reference Collection ... - */ -void AddPVTick( - XCAPVTick &pvTick, - XCAPVTick &pvTicks[] // -) -{ - // - bool has = pvTick.IsValid(); - if (!has) - { - return; - } - - // - has = false; - int count = ArraySize(pvTicks); - for (int i = 0; i < count; i++) - { - // - has = pvTicks[i].pivot.IsSameAs(pvTick.pivot); - if (has) - { - break; - } - } - - // - if (has) - { - return; - } - - // - AddRef( - pvTick, - pvTicks // - ); -} - // // Implementations ... class XCXCAEAPOIDetector : public XCBase @@ -1097,139 +484,79 @@ class XCXCAEAPOIDetector : public XCBase int pivotVerifications; // Pivots Verifications ... int maxAllowedPivots; // Max Allowed Holding Pibots ... + // + // VALE Pivot Support Swing Low ... + + // + XCAPivot valeSupSWLPivot; + bool detectValeSupSWLPivots; + XBoxZone valeSupSWLPivots[]; + bool newValeSupSWLPivotDetected; + + // + // PEAK Pivot Resistance Swing High ... + + // + XCAPivot peakResSWHPivot; + bool detectPeakResSWHPivots; + XBoxZone peakResSWHPivots[]; + bool newPeakResSWHPivotDetected; + + // + // FVG Bullish Pivots ... + + // + bool detectFVGBullishPivots; + XBoxZone fvgBullishPivots[]; + bool newFVGBullishPivotDetected; + + // + // FVG Bearish Pivots ... + + // + bool detectFVGBearishPivots; + XBoxZone fvgBearishPivots[]; + bool newFVGBearishPivotDetected; + + // + // RSI Peak Pivot ... + + // + XCAPivot rsiPeakPivot; + bool detectRSIPeakPivots; + XBoxZone rsiPeakPivots[]; + bool newRSIPeakPivotDetected; + + // + // RSI Vale Pivot ... + + // + XCAPivot rsiValePivot; + bool detectRSIValePivots; + XBoxZone rsiValePivots[]; + bool newRSIValePivotDetected; + + // + // CCI Peak Pivot ... + + // + XCAPivot cciPeakPivot; + bool detectCCIPeakPivots; + XBoxZone cciPeakPivots[]; + bool newCCIPeakPivotDetected; + + // + // CCI Vale Pivot ... + + // + XCAPivot cciValePivot; + bool detectCCIValePivots; + XBoxZone cciValePivots[]; + bool newCCIValePivotDetected; + // // Detector Pivots State Properties ... - // - // PEAK / VALES ... - bool detectPeakPivot; - bool detectValePivot; - - // - // PEAK SWH RES / VALE SWL SUP ... - bool detectPeakSWHResPivot; - bool detectValeSWLSupPivot; - - // - // SWING HIGH / LOW ... - bool detectSWHPivot; - bool detectSWLPivot; - - // - // KI ... - bool detectKIBullishPivot; - bool detectKIBearishPivot; - - // - // TKI ... - bool detectTKIBullishPivot; - bool detectTKIBearishPivot; - - // - // FVG ... - bool detectFVGBullishPivot; - bool detectFVGBearishPivot; - - // - // SAME Cycles HH / LL ... - bool detectCycleSameLLPivot; - bool detectCycleSameHHPivot; - - // - // TREND ... - bool detectTrendBullishPivot; - bool detectTrendBearishPivot; - - // - // TKITRND ... - bool detectTKITRNDBullishPivot; - bool detectTKITRNDBearishPivot; - - // - // OSCS ... - - // - // RSI ... - bool detectRSIPeakPivot; - bool detectRSIValePivot; - bool detectRSICrossedOverOSPivot; - bool detectRSICrossedUnderOBPivot; - - // - // CCI ... - bool detectCCIPeakPivot; - bool detectCCIValePivot; - bool detectCCICrossedOverOSPivot; - bool detectCCICrossedUnderOBPivot; - - // - // Active Pivots ... - XCAPivot swhPivot; - XCAPivot swlPivot; - XCAPivot peakPivot; - XCAPivot valePivot; - XCAPivot sSameHHPivot; - XCAPivot mSameHHPivot; - XCAPivot lSameHHPivot; - XCAPivot hSameHHPivot; - XCAPivot sSameLLPivot; - XCAPivot mSameLLPivot; - XCAPivot lSameLLPivot; - XCAPivot hSameLLPivot; - XCAPivot kiBullishPivot; - XCAPivot kiBearishPivot; - XCAPivot tkiBullishPivot; - XCAPivot tkiBearishPivot; - XCAPivot peakSWHResPivot; - XCAPivot valeSWLSupPivot; - XCAPivot trendBullishPivot; - XCAPivot trendBearishPivot; - XCAPivot tkitrndBullishPivot; - XCAPivot tkitrndBearishPivot; - - // - // UnActive Pivots ... - XCAPivot swhPivots[]; - XCAPivot swlPivots[]; - XCAPivot peakPivots[]; - XCAPivot valePivots[]; - XCAPivot rsiPeakPivots[]; - XCAPivot rsiValePivots[]; - XCAPivot cciPeakPivots[]; - XCAPivot cciValePivots[]; - XCAPivot sSameHHPivots[]; - XCAPivot mSameHHPivots[]; - XCAPivot lSameHHPivots[]; - XCAPivot hSameHHPivots[]; - XCAPivot sSameLLPivots[]; - XCAPivot mSameLLPivots[]; - XCAPivot lSameLLPivots[]; - XCAPivot hSameLLPivots[]; - XCAPivot kiBullishPivots[]; - XCAPivot kiBearishPivots[]; - XCAPivot fvgBullishPivots[]; - XCAPivot fvgBearishPivots[]; - XCAPivot tkiBullishPivots[]; - XCAPivot tkiBearishPivots[]; - XCAPivot peakSWHResPivots[]; - XCAPivot valeSWLSupPivots[]; - XCAPivot trendBullishPivots[]; - XCAPivot trendBearishPivots[]; - XCAPivot tkitrndBullishPivots[]; - XCAPivot tkitrndBearishPivots[]; - XCAPivot rsiCrossedOverOSPivots[]; - XCAPivot cciCrossedOverOSPivots[]; - XCAPivot rsiCrossedUnderOBPivots[]; - XCAPivot cciCrossedUnderOBPivots[]; - - // - XCAPVTick peakTicks[]; - XCAPVTick valeTicks[]; - - // - XCAPVPivot pvFVGBullishPivots[]; - XCAPVPivot pvFVGBearishPivots[]; - // // Constructors ... XCXCAEAPOIDetector( @@ -1250,62 +577,22 @@ class XCXCAEAPOIDetector : public XCBase ~XCXCAEAPOIDetector() { // - swhPivot.Clean(); - swlPivot.Clean(); - peakPivot.Clean(); - valePivot.Clean(); - sSameHHPivot.Clean(); - mSameHHPivot.Clean(); - lSameHHPivot.Clean(); - hSameHHPivot.Clean(); - sSameLLPivot.Clean(); - mSameLLPivot.Clean(); - lSameLLPivot.Clean(); - hSameLLPivot.Clean(); - kiBullishPivot.Clean(); - kiBearishPivot.Clean(); - tkiBullishPivot.Clean(); - tkiBearishPivot.Clean(); - peakSWHResPivot.Clean(); - valeSWLSupPivot.Clean(); - trendBullishPivot.Clean(); - trendBearishPivot.Clean(); - tkitrndBullishPivot.Clean(); - tkitrndBearishPivot.Clean(); + rsiPeakPivot.Clean(); + rsiValePivot.Clean(); + cciPeakPivot.Clean(); + cciValePivot.Clean(); + valeSupSWLPivot.Clean(); + peakResSWHPivot.Clean(); // - Clean(swhPivots); - Clean(swlPivots); - Clean(peakPivots); - Clean(valePivots); Clean(rsiPeakPivots); Clean(rsiValePivots); Clean(cciPeakPivots); Clean(cciValePivots); - Clean(sSameHHPivots); - Clean(mSameHHPivots); - Clean(lSameHHPivots); - Clean(hSameHHPivots); - Clean(sSameLLPivots); - Clean(mSameLLPivots); - Clean(lSameLLPivots); - Clean(hSameLLPivots); - Clean(kiBullishPivots); - Clean(kiBearishPivots); Clean(fvgBullishPivots); Clean(fvgBearishPivots); - Clean(tkiBullishPivots); - Clean(tkiBearishPivots); - Clean(peakSWHResPivots); - Clean(valeSWLSupPivots); - Clean(trendBullishPivots); - Clean(trendBearishPivots); - Clean(tkitrndBullishPivots); - Clean(tkitrndBearishPivots); - Clean(rsiCrossedOverOSPivots); - Clean(cciCrossedOverOSPivots); - Clean(rsiCrossedUnderOBPivots); - Clean(cciCrossedUnderOBPivots); + Clean(valeSupSWLPivots); + Clean(peakResSWHPivots); // ZeroMemory(helper); @@ -1327,30 +614,16 @@ class XCXCAEAPOIDetector : public XCBase pivotVerifications = 5; // - detectSWHPivot = true; - detectSWLPivot = true; - detectPeakPivot = true; - detectValePivot = true; - detectRSIPeakPivot = true; - detectRSIValePivot = true; - detectCCIPeakPivot = true; - detectCCIValePivot = true; - detectKIBullishPivot = true; - detectKIBearishPivot = true; - detectFVGBullishPivot = true; - detectFVGBearishPivot = true; - detectTKIBullishPivot = true; - detectTKIBearishPivot = true; - detectPeakSWHResPivot = true; - detectValeSWLSupPivot = true; - detectCycleSameLLPivot = true; - detectCycleSameHHPivot = true; - detectTrendBullishPivot = true; - detectTrendBearishPivot = true; - detectTKITRNDBullishPivot = true; - detectTKITRNDBearishPivot = true; - detectCCICrossedOverOSPivot = true; - detectCCICrossedUnderOBPivot = true; + detectRSIPeakPivots = true; + detectRSIValePivots = true; + detectCCIPeakPivots = true; + detectCCIValePivots = true; + detectFVGBullishPivots = true; + detectFVGBearishPivots = true; + detectValeSupSWLPivots = true; + detectPeakResSWHPivots = true; + + // } // @@ -1372,6 +645,16 @@ class XCXCAEAPOIDetector : public XCBase int count = 0; bool has = false; + // + newRSIPeakPivotDetected = false; + newRSIValePivotDetected = false; + newCCIPeakPivotDetected = false; + newCCIValePivotDetected = false; + newFVGBullishPivotDetected = false; + newFVGBearishPivotDetected = false; + newValeSupSWLPivotDetected = false; + newPeakResSWHPivotDetected = false; + // int zIDX = 0; int cIDX = zIDX + 1; @@ -1387,9 +670,9 @@ class XCXCAEAPOIDetector : public XCBase { // // Retrieve Conditions ... - XCAEAConditions iConditions; + XCAEAConditions conditions; has = helper.GetConditions( - iConditions, + conditions, start, 5 // ); @@ -1401,8 +684,8 @@ class XCXCAEAPOIDetector : public XCBase XOHCL pBar; XOHCL p2Bar; has = zBar.Init( - iConditions.symbol, - iConditions.period, + conditions.symbol, + conditions.period, start // ); has = @@ -1421,7 +704,7 @@ class XCXCAEAPOIDetector : public XCBase cBar.Clean(); pBar.Clean(); p2Bar.Clean(); - iConditions.Clean(); + conditions.Clean(); // continue; @@ -1451,2988 +734,118 @@ class XCXCAEAPOIDetector : public XCBase double points = GetPoints(zBar.symbol); // - // PEAK ... - - // - double cPeak = iConditions.peakBuffer[cIDX]; - double pPeak = iConditions.peakBuffer[pIDX]; - double p2Peak = iConditions.peakBuffer[p2IDX]; - - // - bool isPeakStartSameLast = - cPeak == pPeak && - pPeak != p2Peak; - - // - bool isPeakFinishedSameLast = - cPeak != pPeak && - pPeak == p2Peak; - - // - // VALE ... - - // - double cVale = iConditions.valeBuffer[cIDX]; - double pVale = iConditions.valeBuffer[pIDX]; - double p2Vale = iConditions.valeBuffer[p2IDX]; - - // - bool isValeStartSameLast = - cVale == pVale && - pVale != p2Vale; - - // - bool isValeFinishedSameLast = - cVale != pVale && - pVale == p2Vale; - - // - // SWH ... - - // - double cSWH = iConditions.swingHighBuffer[cIDX]; - double pSWH = iConditions.swingHighBuffer[pIDX]; - double p2SWH = iConditions.swingHighBuffer[p2IDX]; - - // - bool isSWHStartSameLast = - cSWH == pSWH && - pSWH != p2SWH; - - // - bool isSWHFinishedSameLast = - cSWH != pSWH && - pSWH == p2SWH; - - // - // SWL ... - - // - double pSWL = iConditions.swingLowBuffer[pIDX]; - double cSWL = iConditions.swingLowBuffer[cIDX]; - double p2SWL = iConditions.swingLowBuffer[p2IDX]; - - // - bool isSWLStartSameLast = - cSWL == pSWL && - pSWL != p2SWL; - - // - bool isSWLFinishedSameLast = - cSWL != pSWL && - pSWL == p2SWL; - - // - // SUPPORT ... - - // - double cSupport = iConditions.supportBuffer[cIDX]; - double pSupport = iConditions.supportBuffer[pIDX]; - double p2Support = iConditions.supportBuffer[p2IDX]; - - // - bool isSupportStartSameLast = - cSupport == pSupport && - pSupport != p2Support; - - // - bool isSupportFinishedSameLast = - cSupport != pSupport && - pSupport == p2Support; - - // - // RESISTANCE ... - - // - double pResistance = iConditions.resistanceBuffer[pIDX]; - double cResistance = iConditions.resistanceBuffer[cIDX]; - double p2Resistance = iConditions.resistanceBuffer[p2IDX]; - - // - bool isResistanceStartSameLast = - cResistance == pResistance && - pResistance != p2Resistance; - - // - bool isResistanceFinishedSameLast = - cResistance != pResistance && - pResistance == p2Resistance; - - // - // PEAK SWH RES ... - - // - bool isCPeakIsPivot = - cPeak == cSWH && - cSWH == cResistance; - - // - bool isPPeakIsPivot = - pPeak == pSWH && - pSWH == pResistance; - - // - bool isStartPeakIsPivot = - isCPeakIsPivot && - !isPPeakIsPivot; - - // - bool isFinishedPeakIsPivot = - !isCPeakIsPivot && - isPPeakIsPivot; - - // - // VALE SWL SUP ... - - // - bool isCValeIsPivot = - cVale == cSWL && - cSWL == cSupport; - - // - bool isPValeIsPivot = - pVale == pSWL && - pSWL == pSupport; - - // - bool isStartValeIsPivot = - isCValeIsPivot && - !isPValeIsPivot; - - // - bool isFinishedValeIsPivot = - !isCValeIsPivot && - isPValeIsPivot; - - // - // TKITRND ... - - // - double cKI = iConditions.kiBuffer[cIDX]; - double pKI = iConditions.kiBuffer[pIDX]; - double p2KI = iConditions.kiBuffer[p2IDX]; - - // - double cKIState = iConditions.kiStateBuffer[cIDX]; - double pKIState = iConditions.kiStateBuffer[pIDX]; - double p2KIState = iConditions.kiStateBuffer[p2IDX]; - - // - double cTKI = iConditions.tkiBuffer[cIDX]; - double pTKI = iConditions.tkiBuffer[pIDX]; - double p2TKI = iConditions.tkiBuffer[p2IDX]; - - // - double cTKIState = iConditions.tkiStateBuffer[cIDX]; - double pTKIState = iConditions.tkiStateBuffer[pIDX]; - double p2TKIState = iConditions.tkiStateBuffer[p2IDX]; - - // - double cTrend = iConditions.trendBuffer[cIDX]; - double pTrend = iConditions.trendBuffer[pIDX]; - double p2Trend = iConditions.trendBuffer[p2IDX]; - - // - double cTrendState = iConditions.trendStateBuffer[cIDX]; - double pTrendState = iConditions.trendStateBuffer[pIDX]; - double p2TrendState = iConditions.trendStateBuffer[p2IDX]; - - // - double cTKITRNDs[] = { - cKI, - cTKI, - cTrend // - }; - - // - double cTKITRNDMin = GetMin(cTKITRNDs); - double cTKITRNDMax = GetMax(cTKITRNDs); - - // - double pTKITRNDs[] = { - pKI, - pTKI, - pTrend // - }; - - // - double pTKITRNDMin = GetMin(pTKITRNDs); - double pTKITRNDMax = GetMax(pTKITRNDs); - - // - bool isCTKITRNDBullish = - cKIState > 0 && - cTKIState > 0 && - cTrendState > 0; - - // - bool isPTKITRNDBullish = - pKIState > 0 && - pTKIState > 0 && - pTrendState > 0; - - // - bool isTKITRNDSwitchedBullish = - isCTKITRNDBullish && - !isPTKITRNDBullish; - - // - bool isCTKITRNDBearish = - cKIState < 0 && - cTKIState < 0 && - cTrendState < 0; - - // - bool isPTKITRNDBearish = - pKIState < 0 && - pTKIState < 0 && - pTrendState < 0; - - // - bool isTKITRNDSwitchedBearish = - isCTKITRNDBearish && - !isPTKITRNDBearish; - - // - // CYCLES ... - - // - double cSLL = iConditions.sLLBuffer[cIDX]; - double pSLL = iConditions.sLLBuffer[pIDX]; - double p2SLL = iConditions.sLLBuffer[p2IDX]; - - // - double cSHH = iConditions.sHHBuffer[cIDX]; - double pSHH = iConditions.sHHBuffer[pIDX]; - double p2SHH = iConditions.sHHBuffer[p2IDX]; - - // - double cMLL = iConditions.mLLBuffer[cIDX]; - double pMLL = iConditions.mLLBuffer[pIDX]; - double p2MLL = iConditions.mLLBuffer[p2IDX]; - - // - double cMHH = iConditions.mHHBuffer[cIDX]; - double pMHH = iConditions.mHHBuffer[pIDX]; - double p2MHH = iConditions.mHHBuffer[p2IDX]; - - // - double cLLL = iConditions.lLLBuffer[cIDX]; - double pLLL = iConditions.lLLBuffer[pIDX]; - double p2LLL = iConditions.lLLBuffer[p2IDX]; - - // - double cLHH = iConditions.lHHBuffer[cIDX]; - double pLHH = iConditions.lHHBuffer[pIDX]; - double p2LHH = iConditions.lHHBuffer[p2IDX]; - - // - double cHLL = iConditions.hLLBuffer[cIDX]; - double pHLL = iConditions.hLLBuffer[pIDX]; - double p2HLL = iConditions.hLLBuffer[p2IDX]; - - // - double cHHH = iConditions.hHHBuffer[cIDX]; - double pHHH = iConditions.hHHBuffer[pIDX]; - double p2HHH = iConditions.hHHBuffer[p2IDX]; - - // - // Short Cycle ... - - // - // LL ... - - // - bool isCSLLSame = - cSLL == pSLL; - - // - bool isPSLLSame = - pSLL == p2SLL; - - // - bool isSLLStartSame = - isCSLLSame && - !isPSLLSame; - - // - bool isSLLFinishedSame = - !isCSLLSame && - isPSLLSame; - - // - // HH ... - - // - bool isCSHHSame = - cSHH == pSHH; - - // - bool isPSHHSame = - pSHH == p2SHH; - - // - bool isSHHStartSame = - isCSHHSame && - !isPSHHSame; - - // - bool isSHHFinishedSame = - !isCSHHSame && - isPSHHSame; - - // - // Mediu Cycle ... - - // - // LL ... - - // - bool isCMLLSame = - cMLL == pMLL; - - // - bool isPMLLSame = - pMLL == p2MLL; - - // - bool isMLLStartSame = - isCMLLSame && - !isPMLLSame; - - // - bool isMLLFinishedSame = - !isCMLLSame && - isPMLLSame; - - // - // HH ... - - // - bool isCMHHSame = - cMHH == pMHH; - - // - bool isPMHHSame = - pMHH == p2MHH; - - // - bool isMHHStartSame = - isCMHHSame && - !isPMHHSame; - - // - bool isMHHFinishedSame = - !isCMHHSame && - isPMHHSame; - - // - // Long Cycle ... - - // - // LL ... - - // - bool isCLLLSame = - cLLL == pLLL; - - // - bool isPLLLSame = - pLLL == p2LLL; - - // - bool isLLLStartSame = - isCLLLSame && - !isPLLLSame; - - // - bool isLLLFinishedSame = - !isCLLLSame && - isPLLLSame; - - // - // HH ... - - // - bool isCLHHSame = - cLHH == pLHH; - - // - bool isPLHHSame = - pLHH == p2LHH; - - // - bool isLHHStartSame = - isCLHHSame && - !isPLHHSame; - - // - bool isLHHFinishedSame = - !isCLHHSame && - isPLHHSame; - - // - // Hind Cycle ... - - // - // LL ... - - // - bool isCHLLSame = - cHLL == pHLL; - - // - bool isPHLLSame = - pHLL == p2HLL; - - // - bool isHLLStartSame = - isCHLLSame && - !isPHLLSame; - - // - bool isHLLFinishedSame = - !isCHLLSame && - isPHLLSame; - - // - // HH ... - - // - bool isCHHHSame = - cHHH == pHHH; - - // - bool isPHHHSame = - pHHH == p2HHH; - - // - bool isHHHStartSame = - isCHHHSame && - !isPHHHSame; - - // - bool isHHHFinishedSame = - !isCHHHSame && - isPHHHSame; - - // - // KI ... - - // - bool isCKISame = - cKI == pKI; - - // - bool isPKISame = - pKI == p2KI; - - // - bool isKIStartSame = - isCKISame && - !isPKISame; - - // - bool isKIFinishedSame = - !isCKISame && - isPKISame; - - // - // RSI ... - - // - double zRSI = iConditions.rsiBuffer[zIDX]; - double cRSI = iConditions.rsiBuffer[cIDX]; - double pRSI = iConditions.rsiBuffer[pIDX]; - double p2RSI = iConditions.rsiBuffer[p2IDX]; - - // - bool isRSIPeak = - pRSI > cRSI && - pRSI > p2RSI && - pRSI > zRSI; - - // - bool isRSIVale = - pRSI < cRSI && - pRSI < p2RSI && - pRSI < zRSI; - - // - bool isRSIBullishVPattern = - cRSI > pRSI && - p2RSI > pRSI && - cRSI > iConditions.rsiOSLevel && - pRSI < iConditions.rsiOSLevel; - - // - bool isRSIBearishVPattern = - cRSI < pRSI && - p2RSI < pRSI && - cRSI < iConditions.rsiOBLevel && - pRSI > iConditions.rsiOBLevel; - - // - // CCI ... - - // - double zCCI = iConditions.cciBuffer[zIDX]; - double cCCI = iConditions.cciBuffer[cIDX]; - double pCCI = iConditions.cciBuffer[pIDX]; - double p2CCI = iConditions.cciBuffer[p2IDX]; - - // - bool isCCIPeak = - pCCI > cCCI && - pCCI > p2CCI && - pCCI > zCCI; - - // - bool isCCIVale = - pCCI < cCCI && - pCCI < p2CCI && - pCCI < zCCI; - - // - bool isCCIBullishVPattern = - cCCI > pCCI && - p2CCI > pCCI && - cCCI > iConditions.cciOSLevel && - pCCI < iConditions.cciOSLevel; - - // - bool isCCIBearishVPattern = - cCCI < pCCI && - p2CCI < pCCI && - cCCI < iConditions.cciOBLevel && - pCCI > iConditions.cciOBLevel; + // Reading Values from Conditions and + // Create Customized Conditions if required ... // // Checking Pivots ... // - // Peak Pivot ... - if (detectPeakPivot) + // VALE Pivot Support Swing Low ... + if (detectValeSupSWLPivots) { // - if (!peakPivot.IsValid()) + if (conditions.isValeFinishedFromPivot) { // - peakPivot.type = XCA_PEAK; - peakPivot.symbol = iConditions.symbol; - peakPivot.period = iConditions.period; + valeSupSWLPivot.Clean(); // - if (isPeakFinishedSameLast) - { - // - peakPivot.Clean(); + valeSupSWLPivot.type = XCA_VALESWLSUP; + valeSupSWLPivot.symbol = conditions.symbol; + valeSupSWLPivot.period = conditions.period; - // - peakPivot.type = XCA_PEAK; - peakPivot.symbol = iConditions.symbol; - peakPivot.period = iConditions.period; - - // - peakPivot.to = pBar.time; - peakPivot.from = pBar.time; - peakPivot.value = iConditions.peakBuffer[pIDX]; - peakPivot.reserve = iConditions.peakGoldenBuffer[pIDX]; - } + // + valeSupSWLPivot.to = pBar.time; + valeSupSWLPivot.from = pBar.time; + valeSupSWLPivot.value = conditions.valeBuffer[pIDX]; + valeSupSWLPivot.reserve = conditions.valeGoldenBuffer[pIDX]; } // - if (iConditions.isPeakSameLast) + if (conditions.isValeIsPivot) { // - peakPivot.from = pBar.time; + valeSupSWLPivot.from = pBar.time; // - peakPivot.reserve = - peakPivot.reserve == 0 - ? iConditions.peakGoldenBuffer[cIDX] - : MathMax(peakPivot.reserve, iConditions.peakGoldenBuffer[cIDX]); + valeSupSWLPivot.reserve = + valeSupSWLPivot.reserve == 0 + ? conditions.valeGoldenBuffer[cIDX] + : MathMin(valeSupSWLPivot.reserve, conditions.valeGoldenBuffer[cIDX]); } // - if (isPeakStartSameLast) + if (conditions.isValeSwitchedToPivot) { // has = - peakPivot.IsValid() && - peakPivot.GetAge() >= pivotVerifications; + valeSupSWLPivot.IsValid() && + valeSupSWLPivot.GetAge() >= pivotVerifications; if (has) { // - AddPivot( - peakPivot, - peakPivots, - maxAllowedPivots // - ); - } - - // - peakPivot.Clean(); - } - } - - // - // Vale Pivot ... - if (detectValePivot) - { - // - if (!valePivot.IsValid()) - { - // - valePivot.type = XCA_VALE; - valePivot.symbol = iConditions.symbol; - valePivot.period = iConditions.period; - - // - if (isValeFinishedSameLast) - { - // - valePivot.Clean(); - - // - valePivot.type = XCA_VALE; - valePivot.symbol = iConditions.symbol; - valePivot.period = iConditions.period; - - // - valePivot.to = pBar.time; - valePivot.from = pBar.time; - valePivot.value = iConditions.valeBuffer[pIDX]; - valePivot.reserve = iConditions.valeGoldenBuffer[pIDX]; - } - } - - // - if (iConditions.isValeSameLast) - { - // - valePivot.from = pBar.time; - - // - valePivot.reserve = - valePivot.reserve == 0 - ? iConditions.valeGoldenBuffer[cIDX] - : MathMin(valePivot.reserve, iConditions.valeGoldenBuffer[cIDX]); - } - - // - if (isValeStartSameLast) - { - // - has = valePivot.IsValid() && - valePivot.GetAge() >= pivotVerifications; - if (has) - { - // - AddPivot( - valePivot, - valePivots, - maxAllowedPivots // - ); - } - - // - valePivot.Clean(); - } - } - - // - // SWH Pivot ... - if (detectSWHPivot) - { - // - if (!swhPivot.IsValid()) - { - // - swhPivot.type = XCA_SWH; - swhPivot.symbol = iConditions.symbol; - swhPivot.period = iConditions.period; - - // - if (isSWHFinishedSameLast) - { - // - swhPivot.Clean(); - - // - swhPivot.type = XCA_SWH; - swhPivot.symbol = iConditions.symbol; - swhPivot.period = iConditions.period; - - // - swhPivot.to = pBar.time; - swhPivot.from = pBar.time; - swhPivot.value = iConditions.swingHighBuffer[pIDX]; - } - } - - // - if (iConditions.isSwingHighSameLast) - { - // - swhPivot.from = pBar.time; - - // - double reserve = swhPivot.reserve; - if (pBar.high == pSWH) - { - // - reserve = - reserve == 0 - ? pBar.GetUp() - : MathMin(reserve, pBar.GetUp()); - } - swhPivot.reserve = reserve; - } - - // - if (isSWHStartSameLast) - { - // - double reserve = swhPivot.reserve; - if (cBar.high == cSWH) - { - // - reserve = - reserve == 0 - ? cBar.GetUp() - : MathMin(reserve, cBar.GetUp()); - } - if (pBar.high == pSWH) - { - // - reserve = - reserve == 0 - ? pBar.GetUp() - : MathMin(reserve, pBar.GetUp()); - } - if (reserve == 0 || reserve == swhPivot.value) - { - reserve = swhPivot.value - (5 * points); - } - swhPivot.reserve = reserve; - - // - has = - swhPivot.IsValid() && - swhPivot.GetAge() >= pivotVerifications; - if (has) - { - // - AddPivot( - swhPivot, - swhPivots, - maxAllowedPivots // - ); - } - - // - swhPivot.Clean(); - } - } - - // - // SWL Pivot ... - if (detectSWLPivot) - { - // - if (!swlPivot.IsValid()) - { - // - swlPivot.type = XCA_SWL; - swlPivot.symbol = iConditions.symbol; - swlPivot.period = iConditions.period; - - // - if (isSWLFinishedSameLast) - { - // - swlPivot.Clean(); - - // - swlPivot.type = XCA_SWL; - swlPivot.symbol = iConditions.symbol; - swlPivot.period = iConditions.period; - - // - swlPivot.to = cBar.time; - swlPivot.from = pBar.time; - swlPivot.value = iConditions.swingLowBuffer[cIDX]; - } - } - - // - if (iConditions.isSwingLowSameLast) - { - // - swlPivot.from = pBar.time; - - // - double reserve = swlPivot.reserve; - if (pBar.low == pSWL) - { - // - reserve = - reserve == 0 - ? pBar.GetDown() - : MathMax(reserve, pBar.GetDown()); - } - swlPivot.reserve = reserve; - } - - // - if (isSWLStartSameLast) - { - // - double reserve = swlPivot.reserve; - if (cBar.low == cSWL) - { - // - reserve = - reserve == 0 - ? cBar.GetDown() - : MathMax(reserve, cBar.GetDown()); - } - if (pBar.low == pSWL) - { - // - reserve = - reserve == 0 - ? pBar.GetDown() - : MathMax(reserve, pBar.GetDown()); - } - if (reserve == 0 || reserve == swlPivot.value) - { - reserve = swlPivot.value + (5 * points); - } - swlPivot.reserve = reserve; - - // - has = - swlPivot.IsValid() && - swlPivot.GetAge() >= pivotVerifications; - if (has) - { - // - AddPivot( - swlPivot, - swlPivots, - maxAllowedPivots // - ); - } - - // - swlPivot.Clean(); - } - } - - // - // Peak SWH Res Pivot ... - if (detectPeakSWHResPivot) - { - // - if (!peakSWHResPivot.IsValid()) - { - // - peakSWHResPivot.type = XCA_PEAKSWHRES; - peakSWHResPivot.symbol = iConditions.symbol; - peakSWHResPivot.period = iConditions.period; - - // - if (isFinishedPeakIsPivot) - { - // - peakSWHResPivot.Clean(); - - // - peakSWHResPivot.type = XCA_PEAKSWHRES; - peakSWHResPivot.symbol = iConditions.symbol; - peakSWHResPivot.period = iConditions.period; - - // - peakSWHResPivot.to = pBar.time; - peakSWHResPivot.from = pBar.time; - peakSWHResPivot.value = iConditions.peakBuffer[pIDX]; - peakSWHResPivot.reserve = iConditions.peakGoldenBuffer[pIDX]; - } - } - - // - if (iConditions.isPeakIsPivot) - { - // - peakSWHResPivot.from = pBar.time; - - // - peakSWHResPivot.reserve = - peakSWHResPivot.reserve == 0 - ? iConditions.peakGoldenBuffer[pIDX] - : MathMax(peakSWHResPivot.reserve, iConditions.peakGoldenBuffer[pIDX]); - } - - // - if (isStartPeakIsPivot) - { - // - has = peakSWHResPivot.IsValid() && - peakSWHResPivot.GetAge() >= pivotVerifications; - if (has) - { - // - AddPivot( - peakSWHResPivot, - peakSWHResPivots, - maxAllowedPivots // - ); - - // - XCAPVTick peakTick; - has = peakTick.Init(peakSWHResPivot); - if (has) + XBoxZone iBox; + newValeSupSWLPivotDetected = valeSupSWLPivot.AsBox(iBox); + if (newValeSupSWLPivotDetected) { // - AddPVTick( - peakTick, - peakTicks // + AddBox( + iBox, + valeSupSWLPivots, + maxAllowedPivots // ); } // - peakTick.Clean(); + iBox.Clean(); } // - peakSWHResPivot.Clean(); + valeSupSWLPivot.Clean(); } } // - // Vale SWL Sup Pivot ... - if (detectValeSWLSupPivot) + // PEAK Pivot Resistance Swing High ... + if (detectPeakResSWHPivots) { - // - if (!valeSWLSupPivot.IsValid()) - { - // - valeSWLSupPivot.type = XCA_VALESWLSUP; - valeSWLSupPivot.symbol = iConditions.symbol; - valeSWLSupPivot.period = iConditions.period; - - // - if (isFinishedValeIsPivot) - { - // - valeSWLSupPivot.Clean(); - - // - valeSWLSupPivot.type = XCA_VALESWLSUP; - valeSWLSupPivot.symbol = iConditions.symbol; - valeSWLSupPivot.period = iConditions.period; - - // - valeSWLSupPivot.to = pBar.time; - valeSWLSupPivot.from = pBar.time; - valeSWLSupPivot.value = iConditions.valeBuffer[pIDX]; - valeSWLSupPivot.reserve = iConditions.valeGoldenBuffer[pIDX]; - } - } - - // - if (iConditions.isValeIsPivot) - { - // - valeSWLSupPivot.from = pBar.time; - - // - valeSWLSupPivot.reserve = - valeSWLSupPivot.reserve == 0 - ? iConditions.valeGoldenBuffer[pIDX] - : MathMin(valeSWLSupPivot.reserve, iConditions.valeGoldenBuffer[pIDX]); - } - - // - if (isStartValeIsPivot) - { - // - has = valeSWLSupPivot.IsValid() && - valeSWLSupPivot.GetAge() >= pivotVerifications; - if (has) - { - // - AddPivot( - valeSWLSupPivot, - valeSWLSupPivots, - maxAllowedPivots // - ); - - // - XCAPVTick valeTick; - has = valeTick.Init(valeSWLSupPivot); - if (has) - { - // - AddPVTick( - valeTick, - valeTicks // - ); - } - - // - valeTick.Clean(); - } - - // - valeSWLSupPivot.Clean(); - } - } - - // - // KI Bullish ... - if (detectKIBullishPivot) - { - // - if (!kiBullishPivot.IsValid()) - { - // - kiBullishPivot.type = XCA_KI_BULL; - kiBullishPivot.symbol = iConditions.symbol; - kiBullishPivot.period = iConditions.period; - - // - if (iConditions.isKISwitchedToBearish) - { - // - kiBullishPivot.Clean(); - - // - kiBullishPivot.type = XCA_KI_BULL; - kiBullishPivot.symbol = iConditions.symbol; - kiBullishPivot.period = iConditions.period; - - // - kiBullishPivot.to = pBar.time; - kiBullishPivot.from = pBar.time; - kiBullishPivot.value = iConditions.kiBuffer[pIDX]; - kiBullishPivot.reserve = iConditions.kiBuffer[pIDX]; - } - } - - // - if (iConditions.isKIBullish) - { - // - kiBullishPivot.from = cBar.time; - - // - Add( - iConditions.kiBuffer[cIDX], - kiBullishPivot.values // - ); - - // - kiBullishPivot.value = - kiBullishPivot.value == 0 - ? iConditions.kiBuffer[cIDX] - : MathMin(iConditions.kiBuffer[cIDX], kiBullishPivot.value); - - // - kiBullishPivot.reserve = - kiBullishPivot.reserve == 0 - ? iConditions.kiBuffer[cIDX] - : MathMax(iConditions.kiBuffer[cIDX], kiBullishPivot.reserve); - } - - // - if (iConditions.isKISwitchedToBullish) - { - // - has = - kiBullishPivot.IsValid() && - kiBullishPivot.GetAge() >= pivotVerifications; - if (has) - { - // - AddPivot( - kiBullishPivot, - kiBullishPivots, - maxAllowedPivots // - ); - } - - // - kiBullishPivot.Clean(); - } - } - - // - // KI Bearish ... - if (detectKIBearishPivot) - { - // - if (!kiBearishPivot.IsValid()) - { - // - kiBearishPivot.type = XCA_KI_BEAR; - kiBearishPivot.symbol = iConditions.symbol; - kiBearishPivot.period = iConditions.period; - - // - if (iConditions.isKISwitchedToBullish) - { - // - kiBearishPivot.Clean(); - - // - kiBearishPivot.type = XCA_KI_BEAR; - kiBearishPivot.symbol = iConditions.symbol; - kiBearishPivot.period = iConditions.period; - - // - kiBearishPivot.to = pBar.time; - kiBearishPivot.from = pBar.time; - kiBearishPivot.value = iConditions.kiBuffer[pIDX]; - kiBearishPivot.reserve = iConditions.kiBuffer[pIDX]; - } - } - - // - if (iConditions.isKIBearish) - { - // - kiBearishPivot.from = cBar.time; - - // - Add( - iConditions.kiBuffer[cIDX], - kiBearishPivot.values // - ); - - // - kiBearishPivot.value = - kiBearishPivot.value == 0 - ? iConditions.kiBuffer[cIDX] - : MathMax(iConditions.kiBuffer[cIDX], kiBearishPivot.value); - - // - kiBearishPivot.reserve = - kiBearishPivot.reserve == 0 - ? iConditions.kiBuffer[cIDX] - : MathMin(iConditions.kiBuffer[cIDX], kiBearishPivot.reserve); - } - - // - if (iConditions.isKISwitchedToBearish) - { - // - has = - kiBearishPivot.IsValid() && - kiBearishPivot.GetAge() >= pivotVerifications; - if (has) - { - // - AddPivot( - kiBearishPivot, - kiBearishPivots, - maxAllowedPivots // - ); - } - - // - kiBearishPivot.Clean(); - } } // // FVG Bullish ... - if (detectFVGBullishPivot) + if (detectFVGBullishPivots) { - // - if (isBullishFVG) - { - // - XCAPivot iPivot; - - // - iPivot.to = fvgBox.to; - iPivot.from = fvgBox.from; - iPivot.type = XCA_FVG_BULL; - iPivot.value = fvgBox.lower; - iPivot.reserve = fvgBox.upper; - iPivot.symbol = fvgBox.symbol; - iPivot.period = fvgBox.period; - - // - AddPivot( - iPivot, - fvgBullishPivots, - maxAllowedPivots // - ); - - // - double fValue = - fvgBox.IsBullish() - ? cVale - : cPeak; - - // - // XPVFVG Handling ... - AddOrUpdatePVFVG( - fValue, - iPivot, - pvFVGBullishPivots // - ); - - // - iPivot.Clean(); - } } // // FVG Bearish ... - if (detectFVGBearishPivot) + if (detectFVGBearishPivots) { - // - if (isBearishFVG) - { - // - XCAPivot iPivot; - - // - iPivot.to = fvgBox.to; - iPivot.from = fvgBox.from; - iPivot.type = XCA_FVG_BEAR; - iPivot.value = fvgBox.upper; - iPivot.reserve = fvgBox.lower; - iPivot.symbol = fvgBox.symbol; - iPivot.period = fvgBox.period; - - // - AddPivot( - iPivot, - fvgBearishPivots, - maxAllowedPivots // - ); - - // - double fValue = - fvgBox.IsBullish() - ? cVale - : cPeak; - - // - // XPVFVG Handling ... - AddOrUpdatePVFVG( - fValue, - iPivot, - pvFVGBearishPivots // - ); - - // - iPivot.Clean(); - } } // - // TKI Bullish ... - if (detectTKIBullishPivot) + // RSI Peak Pivot ... + if (detectRSIPeakPivots) { - // - if (!tkiBullishPivot.IsValid()) - { - // - tkiBullishPivot.type = XCA_TKI_BULL; - tkiBullishPivot.symbol = iConditions.symbol; - tkiBullishPivot.period = iConditions.period; - - // - if (iConditions.isTKISwitchedToBearish) - { - // - tkiBullishPivot.Clean(); - - // - tkiBullishPivot.type = XCA_TKI_BULL; - tkiBullishPivot.symbol = iConditions.symbol; - tkiBullishPivot.period = iConditions.period; - - // - tkiBullishPivot.to = pBar.time; - tkiBullishPivot.from = pBar.time; - tkiBullishPivot.value = iConditions.tkiBuffer[pIDX]; - tkiBullishPivot.reserve = iConditions.tkiBuffer[pIDX]; - } - } - - // - if (iConditions.isTKIBullish) - { - // - tkiBullishPivot.from = cBar.time; - - // - Add( - iConditions.tkiBuffer[cIDX], - tkiBullishPivot.values // - ); - - // - tkiBullishPivot.value = - tkiBullishPivot.value == 0 - ? iConditions.tkiBuffer[cIDX] - : MathMin(iConditions.tkiBuffer[cIDX], tkiBullishPivot.value); - - // - tkiBullishPivot.reserve = - tkiBullishPivot.reserve == 0 - ? iConditions.tkiBuffer[cIDX] - : MathMax(iConditions.tkiBuffer[cIDX], tkiBullishPivot.reserve); - } - - // - if (iConditions.isTKISwitchedToBullish) - { - // - has = - tkiBullishPivot.IsValid() && - tkiBullishPivot.GetAge() >= pivotVerifications; - if (has) - { - // - AddPivot( - tkiBullishPivot, - tkiBullishPivots, - maxAllowedPivots // - ); - } - - // - tkiBullishPivot.Clean(); - } } // - // TKI Bearish ... - if (detectTKIBearishPivot) + // RSI Vale Pivot ... + if (detectRSIValePivots) { - // - if (!tkiBearishPivot.IsValid()) - { - // - tkiBearishPivot.type = XCA_TKI_BEAR; - tkiBearishPivot.symbol = iConditions.symbol; - tkiBearishPivot.period = iConditions.period; - - // - if (iConditions.isTKISwitchedToBullish) - { - // - tkiBearishPivot.Clean(); - - // - tkiBearishPivot.type = XCA_TKI_BEAR; - tkiBearishPivot.symbol = iConditions.symbol; - tkiBearishPivot.period = iConditions.period; - - // - tkiBearishPivot.to = pBar.time; - tkiBearishPivot.from = pBar.time; - tkiBearishPivot.value = iConditions.tkiBuffer[pIDX]; - tkiBearishPivot.reserve = iConditions.tkiBuffer[pIDX]; - } - } - - // - if (iConditions.isTKIBearish) - { - // - tkiBearishPivot.from = cBar.time; - - // - Add( - iConditions.tkiBuffer[cIDX], - tkiBearishPivot.values // - ); - - // - tkiBearishPivot.value = - tkiBearishPivot.value == 0 - ? iConditions.tkiBuffer[cIDX] - : MathMax(iConditions.tkiBuffer[cIDX], tkiBearishPivot.value); - - // - tkiBearishPivot.reserve = - tkiBearishPivot.reserve == 0 - ? iConditions.tkiBuffer[cIDX] - : MathMin(iConditions.tkiBuffer[cIDX], tkiBearishPivot.reserve); - } - - // - if (iConditions.isTKISwitchedToBearish) - { - // - has = - tkiBearishPivot.IsValid() && - tkiBearishPivot.GetAge() >= pivotVerifications; - if (has) - { - // - AddPivot( - tkiBearishPivot, - tkiBearishPivots, - maxAllowedPivots // - ); - } - - // - tkiBearishPivot.Clean(); - } } // - // TREND Bullish ... - if (detectTrendBullishPivot) + // CCI Peak Pivot ... + if (detectCCIPeakPivots) { - // - if (!trendBullishPivot.IsValid()) - { - // - trendBullishPivot.type = XCA_TREND_BULL; - trendBullishPivot.symbol = iConditions.symbol; - trendBullishPivot.period = iConditions.period; - - // - if (iConditions.isTrendSwitchedToBearish) - { - // - trendBullishPivot.Clean(); - - // - trendBullishPivot.type = XCA_TREND_BULL; - trendBullishPivot.symbol = iConditions.symbol; - trendBullishPivot.period = iConditions.period; - - // - trendBullishPivot.to = pBar.time; - trendBullishPivot.from = pBar.time; - trendBullishPivot.value = iConditions.trendBuffer[pIDX]; - trendBullishPivot.reserve = iConditions.trendBuffer[pIDX]; - } - } - - // - if (iConditions.isTrendBullish) - { - // - trendBullishPivot.from = cBar.time; - - // - Add( - iConditions.trendBuffer[cIDX], - trendBullishPivot.values // - ); - - // - trendBullishPivot.value = - trendBullishPivot.value == 0 - ? iConditions.trendBuffer[cIDX] - : MathMin(iConditions.trendBuffer[cIDX], trendBullishPivot.value); - - // - trendBullishPivot.reserve = - trendBullishPivot.reserve == 0 - ? iConditions.trendBuffer[cIDX] - : MathMax(iConditions.trendBuffer[cIDX], trendBullishPivot.reserve); - } - - // - if (iConditions.isTrendSwitchedToBullish) - { - // - has = - trendBullishPivot.IsValid() && - trendBullishPivot.GetAge() >= pivotVerifications; - if (has) - { - // - AddPivot( - trendBullishPivot, - trendBullishPivots, - maxAllowedPivots // - ); - } - - // - trendBullishPivot.Clean(); - } } // - // TREND Bearish ... - if (detectTrendBearishPivot) + // CCI Vale Pivot ... + if (detectCCIValePivots) { - // - if (!trendBearishPivot.IsValid()) - { - // - trendBearishPivot.type = XCA_TREND_BEAR; - trendBearishPivot.symbol = iConditions.symbol; - trendBearishPivot.period = iConditions.period; - - // - if (iConditions.isTrendSwitchedToBullish) - { - // - trendBearishPivot.Clean(); - - // - trendBearishPivot.type = XCA_TREND_BEAR; - trendBearishPivot.symbol = iConditions.symbol; - trendBearishPivot.period = iConditions.period; - - // - trendBearishPivot.to = pBar.time; - trendBearishPivot.from = pBar.time; - trendBearishPivot.value = iConditions.trendBuffer[pIDX]; - trendBearishPivot.reserve = iConditions.trendBuffer[pIDX]; - } - } - - // - if (iConditions.isTrendBearish) - { - // - trendBearishPivot.from = cBar.time; - - // - Add( - iConditions.trendBuffer[cIDX], - trendBearishPivot.values // - ); - - // - trendBearishPivot.value = - trendBearishPivot.value == 0 - ? iConditions.trendBuffer[cIDX] - : MathMax(iConditions.trendBuffer[cIDX], trendBearishPivot.value); - - // - trendBearishPivot.reserve = - trendBearishPivot.reserve == 0 - ? iConditions.trendBuffer[cIDX] - : MathMin(iConditions.trendBuffer[cIDX], trendBearishPivot.reserve); - } - - // - if (iConditions.isTrendSwitchedToBearish) - { - // - has = - trendBearishPivot.IsValid() && - trendBearishPivot.GetAge() >= pivotVerifications; - if (has) - { - // - AddPivot( - trendBearishPivot, - trendBearishPivots, - maxAllowedPivots // - ); - } - - // - trendBearishPivot.Clean(); - } - } - - // - // TKITRND Bullish ... - if (detectTKITRNDBullishPivot) - { - // - if (!tkitrndBullishPivot.IsValid()) - { - // - tkitrndBullishPivot.type = XCA_TKITRND_BULL; - tkitrndBullishPivot.symbol = iConditions.symbol; - tkitrndBullishPivot.period = iConditions.period; - - // - if (!isCTKITRNDBullish && isPTKITRNDBullish) - { - // - tkitrndBullishPivot.Clean(); - - // - tkitrndBullishPivot.type = XCA_TKITRND_BULL; - tkitrndBullishPivot.symbol = iConditions.symbol; - tkitrndBullishPivot.period = iConditions.period; - - // - tkitrndBullishPivot.to = pBar.time; - tkitrndBullishPivot.from = pBar.time; - tkitrndBullishPivot.value = pTKITRNDMin; - tkitrndBullishPivot.reserve = pTKITRNDMax; - } - } - - // - if (isCTKITRNDBullish) - { - // - tkitrndBullishPivot.from = cBar.time; - - // - Add( - cTKITRNDMin, - tkitrndBullishPivot.values // - ); - - // - Add( - cTKITRNDMax, - tkitrndBullishPivot.values // - ); - - // - tkitrndBullishPivot.value = - tkitrndBullishPivot.value == 0 - ? cTKITRNDMin - : MathMin(cTKITRNDMin, tkitrndBullishPivot.value); - - // - tkitrndBullishPivot.reserve = - tkitrndBullishPivot.reserve == 0 - ? cTKITRNDMax - : MathMax(cTKITRNDMax, tkitrndBullishPivot.reserve); - } - - // - if (!isCTKITRNDBullish) - { - // - has = - tkitrndBullishPivot.IsValid() && - tkitrndBullishPivot.GetAge() >= pivotVerifications; - if (has) - { - // - AddPivot( - tkitrndBullishPivot, - tkitrndBullishPivots, - maxAllowedPivots // - ); - } - - // - trendBullishPivot.Clean(); - } - } - - // - // TKITRND Bearish ... - if (detectTKITRNDBearishPivot) - { - // - if (!tkitrndBearishPivot.IsValid()) - { - // - tkitrndBearishPivot.type = XCA_TKITRND_BEAR; - tkitrndBearishPivot.symbol = iConditions.symbol; - tkitrndBearishPivot.period = iConditions.period; - - // - if (!isCTKITRNDBearish && isPTKITRNDBearish) - { - // - tkitrndBearishPivot.Clean(); - - // - tkitrndBearishPivot.type = XCA_TKITRND_BEAR; - tkitrndBearishPivot.symbol = iConditions.symbol; - tkitrndBearishPivot.period = iConditions.period; - - // - tkitrndBearishPivot.to = pBar.time; - tkitrndBearishPivot.from = pBar.time; - tkitrndBearishPivot.value = pTKITRNDMax; - tkitrndBearishPivot.reserve = pTKITRNDMin; - } - } - - // - if (isCTKITRNDBearish) - { - // - tkitrndBearishPivot.from = cBar.time; - - // - Add( - cTKITRNDMin, - tkitrndBearishPivot.values // - ); - - // - Add( - cTKITRNDMax, - tkitrndBearishPivot.values // - ); - - // - tkitrndBearishPivot.value = - tkitrndBearishPivot.value == 0 - ? cTKITRNDMax - : MathMax(cTKITRNDMax, tkitrndBearishPivot.value); - - // - tkitrndBearishPivot.reserve = - tkitrndBearishPivot.reserve == 0 - ? cTKITRNDMin - : MathMin(cTKITRNDMin, tkitrndBearishPivot.reserve); - } - - // - if (!isCTKITRNDBearish) - { - // - has = - tkitrndBearishPivot.IsValid() && - tkitrndBearishPivot.GetAge() >= pivotVerifications; - if (has) - { - // - AddPivot( - tkitrndBearishPivot, - tkitrndBearishPivots, - maxAllowedPivots // - ); - } - - // - trendBearishPivot.Clean(); - } - } - - // - // Cycles LL ... - if (detectCycleSameLLPivot) - { - // - // Short Cycle ... - if (!sSameLLPivot.IsValid()) - { - // - sSameLLPivot.type = XCA_LL; - sSameLLPivot.symbol = iConditions.symbol; - sSameLLPivot.period = iConditions.period; - - // - if (isSLLFinishedSame) - { - // - sSameLLPivot.Clean(); - - // - sSameLLPivot.type = XCA_LL; - sSameLLPivot.symbol = iConditions.symbol; - sSameLLPivot.period = iConditions.period; - - // - sSameLLPivot.to = pBar.time; - sSameLLPivot.from = pBar.time; - sSameLLPivot.value = pSLL; - sSameLLPivot.reserve = pSLL; - } - } - - // - if (isCSLLSame) - { - // - sSameLLPivot.from = pBar.time; - - // - double reserve = sSameLLPivot.reserve; - if (pBar.low == pSLL) - { - // - reserve = - reserve == 0 - ? pBar.GetDown() - : MathMax(reserve, pBar.GetDown()); - } - sSameLLPivot.reserve = reserve; - } - - // - if (isSLLStartSame) - { - // - double reserve = sSameLLPivot.reserve; - if (cBar.low == cSLL) - { - // - reserve = - reserve == 0 - ? cBar.GetDown() - : MathMax(reserve, cBar.GetDown()); - } - if (pBar.low == pSLL) - { - // - reserve = - reserve == 0 - ? pBar.GetDown() - : MathMax(reserve, pBar.GetDown()); - } - if (reserve == 0 || reserve == sSameLLPivot.value) - { - reserve = sSameLLPivot.value + (5 * points); - } - sSameLLPivot.reserve = reserve; - - // - has = - sSameLLPivot.IsValid() && - sSameLLPivot.GetAge() >= pivotVerifications; - if (has) - { - // - AddPivot( - sSameLLPivot, - sSameLLPivots, - maxAllowedPivots // - ); - } - - // - sSameLLPivot.Clean(); - } - - // - // Medium Cycle ... - if (!mSameLLPivot.IsValid()) - { - // - mSameLLPivot.type = XCA_LL; - mSameLLPivot.symbol = iConditions.symbol; - mSameLLPivot.period = iConditions.period; - - // - if (isMLLFinishedSame) - { - // - mSameLLPivot.Clean(); - - // - mSameLLPivot.type = XCA_LL; - mSameLLPivot.symbol = iConditions.symbol; - mSameLLPivot.period = iConditions.period; - - // - mSameLLPivot.to = pBar.time; - mSameLLPivot.from = pBar.time; - mSameLLPivot.value = pMLL; - mSameLLPivot.reserve = pMLL; - } - } - - // - if (isCMLLSame) - { - // - mSameLLPivot.from = pBar.time; - - // - double reserve = mSameLLPivot.reserve; - if (pBar.low == pMLL) - { - // - reserve = - reserve == 0 - ? pBar.GetDown() - : MathMax(reserve, pBar.GetDown()); - } - mSameLLPivot.reserve = reserve; - } - - // - if (isMLLStartSame) - { - // - double reserve = mSameLLPivot.reserve; - if (cBar.low == cMLL) - { - // - reserve = - reserve == 0 - ? cBar.GetDown() - : MathMax(reserve, cBar.GetDown()); - } - if (pBar.low == pMLL) - { - // - reserve = - reserve == 0 - ? pBar.GetDown() - : MathMax(reserve, pBar.GetDown()); - } - if (reserve == 0 || reserve == mSameLLPivot.value) - { - reserve = mSameLLPivot.value + (5 * points); - } - mSameLLPivot.reserve = reserve; - - // - has = - mSameLLPivot.IsValid() && - mSameLLPivot.GetAge() >= pivotVerifications; - if (has) - { - // - AddPivot( - mSameLLPivot, - mSameLLPivots, - maxAllowedPivots // - ); - } - - // - mSameLLPivot.Clean(); - } - - // - // Long Cycle ... - if (!lSameLLPivot.IsValid()) - { - // - lSameLLPivot.type = XCA_LL; - lSameLLPivot.symbol = iConditions.symbol; - lSameLLPivot.period = iConditions.period; - - // - if (isLLLFinishedSame) - { - // - lSameLLPivot.Clean(); - - // - lSameLLPivot.type = XCA_LL; - lSameLLPivot.symbol = iConditions.symbol; - lSameLLPivot.period = iConditions.period; - - // - lSameLLPivot.to = pBar.time; - lSameLLPivot.from = pBar.time; - lSameLLPivot.value = pLLL; - lSameLLPivot.reserve = pLLL; - } - } - - // - if (isCLLLSame) - { - // - lSameLLPivot.from = pBar.time; - - // - double reserve = lSameLLPivot.reserve; - if (pBar.low == pLLL) - { - // - reserve = - reserve == 0 - ? pBar.GetDown() - : MathMax(reserve, pBar.GetDown()); - } - lSameLLPivot.reserve = reserve; - } - - // - if (isLLLStartSame) - { - // - double reserve = lSameLLPivot.reserve; - if (cBar.low == cLLL) - { - // - reserve = - reserve == 0 - ? cBar.GetDown() - : MathMax(reserve, cBar.GetDown()); - } - if (pBar.low == pLLL) - { - // - reserve = - reserve == 0 - ? pBar.GetDown() - : MathMax(reserve, pBar.GetDown()); - } - if (reserve == 0 || reserve == lSameLLPivot.value) - { - reserve = lSameLLPivot.value + (5 * points); - } - lSameLLPivot.reserve = reserve; - - // - has = - lSameLLPivot.IsValid() && - lSameLLPivot.GetAge() >= pivotVerifications; - if (has) - { - // - AddPivot( - lSameLLPivot, - lSameLLPivots, - maxAllowedPivots // - ); - } - - // - lSameLLPivot.Clean(); - } - - // - // Hind Cycle ... - if (!hSameLLPivot.IsValid()) - { - // - hSameLLPivot.type = XCA_LL; - hSameLLPivot.symbol = iConditions.symbol; - hSameLLPivot.period = iConditions.period; - - // - if (isHLLFinishedSame) - { - // - hSameLLPivot.Clean(); - - // - hSameLLPivot.type = XCA_LL; - hSameLLPivot.symbol = iConditions.symbol; - hSameLLPivot.period = iConditions.period; - - // - hSameLLPivot.to = pBar.time; - hSameLLPivot.from = pBar.time; - hSameLLPivot.value = pHLL; - hSameLLPivot.reserve = pHLL; - } - } - - // - if (isCHLLSame) - { - // - hSameLLPivot.from = pBar.time; - - // - double reserve = hSameLLPivot.reserve; - if (pBar.low == pHLL) - { - // - reserve = - reserve == 0 - ? pBar.GetDown() - : MathMax(reserve, pBar.GetDown()); - } - hSameLLPivot.reserve = reserve; - } - - // - if (isHLLStartSame) - { - // - double reserve = hSameLLPivot.reserve; - if (cBar.low == cHLL) - { - // - reserve = - reserve == 0 - ? cBar.GetDown() - : MathMax(reserve, cBar.GetDown()); - } - if (pBar.low == pHLL) - { - // - reserve = - reserve == 0 - ? pBar.GetDown() - : MathMax(reserve, pBar.GetDown()); - } - if (reserve == 0 || reserve == hSameLLPivot.value) - { - reserve = hSameLLPivot.value + (5 * points); - } - hSameLLPivot.reserve = reserve; - - // - has = - hSameLLPivot.IsValid() && - hSameLLPivot.GetAge() >= pivotVerifications; - if (has) - { - // - AddPivot( - hSameLLPivot, - hSameLLPivots, - maxAllowedPivots // - ); - } - - // - hSameLLPivot.Clean(); - } - } - - // - // Cycles HH ... - if (detectCycleSameHHPivot) - { - // - // Short Cycle ... - if (!sSameHHPivot.IsValid()) - { - // - sSameHHPivot.type = XCA_HH; - sSameHHPivot.symbol = iConditions.symbol; - sSameHHPivot.period = iConditions.period; - - // - if (isSHHFinishedSame) - { - // - sSameHHPivot.Clean(); - - // - sSameHHPivot.type = XCA_HH; - sSameHHPivot.symbol = iConditions.symbol; - sSameHHPivot.period = iConditions.period; - - // - sSameHHPivot.to = pBar.time; - sSameHHPivot.from = pBar.time; - sSameHHPivot.value = pSHH; - sSameHHPivot.reserve = pSHH; - } - } - - // - if (isCSHHSame) - { - // - sSameHHPivot.from = pBar.time; - - // - double reserve = sSameHHPivot.reserve; - if (pBar.high == pSHH) - { - // - reserve = - reserve == 0 - ? pBar.GetUp() - : MathMin(reserve, pBar.GetUp()); - } - sSameHHPivot.reserve = reserve; - } - - // - if (isSHHStartSame) - { - // - double reserve = sSameHHPivot.reserve; - if (cBar.high == cSHH) - { - // - reserve = - reserve == 0 - ? cBar.GetUp() - : MathMin(reserve, cBar.GetUp()); - } - if (pBar.high == pSHH) - { - // - reserve = - reserve == 0 - ? pBar.GetUp() - : MathMin(reserve, pBar.GetUp()); - } - if (reserve == 0 || reserve == sSameHHPivot.value) - { - reserve = sSameHHPivot.value + (5 * points); - } - sSameHHPivot.reserve = reserve; - - // - has = - sSameHHPivot.IsValid() && - sSameHHPivot.GetAge() >= pivotVerifications; - if (has) - { - // - AddPivot( - sSameHHPivot, - sSameHHPivots, - maxAllowedPivots // - ); - } - - // - sSameHHPivot.Clean(); - } - - // - // Medium Cycle ... - if (!mSameHHPivot.IsValid()) - { - // - mSameHHPivot.type = XCA_HH; - mSameHHPivot.symbol = iConditions.symbol; - mSameHHPivot.period = iConditions.period; - - // - if (isMHHFinishedSame) - { - // - mSameHHPivot.Clean(); - - // - mSameHHPivot.type = XCA_HH; - mSameHHPivot.symbol = iConditions.symbol; - mSameHHPivot.period = iConditions.period; - - // - mSameHHPivot.to = pBar.time; - mSameHHPivot.from = pBar.time; - mSameHHPivot.value = pMHH; - mSameHHPivot.reserve = pMHH; - } - } - - // - if (isCMHHSame) - { - // - mSameHHPivot.from = pBar.time; - - // - double reserve = mSameHHPivot.reserve; - if (pBar.high == pMHH) - { - // - reserve = - reserve == 0 - ? pBar.GetUp() - : MathMin(reserve, pBar.GetUp()); - } - mSameHHPivot.reserve = reserve; - } - - // - if (isMHHStartSame) - { - // - double reserve = mSameHHPivot.reserve; - if (cBar.high == cMHH) - { - // - reserve = - reserve == 0 - ? cBar.GetUp() - : MathMin(reserve, cBar.GetUp()); - } - if (pBar.high == pMHH) - { - // - reserve = - reserve == 0 - ? pBar.GetUp() - : MathMin(reserve, pBar.GetUp()); - } - if (reserve == 0 || reserve == mSameHHPivot.value) - { - reserve = mSameHHPivot.value + (5 * points); - } - mSameHHPivot.reserve = reserve; - - // - has = - mSameHHPivot.IsValid() && - mSameHHPivot.GetAge() >= pivotVerifications; - if (has) - { - // - AddPivot( - mSameHHPivot, - mSameHHPivots, - maxAllowedPivots // - ); - } - - // - mSameHHPivot.Clean(); - } - - // - // Long Cycle ... - if (!lSameHHPivot.IsValid()) - { - // - lSameHHPivot.type = XCA_HH; - lSameHHPivot.symbol = iConditions.symbol; - lSameHHPivot.period = iConditions.period; - - // - if (isLHHFinishedSame) - { - // - lSameHHPivot.Clean(); - - // - lSameHHPivot.type = XCA_HH; - lSameHHPivot.symbol = iConditions.symbol; - lSameHHPivot.period = iConditions.period; - - // - lSameHHPivot.to = pBar.time; - lSameHHPivot.from = pBar.time; - lSameHHPivot.value = pLHH; - lSameHHPivot.reserve = pLHH; - } - } - - // - if (isCLHHSame) - { - // - lSameHHPivot.from = pBar.time; - - // - double reserve = lSameHHPivot.reserve; - if (pBar.high == pLHH) - { - // - reserve = - reserve == 0 - ? pBar.GetUp() - : MathMin(reserve, pBar.GetUp()); - } - lSameHHPivot.reserve = reserve; - } - - // - if (isLHHStartSame) - { - // - double reserve = lSameHHPivot.reserve; - if (cBar.high == cLHH) - { - // - reserve = - reserve == 0 - ? cBar.GetUp() - : MathMin(reserve, cBar.GetUp()); - } - if (pBar.high == pLHH) - { - // - reserve = - reserve == 0 - ? pBar.GetUp() - : MathMin(reserve, pBar.GetUp()); - } - if (reserve == 0 || reserve == lSameHHPivot.value) - { - reserve = lSameHHPivot.value + (5 * points); - } - lSameHHPivot.reserve = reserve; - - // - has = - lSameHHPivot.IsValid() && - lSameHHPivot.GetAge() >= pivotVerifications; - if (has) - { - // - AddPivot( - lSameHHPivot, - lSameHHPivots, - maxAllowedPivots // - ); - } - - // - lSameHHPivot.Clean(); - } - - // - // Hind Cycle ... - if (!hSameHHPivot.IsValid()) - { - // - hSameHHPivot.type = XCA_HH; - hSameHHPivot.symbol = iConditions.symbol; - hSameHHPivot.period = iConditions.period; - - // - if (isHHHFinishedSame) - { - // - hSameHHPivot.Clean(); - - // - hSameHHPivot.type = XCA_HH; - hSameHHPivot.symbol = iConditions.symbol; - hSameHHPivot.period = iConditions.period; - - // - hSameHHPivot.to = pBar.time; - hSameHHPivot.from = pBar.time; - hSameHHPivot.value = pHHH; - hSameHHPivot.reserve = pHHH; - } - } - - // - if (isCHHHSame) - { - // - hSameHHPivot.from = pBar.time; - - // - double reserve = hSameHHPivot.reserve; - if (pBar.high == pHHH) - { - // - reserve = - reserve == 0 - ? pBar.GetUp() - : MathMin(reserve, pBar.GetUp()); - } - hSameHHPivot.reserve = reserve; - } - - // - if (isHHHStartSame) - { - // - double reserve = hSameHHPivot.reserve; - if (cBar.high == cHHH) - { - // - reserve = - reserve == 0 - ? cBar.GetUp() - : MathMin(reserve, cBar.GetUp()); - } - if (pBar.high == pHHH) - { - // - reserve = - reserve == 0 - ? pBar.GetUp() - : MathMin(reserve, pBar.GetUp()); - } - if (reserve == 0 || reserve == hSameHHPivot.value) - { - reserve = hSameHHPivot.value + (5 * points); - } - hSameHHPivot.reserve = reserve; - - // - has = - hSameHHPivot.IsValid() && - hSameHHPivot.GetAge() >= pivotVerifications; - if (has) - { - // - AddPivot( - hSameHHPivot, - hSameHHPivots, - maxAllowedPivots // - ); - } - - // - hSameHHPivot.Clean(); - } - } - - // - // RSI Peak ... - if (detectRSIPeakPivot) - { - // - if (isRSIPeak) - { - // - XCAPivot iPivot; - - // - iPivot.to = cBar.time; - iPivot.from = p2Bar.time; - iPivot.value = pBar.high; - iPivot.type = XCA_RSI_PEAK; - iPivot.symbol = cBar.symbol; - iPivot.period = cBar.period; - - // - Add( - cBar.high, - iPivot.values // - ); - Add( - pBar.high, - iPivot.values // - ); - Add( - p2Bar.high, - iPivot.values // - ); - Add( - cBar.close, - iPivot.values // - ); - Add( - pBar.close, - iPivot.values // - ); - Add( - p2Bar.close, - iPivot.values // - ); - - // - iPivot.reserve = GetMin(iPivot.values); - - // - AddPivot( - iPivot, - rsiPeakPivots, - maxAllowedPivots // - ); - - // - iPivot.Clean(); - } - } - - // - // RSI Vale ... - if (detectRSIValePivot) - { - // - if (isRSIVale) - { - // - XCAPivot iPivot; - - // - iPivot.to = cBar.time; - iPivot.from = p2Bar.time; - iPivot.value = pBar.low; - iPivot.type = XCA_RSI_VALE; - iPivot.symbol = cBar.symbol; - iPivot.period = cBar.period; - - // - Add( - cBar.low, - iPivot.values // - ); - Add( - pBar.low, - iPivot.values // - ); - Add( - p2Bar.low, - iPivot.values // - ); - Add( - cBar.close, - iPivot.values // - ); - Add( - pBar.close, - iPivot.values // - ); - Add( - p2Bar.close, - iPivot.values // - ); - - // - iPivot.reserve = GetMax(iPivot.values); - - // - AddPivot( - iPivot, - rsiValePivots, - maxAllowedPivots // - ); - - // - iPivot.Clean(); - } - } - - // - // RSI Crossed Over OS ... - if (detectRSICrossedOverOSPivot) - { - // - if (isRSIBullishVPattern) - { - // - XCAPivot iPivot; - - // - iPivot.to = cBar.time; - iPivot.from = p2Bar.time; - iPivot.value = pBar.low; - iPivot.type = XCA_RSI_COOS; - iPivot.symbol = cBar.symbol; - iPivot.period = cBar.period; - - // - Add( - cBar.low, - iPivot.values // - ); - Add( - pBar.low, - iPivot.values // - ); - Add( - p2Bar.low, - iPivot.values // - ); - Add( - cBar.close, - iPivot.values // - ); - Add( - pBar.close, - iPivot.values // - ); - Add( - p2Bar.close, - iPivot.values // - ); - - // - iPivot.reserve = GetMax(iPivot.values); - - // - AddPivot( - iPivot, - rsiCrossedOverOSPivots, - maxAllowedPivots // - ); - - // - iPivot.Clean(); - } - } - - // - // RSI Crossed Under OS ... - if (detectRSICrossedUnderOBPivot) - { - // - if (isRSIBearishVPattern) - { - // - XCAPivot iPivot; - - // - iPivot.to = cBar.time; - iPivot.from = p2Bar.time; - iPivot.value = pBar.high; - iPivot.type = XCA_RSI_CUOB; - iPivot.symbol = cBar.symbol; - iPivot.period = cBar.period; - - // - Add( - cBar.high, - iPivot.values // - ); - Add( - pBar.high, - iPivot.values // - ); - Add( - p2Bar.high, - iPivot.values // - ); - Add( - cBar.close, - iPivot.values // - ); - Add( - pBar.close, - iPivot.values // - ); - Add( - p2Bar.close, - iPivot.values // - ); - - // - iPivot.reserve = GetMin(iPivot.values); - - // - AddPivot( - iPivot, - rsiCrossedUnderOBPivots, - maxAllowedPivots // - ); - - // - iPivot.Clean(); - } - } - - // - // CCI Peak ... - if (detectCCIPeakPivot) - { - // - if (isCCIPeak) - { - // - XCAPivot iPivot; - - // - iPivot.to = cBar.time; - iPivot.from = p2Bar.time; - iPivot.value = pBar.high; - iPivot.type = XCA_CCI_PEAK; - iPivot.symbol = cBar.symbol; - iPivot.period = cBar.period; - - // - Add( - cBar.high, - iPivot.values // - ); - Add( - pBar.high, - iPivot.values // - ); - Add( - p2Bar.high, - iPivot.values // - ); - Add( - cBar.close, - iPivot.values // - ); - Add( - pBar.close, - iPivot.values // - ); - Add( - p2Bar.close, - iPivot.values // - ); - - // - iPivot.reserve = GetMin(iPivot.values); - - // - AddPivot( - iPivot, - cciPeakPivots, - maxAllowedPivots // - ); - - // - iPivot.Clean(); - } - } - - // - // CCI Vale ... - if (detectCCIValePivot) - { - // - if (isCCIVale) - { - // - XCAPivot iPivot; - - // - iPivot.to = cBar.time; - iPivot.from = p2Bar.time; - iPivot.value = pBar.low; - iPivot.type = XCA_CCI_VALE; - iPivot.symbol = cBar.symbol; - iPivot.period = cBar.period; - - // - Add( - cBar.low, - iPivot.values // - ); - Add( - pBar.low, - iPivot.values // - ); - Add( - p2Bar.low, - iPivot.values // - ); - Add( - cBar.close, - iPivot.values // - ); - Add( - pBar.close, - iPivot.values // - ); - Add( - p2Bar.close, - iPivot.values // - ); - - // - iPivot.reserve = GetMax(iPivot.values); - - // - AddPivot( - iPivot, - cciValePivots, - maxAllowedPivots // - ); - - // - iPivot.Clean(); - } - } - - // - // CCI Crossed Over OS ... - if (detectCCICrossedOverOSPivot) - { - // - if (isCCIBullishVPattern) - { - // - XCAPivot iPivot; - - // - iPivot.to = cBar.time; - iPivot.from = p2Bar.time; - iPivot.value = pBar.low; - iPivot.type = XCA_CCI_COOS; - iPivot.symbol = cBar.symbol; - iPivot.period = cBar.period; - - // - Add( - cBar.low, - iPivot.values // - ); - Add( - pBar.low, - iPivot.values // - ); - Add( - p2Bar.low, - iPivot.values // - ); - Add( - cBar.close, - iPivot.values // - ); - Add( - pBar.close, - iPivot.values // - ); - Add( - p2Bar.close, - iPivot.values // - ); - - // - iPivot.reserve = GetMax(iPivot.values); - - // - AddPivot( - iPivot, - cciCrossedOverOSPivots, - maxAllowedPivots // - ); - - // - iPivot.Clean(); - } - } - - // - // CCI Crossed Under OS ... - if (detectCCICrossedUnderOBPivot) - { - // - if (isCCIBearishVPattern) - { - // - XCAPivot iPivot; - - // - iPivot.to = cBar.time; - iPivot.from = p2Bar.time; - iPivot.value = pBar.high; - iPivot.type = XCA_CCI_CUOB; - iPivot.symbol = cBar.symbol; - iPivot.period = cBar.period; - - // - Add( - cBar.high, - iPivot.values // - ); - Add( - pBar.high, - iPivot.values // - ); - Add( - p2Bar.high, - iPivot.values // - ); - Add( - cBar.close, - iPivot.values // - ); - Add( - pBar.close, - iPivot.values // - ); - Add( - p2Bar.close, - iPivot.values // - ); - - // - iPivot.reserve = GetMin(iPivot.values); - - // - AddPivot( - iPivot, - cciCrossedUnderOBPivots, - maxAllowedPivots // - ); - - // - iPivot.Clean(); - } } // @@ -4444,7 +857,7 @@ class XCXCAEAPOIDetector : public XCBase pBar.Clean(); p2Bar.Clean(); fvgBox.Clean(); - iConditions.Clean(); + conditions.Clean(); } // @@ -4466,7 +879,7 @@ class XCXCAEAPOIDetector : public XCBase } // - XCAPivot tmp[]; + XBoxZone tmp[]; bool has = false; // @@ -4479,22 +892,26 @@ class XCXCAEAPOIDetector : public XCBase // Implement Validation Senarios ... // - // PEAKS ... + // VALE Pivot Support Swing Low ... // - has = HasPeakPivots(); + has = HasValeSupSWLPivots(); if (has) { // + // Copy Items and Cleanup Collection ... Copy( - peakPivots, + valeSupSWLPivots, tmp // ); - Clean(peakPivots); + Clean(valeSupSWLPivots); + + // + // Do Validation ... while (HasChild(tmp)) { // - XCAPivot iPivot = tmp[0]; + XBoxZone iBox = tmp[0]; ArrayRemove( tmp, 0, @@ -4502,40 +919,49 @@ class XCXCAEAPOIDetector : public XCBase ); // - has = IsPivotBreaked( - iPivot, + has = ValidateBox( + iBox, unAvailableBoxes, barIndex // ); - if (!has) + if (has) { // AddRef( - iPivot, - peakPivots // + iBox, + valeSupSWLPivots // ); } + + // + iBox.Clean(); } + + // Clean(tmp); } // - // VALES ... + // PEAK Pivot Resistance Swing High ... // - has = HasValePivots(); + has = HasPeakResSWHPivots(); if (has) { // + // Copy Items and Cleanup Collection ... Copy( - valePivots, + peakResSWHPivots, tmp // ); - Clean(valePivots); + Clean(peakResSWHPivots); + + // + // Do Validation ... while (HasChild(tmp)) { // - XCAPivot iPivot = tmp[0]; + XBoxZone iBox = tmp[0]; ArrayRemove( tmp, 0, @@ -4543,362 +969,49 @@ class XCXCAEAPOIDetector : public XCBase ); // - has = IsPivotBreaked( - iPivot, + has = ValidateBox( + iBox, unAvailableBoxes, barIndex // ); - if (!has) + if (has) { // AddRef( - iPivot, - valePivots // + iBox, + peakResSWHPivots // ); } + + // + iBox.Clean(); } - Clean(tmp); - } - // - // PEAK SWH RES ... - - // - has = HasPeakSWHResPivots(); - if (has) - { // - Copy( - peakSWHResPivots, - tmp // - ); - Clean(peakSWHResPivots); - while (HasChild(tmp)) - { - // - XCAPivot iPivot = tmp[0]; - ArrayRemove( - tmp, - 0, - 1 // - ); - - // - has = IsPivotBreaked( - iPivot, - unAvailableBoxes, - barIndex // - ); - if (!has) - { - // - AddRef( - iPivot, - peakSWHResPivots // - ); - } - } Clean(tmp); } // - // VALE SWL SUP ... - - // - has = HasValeSWLSupPivots(); - if (has) - { - // - Copy( - valeSWLSupPivots, - tmp // - ); - Clean(valeSWLSupPivots); - while (HasChild(tmp)) - { - // - XCAPivot iPivot = tmp[0]; - ArrayRemove( - tmp, - 0, - 1 // - ); - - // - has = IsPivotBreaked( - iPivot, - unAvailableBoxes, - barIndex // - ); - if (!has) - { - // - AddRef( - iPivot, - valeSWLSupPivots // - ); - } - } - Clean(tmp); - } - - // - // SWING HIGH ... - - // - has = HasSWHPivots(); - if (has) - { - // - Copy( - swhPivots, - tmp // - ); - Clean(swhPivots); - while (HasChild(tmp)) - { - // - XCAPivot iPivot = tmp[0]; - ArrayRemove( - tmp, - 0, - 1 // - ); - - // - has = IsPivotBreaked( - iPivot, - unAvailableBoxes, - barIndex // - ); - if (!has) - { - // - AddRef( - iPivot, - swhPivots // - ); - } - } - Clean(tmp); - } - - // - // SWING LOW ... - - // - has = HasSWLPivots(); - if (has) - { - // - Copy( - swlPivots, - tmp // - ); - Clean(swlPivots); - while (HasChild(tmp)) - { - // - XCAPivot iPivot = tmp[0]; - ArrayRemove( - tmp, - 0, - 1 // - ); - - // - has = IsPivotBreaked( - iPivot, - unAvailableBoxes, - barIndex // - ); - if (!has) - { - // - AddRef( - iPivot, - swlPivots // - ); - } - } - Clean(tmp); - } - - // - // KI ... - - // - has = HasKIBullishPivots(); - if (has) - { - // - Copy( - kiBullishPivots, - tmp // - ); - Clean(kiBullishPivots); - while (HasChild(tmp)) - { - // - XCAPivot iPivot = tmp[0]; - ArrayRemove( - tmp, - 0, - 1 // - ); - - // - has = IsPivotBreaked( - iPivot, - unAvailableBoxes, - barIndex // - ); - if (!has) - { - // - AddRef( - iPivot, - kiBullishPivots // - ); - } - } - Clean(tmp); - } - - // - has = HasKIBearishPivots(); - if (has) - { - // - Copy( - kiBearishPivots, - tmp // - ); - Clean(kiBearishPivots); - while (HasChild(tmp)) - { - // - XCAPivot iPivot = tmp[0]; - ArrayRemove( - tmp, - 0, - 1 // - ); - - // - has = IsPivotBreaked( - iPivot, - unAvailableBoxes, - barIndex // - ); - if (!has) - { - // - AddRef( - iPivot, - kiBearishPivots // - ); - } - } - Clean(tmp); - } - - // - // TKI ... - - // - has = HasTKIBullishPivots(); - if (has) - { - // - Copy( - tkiBullishPivots, - tmp // - ); - Clean(tkiBullishPivots); - while (HasChild(tmp)) - { - // - XCAPivot iPivot = tmp[0]; - ArrayRemove( - tmp, - 0, - 1 // - ); - - // - has = IsPivotBreaked( - iPivot, - unAvailableBoxes, - barIndex // - ); - if (!has) - { - // - AddRef( - iPivot, - tkiBullishPivots // - ); - } - } - Clean(tmp); - } - - // - has = HasTKIBearishPivots(); - if (has) - { - // - Copy( - tkiBearishPivots, - tmp // - ); - Clean(tkiBearishPivots); - while (HasChild(tmp)) - { - // - XCAPivot iPivot = tmp[0]; - ArrayRemove( - tmp, - 0, - 1 // - ); - - // - has = IsPivotBreaked( - iPivot, - unAvailableBoxes, - barIndex // - ); - if (!has) - { - // - AddRef( - iPivot, - tkiBearishPivots // - ); - } - } - Clean(tmp); - } - - // - // FVG ... + // FVG Bullish ... // has = HasFVGBullishPivots(); if (has) { // + // Copy Items and Cleanup Collection ... Copy( fvgBullishPivots, tmp // ); Clean(fvgBullishPivots); + + // + // Do Validation ... while (HasChild(tmp)) { // - XCAPivot iPivot = tmp[0]; + XBoxZone iBox = tmp[0]; ArrayRemove( tmp, 0, @@ -4906,37 +1019,49 @@ class XCXCAEAPOIDetector : public XCBase ); // - has = IsPivotBreaked( - iPivot, + has = ValidateBox( + iBox, unAvailableBoxes, barIndex // ); - if (!has) + if (has) { // AddRef( - iPivot, + iBox, fvgBullishPivots // ); } + + // + iBox.Clean(); } + + // Clean(tmp); } + // + // FVG Bearish ... + // has = HasFVGBearishPivots(); if (has) { // + // Copy Items and Cleanup Collection ... Copy( fvgBearishPivots, tmp // ); Clean(fvgBearishPivots); + + // + // Do Validation ... while (HasChild(tmp)) { // - XCAPivot iPivot = tmp[0]; + XBoxZone iBox = tmp[0]; ArrayRemove( tmp, 0, @@ -4944,648 +1069,49 @@ class XCXCAEAPOIDetector : public XCBase ); // - has = IsPivotBreaked( - iPivot, + has = ValidateBox( + iBox, unAvailableBoxes, barIndex // ); - if (!has) + if (has) { // AddRef( - iPivot, + iBox, fvgBearishPivots // ); } + + // + iBox.Clean(); } - Clean(tmp); - } - // - // PVFVG ... - XCAPVPivot tmpPVFVG[]; - - // - has = HasPVFVGBullishPivots(); - if (has) - { // - Copy( - pvFVGBullishPivots, - tmpPVFVG // - ); - Clean(pvFVGBullishPivots); - while (HasChild(tmpPVFVG)) - { - // - XCAPVPivot iPVFVG = tmpPVFVG[0]; - ArrayRemove( - tmpPVFVG, - 0, - 1 // - ); - - // - XCAPivot tmpFVGs[]; - Copy( - iPVFVG.pivots, - tmpFVGs // - ); - Clean(iPVFVG.pivots); - while (HasChild(tmpFVGs)) - { - // - XCAPivot iPivot = tmpFVGs[0]; - ArrayRemove( - tmpFVGs, - 0, - 1 // - ); - - // - has = IsPivotBreaked( - iPivot, - unAvailableBoxes, - barIndex // - ); - if (!has) - { - // - AddRef( - iPivot, - iPVFVG.pivots // - ); - } - } - Clean(tmpFVGs); - - // - if (HasChild(iPVFVG.pivots)) - { - // - AddRef( - iPVFVG, - pvFVGBullishPivots // - ); - } - } - Clean(tmp); - Clean(tmpPVFVG); - } - - // - has = HasPVFVGBearishPivots(); - if (has) - { - // - Copy( - pvFVGBearishPivots, - tmpPVFVG // - ); - Clean(pvFVGBearishPivots); - while (HasChild(tmpPVFVG)) - { - // - XCAPVPivot iPVFVG = tmpPVFVG[0]; - ArrayRemove( - tmpPVFVG, - 0, - 1 // - ); - - // - XCAPivot tmpFVGs[]; - Copy( - iPVFVG.pivots, - tmpFVGs // - ); - Clean(iPVFVG.pivots); - while (HasChild(tmpFVGs)) - { - // - XCAPivot iPivot = tmpFVGs[0]; - ArrayRemove( - tmpFVGs, - 0, - 1 // - ); - - // - has = IsPivotBreaked( - iPivot, - unAvailableBoxes, - barIndex // - ); - if (!has) - { - // - AddRef( - iPivot, - iPVFVG.pivots // - ); - } - } - Clean(tmpFVGs); - - // - if (HasChild(iPVFVG.pivots)) - { - // - AddRef( - iPVFVG, - pvFVGBearishPivots // - ); - } - } - Clean(tmp); - Clean(tmpPVFVG); - } - - // - // TREND ... - - // - has = HasTrendBullishPivots(); - if (has) - { - // - Copy( - trendBullishPivots, - tmp // - ); - Clean(trendBullishPivots); - while (HasChild(tmp)) - { - // - XCAPivot iPivot = tmp[0]; - ArrayRemove( - tmp, - 0, - 1 // - ); - - // - has = IsPivotBreaked( - iPivot, - unAvailableBoxes, - barIndex // - ); - if (!has) - { - // - AddRef( - iPivot, - trendBullishPivots // - ); - } - } Clean(tmp); } // - has = HasTrendBearishPivots(); - if (has) - { - // - Copy( - trendBearishPivots, - tmp // - ); - Clean(trendBearishPivots); - while (HasChild(tmp)) - { - // - XCAPivot iPivot = tmp[0]; - ArrayRemove( - tmp, - 0, - 1 // - ); - - // - has = IsPivotBreaked( - iPivot, - unAvailableBoxes, - barIndex // - ); - if (!has) - { - // - AddRef( - iPivot, - trendBearishPivots // - ); - } - } - Clean(tmp); - } - - // - // TKITRND ... - - // - has = HasTKITRNDBullishPivots(); - if (has) - { - // - Copy( - tkitrndBullishPivots, - tmp // - ); - Clean(tkitrndBullishPivots); - while (HasChild(tmp)) - { - // - XCAPivot iPivot = tmp[0]; - ArrayRemove( - tmp, - 0, - 1 // - ); - - // - has = IsPivotBreaked( - iPivot, - unAvailableBoxes, - barIndex // - ); - if (!has) - { - // - AddRef( - iPivot, - tkitrndBullishPivots // - ); - } - } - Clean(tmp); - } - - // - has = HasTKITRNDBearishPivots(); - if (has) - { - // - Copy( - tkitrndBearishPivots, - tmp // - ); - Clean(tkitrndBearishPivots); - while (HasChild(tmp)) - { - // - XCAPivot iPivot = tmp[0]; - ArrayRemove( - tmp, - 0, - 1 // - ); - - // - has = IsPivotBreaked( - iPivot, - unAvailableBoxes, - barIndex // - ); - if (!has) - { - // - AddRef( - iPivot, - tkitrndBearishPivots // - ); - } - } - Clean(tmp); - } - - // - // SAME CYCLES HH / LL ... - - // - has = HasSSameLLPivots(); - if (has) - { - // - Copy( - sSameLLPivots, - tmp // - ); - Clean(sSameLLPivots); - while (HasChild(tmp)) - { - // - XCAPivot iPivot = tmp[0]; - ArrayRemove( - tmp, - 0, - 1 // - ); - - // - has = IsPivotBreaked( - iPivot, - unAvailableBoxes, - barIndex // - ); - if (!has) - { - // - AddRef( - iPivot, - sSameLLPivots // - ); - } - } - Clean(tmp); - } - - // - has = HasSSameHHPivots(); - if (has) - { - // - Copy( - sSameHHPivots, - tmp // - ); - Clean(sSameHHPivots); - while (HasChild(tmp)) - { - // - XCAPivot iPivot = tmp[0]; - ArrayRemove( - tmp, - 0, - 1 // - ); - - // - has = IsPivotBreaked( - iPivot, - unAvailableBoxes, - barIndex // - ); - if (!has) - { - // - AddRef( - iPivot, - sSameHHPivots // - ); - } - } - Clean(tmp); - } - - // - has = HasMSameLLPivots(); - if (has) - { - // - Copy( - mSameLLPivots, - tmp // - ); - Clean(mSameLLPivots); - while (HasChild(tmp)) - { - // - XCAPivot iPivot = tmp[0]; - ArrayRemove( - tmp, - 0, - 1 // - ); - - // - has = IsPivotBreaked( - iPivot, - unAvailableBoxes, - barIndex // - ); - if (!has) - { - // - AddRef( - iPivot, - mSameLLPivots // - ); - } - } - Clean(tmp); - } - - // - has = HasMSameHHPivots(); - if (has) - { - // - Copy( - mSameHHPivots, - tmp // - ); - Clean(mSameHHPivots); - while (HasChild(tmp)) - { - // - XCAPivot iPivot = tmp[0]; - ArrayRemove( - tmp, - 0, - 1 // - ); - - // - has = IsPivotBreaked( - iPivot, - unAvailableBoxes, - barIndex // - ); - if (!has) - { - // - AddRef( - iPivot, - mSameHHPivots // - ); - } - } - Clean(tmp); - } - - // - has = HasLSameLLPivots(); - if (has) - { - // - Copy( - lSameLLPivots, - tmp // - ); - Clean(lSameLLPivots); - while (HasChild(tmp)) - { - // - XCAPivot iPivot = tmp[0]; - ArrayRemove( - tmp, - 0, - 1 // - ); - - // - has = IsPivotBreaked( - iPivot, - unAvailableBoxes, - barIndex // - ); - if (!has) - { - // - AddRef( - iPivot, - lSameLLPivots // - ); - } - } - Clean(tmp); - } - - // - has = HasLSameHHPivots(); - if (has) - { - // - Copy( - lSameHHPivots, - tmp // - ); - Clean(lSameHHPivots); - while (HasChild(tmp)) - { - // - XCAPivot iPivot = tmp[0]; - ArrayRemove( - tmp, - 0, - 1 // - ); - - // - has = IsPivotBreaked( - iPivot, - unAvailableBoxes, - barIndex // - ); - if (!has) - { - // - AddRef( - iPivot, - lSameHHPivots // - ); - } - } - Clean(tmp); - } - - // - has = HasHSameLLPivots(); - if (has) - { - // - Copy( - hSameLLPivots, - tmp // - ); - Clean(hSameLLPivots); - while (HasChild(tmp)) - { - // - XCAPivot iPivot = tmp[0]; - ArrayRemove( - tmp, - 0, - 1 // - ); - - // - has = IsPivotBreaked( - iPivot, - unAvailableBoxes, - barIndex // - ); - if (!has) - { - // - AddRef( - iPivot, - hSameLLPivots // - ); - } - } - Clean(tmp); - } - - // - has = HasHSameHHPivots(); - if (has) - { - // - Copy( - hSameHHPivots, - tmp // - ); - Clean(hSameHHPivots); - while (HasChild(tmp)) - { - // - XCAPivot iPivot = tmp[0]; - ArrayRemove( - tmp, - 0, - 1 // - ); - - // - has = IsPivotBreaked( - iPivot, - unAvailableBoxes, - barIndex // - ); - if (!has) - { - // - AddRef( - iPivot, - hSameHHPivots // - ); - } - } - Clean(tmp); - } - - // - // OSCS ... - - // - // RSI ... + // RSI Peak Pivot ... // has = HasRSIPeakPivots(); if (has) { // + // Copy Items and Cleanup Collection ... Copy( rsiPeakPivots, tmp // ); Clean(rsiPeakPivots); + + // + // Do Validation ... while (HasChild(tmp)) { // - XCAPivot iPivot = tmp[0]; + XBoxZone iBox = tmp[0]; ArrayRemove( tmp, 0, @@ -5593,37 +1119,49 @@ class XCXCAEAPOIDetector : public XCBase ); // - has = IsPivotBreaked( - iPivot, + has = ValidateBox( + iBox, unAvailableBoxes, barIndex // ); - if (!has) + if (has) { // AddRef( - iPivot, + iBox, rsiPeakPivots // ); } + + // + iBox.Clean(); } + + // Clean(tmp); } + // + // RSI Vale Pivot ... + // has = HasRSIValePivots(); if (has) { // + // Copy Items and Cleanup Collection ... Copy( rsiValePivots, tmp // ); Clean(rsiValePivots); + + // + // Do Validation ... while (HasChild(tmp)) { // - XCAPivot iPivot = tmp[0]; + XBoxZone iBox = tmp[0]; ArrayRemove( tmp, 0, @@ -5631,116 +1169,49 @@ class XCXCAEAPOIDetector : public XCBase ); // - has = IsPivotBreaked( - iPivot, + has = ValidateBox( + iBox, unAvailableBoxes, barIndex // ); - if (!has) + if (has) { // AddRef( - iPivot, + iBox, rsiValePivots // ); } - } - Clean(tmp); - } - // - has = HasRSICrossedOverOSPivots(); - if (has) - { + // + iBox.Clean(); + } + // - Copy( - rsiCrossedOverOSPivots, - tmp // - ); - Clean(rsiCrossedOverOSPivots); - while (HasChild(tmp)) - { - // - XCAPivot iPivot = tmp[0]; - ArrayRemove( - tmp, - 0, - 1 // - ); - - // - has = IsPivotBreaked( - iPivot, - unAvailableBoxes, - barIndex // - ); - if (!has) - { - // - AddRef( - iPivot, - rsiCrossedOverOSPivots // - ); - } - } Clean(tmp); } // - has = HasRSICrossedUnderOBPivots(); - if (has) - { - // - Copy( - rsiCrossedUnderOBPivots, - tmp // - ); - Clean(rsiCrossedUnderOBPivots); - while (HasChild(tmp)) - { - // - XCAPivot iPivot = tmp[0]; - ArrayRemove( - tmp, - 0, - 1 // - ); - - // - has = IsPivotBreaked( - iPivot, - unAvailableBoxes, - barIndex // - ); - if (!has) - { - // - AddRef( - iPivot, - rsiCrossedUnderOBPivots // - ); - } - } - Clean(tmp); - } - - // - // CCI ... + // CCI Peak Pivot ... // has = HasCCIPeakPivots(); if (has) { // + // Copy Items and Cleanup Collection ... Copy( cciPeakPivots, tmp // ); Clean(cciPeakPivots); + + // + // Do Validation ... while (HasChild(tmp)) { // - XCAPivot iPivot = tmp[0]; + XBoxZone iBox = tmp[0]; ArrayRemove( tmp, 0, @@ -5748,37 +1219,49 @@ class XCXCAEAPOIDetector : public XCBase ); // - has = IsPivotBreaked( - iPivot, + has = ValidateBox( + iBox, unAvailableBoxes, barIndex // ); - if (!has) + if (has) { // AddRef( - iPivot, + iBox, cciPeakPivots // ); } + + // + iBox.Clean(); } + + // Clean(tmp); } + // + // CCI Vale Pivot ... + // has = HasCCIValePivots(); if (has) { // + // Copy Items and Cleanup Collection ... Copy( cciValePivots, tmp // ); Clean(cciValePivots); + + // + // Do Validation ... while (HasChild(tmp)) { // - XCAPivot iPivot = tmp[0]; + XBoxZone iBox = tmp[0]; ArrayRemove( tmp, 0, @@ -5786,1208 +1269,69 @@ class XCXCAEAPOIDetector : public XCBase ); // - has = IsPivotBreaked( - iPivot, + has = ValidateBox( + iBox, unAvailableBoxes, barIndex // ); - if (!has) + if (has) { // AddRef( - iPivot, + iBox, cciValePivots // ); } + + // + iBox.Clean(); } + + // Clean(tmp); } - // - has = HasCCICrossedOverOSPivots(); - if (has) - { - // - Copy( - cciCrossedOverOSPivots, - tmp // - ); - Clean(cciCrossedOverOSPivots); - while (HasChild(tmp)) - { - // - XCAPivot iPivot = tmp[0]; - ArrayRemove( - tmp, - 0, - 1 // - ); - - // - has = IsPivotBreaked( - iPivot, - unAvailableBoxes, - barIndex // - ); - if (!has) - { - // - AddRef( - iPivot, - cciCrossedOverOSPivots // - ); - } - } - Clean(tmp); - } - - // - has = HasCCICrossedUnderOBPivots(); - if (has) - { - // - Copy( - cciCrossedUnderOBPivots, - tmp // - ); - Clean(cciCrossedUnderOBPivots); - while (HasChild(tmp)) - { - // - XCAPivot iPivot = tmp[0]; - ArrayRemove( - tmp, - 0, - 1 // - ); - - // - has = IsPivotBreaked( - iPivot, - unAvailableBoxes, - barIndex // - ); - if (!has) - { - // - AddRef( - iPivot, - cciCrossedUnderOBPivots // - ); - } - } - Clean(tmp); - } - - // - // PVTICKS ... - - // - XCAPVTick tmpTicks[]; - - // - has = HasPeakTicks(); - if (has) - { - // - Copy( - peakTicks, - tmpTicks // - ); - Clean(peakTicks); - while (HasChild(tmpTicks)) - { - // - XCAPVTick iPVTick = tmpTicks[0]; - ArrayRemove( - tmpTicks, - 0, - 1 // - ); - - // - XBoxZone iBox; - bool isBoxBreaked = false; - has = iPVTick.GetMaxVolumeBox(iBox); - if (has) - { - // - isBoxBreaked = IsBoxBreaked( - iBox, - unAvailableBoxes, - barIndex // - ); - } - - // - has = IsPivotBreaked( - iPVTick.pivot, - unAvailableBoxes, - barIndex // - ); - if (!has && !isBoxBreaked) - { - // - AddRef( - iPVTick, - peakTicks // - ); - } - } - Clean(tmpTicks); - } - - // - has = HasValeTicks(); - if (has) - { - // - Copy( - valeTicks, - tmpTicks // - ); - Clean(valeTicks); - while (HasChild(tmpTicks)) - { - // - XCAPVTick iPVTick = tmpTicks[0]; - ArrayRemove( - tmpTicks, - 0, - 1 // - ); - - // - XBoxZone iBox; - bool isBoxBreaked = false; - has = iPVTick.GetMaxVolumeBox(iBox); - if (has) - { - // - isBoxBreaked = IsBoxBreaked( - iBox, - unAvailableBoxes, - barIndex // - ); - } - - // - has = IsPivotBreaked( - iPVTick.pivot, - unAvailableBoxes, - barIndex // - ); - if (!has && !isBoxBreaked) - { - // - AddRef( - iPVTick, - valeTicks // - ); - } - } - Clean(tmpTicks); - } - // Clean(tmp); - Clean(tmpPVFVG); - Clean(tmpTicks); + + // } // - int FillBullishBoxes( - XBoxZone &boxes[] // - ) + // Counters ... + + // + // VALE Pivot Support Swing Low ... + + // + bool HasValeSupSWLPivots() { - // - int result = 0; - - // - int count = 0; - bool has = false; - - // - Clean(boxes); - - // - has = HasSWLPivots(); - if (has) - { - // - count = CountSWLPivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox; - has = swlPivots[i].AsBox(iBox); - if (has) - { - // - AddRef( - iBox, - boxes // - ); - } - - // - iBox.Clean(); - } - } - - // - has = HasValePivots(); - if (has) - { - // - count = CountValePivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox; - has = valePivots[i].AsBox(iBox); - if (has) - { - // - AddRef( - iBox, - boxes // - ); - } - - // - iBox.Clean(); - } - } - - // - has = HasSSameLLPivots(); - if (has) - { - // - count = CountSSameLLPivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox; - has = sSameLLPivots[i].AsBox(iBox); - if (has) - { - // - AddRef( - iBox, - boxes // - ); - } - - // - iBox.Clean(); - } - } - - // - has = HasMSameLLPivots(); - if (has) - { - // - count = CountMSameLLPivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox; - has = mSameLLPivots[i].AsBox(iBox); - if (has) - { - // - AddRef( - iBox, - boxes // - ); - } - - // - iBox.Clean(); - } - } - - // - has = HasLSameLLPivots(); - if (has) - { - // - count = CountLSameLLPivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox; - has = lSameLLPivots[i].AsBox(iBox); - if (has) - { - // - AddRef( - iBox, - boxes // - ); - } - - // - iBox.Clean(); - } - } - - // - has = HasHSameLLPivots(); - if (has) - { - // - count = CountHSameLLPivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox; - has = hSameLLPivots[i].AsBox(iBox); - if (has) - { - // - AddRef( - iBox, - boxes // - ); - } - - // - iBox.Clean(); - } - } - - // - has = HasKIBullishPivots(); - if (has) - { - // - count = CountKIBullishPivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox; - has = kiBullishPivots[i].AsBox(iBox); - if (has) - { - // - AddRef( - iBox, - boxes // - ); - } - - // - iBox.Clean(); - } - } - - // - has = HasFVGBullishPivots(); - if (has) - { - // - count = CountFVGBullishPivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox; - has = fvgBullishPivots[i].AsBox(iBox); - if (has) - { - // - AddRef( - iBox, - boxes // - ); - } - - // - iBox.Clean(); - } - } - - // - has = HasValeSWLSupPivots(); - if (has) - { - // - count = CountValeSWLSupPivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox; - has = valeSWLSupPivots[i].AsBox(iBox); - if (has) - { - // - AddRef( - iBox, - boxes // - ); - } - - // - iBox.Clean(); - } - } - - // - has = HasTKIBullishPivots(); - if (has) - { - // - count = CountTKIBullishPivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox; - has = tkiBullishPivots[i].AsBox(iBox); - if (has) - { - // - AddRef( - iBox, - boxes // - ); - } - - // - iBox.Clean(); - } - } - - // - has = HasTrendBullishPivots(); - if (has) - { - // - count = CountTrendBullishPivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox; - has = trendBullishPivots[i].AsBox(iBox); - if (has) - { - // - AddRef( - iBox, - boxes // - ); - } - - // - iBox.Clean(); - } - } - - // - has = HasTKITRNDBullishPivots(); - if (has) - { - // - count = CountTKITRNDBullishPivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox; - has = tkitrndBullishPivots[i].AsBox(iBox); - if (has) - { - // - AddRef( - iBox, - boxes // - ); - } - - // - iBox.Clean(); - } - } - - // - has = HasRSIValePivots(); - if (has) - { - // - count = CountRSIValePivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox; - has = rsiValePivots[i].AsBox(iBox); - if (has) - { - // - AddRef( - iBox, - boxes // - ); - } - - // - iBox.Clean(); - } - } - - // - has = HasRSICrossedOverOSPivots(); - if (has) - { - // - count = CountRSICrossedOverOSPivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox; - has = rsiCrossedOverOSPivots[i].AsBox(iBox); - if (has) - { - // - AddRef( - iBox, - boxes // - ); - } - - // - iBox.Clean(); - } - } - - // - has = HasCCIValePivots(); - if (has) - { - // - count = CountCCIValePivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox; - has = cciValePivots[i].AsBox(iBox); - if (has) - { - // - AddRef( - iBox, - boxes // - ); - } - - // - iBox.Clean(); - } - } - - // - has = HasCCICrossedOverOSPivots(); - if (has) - { - // - count = CountCCICrossedOverOSPivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox; - has = cciCrossedOverOSPivots[i].AsBox(iBox); - if (has) - { - // - AddRef( - iBox, - boxes // - ); - } - - // - iBox.Clean(); - } - } - - // - result = ArraySize(boxes); - - // - return result; + return HasChild(valeSupSWLPivots); } // - int FillBearishBoxes( - XBoxZone &boxes[] // - ) + int CountValeSupSWLPivots() { - // - int result = 0; - - // - int count = 0; - bool has = false; - - // - Clean(boxes); - - // - has = HasSWHPivots(); - if (has) - { - // - count = CountSWHPivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox; - has = swhPivots[i].AsBox(iBox); - if (has) - { - // - AddRef( - iBox, - boxes // - ); - } - - // - iBox.Clean(); - } - } - - // - has = HasPeakPivots(); - if (has) - { - // - count = CountPeakPivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox; - has = peakPivots[i].AsBox(iBox); - if (has) - { - // - AddRef( - iBox, - boxes // - ); - } - - // - iBox.Clean(); - } - } - - // - has = HasSSameHHPivots(); - if (has) - { - // - count = CountSSameHHPivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox; - has = sSameHHPivots[i].AsBox(iBox); - if (has) - { - // - AddRef( - iBox, - boxes // - ); - } - - // - iBox.Clean(); - } - } - - // - has = HasMSameHHPivots(); - if (has) - { - // - count = CountMSameHHPivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox; - has = mSameHHPivots[i].AsBox(iBox); - if (has) - { - // - AddRef( - iBox, - boxes // - ); - } - - // - iBox.Clean(); - } - } - - // - has = HasLSameHHPivots(); - if (has) - { - // - count = CountLSameHHPivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox; - has = lSameHHPivots[i].AsBox(iBox); - if (has) - { - // - AddRef( - iBox, - boxes // - ); - } - - // - iBox.Clean(); - } - } - - // - has = HasHSameHHPivots(); - if (has) - { - // - count = CountHSameHHPivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox; - has = hSameHHPivots[i].AsBox(iBox); - if (has) - { - // - AddRef( - iBox, - boxes // - ); - } - - // - iBox.Clean(); - } - } - - // - has = HasKIBearishPivots(); - if (has) - { - // - count = CountKIBearishPivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox; - has = kiBearishPivots[i].AsBox(iBox); - if (has) - { - // - AddRef( - iBox, - boxes // - ); - } - - // - iBox.Clean(); - } - } - - // - has = HasFVGBearishPivots(); - if (has) - { - // - count = CountFVGBearishPivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox; - has = fvgBearishPivots[i].AsBox(iBox); - if (has) - { - // - AddRef( - iBox, - boxes // - ); - } - - // - iBox.Clean(); - } - } - - // - has = HasPeakSWHResPivots(); - if (has) - { - // - count = CountPeakSWHResPivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox; - has = peakSWHResPivots[i].AsBox(iBox); - if (has) - { - // - AddRef( - iBox, - boxes // - ); - } - - // - iBox.Clean(); - } - } - - // - has = HasTKIBearishPivots(); - if (has) - { - // - count = CountTKIBearishPivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox; - has = tkiBearishPivots[i].AsBox(iBox); - if (has) - { - // - AddRef( - iBox, - boxes // - ); - } - - // - iBox.Clean(); - } - } - - // - has = HasTrendBearishPivots(); - if (has) - { - // - count = CountTrendBearishPivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox; - has = trendBearishPivots[i].AsBox(iBox); - if (has) - { - // - AddRef( - iBox, - boxes // - ); - } - - // - iBox.Clean(); - } - } - - // - has = HasTKITRNDBearishPivots(); - if (has) - { - // - count = CountTKITRNDBearishPivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox; - has = tkitrndBearishPivots[i].AsBox(iBox); - if (has) - { - // - AddRef( - iBox, - boxes // - ); - } - - // - iBox.Clean(); - } - } - - // - has = HasRSIPeakPivots(); - if (has) - { - // - count = CountRSIPeakPivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox; - has = rsiPeakPivots[i].AsBox(iBox); - if (has) - { - // - AddRef( - iBox, - boxes // - ); - } - - // - iBox.Clean(); - } - } - - // - has = HasRSICrossedUnderOBPivots(); - if (has) - { - // - count = CountRSICrossedUnderOBPivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox; - has = rsiCrossedUnderOBPivots[i].AsBox(iBox); - if (has) - { - // - AddRef( - iBox, - boxes // - ); - } - - // - iBox.Clean(); - } - } - - // - has = HasCCIPeakPivots(); - if (has) - { - // - count = CountCCIPeakPivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox; - has = cciPeakPivots[i].AsBox(iBox); - if (has) - { - // - AddRef( - iBox, - boxes // - ); - } - - // - iBox.Clean(); - } - } - - // - has = HasCCICrossedUnderOBPivots(); - if (has) - { - // - count = CountCCICrossedUnderOBPivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox; - has = cciCrossedUnderOBPivots[i].AsBox(iBox); - if (has) - { - // - AddRef( - iBox, - boxes // - ); - } - - // - iBox.Clean(); - } - } - - // - result = ArraySize(boxes); - - // - return result; + return ArraySize(valeSupSWLPivots); } // - // POI Handlers ... + // PEAK Pivot Resistance Swing High ... // - // PEAK ... - - // - bool HasPeakPivots() + bool HasPeakResSWHPivots() { - return HasChild(peakPivots); + return HasChild(peakResSWHPivots); } // - int CountPeakPivots() + int CountPeakResSWHPivots() { - return ArraySize(peakPivots); + return ArraySize(peakResSWHPivots); } // - // VALE ... - - // - bool HasValePivots() - { - return HasChild(valePivots); - } - - // - int CountValePivots() - { - return ArraySize(valePivots); - } - - // - // PEAK SWH Res ... - - // - bool HasPeakSWHResPivots() - { - return HasChild(peakSWHResPivots); - } - - // - int CountPeakSWHResPivots() - { - return ArraySize(peakSWHResPivots); - } - - // - // VALE SWL Sup ... - - // - bool HasValeSWLSupPivots() - { - return HasChild(valeSWLSupPivots); - } - - // - int CountValeSWLSupPivots() - { - return ArraySize(valeSWLSupPivots); - } - - // - // SWING High ... - - // - bool HasSWHPivots() - { - return HasChild(swhPivots); - } - - // - int CountSWHPivots() - { - return ArraySize(swhPivots); - } - - // - // SWING Low ... - - // - bool HasSWLPivots() - { - return HasChild(swlPivots); - } - - // - int CountSWLPivots() - { - return ArraySize(swlPivots); - } - - // - // KI ... - - // - bool HasKIBullishPivots() - { - return HasChild(kiBullishPivots); - } - - // - int CountKIBullishPivots() - { - return ArraySize(kiBullishPivots); - } - - // - bool HasKIBearishPivots() - { - return HasChild(kiBearishPivots); - } - - // - int CountKIBearishPivots() - { - return ArraySize(kiBearishPivots); - } - - // - // TKI ... - - // - bool HasTKIBullishPivots() - { - return HasChild(tkiBullishPivots); - } - - // - int CountTKIBullishPivots() - { - return ArraySize(tkiBullishPivots); - } - - // - bool HasTKIBearishPivots() - { - return HasChild(tkiBearishPivots); - } - - // - int CountTKIBearishPivots() - { - return ArraySize(tkiBearishPivots); - } - - // - // FVG ... + // FVG Bullish ... // bool HasFVGBullishPivots() @@ -7001,6 +1345,9 @@ class XCXCAEAPOIDetector : public XCBase return ArraySize(fvgBullishPivots); } + // + // FVG Bearish ... + // bool HasFVGBearishPivots() { @@ -7014,190 +1361,7 @@ class XCXCAEAPOIDetector : public XCBase } // - // PVFVG ... - - // - bool HasPVFVGBullishPivots() - { - return HasChild(pvFVGBullishPivots); - } - - // - int CountPVFVGBullishPivots() - { - return ArraySize(pvFVGBullishPivots); - } - - // - bool HasPVFVGBearishPivots() - { - return HasChild(pvFVGBearishPivots); - } - - // - int CountPVFVGBearishPivots() - { - return ArraySize(pvFVGBearishPivots); - } - - // - // TREND ... - - // - bool HasTrendBullishPivots() - { - return HasChild(trendBullishPivots); - } - - // - int CountTrendBullishPivots() - { - return ArraySize(trendBullishPivots); - } - - // - bool HasTrendBearishPivots() - { - return HasChild(trendBearishPivots); - } - - // - int CountTrendBearishPivots() - { - return ArraySize(trendBearishPivots); - } - - // - // TKITRND ... - - // - bool HasTKITRNDBullishPivots() - { - return HasChild(tkitrndBullishPivots); - } - - // - int CountTKITRNDBullishPivots() - { - return ArraySize(tkitrndBullishPivots); - } - - // - bool HasTKITRNDBearishPivots() - { - return HasChild(tkitrndBearishPivots); - } - - // - int CountTKITRNDBearishPivots() - { - return ArraySize(tkitrndBearishPivots); - } - - // - // SAME CYCLES HH / LL ... - - // - bool HasSSameLLPivots() - { - return HasChild(sSameLLPivots); - } - - // - int CountSSameLLPivots() - { - return ArraySize(sSameLLPivots); - } - - // - bool HasMSameLLPivots() - { - return HasChild(mSameLLPivots); - } - - // - int CountMSameLLPivots() - { - return ArraySize(mSameLLPivots); - } - - // - bool HasLSameLLPivots() - { - return HasChild(lSameLLPivots); - } - - // - int CountLSameLLPivots() - { - return ArraySize(lSameLLPivots); - } - - // - bool HasHSameLLPivots() - { - return HasChild(hSameLLPivots); - } - - // - int CountHSameLLPivots() - { - return ArraySize(hSameLLPivots); - } - - // - bool HasSSameHHPivots() - { - return HasChild(sSameHHPivots); - } - - // - int CountSSameHHPivots() - { - return ArraySize(sSameHHPivots); - } - - // - bool HasMSameHHPivots() - { - return HasChild(mSameHHPivots); - } - - // - int CountMSameHHPivots() - { - return ArraySize(mSameHHPivots); - } - - // - bool HasLSameHHPivots() - { - return HasChild(lSameHHPivots); - } - - // - int CountLSameHHPivots() - { - return ArraySize(lSameHHPivots); - } - - // - bool HasHSameHHPivots() - { - return HasChild(hSameHHPivots); - } - - // - int CountHSameHHPivots() - { - return ArraySize(hSameHHPivots); - } - - // - // OSCS ... - - // - // RSI ... + // RSI Peak Pivot ... // bool HasRSIPeakPivots() @@ -7211,6 +1375,9 @@ class XCXCAEAPOIDetector : public XCBase return ArraySize(rsiPeakPivots); } + // + // RSI Vale Pivot ... + // bool HasRSIValePivots() { @@ -7224,31 +1391,7 @@ class XCXCAEAPOIDetector : public XCBase } // - bool HasRSICrossedOverOSPivots() - { - return HasChild(rsiCrossedOverOSPivots); - } - - // - int CountRSICrossedOverOSPivots() - { - return ArraySize(rsiCrossedOverOSPivots); - } - - // - bool HasRSICrossedUnderOBPivots() - { - return HasChild(rsiCrossedUnderOBPivots); - } - - // - int CountRSICrossedUnderOBPivots() - { - return ArraySize(rsiCrossedUnderOBPivots); - } - - // - // CCI ... + // CCI Peak Pivot ... // bool HasCCIPeakPivots() @@ -7262,6 +1405,9 @@ class XCXCAEAPOIDetector : public XCBase return ArraySize(cciPeakPivots); } + // + // CCI Vale Pivot ... + // bool HasCCIValePivots() { @@ -7274,57 +1420,6 @@ class XCXCAEAPOIDetector : public XCBase return ArraySize(cciValePivots); } - // - bool HasCCICrossedOverOSPivots() - { - return HasChild(cciCrossedOverOSPivots); - } - - // - int CountCCICrossedOverOSPivots() - { - return ArraySize(cciCrossedOverOSPivots); - } - - // - bool HasCCICrossedUnderOBPivots() - { - return HasChild(cciCrossedUnderOBPivots); - } - - // - int CountCCICrossedUnderOBPivots() - { - return ArraySize(cciCrossedUnderOBPivots); - } - - // - // PVTICKS ... - - // - bool HasPeakTicks() - { - return HasChild(peakTicks); - } - - // - int CountPeakTicks() - { - return ArraySize(peakTicks); - } - - // - bool HasValeTicks() - { - return HasChild(valeTicks); - } - - // - int CountValeTicks() - { - return ArraySize(valeTicks); - } - // // Protected ... protected: @@ -7343,63 +1438,17 @@ class XCXCAEAPOIDetector : public XCBase XCBarAnalyser *barAnalyser; // - bool CheckPivotCommons( - XCAPivot &pivot, + bool AddBox( XBoxZone &box, - XBoxZone &unAvailableBoxes[], - int barIndex = 0 // + XBoxZone &boxes[], + int maxAllowedPivots // ) { // bool result = false; // - box.Clean(); - - // - barIndex = NormalizeInt(barIndex, 0); - - // - result = pivot.IsValid(); - if (!result) - { - return result; - } - - // - int pivotToIDX = pivot.ToIndex(); - - // - result = pivotToIDX > barIndex; - if (!result) - { - return result; - } - - // - result = pivot.AsBox(box); - if (!result) - { - // - box.Clean(); - return result; - } - - // - return result; - } - - // - bool CheckPivotIsAvailable( - XBoxZone &pivotBox, - XBoxZone &unAvailableBoxes[] // - ) - { - // - bool result = false; - - // - result = pivotBox.IsValid(); + result = box.IsValid(); if (!result) { return result; @@ -7409,153 +1458,49 @@ class XCXCAEAPOIDetector : public XCBase int idx = -1; bool isExists = FindBoxIndex( idx, - pivotBox, - unAvailableBoxes // + box, + boxes // ); result = !isExists; - - // - return result; - } - - // - bool IsPivotBreaked( - XCAPivot &pivot, - XBoxZone &unAvailableBoxes[], - int barIndex = 0 // - ) - { - // - bool result = false; - - // - XBoxZone iBox; - result = CheckPivotCommons( - pivot, - iBox, - unAvailableBoxes, - barIndex // - ); if (!result) { - // - iBox.Clean(); return result; } // - // Check Box is Available Or Not ... - bool isAvailable = CheckPivotIsAvailable( - iBox, - unAvailableBoxes // + int before = ArraySize(boxes); + if (IsValidSize(before)) + { + ArrayReverse(boxes); + } + + // + AddRef( + box, + boxes // ); - if (!isAvailable) + int after = ArraySize(boxes); + + // + result = after > before; + if (result) { // - iBox.Clean(); + ArrayReverse(boxes); // - // Assume UnAvailable Boes as Breaked ... - result = true; - return result; - } - - // - bool isBullish = iBox.IsBullish(); - double boundary = - isBullish - ? iBox.lower - : iBox.upper; - - // - int toIDX = iBox.ToIndex(); - - // - // for validating Box Break we have to wait At Least 3 Bars Close - // out of Box Boundary ... - int barsLength = 3; - - // - int startCheckBreaktionBarIndex = toIDX - barsLength; - result = startCheckBreaktionBarIndex > 0 && - barIndex < startCheckBreaktionBarIndex; - if (!result) - { - // - iBox.Clean(); - return result; - } - - // - XOHCL cBar; - XOHCL pBar; - XOHCL p2Bar; - for (int i = barIndex; i < startCheckBreaktionBarIndex; i++) - { - // - result = cBar.Init( - iBox.symbol, - iBox.period, - i + 1 // + CleanupArray( + boxes, + maxAllowedPivots // ); - result = - result && - cBar.GetPreviousBar(pBar); - result = - result && - pBar.GetPreviousBar(p2Bar); - if (!result) - { - // - iBox.Clean(); - cBar.Clean(); - pBar.Clean(); - p2Bar.Clean(); - - // - break; - } - - // - bool isBullishBreaked = - isBullish && - cBar.close < boundary && - pBar.close < boundary && - p2Bar.close < boundary; - - // - bool isBearishBreaked = - !isBullish && - cBar.close > boundary && - pBar.close > boundary && - p2Bar.close > boundary; - - // - result = isBullishBreaked || - isBearishBreaked; - if (result) - { - break; - } - - // - cBar.Clean(); - pBar.Clean(); - p2Bar.Clean(); } - // - iBox.Clean(); - cBar.Clean(); - pBar.Clean(); - p2Bar.Clean(); - // return result; } // - bool IsBoxBreaked( + bool ValidateBox( XBoxZone &box, XBoxZone &unAvailableBoxes[], int barIndex = 0 // @@ -7565,40 +1510,54 @@ class XCXCAEAPOIDetector : public XCBase bool result = false; // + // Normalize Bar Index ... barIndex = NormalizeInt(barIndex, 0); // + // Ceck Input Box is Valid ... result = box.IsValid(); if (!result) { - // - // Assume Invalid Boxes as Broken ... - return true; - } - - // - int idx = -1; - result = FindBoxIndex( - idx, - box, - unAvailableBoxes // - ); - if (result) - { - // - // Assume UnAvailable Boxes as Broken ... return result; } // + // Check Input Box is Available ... + bool canCheckUnAvailableBoxes = HasChild(unAvailableBoxes); + if (canCheckUnAvailableBoxes) + { + // + int idx = -1; + bool isUnAvailable = FindBoxIndex( + idx, + box, + unAvailableBoxes // + ); + result = isUnAvailable; + if (!result) + { + return !result; + } + } + + // + // Check Input Box is Breaked or not ... + + // + // Check Bar Index must after Box To Index ... int toIDX = box.ToIndex(); - result = toIDX > barIndex; + int fromIDX = box.FromIndex(); + result = toIDX > barIndex && + fromIDX > barIndex && + fromIDX > toIDX; if (!result) { return result; } // + // Detect Box Applied Boundary Price ... + // For Checking Break of Box ... bool isBullish = box.IsBullish(); double boundary = isBullish @@ -7611,43 +1570,58 @@ class XCXCAEAPOIDetector : public XCBase int barsLength = 3; // + // Calculate Start Checking Bar Index ... int startCheckBreaktionBarIndex = toIDX - barsLength; - result = startCheckBreaktionBarIndex > 0 && - barIndex < startCheckBreaktionBarIndex; + bool isBarIndexValid = startCheckBreaktionBarIndex > 0 && + barIndex < startCheckBreaktionBarIndex; + result = isBarIndexValid; if (!result) { + // + // Assume Box is Valid if Bar Index not Valid for Checking ... + result = true; return result; } // + // Try to Check Box Validation if Everything is OK ... XOHCL cBar; XOHCL pBar; XOHCL p2Bar; + bool isValid = false; + bool isBreaked = false; for (int i = barIndex; i < startCheckBreaktionBarIndex; i++) { // - result = cBar.Init( + // Initialize Bars ... + isValid = cBar.Init( box.symbol, box.period, i + 1 // ); - result = + isValid = result && cBar.GetPreviousBar(pBar); - result = + isValid = result && pBar.GetPreviousBar(p2Bar); - if (!result) + if (!isValid) { // cBar.Clean(); pBar.Clean(); p2Bar.Clean(); + // + result = false; + // break; } + // + // Preparing Conditions ... + // bool isBullishBreaked = isBullish && @@ -7663,10 +1637,20 @@ class XCXCAEAPOIDetector : public XCBase p2Bar.close > boundary; // - result = isBullishBreaked || - isBearishBreaked; - if (result) + // Calculate Result ... + isBreaked = isBullishBreaked || + isBearishBreaked; + if (isBreaked) { + // + cBar.Clean(); + pBar.Clean(); + p2Bar.Clean(); + + // + result = false; + + // break; } @@ -7676,6 +1660,13 @@ class XCXCAEAPOIDetector : public XCBase p2Bar.Clean(); } + // + result = isValid && + !isBreaked; + + // + // Cleanup Resource ... + // cBar.Clean(); pBar.Clean(); diff --git a/XCAEA/Classes/xcaea.x-poi.drawer.class.mq5 b/XCAEA/Classes/xcaea.x-poi.drawer.class.mq5 index 14d0bfd0..173f6dfa 100644 --- a/XCAEA/Classes/xcaea.x-poi.drawer.class.mq5 +++ b/XCAEA/Classes/xcaea.x-poi.drawer.class.mq5 @@ -37,100 +37,78 @@ class XCXCAEAPOIDrawer : public XCBase public: // // Props ... - bool drawSWHPivots; - bool drawSWLPivots; - bool drawPeakPivots; - bool drawValePivots; + + // + // Drawers ... bool drawRSIPeakPivots; bool drawRSIValePivots; bool drawCCIPeakPivots; bool drawCCIValePivots; - bool drawKIBullishPivots; - bool drawKIBearishPivots; bool drawFVGBullishPivots; bool drawFVGBearishPivots; - bool drawPeakSWHResPivots; - bool drawValeSWLSupPivots; - bool drawTKIBullishPivots; - bool drawTKIBearishPivots; - bool drawCycleSameLLPivots; - bool drawCycleSameHHPivots; - bool drawTrendBullishPivots; - bool drawTrendBearishPivots; - bool drawPVFVGBullishPivots; - bool drawPVFVGBearishPivots; - bool drawTKITRNDBullishPivots; - bool drawTKITRNDBearishPivots; - bool drawRSICrossedOverOSPivots; - bool drawRSICrossedUnderOBPivots; - bool drawCCICrossedOverOSPivots; - bool drawCCICrossedUnderOBPivots; + bool drawValeSupSWLPivots; + bool drawPeakResSWHPivots; // - bool drawTicks; + // Colors ... + + // + color defaultBullishColor; + color defaultBearishColor; + + // + color rsiPeakPivotsColor; + color rsiValePivotsColor; + color cciPeakPivotsColor; + color cciValePivotsColor; + color fvgBullishPivotsColor; + color fvgBearishPivotsColor; + color valeSupSWLPivotsColor; + color peakResSWHPivotsColor; + + // + // Width ... + + // + int defaultBullishWidth; + int defaultBearishWidth; + + // + int rsiPeakPivotsWidth; + int rsiValePivotsWidth; + int cciPeakPivotsWidth; + int cciValePivotsWidth; + int fvgBullishPivotsWidth; + int fvgBearishPivotsWidth; + int valeSupSWLPivotsWidth; + int peakResSWHPivotsWidth; + + // + // Style ... + + // + ENUM_LINE_STYLE defaultBullishStyle; + ENUM_LINE_STYLE defaultBearishStyle; + + // + ENUM_LINE_STYLE rsiPeakPivotsStyle; + ENUM_LINE_STYLE rsiValePivotsStyle; + ENUM_LINE_STYLE cciPeakPivotsStyle; + ENUM_LINE_STYLE cciValePivotsStyle; + ENUM_LINE_STYLE fvgBullishPivotsStyle; + ENUM_LINE_STYLE fvgBearishPivotsStyle; + ENUM_LINE_STYLE valeSupSWLPivotsStyle; + ENUM_LINE_STYLE peakResSWHPivotsStyle; // // Colorize Props ... - // - color peakPivotColor; - color valePivotColor; - color sameHHPivotColor; - color sameLLPivotColor; - color ticksBullishColor; - color ticksBearishColor; - color kiBullishPivotColor; - color kiBearishPivotColor; - color fvgBullishPivotColor; - color fvgBearishPivotColor; - color defBullishPivotColor; - color defBearishPivotColor; - color oscsBullishPivotColor; - color oscsBearishPivotColor; - color trendBullishPivotColor; - color trendBearishPivotColor; - // // Width Props ... - // - int peakPivotWidth; - int valePivotWidth; - int sameHHPivotWidth; - int sameLLPivotWidth; - int ticksBullishWidth; - int ticksBearishWidth; - int kiBullishPivotWidth; - int kiBearishPivotWidth; - int fvgBullishPivotWidth; - int fvgBearishPivotWidth; - int defBullishPivotWidth; - int defBearishPivotWidth; - int oscsBullishPivotWidth; - int oscsBearishPivotWidth; - int trendBullishPivotWidth; - int trendBearishPivotWidth; - // // Style Props ... - // - ENUM_LINE_STYLE peakPivotStyle; - ENUM_LINE_STYLE valePivotStyle; - ENUM_LINE_STYLE sameHHPivotStyle; - ENUM_LINE_STYLE sameLLPivotStyle; - ENUM_LINE_STYLE ticksBullishStyle; - ENUM_LINE_STYLE ticksBearishStyle; - ENUM_LINE_STYLE kiBullishPivotStyle; - ENUM_LINE_STYLE kiBearishPivotStyle; - ENUM_LINE_STYLE fvgBullishPivotStyle; - ENUM_LINE_STYLE fvgBearishPivotStyle; - ENUM_LINE_STYLE defBullishPivotStyle; - ENUM_LINE_STYLE defBearishPivotStyle; - ENUM_LINE_STYLE oscsBullishPivotStyle; - ENUM_LINE_STYLE oscsBearishPivotStyle; - ENUM_LINE_STYLE trendBullishPivotStyle; - ENUM_LINE_STYLE trendBearishPivotStyle; // // Constructors ... XCXCAEAPOIDrawer( @@ -150,32 +128,7 @@ class XCXCAEAPOIDrawer : public XCBase ~XCXCAEAPOIDrawer() { // - mSWHPivotObjects.Clear(); - mSWLPivotObjects.Clear(); - mPeakPivotObjects.Clear(); - mValePivotObjects.Clear(); - mRSIPeakPivotObjects.Clear(); - mRSIValePivotObjects.Clear(); - mCCIPeakPivotObjects.Clear(); - mCCIValePivotObjects.Clear(); - mKIBullishPivotObjects.Clear(); - mKIBearishPivotObjects.Clear(); - mFVGBullishPivotObjects.Clear(); - mFVGBearishPivotObjects.Clear(); - mPeakSWHResPivotObjects.Clear(); - mValeSWLSupPivotObjects.Clear(); - mTKIBullishPivotObjects.Clear(); - mTKIBearishPivotObjects.Clear(); - mTrendBullishPivotObjects.Clear(); - mTrendBearishPivotObjects.Clear(); - mCycleSameLLPivotObjects.Clear(); - mCycleSameHHPivotObjects.Clear(); - mTKITRNDBullishPivotObjects.Clear(); - mTKITRNDBearishPivotObjects.Clear(); - mRSICrossedOverOSPivotObjects.Clear(); - mRSICrossedUnderOBPivotObjects.Clear(); - mCCICrossedOverOSPivotObjects.Clear(); - mCCICrossedUnderOBPivotObjects.Clear(); + Clear(); // ZeroMemory(drawer); @@ -192,1766 +145,151 @@ class XCXCAEAPOIDrawer : public XCBase virtual void Default() { // - drawSWHPivots = false; - drawSWLPivots = false; - drawPeakPivots = false; - drawValePivots = false; drawRSIPeakPivots = false; drawRSIValePivots = false; drawCCIPeakPivots = false; drawCCIValePivots = false; - drawKIBullishPivots = false; - drawKIBearishPivots = false; drawFVGBullishPivots = false; drawFVGBearishPivots = false; - drawPeakSWHResPivots = false; - drawValeSWLSupPivots = false; - drawTKIBullishPivots = false; - drawTKIBearishPivots = false; - drawCycleSameLLPivots = false; - drawCycleSameHHPivots = false; - drawPVFVGBullishPivots = false; - drawPVFVGBearishPivots = false; - drawTrendBullishPivots = false; - drawTrendBearishPivots = false; - drawTKITRNDBullishPivots = false; - drawTKITRNDBearishPivots = false; - drawRSICrossedOverOSPivots = false; - drawRSICrossedUnderOBPivots = false; - drawCCICrossedOverOSPivots = false; - drawCCICrossedUnderOBPivots = false; + drawValeSupSWLPivots = false; + drawPeakResSWHPivots = false; // - drawTicks = false; + defaultBullishColor = clrLime; + defaultBearishColor = clrRed; // - // Color ... - defBullishPivotColor = clrLime; - defBearishPivotColor = clrRed; + rsiValePivotsColor = defaultBullishColor; + cciValePivotsColor = defaultBullishColor; + fvgBullishPivotsColor = defaultBullishColor; + valeSupSWLPivotsColor = defaultBullishColor; // - peakPivotColor = defBearishPivotColor; - valePivotColor = defBullishPivotColor; - sameHHPivotColor = defBearishPivotColor; - sameLLPivotColor = defBullishPivotColor; - ticksBullishColor = defBearishPivotColor; - ticksBearishColor = defBullishPivotColor; - kiBullishPivotColor = defBullishPivotColor; - kiBearishPivotColor = defBearishPivotColor; - fvgBullishPivotColor = defBullishPivotColor; - fvgBearishPivotColor = defBearishPivotColor; - oscsBullishPivotColor = defBullishPivotColor; - oscsBearishPivotColor = defBearishPivotColor; - trendBullishPivotColor = defBullishPivotColor; - trendBearishPivotColor = defBearishPivotColor; + rsiPeakPivotsColor = defaultBearishColor; + cciPeakPivotsColor = defaultBearishColor; + fvgBearishPivotsColor = defaultBearishColor; + peakResSWHPivotsColor = defaultBearishColor; // - // Width ... - defBullishPivotWidth = 1; - defBearishPivotWidth = 1; + defaultBullishWidth = 1; + defaultBearishWidth = 1; // - peakPivotWidth = defBearishPivotWidth; - valePivotWidth = defBullishPivotWidth; - sameHHPivotWidth = defBearishPivotWidth; - sameLLPivotWidth = defBullishPivotWidth; - ticksBullishWidth = defBearishPivotWidth; - ticksBearishWidth = defBullishPivotWidth; - kiBullishPivotWidth = defBullishPivotWidth; - kiBearishPivotWidth = defBearishPivotWidth; - fvgBullishPivotWidth = defBullishPivotWidth; - fvgBearishPivotWidth = defBearishPivotWidth; - oscsBullishPivotWidth = defBullishPivotWidth; - oscsBearishPivotWidth = defBearishPivotWidth; - trendBullishPivotWidth = defBullishPivotWidth; - trendBearishPivotWidth = defBearishPivotWidth; + rsiValePivotsWidth = defaultBullishWidth; + cciValePivotsWidth = defaultBullishWidth; + fvgBullishPivotsWidth = defaultBullishWidth; + valeSupSWLPivotsWidth = defaultBullishWidth; // - // Style ... - defBullishPivotStyle = STYLE_DOT; - defBearishPivotStyle = STYLE_DOT; + rsiPeakPivotsWidth = defaultBearishWidth; + cciPeakPivotsWidth = defaultBearishWidth; + fvgBearishPivotsWidth = defaultBearishWidth; + peakResSWHPivotsWidth = defaultBearishWidth; // - peakPivotStyle = defBearishPivotStyle; - valePivotStyle = defBullishPivotStyle; - sameHHPivotStyle = defBearishPivotStyle; - sameLLPivotStyle = defBullishPivotStyle; - ticksBullishStyle = defBearishPivotStyle; - ticksBearishStyle = defBullishPivotStyle; - kiBullishPivotStyle = defBullishPivotStyle; - kiBearishPivotStyle = defBearishPivotStyle; - fvgBullishPivotStyle = defBullishPivotStyle; - fvgBearishPivotStyle = defBearishPivotStyle; - oscsBullishPivotStyle = defBullishPivotStyle; - oscsBearishPivotStyle = defBearishPivotStyle; - trendBullishPivotStyle = defBullishPivotStyle; - trendBearishPivotStyle = defBearishPivotStyle; + defaultBullishStyle = STYLE_SOLID; + defaultBearishStyle = STYLE_SOLID; + + // + rsiValePivotsStyle = defaultBullishStyle; + cciValePivotsStyle = defaultBullishStyle; + fvgBullishPivotsStyle = defaultBullishStyle; + valeSupSWLPivotsStyle = defaultBullishStyle; + + // + rsiPeakPivotsStyle = defaultBearishStyle; + cciPeakPivotsStyle = defaultBearishStyle; + fvgBearishPivotsStyle = defaultBearishStyle; + peakResSWHPivotsStyle = defaultBearishStyle; } // void Draw(datetime to = NULL) { // - DrawTicks(to); - DrawSWHPivots(to); - DrawSWLPivots(to); - DrawPeakPivots(to); - DrawValePivots(to); DrawRSIPeakPivots(to); DrawRSIValePivots(to); DrawCCIPeakPivots(to); DrawCCIValePivots(to); - DrawKIBullishPivots(to); - DrawKIBearishPivots(to); DrawFVGBullishPivots(to); DrawFVGBearishPivots(to); - DrawPeakSWHResPivots(to); - DrawValeSWLSupPivots(to); - DrawTKIBullishPivots(to); - DrawTKIBearishPivots(to); - DrawCycleSameLLPivots(to); - DrawCycleSameHHPivots(to); - DrawTrendBullishPivots(to); - DrawTrendBearishPivots(to); - DrawTKITRNDBullishPivots(to); - DrawTKITRNDBearishPivots(to); - DrawRSICrossedOverOSPivots(to); - DrawRSICrossedUnderOBPivots(to); - DrawCCICrossedOverOSPivots(to); - DrawCCICrossedUnderOBPivots(to); + DrawValeSupSWLPivots(to); + DrawPeakResSWHPivots(to); } // - // - // - - // - void DrawTicks(datetime to = NULL) + void Clear() { // - if (!drawTicks) - { - return; - } - - // - bool canUpdateTo = IsValid(to); - - // - // PEAK TICKS ... - bool has = detector.HasPeakTicks(); - if (has) - { - // - int count = detector.CountPeakTicks(); - for (int i = 0; i < count; i++) - { - // - XCAPVTick iPVTick = detector.peakTicks[i]; - - // - // Converts Zone to Box ... - XBoxZone iBox; - has = iPVTick.GetMaxVolumeBox(iBox); - if (!has) - { - // - iBox.Clean(); - iPVTick.Clean(); - - // - continue; - } - if (canUpdateTo) - { - iBox.to = to; - } - - // - XCBoxObject *iObj; - has = drawer.DrawBox( - iBox, - iObj // - ); - if (has) - { - // - iObj.BoxColor(ticksBearishColor); - iObj.BoxWidth(ticksBearishWidth); - iObj.BoxStyle(ticksBearishStyle); - - // - mPeakSWHResPivotObjects.Add(iObj); - } - - // - iBox.Clean(); - iPVTick.Clean(); - ZeroMemory(iObj); - } - } - - // - // VALE TICKS ... - has = detector.HasValeTicks(); - if (has) - { - // - int count = detector.CountValeTicks(); - for (int i = 0; i < count; i++) - { - // - XCAPVTick iPVTick = detector.valeTicks[i]; - - // - // Converts Zone to Box ... - XBoxZone iBox; - has = iPVTick.GetMaxVolumeBox(iBox); - if (!has) - { - // - iBox.Clean(); - iPVTick.Clean(); - - // - continue; - } - if (canUpdateTo) - { - iBox.to = to; - } - - // - XCBoxObject *iObj; - has = drawer.DrawBox( - iBox, - iObj // - ); - if (has) - { - // - iObj.BoxColor(ticksBullishColor); - iObj.BoxWidth(ticksBullishWidth); - iObj.BoxStyle(ticksBullishStyle); - - // - mValeSWLSupPivotObjects.Add(iObj); - } - - // - iBox.Clean(); - iPVTick.Clean(); - ZeroMemory(iObj); - } - } + mRSIPeakPivotObjects.Clear(); + mRSIValePivotObjects.Clear(); + mCCIPeakPivotObjects.Clear(); + mCCIValePivotObjects.Clear(); + mFVGBullishPivotObjects.Clear(); + mFVGBearishPivotObjects.Clear(); + mValeSupSWLPivotObjects.Clear(); + mPeakResSWHPivotObjects.Clear(); } // - void DrawSWHPivots(datetime to = NULL) - { - // - if (!drawSWHPivots) - { - return; - } - - // - bool canUpdateTo = IsValid(to); - - // - bool has = detector.HasSWHPivots(); - if (!has) - { - return; - } - - // - int count = detector.CountSWHPivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox; - has = detector.swhPivots[i].AsBox(iBox); - if (!has) - { - continue; - } - - // - if (canUpdateTo) - { - iBox.to = to; - } - - // - XCBoxObject *iObj; - has = drawer.DrawBox( - iBox, - iObj // - ); - if (has) - { - // - iObj.BoxColor(peakPivotColor); - iObj.BoxWidth(peakPivotWidth); - iObj.BoxStyle(peakPivotStyle); - - // - mSWHPivotObjects.Add(iObj); - } - - // - iBox.Clean(); - } - } - // - void DrawSWLPivots(datetime to = NULL) - { - // - if (!drawSWLPivots) - { - return; - } - - // - bool canUpdateTo = IsValid(to); - - // - bool has = detector.HasSWLPivots(); - if (!has) - { - return; - } - - // - int count = detector.CountSWLPivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox; - has = detector.swlPivots[i].AsBox(iBox); - if (!has) - { - continue; - } - - // - if (canUpdateTo) - { - iBox.to = to; - } - - // - XCBoxObject *iObj; - has = drawer.DrawBox( - iBox, - iObj // - ); - if (has) - { - // - iObj.BoxColor(valePivotColor); - iObj.BoxWidth(valePivotWidth); - iObj.BoxStyle(valePivotStyle); - - // - mSWLPivotObjects.Add(iObj); - } - - // - iBox.Clean(); - } - } - // - void DrawPeakPivots(datetime to = NULL) - { - // - if (!drawPeakPivots) - { - return; - } - - // - bool canUpdateTo = IsValid(to); - - // - bool has = detector.HasPeakPivots(); - if (!has) - { - return; - } - - // - int count = detector.CountPeakPivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox; - has = detector.peakPivots[i].AsBox(iBox); - if (!has) - { - continue; - } - - // - if (canUpdateTo) - { - iBox.to = to; - } - - // - XCBoxObject *iObj; - has = drawer.DrawBox( - iBox, - iObj // - ); - if (has) - { - // - iObj.BoxColor(peakPivotColor); - iObj.BoxWidth(peakPivotWidth); - iObj.BoxStyle(peakPivotStyle); - - // - mPeakPivotObjects.Add(iObj); - } - - // - iBox.Clean(); - } - } - - // - void DrawValePivots(datetime to = NULL) - { - // - if (!drawValePivots) - { - return; - } - - // - bool canUpdateTo = IsValid(to); - - // - bool has = detector.HasValePivots(); - if (!has) - { - return; - } - - // - int count = detector.CountValePivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox; - has = detector.valePivots[i].AsBox(iBox); - if (!has) - { - continue; - } - - // - if (canUpdateTo) - { - iBox.to = to; - } - - // - XCBoxObject *iObj; - has = drawer.DrawBox( - iBox, - iObj // - ); - if (has) - { - // - iObj.BoxColor(valePivotColor); - iObj.BoxWidth(valePivotWidth); - iObj.BoxStyle(valePivotStyle); - - // - mValePivotObjects.Add(iObj); - } - - // - iBox.Clean(); - } - } - - // - void DrawKIBullishPivots(datetime to = NULL) - { - // - if (!drawKIBullishPivots) - { - return; - } - - // - bool canUpdateTo = IsValid(to); - - // - bool has = detector.HasKIBullishPivots(); - if (!has) - { - return; - } - - // - int count = detector.CountKIBullishPivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox; - has = detector.kiBullishPivots[i].AsBox(iBox); - if (!has) - { - continue; - } - - // - if (canUpdateTo) - { - iBox.to = to; - } - - // - XCBoxObject *iObj; - has = drawer.DrawBox( - iBox, - iObj // - ); - if (has) - { - // - iObj.BoxColor(kiBullishPivotColor); - iObj.BoxWidth(kiBullishPivotWidth); - iObj.BoxStyle(kiBullishPivotStyle); - - // - mKIBullishPivotObjects.Add(iObj); - } - - // - iBox.Clean(); - } - } - - // - void DrawKIBearishPivots(datetime to = NULL) - { - // - if (!drawKIBearishPivots) - { - return; - } - - // - bool canUpdateTo = IsValid(to); - - // - bool has = detector.HasKIBearishPivots(); - if (!has) - { - return; - } - - // - int count = detector.CountKIBearishPivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox; - has = detector.kiBearishPivots[i].AsBox(iBox); - if (!has) - { - continue; - } - - // - if (canUpdateTo) - { - iBox.to = to; - } - - // - XCBoxObject *iObj; - has = drawer.DrawBox( - iBox, - iObj // - ); - if (has) - { - // - iObj.BoxColor(kiBearishPivotColor); - iObj.BoxWidth(kiBearishPivotWidth); - iObj.BoxStyle(kiBearishPivotStyle); - - // - mKIBearishPivotObjects.Add(iObj); - } - - // - iBox.Clean(); - } - } - - // - void DrawFVGBullishPivots(datetime to = NULL) - { - // - bool canUpdateTo = IsValid(to); - - // - if (drawFVGBullishPivots) - { - // - bool has = detector.HasFVGBullishPivots(); - if (has) - { - // - int count = detector.CountFVGBullishPivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox; - has = detector.fvgBullishPivots[i].AsBox(iBox); - if (!has) - { - // - iBox.Clean(); - continue; - } - - // - if (canUpdateTo) - { - iBox.to = to; - } - - // - XCBoxObject *iObj; - has = drawer.DrawBox( - iBox, - iObj // - ); - if (has) - { - // - iObj.BoxColor(fvgBullishPivotColor); - iObj.BoxWidth(fvgBullishPivotWidth); - iObj.BoxStyle(fvgBullishPivotStyle); - - // - mFVGBullishPivotObjects.Add(iObj); - } - } - } - } - - // - if (drawPVFVGBullishPivots) - { - // - bool has = detector.HasPVFVGBullishPivots(); - if (has) - { - // - int count = detector.CountPVFVGBullishPivots(); - for (int i = 0; i < count; i++) - { - // - XCAPVPivot iPVFVG = detector.pvFVGBullishPivots[i]; - - // - XBoxZone fvgBoxes[]; - int fvgBoxesCount = iPVFVG.GetPivots(fvgBoxes); - has = IsValidSize(fvgBoxesCount); - if (has) - { - // - int idx = GetLowest(fvgBoxes); - if (IsValidIndex(idx)) - { - // - XBoxZone iBox = fvgBoxes[idx]; - - // - if (canUpdateTo) - { - iBox.to = to; - } - - // - XCBoxObject *iObj; - - // - has = drawer.DrawBox( - iBox, - iObj // - ); - if (has) - { - // - iObj.BoxColor(fvgBullishPivotColor); - iObj.BoxWidth(fvgBullishPivotWidth); - iObj.BoxStyle(fvgBullishPivotStyle); - - // - mFVGBullishPivotObjects.Add(iObj); - } - - // - iBox.Clean(); - ZeroMemory(iObj); - } - } - } - } - } - } - - // - void DrawFVGBearishPivots(datetime to = NULL) - { - // - bool canUpdateTo = IsValid(to); - - // - if (drawFVGBearishPivots) - { - // - bool has = detector.HasFVGBearishPivots(); - if (has) - { - // - int count = detector.CountFVGBearishPivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox; - has = detector.fvgBearishPivots[i].AsBox(iBox); - if (!has) - { - // - iBox.Clean(); - continue; - } - - // - if (canUpdateTo) - { - iBox.to = to; - } - - // - XCBoxObject *iObj; - has = drawer.DrawBox( - iBox, - iObj // - ); - if (has) - { - // - iObj.BoxColor(fvgBearishPivotColor); - iObj.BoxWidth(fvgBearishPivotWidth); - iObj.BoxStyle(fvgBearishPivotStyle); - - // - mFVGBearishPivotObjects.Add(iObj); - } - } - } - } - - // - if (drawPVFVGBullishPivots) - { - // - bool has = detector.HasPVFVGBearishPivots(); - if (has) - { - // - int count = detector.CountPVFVGBearishPivots(); - for (int i = 0; i < count; i++) - { - // - XCAPVPivot iPVFVG = detector.pvFVGBearishPivots[i]; - - // - XBoxZone fvgBoxes[]; - int fvgBoxesCount = iPVFVG.GetPivots(fvgBoxes); - has = IsValidSize(fvgBoxesCount); - if (has) - { - // - int idx = GetHighest(fvgBoxes); - if (IsValidIndex(idx)) - { - // - XBoxZone iBox = fvgBoxes[idx]; - - // - if (canUpdateTo) - { - iBox.to = to; - } - - // - XCBoxObject *iObj; - - // - has = drawer.DrawBox( - iBox, - iObj // - ); - if (has) - { - // - iObj.BoxColor(fvgBearishPivotColor); - iObj.BoxWidth(fvgBearishPivotWidth); - iObj.BoxStyle(fvgBearishPivotStyle); - - // - mFVGBearishPivotObjects.Add(iObj); - } - - // - iBox.Clean(); - ZeroMemory(iObj); - } - } - } - } - } - } - - // - void DrawPeakSWHResPivots(datetime to = NULL) - { - // - if (!drawPeakSWHResPivots) - { - return; - } - - // - bool canUpdateTo = IsValid(to); - - // - bool has = detector.HasPeakSWHResPivots(); - if (!has) - { - return; - } - - // - int count = detector.CountPeakSWHResPivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox; - has = detector.peakSWHResPivots[i].AsBox(iBox); - if (!has) - { - continue; - } - - // - if (canUpdateTo) - { - iBox.to = to; - } - - // - XCBoxObject *iObj; - has = drawer.DrawBox( - iBox, - iObj // - ); - if (has) - { - // - iObj.BoxColor(peakPivotColor); - iObj.BoxWidth(peakPivotWidth); - iObj.BoxStyle(peakPivotStyle); - - // - mPeakSWHResPivotObjects.Add(iObj); - } - - // - iBox.Clean(); - } - } - - // - void DrawValeSWLSupPivots(datetime to = NULL) - { - // - if (!drawValeSWLSupPivots) - { - return; - } - - // - bool canUpdateTo = IsValid(to); - - // - bool has = detector.HasValeSWLSupPivots(); - if (!has) - { - return; - } - - // - int count = detector.CountValeSWLSupPivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox; - has = detector.valeSWLSupPivots[i].AsBox(iBox); - if (!has) - { - continue; - } - - // - if (canUpdateTo) - { - iBox.to = to; - } - - // - XCBoxObject *iObj; - has = drawer.DrawBox( - iBox, - iObj // - ); - if (has) - { - // - iObj.BoxColor(valePivotColor); - iObj.BoxWidth(valePivotWidth); - iObj.BoxStyle(valePivotStyle); - - // - mValeSWLSupPivotObjects.Add(iObj); - } - - // - iBox.Clean(); - } - } - - // - void DrawTKIBullishPivots(datetime to = NULL) - { - // - if (!drawTKIBullishPivots) - { - return; - } - - // - bool canUpdateTo = IsValid(to); - - // - bool has = detector.HasTKIBullishPivots(); - if (!has) - { - return; - } - - // - int count = detector.CountTKIBullishPivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox; - has = detector.tkiBullishPivots[i].AsBox(iBox); - if (!has) - { - continue; - } - - // - if (canUpdateTo) - { - iBox.to = to; - } - - // - XCBoxObject *iObj; - has = drawer.DrawBox( - iBox, - iObj // - ); - if (has) - { - // - iObj.BoxColor(kiBullishPivotColor); - iObj.BoxWidth(kiBullishPivotWidth); - iObj.BoxStyle(kiBullishPivotStyle); - - // - mTKIBullishPivotObjects.Add(iObj); - } - - // - iBox.Clean(); - } - } - - // - void DrawTKIBearishPivots(datetime to = NULL) - { - // - if (!drawTKIBearishPivots) - { - return; - } - - // - bool canUpdateTo = IsValid(to); - - // - bool has = detector.HasTKIBearishPivots(); - if (!has) - { - return; - } - - // - int count = detector.CountTKIBearishPivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox; - has = detector.tkiBearishPivots[i].AsBox(iBox); - if (!has) - { - continue; - } - - // - if (canUpdateTo) - { - iBox.to = to; - } - - // - XCBoxObject *iObj; - has = drawer.DrawBox( - iBox, - iObj // - ); - if (has) - { - // - iObj.BoxColor(kiBearishPivotColor); - iObj.BoxWidth(kiBearishPivotWidth); - iObj.BoxStyle(kiBearishPivotStyle); - - // - mTKIBearishPivotObjects.Add(iObj); - } - - // - iBox.Clean(); - } - } - - // - void DrawTrendBullishPivots(datetime to = NULL) - { - // - if (!drawTrendBullishPivots) - { - return; - } - - // - bool canUpdateTo = IsValid(to); - - // - bool has = detector.HasTrendBullishPivots(); - if (!has) - { - return; - } - - // - int count = detector.CountTrendBullishPivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox; - has = detector.trendBullishPivots[i].AsBox(iBox); - if (!has) - { - continue; - } - - // - if (canUpdateTo) - { - iBox.to = to; - } - - // - XCBoxObject *iObj; - has = drawer.DrawBox( - iBox, - iObj // - ); - if (has) - { - // - iObj.BoxColor(trendBullishPivotColor); - iObj.BoxWidth(trendBullishPivotWidth); - iObj.BoxStyle(trendBullishPivotStyle); - - // - mTrendBullishPivotObjects.Add(iObj); - } - - // - iBox.Clean(); - } - } - - // - void DrawTrendBearishPivots(datetime to = NULL) - { - // - if (!drawTrendBearishPivots) - { - return; - } - - // - bool canUpdateTo = IsValid(to); - - // - bool has = detector.HasTrendBearishPivots(); - if (!has) - { - return; - } - - // - int count = detector.CountTrendBearishPivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox; - has = detector.trendBearishPivots[i].AsBox(iBox); - if (!has) - { - continue; - } - - // - if (canUpdateTo) - { - iBox.to = to; - } - - // - XCBoxObject *iObj; - has = drawer.DrawBox( - iBox, - iObj // - ); - if (has) - { - // - iObj.BoxColor(trendBearishPivotColor); - iObj.BoxWidth(trendBearishPivotWidth); - iObj.BoxStyle(trendBearishPivotStyle); - - // - mTrendBearishPivotObjects.Add(iObj); - } - - // - iBox.Clean(); - } - } - - // - void DrawTKITRNDBullishPivots(datetime to = NULL) - { - // - if (!drawTKITRNDBullishPivots) - { - return; - } - - // - bool canUpdateTo = IsValid(to); - - // - bool has = detector.HasTKITRNDBullishPivots(); - if (!has) - { - return; - } - - // - int count = detector.CountTKITRNDBullishPivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox; - has = detector.tkitrndBullishPivots[i].AsBox(iBox); - if (!has) - { - continue; - } - - // - if (canUpdateTo) - { - iBox.to = to; - } - - // - XCBoxObject *iObj; - has = drawer.DrawBox( - iBox, - iObj // - ); - if (has) - { - // - iObj.BoxColor(trendBullishPivotColor); - iObj.BoxWidth(trendBullishPivotWidth); - iObj.BoxStyle(trendBullishPivotStyle); - - // - mTKITRNDBullishPivotObjects.Add(iObj); - } - - // - iBox.Clean(); - } - } - - // - void DrawTKITRNDBearishPivots(datetime to = NULL) - { - // - if (!drawTKITRNDBearishPivots) - { - return; - } - - // - bool canUpdateTo = IsValid(to); - - // - bool has = detector.HasTKITRNDBearishPivots(); - if (!has) - { - return; - } - - // - int count = detector.CountTKITRNDBearishPivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox; - has = detector.tkitrndBearishPivots[i].AsBox(iBox); - if (!has) - { - continue; - } - - // - if (canUpdateTo) - { - iBox.to = to; - } - - // - XCBoxObject *iObj; - has = drawer.DrawBox( - iBox, - iObj // - ); - if (has) - { - // - iObj.BoxColor(trendBearishPivotColor); - iObj.BoxWidth(trendBearishPivotWidth); - iObj.BoxStyle(trendBearishPivotStyle); - - // - mTKITRNDBearishPivotObjects.Add(iObj); - } - - // - iBox.Clean(); - } - } - - // - void DrawCycleSameLLPivots(datetime to = NULL) - { - // - if (!drawCycleSameLLPivots) - { - return; - } - - // - bool canUpdateTo = IsValid(to); - - // - int count = 0; - - // - // SHORT ... - bool has = detector.HasSSameLLPivots(); - if (has) - { - // - count = detector.CountSSameLLPivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox; - has = detector.sSameLLPivots[i].AsBox(iBox); - if (!has) - { - continue; - } - - // - if (canUpdateTo) - { - iBox.to = to; - } - - // - XCBoxObject *iObj; - has = drawer.DrawBox( - iBox, - iObj // - ); - if (has) - { - // - iObj.BoxColor(sameLLPivotColor); - iObj.BoxWidth(sameLLPivotWidth); - iObj.BoxStyle(sameLLPivotStyle); - - // - mCycleSameLLPivotObjects.Add(iObj); - } - - // - iBox.Clean(); - } - } - - // - // MEDIUM ... - has = detector.HasMSameLLPivots(); - if (has) - { - // - count = detector.CountMSameLLPivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox; - has = detector.mSameLLPivots[i].AsBox(iBox); - if (!has) - { - continue; - } - - // - if (canUpdateTo) - { - iBox.to = to; - } - - // - XCBoxObject *iObj; - has = drawer.DrawBox( - iBox, - iObj // - ); - if (has) - { - // - iObj.BoxColor(sameLLPivotColor); - iObj.BoxWidth(sameLLPivotWidth); - iObj.BoxStyle(sameLLPivotStyle); - - // - mCycleSameLLPivotObjects.Add(iObj); - } - - // - iBox.Clean(); - } - } - - // - // LONG ... - has = detector.HasLSameLLPivots(); - if (has) - { - // - count = detector.CountLSameLLPivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox; - has = detector.lSameLLPivots[i].AsBox(iBox); - if (!has) - { - continue; - } - - // - if (canUpdateTo) - { - iBox.to = to; - } - - // - XCBoxObject *iObj; - has = drawer.DrawBox( - iBox, - iObj // - ); - if (has) - { - // - iObj.BoxColor(sameLLPivotColor); - iObj.BoxWidth(sameLLPivotWidth); - iObj.BoxStyle(sameLLPivotStyle); - - // - mCycleSameLLPivotObjects.Add(iObj); - } - - // - iBox.Clean(); - } - } - - // - // HIND ... - has = detector.HasHSameLLPivots(); - if (has) - { - // - count = detector.CountHSameLLPivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox; - has = detector.hSameLLPivots[i].AsBox(iBox); - if (!has) - { - continue; - } - - // - if (canUpdateTo) - { - iBox.to = to; - } - - // - XCBoxObject *iObj; - has = drawer.DrawBox( - iBox, - iObj // - ); - if (has) - { - // - iObj.BoxColor(sameLLPivotColor); - iObj.BoxWidth(sameLLPivotWidth); - iObj.BoxStyle(sameLLPivotStyle); - - // - mCycleSameLLPivotObjects.Add(iObj); - } - - // - iBox.Clean(); - } - } - } - - // - void DrawCycleSameHHPivots(datetime to = NULL) - { - // - if (!drawCycleSameHHPivots) - { - return; - } - - // - bool canUpdateTo = IsValid(to); - - // - int count = 0; - - // - // SHORT ... - bool has = detector.HasSSameHHPivots(); - if (has) - { - // - count = detector.CountSSameHHPivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox; - has = detector.sSameHHPivots[i].AsBox(iBox); - if (!has) - { - continue; - } - - // - if (canUpdateTo) - { - iBox.to = to; - } - - // - XCBoxObject *iObj; - has = drawer.DrawBox( - iBox, - iObj // - ); - if (has) - { - // - iObj.BoxColor(sameHHPivotColor); - iObj.BoxWidth(sameHHPivotWidth); - iObj.BoxStyle(sameHHPivotStyle); - - // - mCycleSameHHPivotObjects.Add(iObj); - } - - // - iBox.Clean(); - } - } - - // - // MEDIUM ... - has = detector.HasMSameHHPivots(); - if (has) - { - // - count = detector.CountMSameHHPivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox; - has = detector.mSameHHPivots[i].AsBox(iBox); - if (!has) - { - continue; - } - - // - if (canUpdateTo) - { - iBox.to = to; - } - - // - XCBoxObject *iObj; - has = drawer.DrawBox( - iBox, - iObj // - ); - if (has) - { - // - iObj.BoxColor(sameHHPivotColor); - iObj.BoxWidth(sameHHPivotWidth); - iObj.BoxStyle(sameHHPivotStyle); - - // - mCycleSameHHPivotObjects.Add(iObj); - } - - // - iBox.Clean(); - } - } - - // - // LONG ... - has = detector.HasLSameHHPivots(); - if (has) - { - // - count = detector.CountLSameHHPivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox; - has = detector.lSameHHPivots[i].AsBox(iBox); - if (!has) - { - continue; - } - - // - if (canUpdateTo) - { - iBox.to = to; - } - - // - XCBoxObject *iObj; - has = drawer.DrawBox( - iBox, - iObj // - ); - if (has) - { - // - iObj.BoxColor(sameHHPivotColor); - iObj.BoxWidth(sameHHPivotWidth); - iObj.BoxStyle(sameHHPivotStyle); - - // - mCycleSameHHPivotObjects.Add(iObj); - } - - // - iBox.Clean(); - } - } - - // - // HIND ... - has = detector.HasHSameHHPivots(); - if (has) - { - // - count = detector.CountHSameHHPivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox; - has = detector.hSameHHPivots[i].AsBox(iBox); - if (!has) - { - continue; - } - - // - if (canUpdateTo) - { - iBox.to = to; - } - - // - XCBoxObject *iObj; - has = drawer.DrawBox( - iBox, - iObj // - ); - if (has) - { - // - iObj.BoxColor(sameHHPivotColor); - iObj.BoxWidth(sameHHPivotWidth); - iObj.BoxStyle(sameHHPivotStyle); - - // - mCycleSameHHPivotObjects.Add(iObj); - } - - // - iBox.Clean(); - } - } - } // void DrawRSIPeakPivots(datetime to = NULL) { // - if (!drawRSIPeakPivots) + bool has = drawRSIPeakPivots; + if (!has) + { + return; + } + + // + has = detector.HasRSIPeakPivots(); + if (!has) { return; } // - to = NULL; bool canUpdateTo = IsValid(to); // - int count = 0; - bool has = detector.HasRSIPeakPivots(); - if (has) + int count = detector.CountRSIPeakPivots(); + for (int i = 0; i < count; i++) { // - count = detector.CountRSIPeakPivots(); - for (int i = 0; i < count; i++) + XBoxZone iBox = detector.rsiPeakPivots[i]; + + // + if (canUpdateTo) + { + iBox.to = to; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + iBox, + iObj // + ); + if (has) { // - XBoxZone iBox; - has = detector.rsiPeakPivots[i].AsBox(iBox); - if (!has) - { - // - iBox.Clean(); - continue; - } + // Style Object ... + iObj.BoxColor(rsiPeakPivotsColor); + iObj.BoxWidth(rsiPeakPivotsWidth); + iObj.BoxStyle(rsiPeakPivotsStyle); // - if (canUpdateTo) - { - iBox.to = to; - } - - // - XCBoxObject *iObj; - has = drawer.DrawBox( - iBox, - iObj // - ); - if (has) - { - // - iObj.BoxColor(oscsBearishPivotColor); - iObj.BoxWidth(oscsBearishPivotWidth); - iObj.BoxStyle(oscsBearishPivotStyle); - - // - mRSIPeakPivotObjects.Add(iObj); - } - - // - iBox.Clean(); + // Store Object ... + mRSIPeakPivotObjects.Add(iObj); } + + // + iBox.Clean(); + ZeroMemory(iObj); } } @@ -1959,178 +297,57 @@ class XCXCAEAPOIDrawer : public XCBase void DrawRSIValePivots(datetime to = NULL) { // - if (!drawRSIValePivots) + bool has = drawRSIValePivots; + if (!has) { return; } // - to = NULL; - bool canUpdateTo = IsValid(to); - - // - int count = 0; - bool has = detector.HasRSIValePivots(); - if (has) - { - // - count = detector.CountRSIValePivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox; - has = detector.rsiValePivots[i].AsBox(iBox); - if (!has) - { - // - iBox.Clean(); - continue; - } - - // - if (canUpdateTo) - { - iBox.to = to; - } - - // - XCBoxObject *iObj; - has = drawer.DrawBox( - iBox, - iObj // - ); - if (has) - { - // - iObj.BoxColor(oscsBullishPivotColor); - iObj.BoxWidth(oscsBullishPivotWidth); - iObj.BoxStyle(oscsBullishPivotStyle); - - // - mRSIValePivotObjects.Add(iObj); - } - - // - iBox.Clean(); - } - } - } - - // - void DrawRSICrossedOverOSPivots(datetime to = NULL) - { - // - if (!drawRSICrossedOverOSPivots) + has = detector.HasRSIValePivots(); + if (!has) { return; } // - to = NULL; bool canUpdateTo = IsValid(to); // - int count = 0; - bool has = detector.HasRSICrossedOverOSPivots(); - if (has) + int count = detector.CountRSIValePivots(); + for (int i = 0; i < count; i++) { // - count = detector.CountRSICrossedOverOSPivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox; - has = detector.rsiCrossedOverOSPivots[i].AsBox(iBox); - if (!has) - { - continue; - } + XBoxZone iBox = detector.rsiValePivots[i]; - // - if (canUpdateTo) - { - iBox.to = to; - } - - // - XCBoxObject *iObj; - has = drawer.DrawBox( - iBox, - iObj // - ); - if (has) - { - // - iObj.BoxColor(oscsBullishPivotColor); - iObj.BoxWidth(oscsBullishPivotWidth); - iObj.BoxStyle(oscsBullishPivotStyle); - - // - mRSICrossedOverOSPivotObjects.Add(iObj); - } - - // - iBox.Clean(); - } - } - } - - // - void DrawRSICrossedUnderOBPivots(datetime to = NULL) - { - // - if (!drawRSICrossedUnderOBPivots) - { - return; - } - - // - to = NULL; - bool canUpdateTo = IsValid(to); - - // - int count = 0; - bool has = detector.HasRSICrossedUnderOBPivots(); - if (has) - { // - count = detector.CountRSICrossedUnderOBPivots(); - for (int i = 0; i < count; i++) + if (canUpdateTo) + { + iBox.to = to; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + iBox, + iObj // + ); + if (has) { // - XBoxZone iBox; - has = detector.rsiCrossedUnderOBPivots[i].AsBox(iBox); - if (!has) - { - continue; - } + // Style Object ... + iObj.BoxColor(rsiValePivotsColor); + iObj.BoxWidth(rsiValePivotsWidth); + iObj.BoxStyle(rsiValePivotsStyle); // - if (canUpdateTo) - { - iBox.to = to; - } - - // - XCBoxObject *iObj; - has = drawer.DrawBox( - iBox, - iObj // - ); - if (has) - { - // - iObj.BoxColor(oscsBearishPivotColor); - iObj.BoxWidth(oscsBearishPivotWidth); - iObj.BoxStyle(oscsBearishPivotStyle); - - // - mRSICrossedUnderOBPivotObjects.Add(iObj); - } - - // - iBox.Clean(); + // Store Object ... + mRSIValePivotObjects.Add(iObj); } + + // + iBox.Clean(); + ZeroMemory(iObj); } } @@ -2138,60 +355,57 @@ class XCXCAEAPOIDrawer : public XCBase void DrawCCIPeakPivots(datetime to = NULL) { // - if (!drawCCIPeakPivots) + bool has = drawCCIPeakPivots; + if (!has) + { + return; + } + + // + has = detector.HasCCIPeakPivots(); + if (!has) { return; } // - to = NULL; bool canUpdateTo = IsValid(to); // - int count = 0; - bool has = detector.HasCCIPeakPivots(); - if (has) + int count = detector.CountCCIPeakPivots(); + for (int i = 0; i < count; i++) { // - count = detector.CountCCIPeakPivots(); - for (int i = 0; i < count; i++) + XBoxZone iBox = detector.cciPeakPivots[i]; + + // + if (canUpdateTo) + { + iBox.to = to; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + iBox, + iObj // + ); + if (has) { // - XBoxZone iBox; - has = detector.cciPeakPivots[i].AsBox(iBox); - if (!has) - { - // - iBox.Clean(); - continue; - } + // Style Object ... + iObj.BoxColor(cciPeakPivotsColor); + iObj.BoxWidth(cciPeakPivotsWidth); + iObj.BoxStyle(cciPeakPivotsStyle); // - if (canUpdateTo) - { - iBox.to = to; - } - - // - XCBoxObject *iObj; - has = drawer.DrawBox( - iBox, - iObj // - ); - if (has) - { - // - iObj.BoxColor(oscsBearishPivotColor); - iObj.BoxWidth(oscsBearishPivotWidth); - iObj.BoxStyle(oscsBearishPivotStyle); - - // - mCCIPeakPivotObjects.Add(iObj); - } - - // - iBox.Clean(); + // Store Object ... + mCCIPeakPivotObjects.Add(iObj); } + + // + iBox.Clean(); + ZeroMemory(iObj); } } @@ -2199,178 +413,289 @@ class XCXCAEAPOIDrawer : public XCBase void DrawCCIValePivots(datetime to = NULL) { // - if (!drawCCIValePivots) + bool has = drawCCIValePivots; + if (!has) + { + return; + } + + // + has = detector.HasCCIValePivots(); + if (!has) { return; } // - to = NULL; bool canUpdateTo = IsValid(to); // - int count = 0; - bool has = detector.HasCCIValePivots(); - if (has) + int count = detector.CountCCIValePivots(); + for (int i = 0; i < count; i++) { // - count = detector.CountCCIValePivots(); - for (int i = 0; i < count; i++) + XBoxZone iBox = detector.cciValePivots[i]; + + // + if (canUpdateTo) + { + iBox.to = to; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + iBox, + iObj // + ); + if (has) { // - XBoxZone iBox; - has = detector.cciValePivots[i].AsBox(iBox); - if (!has) - { - // - iBox.Clean(); - continue; - } + // Style Object ... + iObj.BoxColor(cciValePivotsColor); + iObj.BoxWidth(cciValePivotsWidth); + iObj.BoxStyle(cciValePivotsStyle); // - if (canUpdateTo) - { - iBox.to = to; - } - - // - XCBoxObject *iObj; - has = drawer.DrawBox( - iBox, - iObj // - ); - if (has) - { - // - iObj.BoxColor(oscsBullishPivotColor); - iObj.BoxWidth(oscsBullishPivotWidth); - iObj.BoxStyle(oscsBullishPivotStyle); - - // - mCCIValePivotObjects.Add(iObj); - } - - // - iBox.Clean(); + // Store Object ... + mCCIValePivotObjects.Add(iObj); } + + // + iBox.Clean(); + ZeroMemory(iObj); } } // - void DrawCCICrossedOverOSPivots(datetime to = NULL) + void DrawFVGBullishPivots(datetime to = NULL) { // - if (!drawCCICrossedOverOSPivots) + bool has = drawFVGBullishPivots; + if (!has) + { + return; + } + + // + has = detector.HasFVGBullishPivots(); + if (!has) { return; } // - to = NULL; bool canUpdateTo = IsValid(to); // - int count = 0; - bool has = detector.HasCCICrossedOverOSPivots(); - if (has) + int count = detector.CountFVGBullishPivots(); + for (int i = 0; i < count; i++) { // - count = detector.CountCCICrossedOverOSPivots(); - for (int i = 0; i < count; i++) + XBoxZone iBox = detector.fvgBullishPivots[i]; + + // + if (canUpdateTo) + { + iBox.to = to; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + iBox, + iObj // + ); + if (has) { // - XBoxZone iBox; - has = detector.cciCrossedOverOSPivots[i].AsBox(iBox); - if (!has) - { - continue; - } + // Style Object ... + iObj.BoxColor(fvgBullishPivotsColor); + iObj.BoxWidth(fvgBullishPivotsWidth); + iObj.BoxStyle(fvgBullishPivotsStyle); // - if (canUpdateTo) - { - iBox.to = to; - } - - // - XCBoxObject *iObj; - has = drawer.DrawBox( - iBox, - iObj // - ); - if (has) - { - // - iObj.BoxColor(oscsBullishPivotColor); - iObj.BoxWidth(oscsBullishPivotWidth); - iObj.BoxStyle(oscsBullishPivotStyle); - - // - mCCICrossedOverOSPivotObjects.Add(iObj); - } - - // - iBox.Clean(); + // Store Object ... + mFVGBullishPivotObjects.Add(iObj); } + + // + iBox.Clean(); + ZeroMemory(iObj); } } // - void DrawCCICrossedUnderOBPivots(datetime to = NULL) + void DrawFVGBearishPivots(datetime to = NULL) { // - if (!drawCCICrossedUnderOBPivots) + bool has = drawFVGBearishPivots; + if (!has) + { + return; + } + + // + has = detector.HasFVGBearishPivots(); + if (!has) { return; } // - to = NULL; bool canUpdateTo = IsValid(to); // - int count = 0; - bool has = detector.HasCCICrossedUnderOBPivots(); - if (has) + int count = detector.CountFVGBearishPivots(); + for (int i = 0; i < count; i++) { // - count = detector.CountCCICrossedUnderOBPivots(); - for (int i = 0; i < count; i++) + XBoxZone iBox = detector.fvgBearishPivots[i]; + + // + if (canUpdateTo) + { + iBox.to = to; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + iBox, + iObj // + ); + if (has) { // - XBoxZone iBox; - has = detector.cciCrossedUnderOBPivots[i].AsBox(iBox); - if (!has) - { - continue; - } + // Style Object ... + iObj.BoxColor(fvgBearishPivotsColor); + iObj.BoxWidth(fvgBearishPivotsWidth); + iObj.BoxStyle(fvgBearishPivotsStyle); // - if (canUpdateTo) - { - iBox.to = to; - } - - // - XCBoxObject *iObj; - has = drawer.DrawBox( - iBox, - iObj // - ); - if (has) - { - // - iObj.BoxColor(oscsBearishPivotColor); - iObj.BoxWidth(oscsBearishPivotWidth); - iObj.BoxStyle(oscsBearishPivotStyle); - - // - mCCICrossedUnderOBPivotObjects.Add(iObj); - } - - // - iBox.Clean(); + // Store Object ... + mFVGBearishPivotObjects.Add(iObj); } + + // + iBox.Clean(); + ZeroMemory(iObj); + } + } + + // + void DrawValeSupSWLPivots(datetime to = NULL) + { + // + bool has = drawValeSupSWLPivots; + if (!has) + { + return; + } + + // + has = detector.HasValeSupSWLPivots(); + if (!has) + { + return; + } + + // + bool canUpdateTo = IsValid(to); + + // + int count = detector.CountValeSupSWLPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox = detector.valeSupSWLPivots[i]; + + // + if (canUpdateTo) + { + iBox.to = to; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + iBox, + iObj // + ); + if (has) + { + // + // Style Object ... + iObj.BoxColor(valeSupSWLPivotsColor); + iObj.BoxWidth(valeSupSWLPivotsWidth); + iObj.BoxStyle(valeSupSWLPivotsStyle); + + // + // Store Object ... + mValeSupSWLPivotObjects.Add(iObj); + } + + // + iBox.Clean(); + ZeroMemory(iObj); + } + } + + // + void DrawPeakResSWHPivots(datetime to = NULL) + { + // + bool has = drawPeakResSWHPivots; + if (!has) + { + return; + } + + // + has = detector.HasPeakResSWHPivots(); + if (!has) + { + return; + } + + // + bool canUpdateTo = IsValid(to); + + // + int count = detector.CountPeakResSWHPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox = detector.peakResSWHPivots[i]; + + // + if (canUpdateTo) + { + iBox.to = to; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + iBox, + iObj // + ); + if (has) + { + // + // Style Object ... + iObj.BoxColor(peakResSWHPivotsColor); + iObj.BoxWidth(peakResSWHPivotsWidth); + iObj.BoxStyle(peakResSWHPivotsStyle); + + // + // Store Object ... + mPeakResSWHPivotObjects.Add(iObj); + } + + // + iBox.Clean(); + ZeroMemory(iObj); } } @@ -2391,32 +716,14 @@ class XCXCAEAPOIDrawer : public XCBase XCXCAEAPOIDetector *detector; // - CArrayObj mSWHPivotObjects; - CArrayObj mSWLPivotObjects; - CArrayObj mPeakPivotObjects; - CArrayObj mValePivotObjects; CArrayObj mRSIPeakPivotObjects; CArrayObj mRSIValePivotObjects; CArrayObj mCCIPeakPivotObjects; CArrayObj mCCIValePivotObjects; - CArrayObj mKIBullishPivotObjects; - CArrayObj mKIBearishPivotObjects; CArrayObj mFVGBullishPivotObjects; CArrayObj mFVGBearishPivotObjects; - CArrayObj mPeakSWHResPivotObjects; - CArrayObj mValeSWLSupPivotObjects; - CArrayObj mTKIBullishPivotObjects; - CArrayObj mTKIBearishPivotObjects; - CArrayObj mCycleSameLLPivotObjects; - CArrayObj mCycleSameHHPivotObjects; - CArrayObj mTrendBullishPivotObjects; - CArrayObj mTrendBearishPivotObjects; - CArrayObj mTKITRNDBullishPivotObjects; - CArrayObj mTKITRNDBearishPivotObjects; - CArrayObj mRSICrossedOverOSPivotObjects; - CArrayObj mRSICrossedUnderOBPivotObjects; - CArrayObj mCCICrossedOverOSPivotObjects; - CArrayObj mCCICrossedUnderOBPivotObjects; + CArrayObj mValeSupSWLPivotObjects; + CArrayObj mPeakResSWHPivotObjects; // }; diff --git a/XCAEA/Helpers/xcaea.helper.mq5 b/XCAEA/Helpers/xcaea.helper.mq5 index 761d55b3..be344d02 100644 --- a/XCAEA/Helpers/xcaea.helper.mq5 +++ b/XCAEA/Helpers/xcaea.helper.mq5 @@ -221,6 +221,10 @@ struct XCAEAConditions bool isKISwitchedToBullish; bool isKISwitchedToBearish; + // + bool isKIFinishedFromBullish; + bool isKIFinishedFromBearish; + // // TKI ... @@ -236,6 +240,10 @@ struct XCAEAConditions bool isTKISwitchedToBullish; bool isTKISwitchedToBearish; + // + bool isTKIFinishedFromBullish; + bool isTKIFinishedFromBearish; + // // VIDYA ... @@ -251,6 +259,10 @@ struct XCAEAConditions bool isVidyaSwitchedToBullish; bool isVidyaSwitchedToBearish; + // + bool isVidyaFinishedFromBullish; + bool isVidyaFinishedFromBearish; + // // SAR ... @@ -262,6 +274,10 @@ struct XCAEAConditions bool isSarSwitchedToBullish; bool isSarSwitchedToBearish; + // + bool isSarFinishedFromBullish; + bool isSarFinishedFromBearish; + // // PEAK ... @@ -293,6 +309,10 @@ struct XCAEAConditions bool isTrendSwitchedToBullish; bool isTrendSwitchedToBearish; + // + bool isTrendFinishedFromBullish; + bool isTrendFinishedFromBearish; + // // SUPPORT ... @@ -348,6 +368,14 @@ struct XCAEAConditions bool isPeakIsPivot; bool isValeIsPivot; + // + bool isPeakSwitchedToPivot; + bool isValeSwitchedToPivot; + + // + bool isPeakFinishedFromPivot; + bool isValeFinishedFromPivot; + // bool isSwingLowSameAsVale; bool isSwingHighSameAsPeak; @@ -408,7 +436,6 @@ struct XCAEAConditions double stochasticOSLevel; double stochasticReversalLevel; - // // Conditions ... @@ -730,6 +757,10 @@ struct XCAEAConditions isKISwitchedToBullish = false; isKISwitchedToBearish = false; + // + isKIFinishedFromBullish = false; + isKIFinishedFromBearish = false; + // // TKI ... @@ -745,6 +776,10 @@ struct XCAEAConditions isTKISwitchedToBullish = false; isTKISwitchedToBearish = false; + // + isTKIFinishedFromBullish = false; + isTKIFinishedFromBearish = false; + // // VIDYA ... @@ -760,6 +795,10 @@ struct XCAEAConditions isVidyaSwitchedToBullish = false; isVidyaSwitchedToBearish = false; + // + isVidyaFinishedFromBullish = false; + isVidyaFinishedFromBearish = false; + // // SAR ... @@ -771,6 +810,10 @@ struct XCAEAConditions isSarSwitchedToBullish = false; isSarSwitchedToBearish = false; + // + isSarFinishedFromBullish = false; + isSarFinishedFromBearish = false; + // // PEAK ... @@ -802,6 +845,10 @@ struct XCAEAConditions isTrendSwitchedToBullish = false; isTrendSwitchedToBearish = false; + // + isTrendFinishedFromBullish = false; + isTrendFinishedFromBearish = false; + // // SUPPORT ... @@ -857,6 +904,14 @@ struct XCAEAConditions isPeakIsPivot = false; isValeIsPivot = false; + // + isPeakSwitchedToPivot = false; + isValeSwitchedToPivot = false; + + // + isPeakFinishedFromPivot = false; + isValeFinishedFromPivot = false; + // isSwingLowSameAsVale = false; isSwingHighSameAsPeak = false; @@ -1875,7 +1930,6 @@ struct XCAEAConditions // string conditionsStr = - // // "-----------------------" + separator + "XCA: " + separator + @@ -1885,23 +1939,31 @@ struct XCAEAConditions ToString("isKIBullish", isKIBullish, ignoreFalseConditions, separator) + ToString("isKIBearish", isKIBearish, ignoreFalseConditions, separator) + ToString("isKISwitchedToBullish", isKISwitchedToBullish, ignoreFalseConditions, separator) + + ToString("isKIFinishedFromBullish", isKIFinishedFromBullish, ignoreFalseConditions, separator) + ToString("isKISwitchedToBearish", isKISwitchedToBearish, ignoreFalseConditions, separator) + + ToString("isKIFinishedFromBearish", isKIFinishedFromBearish, ignoreFalseConditions, separator) + ToString("isTKIRejectUp", isTKIRejectUp, ignoreFalseConditions, separator) + ToString("isTKIRejectDown", isTKIRejectDown, ignoreFalseConditions, separator) + ToString("isTKIBullish", isTKIBullish, ignoreFalseConditions, separator) + ToString("isTKIBearish", isTKIBearish, ignoreFalseConditions, separator) + ToString("isTKISwitchedToBullish", isTKISwitchedToBullish, ignoreFalseConditions, separator) + + ToString("isTKIFinishedFromBullish", isTKIFinishedFromBullish, ignoreFalseConditions, separator) + ToString("isTKISwitchedToBearish", isTKISwitchedToBearish, ignoreFalseConditions, separator) + + ToString("isTKIFinishedFromBearish", isTKIFinishedFromBearish, ignoreFalseConditions, separator) + ToString("isVidyaRejectUp", isVidyaRejectUp, ignoreFalseConditions, separator) + ToString("isVidyaRejectDown", isVidyaRejectDown, ignoreFalseConditions, separator) + ToString("isVidyaBullish", isVidyaBullish, ignoreFalseConditions, separator) + ToString("isVidyaBearish", isVidyaBearish, ignoreFalseConditions, separator) + ToString("isVidyaSwitchedToBullish", isVidyaSwitchedToBullish, ignoreFalseConditions, separator) + + ToString("isVidyaFinishedFromBullish", isVidyaFinishedFromBullish, ignoreFalseConditions, separator) + ToString("isVidyaSwitchedToBearish", isVidyaSwitchedToBearish, ignoreFalseConditions, separator) + + ToString("isVidyaFinishedFromBearish", isVidyaFinishedFromBearish, ignoreFalseConditions, separator) + ToString("isSarBullish", isSarBullish, ignoreFalseConditions, separator) + ToString("isSarBearish", isSarBearish, ignoreFalseConditions, separator) + ToString("isSarSwitchedToBullish", isSarSwitchedToBullish, ignoreFalseConditions, separator) + + ToString("isSarFinishedFromBullish", isSarFinishedFromBullish, ignoreFalseConditions, separator) + ToString("isSarSwitchedToBearish", isSarSwitchedToBearish, ignoreFalseConditions, separator) + + ToString("isSarFinishedFromBearish", isSarFinishedFromBearish, ignoreFalseConditions, separator) + ToString("isPeakSameLast", isPeakSameLast, ignoreFalseConditions, separator) + ToString("isPeakOverLast", isPeakOverLast, ignoreFalseConditions, separator) + ToString("isPeakUnderLast", isPeakUnderLast, ignoreFalseConditions, separator) + @@ -1913,7 +1975,9 @@ struct XCAEAConditions ToString("isTrendBullish", isTrendBullish, ignoreFalseConditions, separator) + ToString("isTrendBearish", isTrendBearish, ignoreFalseConditions, separator) + ToString("isTrendSwitchedToBullish", isTrendSwitchedToBullish, ignoreFalseConditions, separator) + + ToString("isTrendFinishedFromBullish", isTrendFinishedFromBullish, ignoreFalseConditions, separator) + ToString("isTrendSwitchedToBearish", isTrendSwitchedToBearish, ignoreFalseConditions, separator) + + ToString("isTrendFinishedFromBearish", isTrendFinishedFromBearish, ignoreFalseConditions, separator) + ToString("isSupportSameLast", isSupportSameLast, ignoreFalseConditions, separator) + ToString("isSupportOverLast", isSupportOverLast, ignoreFalseConditions, separator) + ToString("isSupportUnderLast", isSupportUnderLast, ignoreFalseConditions, separator) + @@ -1936,6 +2000,10 @@ struct XCAEAConditions ToString("isLastSwingHighRejected", isLastSwingHighRejected, ignoreFalseConditions, separator) + ToString("isPeakIsPivot", isPeakIsPivot, ignoreFalseConditions, separator) + ToString("isValeIsPivot", isValeIsPivot, ignoreFalseConditions, separator) + + ToString("isPeakSwitchedToPivot", isPeakSwitchedToPivot, ignoreFalseConditions, separator) + + ToString("isPeakFinishedFromPivot", isPeakFinishedFromPivot, ignoreFalseConditions, separator) + + ToString("isValeSwitchedToPivot", isValeSwitchedToPivot, ignoreFalseConditions, separator) + + ToString("isValeFinishedFromPivot", isValeFinishedFromPivot, ignoreFalseConditions, separator) + ToString("isSwingLowSameAsVale", isSwingLowSameAsVale, ignoreFalseConditions, separator) + ToString("isSwingHighSameAsPeak", isSwingHighSameAsPeak, ignoreFalseConditions, separator) + ToString("isSupportSameAsVale", isSupportSameAsVale, ignoreFalseConditions, separator) + @@ -2899,6 +2967,8 @@ class XCXCAEAHelper : XCBase conditions.isKISwitchedToBearish = xcaConditions.isKISwitchedToBearish; conditions.isLastSwingLowBreaked = xcaConditions.isLastSwingLowBreaked; conditions.isSwingHighSameAsPeak = xcaConditions.isSwingHighSameAsPeak; + conditions.isPeakSwitchedToPivot = xcaConditions.isPeakSwitchedToPivot; + conditions.isValeSwitchedToPivot = xcaConditions.isValeSwitchedToPivot; conditions.isTKISwitchedToBullish = xcaConditions.isTKISwitchedToBullish; conditions.isTKISwitchedToBearish = xcaConditions.isTKISwitchedToBearish; conditions.isLastSwingLowRejected = xcaConditions.isLastSwingLowRejected; @@ -2906,14 +2976,26 @@ class XCXCAEAHelper : XCBase conditions.isSarSwitchedToBearish = xcaConditions.isSarSwitchedToBearish; conditions.isLastSwingHighBreaked = xcaConditions.isLastSwingHighBreaked; conditions.isResistanceSameAsPeak = xcaConditions.isResistanceSameAsPeak; + conditions.isPeakFinishedFromPivot = xcaConditions.isPeakFinishedFromPivot; + conditions.isValeFinishedFromPivot = xcaConditions.isValeFinishedFromPivot; conditions.isLastSwingHighRejected = xcaConditions.isLastSwingHighRejected; conditions.isLastResistanceBreaked = xcaConditions.isLastResistanceBreaked; conditions.isSupportSameAsSwingLow = xcaConditions.isSupportSameAsSwingLow; + conditions.isKIFinishedFromBullish = xcaConditions.isKIFinishedFromBullish; + conditions.isKIFinishedFromBearish = xcaConditions.isKIFinishedFromBearish; + conditions.isTKIFinishedFromBullish = xcaConditions.isTKIFinishedFromBullish; + conditions.isTKIFinishedFromBearish = xcaConditions.isTKIFinishedFromBearish; + conditions.isSarFinishedFromBullish = xcaConditions.isSarFinishedFromBullish; + conditions.isSarFinishedFromBearish = xcaConditions.isSarFinishedFromBearish; conditions.isVidyaSwitchedToBullish = xcaConditions.isVidyaSwitchedToBullish; conditions.isVidyaSwitchedToBearish = xcaConditions.isVidyaSwitchedToBearish; conditions.isLastResistanceRejected = xcaConditions.isLastResistanceRejected; conditions.isTrendSwitchedToBullish = xcaConditions.isTrendSwitchedToBullish; conditions.isTrendSwitchedToBearish = xcaConditions.isTrendSwitchedToBearish; + conditions.isVidyaFinishedFromBullish = xcaConditions.isVidyaFinishedFromBullish; + conditions.isVidyaFinishedFromBearish = xcaConditions.isVidyaFinishedFromBearish; + conditions.isTrendFinishedFromBullish = xcaConditions.isTrendFinishedFromBullish; + conditions.isTrendFinishedFromBearish = xcaConditions.isTrendFinishedFromBearish; conditions.isResistanceSameAsSwingHigh = xcaConditions.isResistanceSameAsSwingHigh; // @@ -3040,11 +3122,11 @@ class XCXCAEAHelper : XCBase conditions.momentumBearishLevel = xocsConditions.momentumBearishLevel; conditions.stochasticOBLevel = xocsConditions.stochasticOBLevel; conditions.stochasticOSLevel = xocsConditions.stochasticOSLevel; - conditions.stochasticReversalLevel = xocsConditions.stochasticReversalLevel; + conditions.stochasticReversalLevel = xocsConditions.stochasticReversalLevel; // // Conditions ... - + // conditions.isCCIOB = xocsConditions.isCCIOB; conditions.isCCIOS = xocsConditions.isCCIOS; @@ -3185,4 +3267,4 @@ class XCXCAEAHelper : XCBase int stochasticHandler; }; -// \ No newline at end of file +// \ No newline at end of file diff --git a/XCAEA/Libraries/xcaea.signaller.lib.mq5 b/XCAEA/Libraries/xcaea.signaller.lib.mq5 index 1230ed7a..1a2f09f9 100644 --- a/XCAEA/Libraries/xcaea.signaller.lib.mq5 +++ b/XCAEA/Libraries/xcaea.signaller.lib.mq5 @@ -559,6 +559,21 @@ bool DetectXCAEAConditions( double p2Vale = conditions.valeBuffer[p2IDX]; double p3Vale = conditions.valeBuffer[p3IDX]; + // + // VIDYA ... + double zVidya = conditions.vidyaBuffer[zIDX]; + double cVidya = conditions.vidyaBuffer[cIDX]; + double pVidya = conditions.vidyaBuffer[pIDX]; + double p2Vidya = conditions.vidyaBuffer[p2IDX]; + double p3Vidya = conditions.vidyaBuffer[p3IDX]; + + // + double zVidyaState = conditions.vidyaStateBuffer[zIDX]; + double cVidyaState = conditions.vidyaStateBuffer[cIDX]; + double pVidyaState = conditions.vidyaStateBuffer[pIDX]; + double p2VidyaState = conditions.vidyaStateBuffer[p2IDX]; + double p3VidyaState = conditions.vidyaStateBuffer[p3IDX]; + // // RSI ... double zRSI = conditions.rsiBuffer[zIDX]; @@ -776,8 +791,11 @@ bool DetectXCAEAConditions( // // Detect Selected Box ... + XBoxZone oscBoxes[]; + XBoxZone lastOSCBox; double providedSL = 0; bool isBoxFVG = false; + bool hasOSCBox = false; bool hasPivotBox = false; bool isBoxPeakVale = false; bool isBoxRejected = false; @@ -831,6 +849,32 @@ bool DetectXCAEAConditions( isBoxPeakVale; if (!has) { + // + bool isOSC = Contains( + "XCA_CCI_VALE", + iBox.type // + ) || + Contains( + "XCA_CCI_PEAK", + iBox.type // + ) || + Contains( + "XCA_RSI_VALE", + iBox.type // + ) || + Contains( + "XCA_RSI_PEAK", + iBox.type // + ); + if (isOSC) + { + // + AddRef( + iBox, + oscBoxes // + ); + } + // iBox.Clean(); @@ -918,33 +962,78 @@ bool DetectXCAEAConditions( Clean(tmp); } + // + // Check OSC Boxes ... + bool hasOSCBoxes = HasChild(oscBoxes); + if (hasOSCBoxes) + { + // + // Detect Newest OSC Box ... + idx = GetYoungest(oscBoxes); + has = IsValidIndex(idx); + if (has) + { + lastOSCBox = oscBoxes[idx]; + } + + // + // Validate OSC Box is Valid or not ... + has = lastOSCBox.IsValid(); + if (has) + { + // + // Check Bar is Inside OSC Box or not ... + has = cBar.time > lastOSCBox.from && + cBar.time <= lastOSCBox.to; + if (!has) + { + lastOSCBox.Clean(); + } + } + + // + hasOSCBox = lastOSCBox.IsValid(); + if (hasOSCBox) + { + // // + // XCBoxObject *iObj; + // has = helper.poiDrawer.DrawBox( + // lastOSCBox, + // iObj // + // ); + // if (has) { + // iObj.BoxWidth(4); + // } + } + } + // // Force Conditions to Have Selected Box ... hasPivotBox = hasBoxes && pivotBox.IsValid(); if (hasPivotBox) { - // - pivotBox.to = TimeCurrent(); + // // + // pivotBox.to = TimeCurrent(); - // - // Draw Pivot Box Here ... - if (isBoxPeakVale) - { - // - XCBoxObject *iObj; - has = helper.poiDrawer.DrawBox( - pivotBox, - iObj // - ); - if (has) - { - // - iObj.BoxWidth(5); - iObj.BoxColor(clrDodgerBlue); - Print("Draw Pivot Box ..."); - } - } + // // + // // Draw Pivot Box Here ... + // if (isBoxPeakVale) + // { + // // + // XCBoxObject *iObj; + // has = helper.poiDrawer.DrawBox( + // pivotBox, + // iObj // + // ); + // if (has) + // { + // // + // iObj.BoxWidth(5); + // iObj.BoxColor(clrDodgerBlue); + // Print("Draw Pivot Box ..."); + // } + // } } // @@ -977,6 +1066,7 @@ bool DetectXCAEAConditions( // bool isCond1Bullish = // + false && hasPivotBox && isBoxPeakVale && isScoreBullish && @@ -992,6 +1082,7 @@ bool DetectXCAEAConditions( // bool isCond1Bearish = // + false && hasPivotBox && isBoxPeakVale && isScoreBearish && @@ -1023,19 +1114,25 @@ bool DetectXCAEAConditions( } // - // Cond2 Act Using Box Rejection ... + // Cond2 Act Using OSC Box and Vydia ... // bool isCond2Bullish = // - false + hasOSCBox && + // cVidyaState < 0 && + lastOSCBox.IsBullish() // && + // lastOSCBox.upper < cVidya // ; // bool isCond2Bearish = // - false + hasOSCBox && + // cVidyaState > 0 && + lastOSCBox.IsBearish() // && + // lastOSCBox.lower > cVidya // ; @@ -1052,6 +1149,8 @@ bool DetectXCAEAConditions( // Print("Cond2"); + isCond2Bullish = false; + isCond2Bearish = false; } // @@ -1168,6 +1267,7 @@ bool DetectXCAEAConditions( p2Bar.Clean(); p3Bar.Clean(); p4Bar.Clean(); + Clean(oscBoxes); pConditions.Clean(); // diff --git a/XCAEA/Signals/xcaea.signaller.class.mq5 b/XCAEA/Signals/xcaea.signaller.class.mq5 index c0bce114..8dc9e21c 100644 --- a/XCAEA/Signals/xcaea.signaller.class.mq5 +++ b/XCAEA/Signals/xcaea.signaller.class.mq5 @@ -182,6 +182,11 @@ class XCXCAEASignaller : XCBase detector.Update( zIndex // ); + + // + if (detector.newValeSupSWLPivotDetected) { + Print("Salam"); + } // // Validate Pivots ... @@ -197,29 +202,29 @@ class XCXCAEASignaller : XCBase // // Retrieve Valid Boxes ... - // - // Bullish ... - int bullishBoxesCount = - detector - .FillBullishBoxes(bullishBoxes); + // // + // // Bullish ... + // int bullishBoxesCount = + // detector + // .FillBullishBoxes(bullishBoxes); - // - // Bearish ... - int bearishBoxesCount = - detector - .FillBearishBoxes(bearishBoxes); + // // + // // Bearish ... + // int bearishBoxesCount = + // detector + // .FillBearishBoxes(bearishBoxes); - // - Copy( - bullishBoxes, - boxes, - false // - ); - Copy( - bearishBoxes, - boxes, - false // - ); + // // + // Copy( + // bullishBoxes, + // boxes, + // false // + // ); + // Copy( + // bearishBoxes, + // boxes, + // false // + // ); int boxesCount = ArraySize(boxes); bool hasBoxes = IsValidSize(boxesCount); @@ -267,32 +272,33 @@ class XCXCAEASignaller : XCBase // // - if (hasBoxes) + // if (hasBoxes) + // { + // } + + // + // Detect Sinal Box ... + hasSignalBox = DetectXCAEAConditions( + boxes, + conditions, + pivotBox, + signalBox, + additionalSL, + signalBoxDir, + helper, + zIndex, + loopback // + ); + + // + // Make Pivot Box UnAvailable ... + if (pivotBox.IsValid()) { // - // Detect Sinal Box ... - hasSignalBox = DetectXCAEAConditions( - boxes, - conditions, + AddRef( pivotBox, - signalBox, - additionalSL, - signalBoxDir, - helper, - zIndex, - loopback // + unAvailableBoxes // ); - - // - // Make Pivot Box UnAvailable ... - if (pivotBox.IsValid()) - { - // - AddRef( - pivotBox, - unAvailableBoxes // - ); - } } // @@ -701,9 +707,10 @@ class XCXCAEASignaller : XCBase // inputs.caInputs.showKI = true; - inputs.caInputs.showTKI = true; - inputs.caInputs.showSar = true; - inputs.caInputs.showTrend = true; + inputs.caInputs.showTKI = false; + inputs.caInputs.showSar = false; + inputs.caInputs.showVidya = true; + inputs.caInputs.showTrend = false; inputs.caInputs.showSwings = false; inputs.caInputs.showLongCycle = false; inputs.caInputs.showHindCycle = false; @@ -746,103 +753,33 @@ class XCXCAEASignaller : XCBase detector = new XCXCAEAPOIDetector(helper); // - detector.detectSWHPivot = false; - detector.detectSWLPivot = false; - detector.detectPeakPivot = false; - detector.detectValePivot = false; - detector.detectRSIPeakPivot = true; - detector.detectRSIValePivot = true; - detector.detectCCIPeakPivot = true; - detector.detectCCIValePivot = true; - detector.detectKIBullishPivot = false; - detector.detectKIBearishPivot = false; - detector.detectFVGBullishPivot = true; - detector.detectFVGBearishPivot = true; - detector.detectPeakSWHResPivot = true; - detector.detectValeSWLSupPivot = true; - detector.detectTKIBullishPivot = false; - detector.detectCycleSameLLPivot = false; - detector.detectCycleSameHHPivot = false; - detector.detectTKIBearishPivot = false; - detector.detectTrendBullishPivot = true; - detector.detectTrendBearishPivot = true; - detector.detectTKITRNDBullishPivot = false; - detector.detectTKITRNDBearishPivot = false; - detector.detectRSICrossedOverOSPivot = false; - detector.detectRSICrossedUnderOBPivot = false; - detector.detectCCICrossedOverOSPivot = false; - detector.detectCCICrossedUnderOBPivot = false; + // Configure Detector ... + detector.detectRSIPeakPivots = true; + detector.detectRSIValePivots = true; + detector.detectCCIPeakPivots = true; + detector.detectCCIValePivots = true; + detector.detectFVGBullishPivots = true; + detector.detectFVGBearishPivots = true; + detector.detectValeSupSWLPivots = true; + detector.detectPeakResSWHPivots = true; // // Initialize and Configure Drawer ... drawer = new XCXCAEAPOIDrawer(detector); + // + // Configure Drawer ... + drawer.drawRSIPeakPivots = true; + drawer.drawRSIValePivots = true; + drawer.drawCCIPeakPivots = true; + drawer.drawCCIValePivots = true; + drawer.drawFVGBullishPivots = true; + drawer.drawFVGBearishPivots = true; + drawer.drawValeSupSWLPivots = true; + drawer.drawPeakResSWHPivots = true; + // // UnActive Pivots ... - drawer.drawSWHPivots = false; - drawer.drawSWLPivots = false; - drawer.drawPeakPivots = false; - drawer.drawValePivots = false; - drawer.drawRSIPeakPivots = true; // true; - drawer.drawRSIValePivots = true; // true; - drawer.drawCCIPeakPivots = false; // true; - drawer.drawCCIValePivots = false; // true; - drawer.drawKIBullishPivots = false; - drawer.drawKIBearishPivots = false; - drawer.drawFVGBullishPivots = false; - drawer.drawFVGBearishPivots = false; - drawer.drawPeakSWHResPivots = false; // true; - drawer.drawValeSWLSupPivots = false; // true; - drawer.drawTKIBullishPivots = false; - drawer.drawTKIBearishPivots = false; - drawer.drawPVFVGBullishPivots = false; // true; - drawer.drawPVFVGBearishPivots = false; // true; - drawer.drawCycleSameLLPivots = false; - drawer.drawCycleSameHHPivots = false; - drawer.drawTrendBullishPivots = false; - drawer.drawTrendBearishPivots = false; - drawer.drawTKITRNDBullishPivots = false; - drawer.drawTKITRNDBearishPivots = false; - drawer.drawRSICrossedOverOSPivots = true; - drawer.drawRSICrossedUnderOBPivots = true; - drawer.drawCCICrossedOverOSPivots = false; - drawer.drawCCICrossedUnderOBPivots = false; - - // - drawer.drawTicks = true; - - // - // Configure Width ... - drawer.peakPivotWidth = 1; - drawer.valePivotWidth = 1; - drawer.ticksBullishWidth = 2; - drawer.ticksBearishWidth = 2; - drawer.fvgBullishPivotWidth = 1; - drawer.fvgBearishPivotWidth = 1; - drawer.oscsBullishPivotWidth = 2; - drawer.oscsBearishPivotWidth = 2; - - // - // Configure Colors ... - drawer.peakPivotColor = clrMagenta; - drawer.valePivotColor = clrAqua; - drawer.ticksBullishColor = clrYellow; - drawer.ticksBearishColor = clrOrange; - drawer.fvgBullishPivotColor = clrLime; - drawer.fvgBearishPivotColor = clrRed; - drawer.oscsBullishPivotColor = clrYellow; - drawer.oscsBearishPivotColor = clrOrange; - - // - // Configure Style ... - drawer.peakPivotStyle = STYLE_SOLID; - drawer.valePivotStyle = STYLE_SOLID; - drawer.ticksBullishStyle = STYLE_DOT; - drawer.ticksBearishStyle = STYLE_DOT; - drawer.fvgBullishPivotStyle = STYLE_DASH; - drawer.fvgBearishPivotStyle = STYLE_DASH; - drawer.oscsBullishPivotStyle = STYLE_SOLID; - drawer.oscsBearishPivotStyle = STYLE_SOLID; } /**