From 70d673b6d7cf71b908c9595385b321299540a72c Mon Sep 17 00:00:00 2001 From: Hadi Khazaee Asl Date: Sat, 3 May 2025 21:59:49 +0330 Subject: [PATCH] works on poi detector ... --- Documents/BKP/2.mq5 | 449 ++ .../BKP/xcaea.x-poi.detector.class.bkp.mq5 | 4936 +++++++++++++++++ .../BKP/xcaea.x-poi.drawer.class.bkp.mq5 | 2329 ++++++++ Documents/Temlates/temp.pivot.detect.mq5 | 83 + XCAEA/Classes/xcaea.x-poi.detector.class.mq5 | 4459 ++++----------- XCAEA/Classes/xcaea.x-poi.drawer.class.mq5 | 1923 +------ XCAEA/Libraries/xcaea.signaller.lib.mq5 | 268 +- XCAEA/Signals/xcaea.signaller.class.mq5 | 198 +- 8 files changed, 9017 insertions(+), 5628 deletions(-) create mode 100644 Documents/BKP/2.mq5 create mode 100644 Documents/BKP/xcaea.x-poi.detector.class.bkp.mq5 create mode 100644 Documents/BKP/xcaea.x-poi.drawer.class.bkp.mq5 create mode 100644 Documents/Temlates/temp.pivot.detect.mq5 diff --git a/Documents/BKP/2.mq5 b/Documents/BKP/2.mq5 new file mode 100644 index 00000000..68f4b907 --- /dev/null +++ b/Documents/BKP/2.mq5 @@ -0,0 +1,449 @@ + // + void ApplyManalyswerValidation( + XBoxZone &pivots[], + int barIndex = 0 // + ) + { + // + int zIDX = 0; + int cIDX = zIDX + 1; + int pIDX = cIDX + 1; + int p2IDX = pIDX + 1; + + // + barIndex = NormalizeInt(barIndex, 0); + + // + bool has = HasChild(pivots); + if (!has) + { + return; + } + + // + XBoxZone tmp[]; + Copy( + pivots, + tmp // + ); + Clean(pivots); + while (HasChild(tmp)) + { + // + XBoxZone iPivot = tmp[0]; + ArrayRemove( + tmp, + 0, + 1 // + ); + + // + // Retrieve Pivot info ... + // int toIDX = iPivot.ToIndex(); + // int fromIDX = iPivot.FromIndex(); + // bool isBullish = iPivot.IsBullish(); + + // + // Retrieve Conditions ... + // XCAEAConditions conditions; + // has = helper.GetConditions( + // conditions, + // toIDX, + // 5 // + // ); + + // + // Retrieve Bars ... + + // + // XOHCL cBar; + // XOHCL pBar; + // XOHCL p2Bar; + + // // + // has = + // has && + // cBar.Init( + // conditions.symbol, + // conditions.period, + // toIDX // + // ); + // has = has && + // cBar.GetPreviousBar(pBar); + // has = has && + // pBar.GetPreviousBar(p2Bar); + // if (!has) + // { + // // + // cBar.Clean(); + // pBar.Clean(); + // p2Bar.Clean(); + // iPivot.Clean(); + // conditions.Clean(); + + // // + // continue; + // } + + // + // Reading Conditions ... + + // // + // // MAL ... + // double zMAL = conditions.malBuffer[zIDX]; + // double cMAL = conditions.malBuffer[cIDX]; + // double pMAL = conditions.malBuffer[pIDX]; + // double p2MAL = conditions.malBuffer[p2IDX]; + + // // + // // MAC ... + // double zMAC = conditions.macBuffer[zIDX]; + // double cMAC = conditions.macBuffer[cIDX]; + // double pMAC = conditions.macBuffer[pIDX]; + // double p2MAC = conditions.macBuffer[p2IDX]; + + // // + // // MAH ... + // double zMAH = conditions.mahBuffer[zIDX]; + // double cMAH = conditions.mahBuffer[cIDX]; + // double pMAH = conditions.mahBuffer[pIDX]; + // double p2MAH = conditions.mahBuffer[p2IDX]; + + // + // Checking Conditions ... + // has = isBullish + // ? cBar.high < cMAL || + // pBar.high < pMAL + // : cBar.low < cMAH || + // pBar.low < pMAL; + + // + has = + isBullish + ? iPivot. + if (has) + { + // + AddRef( + iPivot, + pivots // + ); + } + + // + // Cleanup Resources ... + // cBar.Clean(); + // pBar.Clean(); + // p2Bar.Clean(); + iPivot.Clean(); + // conditions.Clean(); + } + + // + Clean(tmp); + } + + +////////////////////////////////////////////////////////////// + + + // + // Parsing Pivots ... + XBoxZone rciPivot; + double providedSL = 0; + XBoxZone rejectedPivot; + XBoxZone insidePivots[]; + XBoxZone rciContainers[]; + int insidePivotsCount = 0; + bool isRejectedOnMid = false; + bool hasInsidePivots = false; + bool hasRCIContainers = false; + bool hasPivots = HasChild(pivots); + if (hasPivots) + { + // + // drawer.DrawBoxes( + // pivots, + // TimeCurrent() // + // ); + + // + // Select Inside Boxes ... + + // + ENUM_XCA_PIVOTS allowedInsidePivots[] = { + XCA_FVG_BULL, + XCA_FVG_BEAR, + XCA_PEAKSWHRES, + XCA_VALESWLSUP, + XCA_TREND_BULL, + XCA_TREND_BEAR, + }; + insidePivotsCount = SelectInsideBoxes( + allowedInsidePivots, + insidePivots, + pivots, + zBar, + cBar, + pBar, + p2Bar // + ); + hasInsidePivots = IsValidSize(insidePivotsCount); + if (hasInsidePivots) + { + // + // drawer.DrawBoxes( + // insidePivots, + // zBar.time // + // ); + } + + // + // Detect Rejected Pivot ... + ENUM_XCA_PIVOTS allowedRejectedPivots[] = { + XCA_FVG_BULL, + XCA_FVG_BEAR, + // XCA_PEAKSWHRES, + // XCA_VALESWLSUP, + // XCA_TREND_BULL, + // XCA_TREND_BEAR, + }; + has = SelectRejectedBox( + allowedRejectedPivots, + rejectedPivot, + isRejectedOnMid, + pivots, + zBar, + cBar, + pBar, + p2Bar, + false, // Ignore Mid Rejection ... + true, + true // + ); + + // + // Select CCI/RSI Cross Object ... + count = ArraySize(pivots); + for (int i = 0; i < count; i++) + { + // + XBoxZone iPivot = pivots[i]; + + // + ENUM_XCA_PIVOTS iType = GetPivotType(iPivot); + + // + // Checking Type is Passed ... + has = + // + iType == XCA_RSI_COOS || + iType == XCA_CCI_COOS || + iType == XCA_RSI_CUOB || + iType == XCA_CCI_CUOB + // + ; + + // + // Checking cBar is Pivots' Last Bar ... + has = + has && + cBar.time <= iPivot.to && + cBar.time > iPivot.from; + if (has) + { + // + rciPivot = iPivot; + + // + iPivot.Clean(); + + // + break; + } + + // + iPivot.Clean(); + } + + // + // Detect RCI Pivot Containers Pivots ... + count = ArraySize(pivots); + has = rciPivot.IsValid(); + if (has) + { + // + for (int i = 0; i < count; i++) + { + // + XBoxZone iPivot = pivots[i]; + + // + ENUM_XCA_PIVOTS iType = GetPivotType(iPivot); + + // + // Checking Type is Passed ... + has = + // + IsValid(iType) && + (iType == XCA_PEAKSWHRES || + iType == XCA_VALESWLSUP) + // + ; + + // + // Check Dir is Passed ... + has = + has && + rciPivot.dir == iPivot.dir; + + // + // Check RCI Pivot is Inside Pivot ... + has = + has && + // + ( + // + (rciPivot.lower >= iPivot.lower && + rciPivot.lower < iPivot.upper) + // + || + // + (rciPivot.upper <= iPivot.upper && + rciPivot.upper > iPivot.lower) + // + || + // + (rciPivot.upper > iPivot.upper && + rciPivot.lower < iPivot.lower) + // + ) + // + ; + + // + if (has) + { + // + AddRef( + iPivot, + rciContainers // + ); + } + + // + iPivot.Clean(); + } + + // + hasRCIContainers = HasChild(rciContainers); + } + } + +///////////////////////////////////////////////////////////////////// + + + // + // Box Based Conditions ... + + // + // if (isCBarHasStrongATR) + // { + // // + // Print(ToString(cBar.GetDirection()), " ATR Growing ..."); + // } + + // + // bool isZeroVScore = isScoreNeutural || + // isVolumeNeutural; + + // // + // bool isBullishTested = + // isZeroVScore && + // isCBarValidForBullish // && + // // rejectedPivot.IsValid() && + // // rejectedPivot.IsBullish() + // ; + // bool isBearishTested = + // isZeroVScore && + // isCBarValidForBearish // && + // // rejectedPivot.IsValid() && + // // rejectedPivot.IsBearish() + // ; + + // // + // bool isTested = + // // + // isBullishTested || + // isBearishTested + // // + // ; + // if (isTested) + // { + // // + // Print("Zero Volume ..."); + // } + + +///////////////////////////////////////////////////////////////////// + + + // + bool isCond2Bullish = + // + false // && + // + // conditions. + // + // zPeak > cPeak && + // zBar.close > cPeak && + // ((zPeak - cPeak) > 2 * points) && + // + // z3MAFastState > 0 && + // isValeGoldenRejected && + // isCBarBullishRejected && + // conditions.isValeIsPivot + // + // isPCCIOS && + // isRSIBullish && + // conditions.isCloseUnderMal + // rciPivot.IsValid() && + // rciPivot.IsBullish() && + // isCCIBullish && + // cBar.close > c3MAFast + // isADXBullish && + // hasRCIContainers && + // conditions.isValeIsPivot && + // (conditions.isRSICrossedOverOS || + // conditions.isCCICrossedOverOS) // && + // conditions.swingLowBuffer[cIDX] < conditions.fiboLevel3Buffer[cIDX] + // // + ; + + // + bool isCond2Bearish = + // + false // && + // + // z3MAFastState < 0 && + // isPeakGoldenRejected && + // isCBarBullishRejected && + // conditions.isPeakIsPivot + // + // isPCCIOB && + // isRSIBearish && + // c3MAFastState < 0 && + // conditions.isCloseOverMah + // rciPivot.IsValid() && + // rciPivot.IsBearish() && + // conditions.isRSIOB && + // isCCIBearish && + // cBar.close < c3MAFast + // isADXBearish && + // hasRCIContainers && + // conditions.isPeakIsPivot && + // (conditions.isRSICrossedUnderOB || + // conditions.isCCICrossedUnderOB) // && + // conditions.swingHighBuffer[cIDX] > conditions.fiboLevel1Buffer[cIDX] + // // + ; diff --git a/Documents/BKP/xcaea.x-poi.detector.class.bkp.mq5 b/Documents/BKP/xcaea.x-poi.detector.class.bkp.mq5 new file mode 100644 index 00000000..7fc68ece --- /dev/null +++ b/Documents/BKP/xcaea.x-poi.detector.class.bkp.mq5 @@ -0,0 +1,4936 @@ +/////////////////////////////////////////////////////// +// +// 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_TICK, // Tick + XCA_VOLUME, // Volume + 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_PEAKSWHRES, // PeakSWHRes + XCA_VALESWLSUP, // ValeSWLSup + XCA_TREND_BULL, // TrendBull + XCA_TREND_BEAR, // TrendBear +}; + +// +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; +} + +// +ENUM_X_DIRECTION GetDirection(ENUM_XCA_PIVOTS value) +{ + // + ENUM_X_DIRECTION result = X_DIRECTION_NONE; + + // + switch (value) + { + // + case XCA_FVG_BULL: + case XCA_RSI_COOS: + case XCA_RSI_VALE: + case XCA_CCI_COOS: + case XCA_CCI_VALE: + case XCA_TREND_BULL: + case XCA_VALESWLSUP: + result = X_DIRECTION_BULLISH; + break; + + // + case XCA_FVG_BEAR: + case XCA_RSI_CUOB: + case XCA_RSI_PEAK: + case XCA_CCI_CUOB: + case XCA_CCI_PEAK: + case XCA_TREND_BEAR: + case XCA_PEAKSWHRES: + result = X_DIRECTION_BEARISH; + break; + } + + // + return result; +} + +// +string GetBoxType(ENUM_XCA_PIVOTS value) +{ + // + string result = NULL; + + // + switch (value) + { + // + case XCA_TICK: + case XCA_VOLUME: + case XCA_RSI_COOS: + case XCA_RSI_VALE: + case XCA_CCI_COOS: + case XCA_CCI_VALE: + case XCA_RSI_CUOB: + case XCA_RSI_PEAK: + case XCA_CCI_CUOB: + case XCA_CCI_PEAK: + case XCA_VALESWLSUP: + case XCA_PEAKSWHRES: + result = ToString(value); + break; + // + case XCA_FVG_BULL: + case XCA_FVG_BEAR: + result = "XCA_FVG"; + break; + + // + case XCA_TREND_BULL: + case XCA_TREND_BEAR: + result = "XCA_TREND"; + break; + } + + // + return result; +} + +// +ENUM_XCA_PIVOTS GetPivotType(XBoxZone &value) +{ + // + ENUM_XCA_PIVOTS result = XCA_NONE; + + // + bool has = value.IsValid(); + if (!has) + { + return result; + } + + // + bool isTick = value.type == GetBoxType(XCA_TICK); + bool isVolume = value.type == GetBoxType(XCA_VOLUME); + bool isFVGBull = value.type == GetBoxType(XCA_FVG_BULL) && + value.dir == GetDirection(XCA_FVG_BULL); + bool isFVGBear = value.type == GetBoxType(XCA_FVG_BEAR) && + value.dir == GetDirection(XCA_FVG_BEAR); + bool isRSIPeak = value.type == GetBoxType(XCA_RSI_PEAK) && + value.dir == GetDirection(XCA_RSI_PEAK); + bool isRSIVale = value.type == GetBoxType(XCA_RSI_VALE) && + value.dir == GetDirection(XCA_RSI_VALE); + bool isCCIPeak = value.type == GetBoxType(XCA_CCI_PEAK) && + value.dir == GetDirection(XCA_CCI_PEAK); + bool isCCIVale = value.type == GetBoxType(XCA_CCI_VALE) && + value.dir == GetDirection(XCA_CCI_VALE); + bool isRSICrossedOverOS = value.type == GetBoxType(XCA_RSI_COOS) && + value.dir == GetDirection(XCA_RSI_COOS); + bool isRSICrossedUnderOB = value.type == GetBoxType(XCA_RSI_CUOB) && + value.dir == GetDirection(XCA_RSI_CUOB); + bool isCCICrossedOverOS = value.type == GetBoxType(XCA_CCI_COOS) && + value.dir == GetDirection(XCA_CCI_COOS); + bool isCCICrossedUnderOB = value.type == GetBoxType(XCA_CCI_CUOB) && + value.dir == GetDirection(XCA_CCI_CUOB); + bool isTrendBullish = value.type == GetBoxType(XCA_TREND_BULL) && + value.dir == GetDirection(XCA_TREND_BULL); + bool isTrendBearish = value.type == GetBoxType(XCA_TREND_BEAR) && + value.dir == GetDirection(XCA_TREND_BEAR); + bool isPeakSWHRes = value.type == GetBoxType(XCA_PEAKSWHRES) && + value.dir == GetDirection(XCA_PEAKSWHRES); + bool isValeSWLSup = value.type == GetBoxType(XCA_VALESWLSUP) && + value.dir == GetDirection(XCA_VALESWLSUP); + + // + if (isTick) + { + result = XCA_TICK; + } + else if (isVolume) + { + result = XCA_VOLUME; + } + else if (isFVGBull) + { + result = XCA_FVG_BULL; + } + else if (isFVGBear) + { + result = XCA_FVG_BEAR; + } + else if (isRSIPeak) + { + result = XCA_RSI_PEAK; + } + else if (isRSIVale) + { + result = XCA_RSI_VALE; + } + else if (isCCIPeak) + { + result = XCA_CCI_PEAK; + } + else if (isCCIVale) + { + result = XCA_CCI_VALE; + } + else if (isRSICrossedOverOS) + { + result = XCA_RSI_COOS; + } + else if (isRSICrossedUnderOB) + { + result = XCA_RSI_CUOB; + } + else if (isCCICrossedOverOS) + { + result = XCA_CCI_COOS; + } + else if (isCCICrossedUnderOB) + { + result = XCA_CCI_CUOB; + } + else if (isTrendBullish) + { + result = XCA_TREND_BULL; + } + else if (isTrendBearish) + { + result = XCA_TREND_BEAR; + } + else if (isPeakSWHRes) + { + result = XCA_PEAKSWHRES; + } + else if (isValeSWLSup) + { + result = XCA_VALESWLSUP; + } + + // + return result; +} + +// +int ExtractPivots( + XBoxZone &extracted[], + ENUM_XCA_PIVOTS type, + XBoxZone &source[] // +) +{ + // + int result = 0; + + // + Clean(extracted); + + // + bool has = + IsValid(type) && + HasChild(source); + if (!has) + { + return result; + } + + // + int count = ArraySize(source); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox = source[i]; + + // + ENUM_XCA_PIVOTS iType = GetPivotType(iBox); + + // + has = iType == type; + if (has) + { + // + AddRef( + iBox, + extracted // + ); + } + + // + iBox.Clean(); + } + + // + result = ArraySize(extracted); + + // + 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 = GetDirection(type); + + // + 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 = GetBoxType(type); + box.type = typeStr; + + // + box.upper = + isBullish + ? reserve + : value; + box.lower = + isBullish + ? value + : reserve; + + // + result = box.IsValid(); + if (!result) + { + box.Clean(); + } + + // + return result; + } + + // +}; + +// +struct XCATRENDFVG +{ + // + XBoxZone trend; + XBoxZone fvgs[]; + + // + XCATRENDFVG() + { + Clean(); + } + + // + // Tools ... + + // + void Clean() + { + // + Clean(fvgs); + trend.Clean(); + + // + ZeroMemory(this); + } + + // + bool IsValid() + { + // + bool result = false; + + // + result = trend.IsValid(); + + // + return result; + } + + // + void AddFVG(XBoxZone &fvg) + { + // + bool has = trend.IsValid() && + fvg.IsValid() && + fvg.dir == trend.dir; + if (!has) + { + return; + } + + // + int idx = -1; + has = FindBoxIndex( + idx, + fvg, + fvgs // + ); + if (has) + { + return; + } + + // + AddRef( + fvg, + fvgs // + ); + } + + // + bool IsBullish() + { + return IsValid() && + trend.IsBullish(); + } + + // + bool IsBearish() + { + return IsValid() && + trend.IsBearish(); + } + + // + bool GetSelectedFVG(XBoxZone &fvg) + { + // + bool result = false; + + // + fvg.Clean(); + + // + result = IsValid(); + if (!result) + { + return result; + } + + // + int idx = -1; + if (IsBullish()) + { + idx = GetLowest(fvgs); + } + else if (IsBearish()) + { + idx = GetHighest(fvgs); + } + result = IsValidIndex(idx); + if (!result) + { + return result; + } + + // + fvg = fvgs[idx]; + + // + result = fvg.IsValid(); + + // + return result; + } + + // +}; + +// +int ExtractTrendFVGs( + XBoxZone &extracteds[], + XBoxZone &trend, + XBoxZone &fvgs[] // +) +{ + // + int result = 0; + + // + Clean(extracteds); + + // + bool has = HasChild(fvgs) && + trend.IsValid(); + if (!has) + { + return result; + } + + // + // Check Trend Box Pivot is Valid Trend ... + ENUM_XCA_PIVOTS iType = GetPivotType(trend); + has = iType == XCA_TREND_BULL || + iType == XCA_TREND_BEAR; + if (!has) + { + return result; + } + + // + int count = ArraySize(fvgs); + for (int i = 0; i < count; i++) + { + // + XBoxZone iFVG = fvgs[i]; + + // + bool isDirPassed = iFVG.dir == trend.dir; + bool isPricePassed = iFVG.upper <= trend.upper && + iFVG.lower >= trend.lower; + bool isFromPassed = iFVG.from > trend.from; + has = + isDirPassed && + isFromPassed && + isPricePassed; + if (has) + { + // + AddRef( + iFVG, + extracteds // + ); + } + + // + iFVG.Clean(); + } + + // + result = ArraySize(extracteds); + + // + return result; +} + +// +int ExtractTrendPivots( + XCATRENDFVG &items[], + XBoxZone &boxes[] // +) +{ + // + int result = 0; + + // + Clean(items); + + // + bool has = HasChild(boxes); + if (!has) + { + return result; + } + + // + // Extract Trend Boxes ... + XBoxZone tmp[]; + XBoxZone trendBoxes[]; + ExtractPivots( + tmp, + XCA_TREND_BULL, + boxes // + ); + Copy( + tmp, + trendBoxes, + false // + ); + Clean(tmp); + ExtractPivots( + tmp, + XCA_TREND_BEAR, + boxes // + ); + Copy( + tmp, + trendBoxes, + false // + ); + Clean(tmp); + + // + // Check Trend Boxes Exists ... + has = HasChild(trendBoxes); + if (!has) + { + // + Clean(trendBoxes); + return result; + } + + // + // Extract FVG Boxes ... + XBoxZone fvgBoxes[]; + + // + ExtractPivots( + tmp, + XCA_FVG_BULL, + boxes // + ); + Copy( + tmp, + fvgBoxes, + false // + ); + Clean(tmp); + ExtractPivots( + tmp, + XCA_FVG_BEAR, + boxes // + ); + Copy( + tmp, + fvgBoxes, + false // + ); + Clean(tmp); + bool hasFVGs = HasChild(fvgBoxes); + int fvgsCount = ArraySize(fvgBoxes); + + // + // Loop through Trend Boxes to Extract XCATRENDFVG Models ... + int count = ArraySize(trendBoxes); + for (int i = 0; i < count; i++) + { + // + XBoxZone iTrendBox = trendBoxes[i]; + + // + XCATRENDFVG iTrendFVG; + iTrendFVG.trend = iTrendBox; + + // + XBoxZone fvgs[]; + if (hasFVGs) + { + // + int fvgsCount = ExtractTrendFVGs( + fvgs, + iTrendBox, + fvgBoxes // + ); + + // + Copy( + fvgs, + iTrendFVG.fvgs // + ); + } + + // + has = iTrendFVG.IsValid(); + if (has) + { + // + AddRef( + iTrendFVG, + items // + ); + } + + // + iTrendBox.Clean(); + iTrendFVG.Clean(); + } + + // + Clean(tmp); + Clean(fvgBoxes); + Clean(trendBoxes); + + // + result = ArraySize(items); + + // + return result; +} + +// +int GetOldest(XCATRENDFVG &items[]) +{ + // + int result = -1; + + // + bool has = HasChild(items); + if (!has) + { + return result; + } + + // + XCATRENDFVG item; + int count = ArraySize(items); + for (int i = 0; i < count; i++) + { + // + XCATRENDFVG iTrendFVG = items[i]; + + // + bool canSet = + !item.IsValid() + ? true + : item.trend.from > iTrendFVG.trend.from; + if (canSet) + { + // + result = i; + item = iTrendFVG; + } + + // + iTrendFVG.Clean(); + } + + // + has = IsValidIndex(result); + item.Clean(); + + // + return result; +} + +// +// Implementations ... +class XCXCAEAPOIDetector : public XCBase +{ + // + // Public ... + public: + // + // Props ... + + // + // Pivot Verifications and Max Allowed Holding Items ... + int maxAllowedPivots; // Max Allowed Holding Pibots ... + int pivotVerifications; // Pivots Verifications ... + int pivotDetectionLoopbac; // Pivots Detection Loopback ... + double ticksDividerInPoints; // Ticks and Volume Detection Divider in Point ... + ENUM_TIMEFRAMES ticksDetectionPerid; // Ticks and Volume Detection Loopback ... + + // + // FVG Validations ... + int maxAllowedFVGsAge; + bool validateFVGsUsingPV; + bool validateFVGsUsingMANALYSER; + + // + // TREND ... + XBoxZone trendPivotP; // Prev Pivot of Market Trend ... + XBoxZone trendPivotC; // Current Pivot of Market Trend ... + ENUM_X_DIRECTION trendDir; // Trend Direction ... + + // + // Breaked Pivots ... + XBoxZone invalidPivots[]; + + // + // TICK Pivots ... + + // + bool detectTickPivots; + XBoxZone tickPivots[]; + + // + // VOLUME Pivots ... + + // + bool detectVolumePivots; + XBoxZone volumePivots[]; + + // + // RSI Peak Pivot ... + + // + bool detectRSIPeakPivots; + XBoxZone rsiPeakPivots[]; + bool newRSIPeakPivotDetected; + + // + // RSI Vale Pivot ... + + // + bool detectRSIValePivots; + XBoxZone rsiValePivots[]; + bool newRSIValePivotDetected; + + // + // CCI Peak Pivot ... + + // + bool detectCCIPeakPivots; + XBoxZone cciPeakPivots[]; + bool newCCIPeakPivotDetected; + + // + // CCI Vale Pivot ... + + // + bool detectCCIValePivots; + XBoxZone cciValePivots[]; + bool newCCIValePivotDetected; + + // + // FVG Bullish Pivots ... + + // + bool detectFVGBullishPivots; + XBoxZone fvgBullishPivots[]; + bool newFVGBullishPivotDetected; + + // + // FVG Bearish Pivots ... + + // + bool detectFVGBearishPivots; + XBoxZone fvgBearishPivots[]; + bool newFVGBearishPivotDetected; + + // + // 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; + + // + // TREND Bullish ... + + // + XCAPivot trendBullishPivot; + XBoxZone trendBullishFVGs[]; + bool detectTrendBullishPivots; + XCATRENDFVG trendBullishPivots[]; + bool newTrendBullishPivotDetected; + + // + // TREND Bearish ... + + // + XCAPivot trendBearishPivot; + XBoxZone trendBearishFVGs[]; + bool detectTrendBearishPivots; + XCATRENDFVG trendBearishPivots[]; + bool newTrendBearishPivotDetected; + + // + // RSI Crossed Over OS Pivot ... + + // + bool detectRSICrossedOverOSPivots; + XBoxZone rsiCrossedOverOSPivots[]; + bool newRSICrossedOverOSPivotDetected; + + // + // RSI Crossed Under OB Pivot ... + + // + bool detectRSICrossedUnderOBPivots; + XBoxZone rsiCrossedUnderOBPivots[]; + bool newRSICrossedUnderOBPivotDetected; + + // + // CCI Crossed Over OS Pivot ... + + // + bool detectCCICrossedOverOSPivots; + XBoxZone cciCrossedOverOSPivots[]; + bool newCCICrossedOverOSPivotDetected; + + // + // CCI Crossed Under OB Pivot ... + + // + bool detectCCICrossedUnderOBPivots; + XBoxZone cciCrossedUnderOBPivots[]; + bool newCCICrossedUnderOBPivotDetected; + + // + // Constructors ... + XCXCAEAPOIDetector( + XCXCAEAHelper *_helper // + ) + { + // + helper = _helper; + drawer = new XCPOIDrawer(); + barAnalyser = new XCBarAnalyser(); + + // + Default(); + } + + // + // De Constructors ... + ~XCXCAEAPOIDetector() + { + // + valeSupSWLPivot.Clean(); + peakResSWHPivot.Clean(); + + // + Clean(trendBullishFVGs); + trendBullishPivot.Clean(); + + // + Clean(trendBearishFVGs); + trendBearishPivot.Clean(); + + // + trendPivotP.Clean(); + trendPivotC.Clean(); + trendDir = X_DIRECTION_NONE; + + // + CleanPivots(); + + // + ZeroMemory(helper); + ZeroMemory(drawer); + ZeroMemory(barAnalyser); + } + + // + // Properties ... + + // + // Tools ... + + // + virtual void Default() + { + // + maxAllowedPivots = 50; + pivotVerifications = 5; + ticksDividerInPoints = 15; + pivotDetectionLoopbac = 100; + ticksDetectionPerid = PERIOD_D1; + + // + maxAllowedFVGsAge = 0; + validateFVGsUsingPV = false; + validateFVGsUsingMANALYSER = false; + + // + detectTickPivots = true; + detectVolumePivots = true; + detectRSIPeakPivots = true; + detectRSIValePivots = true; + detectCCIPeakPivots = true; + detectCCIValePivots = true; + detectFVGBullishPivots = true; + detectFVGBearishPivots = true; + detectValeSupSWLPivots = true; + detectPeakResSWHPivots = true; + detectTrendBullishPivots = true; + detectTrendBearishPivots = true; + detectRSICrossedOverOSPivots = true; + detectRSICrossedUnderOBPivots = true; + detectCCICrossedOverOSPivots = true; + detectCCICrossedUnderOBPivots = true; + + // + trendDir = X_DIRECTION_NONE; + } + + // + void Update( + int barIndex = 0 // + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + int loopback = pivotDetectionLoopbac; + loopback = NormalizeInt(loopback, 50); + + // + int idx = -1; + int count = 0; + bool has = false; + + // + newRSIPeakPivotDetected = false; + newRSIValePivotDetected = false; + newCCIPeakPivotDetected = false; + newCCIValePivotDetected = false; + newFVGBullishPivotDetected = false; + newFVGBearishPivotDetected = false; + newValeSupSWLPivotDetected = false; + newPeakResSWHPivotDetected = false; + newTrendBullishPivotDetected = false; + newTrendBearishPivotDetected = false; + newRSICrossedOverOSPivotDetected = false; + newRSICrossedUnderOBPivotDetected = false; + newCCICrossedOverOSPivotDetected = false; + newCCICrossedUnderOBPivotDetected = 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 conditions; + has = helper.GetConditions( + conditions, + start, + 10 // + ); + if (!has) + { + conditions.Clean(); + continue; + } + + // + // Retrieve Bars ... + XOHCL zBar; + XOHCL cBar; + XOHCL pBar; + XOHCL p2Bar; + has = zBar.Init( + conditions.symbol, + conditions.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(); + conditions.Clean(); + + // + continue; + } + + // + // Bars Conditions ... + + // + // Bars Conditions ... + + // + ENUM_X_DIRECTION cBarDir; + + // + // Hammer ... + bool isCBarHammer = helper + .barAnalyser + .IsHammer( + cBar, + cBarDir // + ); + bool isCBarBullishHammer = + isCBarHammer && + IsBullish(cBarDir); + bool isCBarBearishHammer = + isCBarHammer && + IsBearish(cBarDir); + + // + // Rejected ... + bool isCBarRejected = helper + .barAnalyser + .IsRejected( + cBar, + cBarDir, + false, // Force Type ... + true // Force Fibo Pressure ... + ); + bool isCBarBullishRejected = + isCBarRejected && + IsBullish(cBarDir); + bool isCBarBearishRejected = + isCBarRejected && + IsBearish(cBarDir); + + // + // Engulfed ... + bool isCBarEngulfed = helper + .barAnalyser + .IsEngulfed( + cBar, + cBarDir // + ); + bool isCBarBullishEngulfed = + isCBarEngulfed && + IsBullish(cBarDir); + bool isCBarBearishEngulfed = + isCBarEngulfed && + IsBearish(cBarDir); + + // + // Momentum ... + bool isCBarMomentum = helper + .barAnalyser + .IsMomentum( + cBar, + cBarDir, + 1 // + ); + bool isCBarBullishMomentum = + isCBarMomentum && + IsBullish(cBarDir); + bool isCBarBearishMomentum = + isCBarMomentum && + IsBearish(cBarDir); + + // + // FVG ... + + // + XBoxZone fvgBox; + bool isFVG = barAnalyser.IsFVG( + cBar, + fvgBox // + ); + bool isBullishFVG = + isFVG && + fvgBox.IsBullish(); + bool isBearishFVG = + isFVG && + fvgBox.IsBearish(); + + // + bool isCBarHasBullishPower = isBullishFVG || + isCBarBullishRejected || + isCBarBullishEngulfed || + isCBarBullishMomentum; + + // + bool isCBarHasBearishPower = isBearishFVG || + isCBarBearishRejected || + isCBarBearishEngulfed || + isCBarBearishMomentum; + + // + // Reading Values from Conditions and + // Create Customized Conditions if required ... + + // + // PEAK ... + double zPeak = conditions.peakBuffer[zIDX]; + double cPeak = conditions.peakBuffer[cIDX]; + double pPeak = conditions.peakBuffer[pIDX]; + double p2Peak = conditions.peakBuffer[p2IDX]; + + // + // VALE ... + double zVale = conditions.valeBuffer[zIDX]; + double cVale = conditions.valeBuffer[cIDX]; + double pVale = conditions.valeBuffer[pIDX]; + double p2Vale = conditions.valeBuffer[p2IDX]; + + // + // MANALYSER ... + + // + // MAH ... + double zMAH = conditions.mahBuffer[zIDX]; + double cMAH = conditions.mahBuffer[cIDX]; + double pMAH = conditions.mahBuffer[pIDX]; + double p2MAH = conditions.mahBuffer[p2IDX]; + + // + // MAL ... + double zMAL = conditions.malBuffer[zIDX]; + double cMAL = conditions.malBuffer[cIDX]; + double pMAL = conditions.malBuffer[pIDX]; + double p2MAL = conditions.malBuffer[p2IDX]; + + // + // MAC ... + double zMAC = conditions.macBuffer[zIDX]; + double cMAC = conditions.macBuffer[cIDX]; + double pMAC = conditions.macBuffer[pIDX]; + double p2MAC = conditions.macBuffer[p2IDX]; + + // + // RSI ... + + // + double zRSI = conditions.rsiBuffer[zIDX]; + double cRSI = conditions.rsiBuffer[cIDX]; + double pRSI = conditions.rsiBuffer[pIDX]; + double p2RSI = conditions.rsiBuffer[p2IDX]; + + // + bool isRSIPeak = + pRSI > cRSI && + pRSI > p2RSI && + pRSI > zRSI; + + // + bool isRSIVale = + pRSI < cRSI && + pRSI < p2RSI && + pRSI < zRSI; + + // + // CCI ... + + // + double zCCI = conditions.cciBuffer[zIDX]; + double cCCI = conditions.cciBuffer[cIDX]; + double pCCI = conditions.cciBuffer[pIDX]; + double p2CCI = conditions.cciBuffer[p2IDX]; + + // + bool isCCIPeak = + pCCI > cCCI && + pCCI > p2CCI && + pCCI > zCCI; + + // + bool isCCIVale = + pCCI < cCCI && + pCCI < p2CCI && + pCCI < zCCI; + + // + // ATR ... + double zATR = conditions.atrBuffer[zIDX]; + double cATR = conditions.atrBuffer[cIDX]; + double pATR = conditions.atrBuffer[pIDX]; + double p2ATR = conditions.atrBuffer[p2IDX]; + + // + double atrSum = GetSum(conditions.atrBuffer); + double atrMax = GetMax(conditions.atrBuffer); + double atrMin = GetMin(conditions.atrBuffer); + double atrAvg = GetAverage(conditions.atrBuffer); + + // + // Extracting Required Data about Trending ... + + // + double zFast = conditions.fastBuffer[zIDX]; + double cFast = conditions.fastBuffer[cIDX]; + double pFast = conditions.fastBuffer[pIDX]; + double p2Fast = conditions.fastBuffer[p2IDX]; + + // + double zMedium = conditions.mediumBuffer[zIDX]; + double cMedium = conditions.mediumBuffer[cIDX]; + double pMedium = conditions.mediumBuffer[pIDX]; + double p2Medium = conditions.mediumBuffer[p2IDX]; + + // + double zSlow = conditions.slowBuffer[zIDX]; + double cSlow = conditions.slowBuffer[cIDX]; + double pSlow = conditions.slowBuffer[pIDX]; + double p2Slow = conditions.slowBuffer[p2IDX]; + + // + double z3Mas[] = { + zFast, + zMedium, + zSlow, + }; + double z3MasMin = GetMin(z3Mas); + double z3MasMax = GetMax(z3Mas); + + // + double c3Mas[] = { + cFast, + cMedium, + cSlow, + }; + double c3MasMin = GetMin(c3Mas); + double c3MasMax = GetMax(c3Mas); + + // + double p3Mas[] = { + pFast, + pMedium, + pSlow, + }; + double p3MasMin = GetMin(p3Mas); + double p3MasMax = GetMax(p3Mas); + + // + double p23Mas[] = { + p2Fast, + p2Medium, + p2Slow, + }; + double p23MasMin = GetMin(p23Mas); + double p23MasMax = GetMax(p23Mas); + + // + // Try to Custom Mechanism for Trend Detection ... + + // + bool is3MaBullish = + cFast > cSlow && + cMedium > cSlow; + bool is3MaBullishPrev = + pFast > pSlow && + pMedium > pSlow; + + // + bool is3MaBearish = + cFast < cSlow && + cMedium < cSlow; + bool is3MaBearishPrev = + pFast < pSlow && + pMedium < pSlow; + + // + bool is3MaSwitchedToBullish = is3MaBullish && + !is3MaBullishPrev; + bool is3MaSwitchedToBearish = is3MaBearish && + !is3MaBearishPrev; + + // + bool is3MaFinishedFromBullish = !is3MaBullish && + is3MaBullishPrev; + bool is3MaFinishedFromBearish = !is3MaBearish && + is3MaBearishPrev; + + // + // TREND BULLISH Conditions ... + + // + bool trendBullishStartPivotCondition = + // + // One ... + // conditions.is3MaFinishedFromBullish + // // + // || + // + // Two ... + is3MaFinishedFromBullish + // + ; + + // + bool trendBullishPivotContinuationCondition = + // + // One ... + // conditions.is3MaBullish + // // + // || + // + // Two ... + is3MaBullish + // + ; + + // + bool trendBullisPivothFinishedCondition = + // + // One ... + // conditions.is3MaSwitchedToBullish + // // + // || + // + // Two ... + is3MaSwitchedToBullish + // + ; + + // + // TREND BEARISH Conditions ... + + // + bool trendBearishStartPivotCondition = + // + // One ... + // conditions.is3MaFinishedFromBearish + // // + // || + // + // Two ... + is3MaFinishedFromBearish + // + ; + + // + bool trendBearishPivotContinuationCondition = + // + // One ... + // conditions.is3MaBearish + // // + // || + // + // Two ... + is3MaBearish + // + ; + + // + bool trendBearishivothFinishedCondition = + // + // One ... + // conditions.is3MaSwitchedToBearish + // // + // || + // + // Two ... + is3MaSwitchedToBearish + // + ; + + // + // Checking Pivots ... + + // + // Detect TICK and VOLUME Pivots ... + if (detectTickPivots || detectVolumePivots) + { + // + XOHCL ticksToBar; + XOHCL ticksFromBar; + XCTicksZone *ticksZone = NULL; + + // + datetime ticksTo = GetPeriodStartTime( + zBar.symbol, + ticksDetectionPerid, + zBar.time // + ); + bool isTicksBarInited = ticksToBar.Init( + zBar.symbol, + zBar.period, + ticksTo // + ); + datetime ticksFrom = ticksTo - PeriodSeconds(ticksDetectionPerid); + isTicksBarInited = isTicksBarInited && + ticksFromBar.Init( + zBar.symbol, + zBar.period, + ticksFrom // + ); + bool hasValidTicksTimeRange = IsValid(ticksTo) && + isTicksBarInited && + IsValid(ticksFrom) && + ticksFrom < ticksTo; + + // + bool isTickPivotExists = + hasValidTicksTimeRange && + IsExistsTickPivot( + ticksTo, + ticksFrom // + ); + + // + bool isVolumePivotExists = + hasValidTicksTimeRange && + IsExistsVolumePivot( + ticksTo, + ticksFrom // + ); + + // + bool isInitializedZone = !isTickPivotExists || + !isVolumePivotExists; + if (isInitializedZone) + { + // + isInitializedZone = InitializeTicksZone( + ticksZone, + ticksToBar, + ticksFromBar // + ); + } + + // + // TICK Pivots ... + if (detectTickPivots) + { + // + // Check Current Zone Exists or Not ... + if (isInitializedZone && !isTickPivotExists) + { + // + XBoxZone iBox; + XCTickZone *iZone; + has = ticksZone.GetMaxTickZone(iZone); + if (has) + { + // + // Try to Converts a Tick Zone to XBoxZone ... + iBox.to = ticksTo; + iBox.from = ticksFrom; + iBox.lower = iZone.low; + iBox.upper = iZone.high; + iBox.symbol = iZone.symbol; + iBox.period = iZone.period; + iBox.type = GetBoxType(XCA_TICK); + iBox.dir = X_DIRECTION_BULLISH; // Temparory ... + + // + has = iBox.IsValid(); + if (has) + { + // + AddBox( + iBox, + tickPivots // + ); + } + } + + // + iBox.Clean(); + ZeroMemory(iZone); + } + } + + // + // VOLUME Pivots ... + if (detectVolumePivots) + { + // + // Check Current Zone Exists or Not ... + if (isInitializedZone && !isVolumePivotExists) + { + // + XBoxZone iBox; + XCTickZone *iZone; + has = ticksZone.GetMaxVolumeZone(iZone); + if (has) + { + // + // Try to Converts a Tick Zone to XBoxZone ... + iBox.to = ticksTo; + iBox.from = ticksFrom; + iBox.lower = iZone.low; + iBox.upper = iZone.high; + iBox.symbol = iZone.symbol; + iBox.period = iZone.period; + iBox.type = GetBoxType(XCA_VOLUME); + iBox.dir = X_DIRECTION_BULLISH; // Temparory ... + + // + has = iBox.IsValid(); + if (has) + { + // + AddBox( + iBox, + volumePivots // + ); + } + } + + // + iBox.Clean(); + ZeroMemory(iZone); + } + } + + // + ticksToBar.Clean(); + ticksFromBar.Clean(); + ZeroMemory(ticksZone); + + // + } + + // + // RSI Peak Pivot ... + if (detectRSIPeakPivots) + { + // + bool checkingCondition = + isRSIPeak && + isCBarHasBearishPower // && + // conditions.isRSICrossedUnderOB + ; + + // + if (checkingCondition) + { + // + 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); + + // + XBoxZone iBox; + has = iPivot.IsValid(); + if (has) + { + // + has = iPivot.AsBox(iBox); + if (has) + { + // + newRSIPeakPivotDetected = AddBox( + iBox, + rsiPeakPivots // + ); + } + } + + // + iBox.Clean(); + iPivot.Clean(); + } + } + + // + // RSI Vale Pivot ... + if (detectRSIValePivots) + { + // + bool checkingCondition = + isRSIVale && + isCBarHasBullishPower // && + // conditions.isRSICrossedOverOS + ; + + // + if (checkingCondition) + { + // + 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); + + // + XBoxZone iBox; + has = iPivot.IsValid(); + if (has) + { + // + has = iPivot.AsBox(iBox); + if (has) + { + // + newRSIValePivotDetected = AddBox( + iBox, + rsiValePivots // + ); + } + } + + // + iBox.Clean(); + iPivot.Clean(); + } + } + + // + // CCI Peak Pivot ... + if (detectCCIPeakPivots) + { + // + bool checkingCondition = + isCCIPeak && + isCBarHasBearishPower // && + // conditions.isCCICrossedUnderOB + ; + + // + if (checkingCondition) + { + // + 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); + + // + XBoxZone iBox; + has = iPivot.IsValid(); + if (has) + { + // + has = iPivot.AsBox(iBox); + if (has) + { + // + newCCIPeakPivotDetected = AddBox( + iBox, + cciPeakPivots // + ); + } + } + + // + iBox.Clean(); + iPivot.Clean(); + } + } + + // + // CCI Vale Pivot ... + if (detectCCIValePivots) + { + // + bool checkingCondition = + isCCIVale && + isCBarHasBullishPower // && + // conditions.isCCICrossedOverOS + ; + + // + if (checkingCondition) + { + // + 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); + + // + XBoxZone iBox; + has = iPivot.IsValid(); + if (has) + { + // + has = iPivot.AsBox(iBox); + if (has) + { + // + newCCIValePivotDetected = AddBox( + iBox, + cciValePivots // + ); + } + } + + // + iBox.Clean(); + iPivot.Clean(); + } + } + + // + // FVG Bullish ... + if (detectFVGBullishPivots) + { + // + bool checkingCondition = + // + isBullishFVG && + // + fvgBox.upper < cMAL + // + // (cPeak > pPeak || + // pPeak > p2Peak) + // + ; + + // + if (checkingCondition) + { + // + XBoxZone iBox; + 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; + + // + has = iPivot.IsValid(); + if (has) + { + // + has = iPivot.AsBox(iBox); + if (has) + { + // + newFVGBullishPivotDetected = AddBox( + iBox, + fvgBullishPivots // + ); + } + } + + // + iBox.Clean(); + iPivot.Clean(); + } + } + + // + // FVG Bearish ... + if (detectFVGBearishPivots) + { + // + bool checkingCondition = + // + isBearishFVG && + // + fvgBox.lower > cMAH + // + // (cVale < pVale || + // pVale < p2Vale) + // + ; + + // + if (checkingCondition) + { + // + XBoxZone iBox; + 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; + + // + has = iPivot.IsValid(); + if (has) + { + // + has = iPivot.AsBox(iBox); + if (has) + { + // + newFVGBearishPivotDetected = AddBox( + iBox, + fvgBearishPivots // + ); + } + } + + // + iBox.Clean(); + iPivot.Clean(); + } + } + + // + // VALE Pivot Support Swing Low ... + if (detectValeSupSWLPivots) + { + // + if (conditions.isValeFinishedFromPivot) + { + // + valeSupSWLPivot.Clean(); + + // + valeSupSWLPivot.type = XCA_VALESWLSUP; + valeSupSWLPivot.symbol = conditions.symbol; + valeSupSWLPivot.period = conditions.period; + + // + valeSupSWLPivot.to = pBar.time; + valeSupSWLPivot.from = pBar.time; + valeSupSWLPivot.value = conditions.valeBuffer[pIDX]; + valeSupSWLPivot.reserve = conditions.valeGoldenBuffer[pIDX]; + } + + // + if (conditions.isValeIsPivot) + { + // + valeSupSWLPivot.from = pBar.time; + + // + valeSupSWLPivot.reserve = + valeSupSWLPivot.reserve == 0 + ? conditions.valeGoldenBuffer[cIDX] + : MathMin(valeSupSWLPivot.reserve, conditions.valeGoldenBuffer[cIDX]); + } + + // + if (conditions.isValeSwitchedToPivot) + { + // + has = + valeSupSWLPivot.IsValid() && + valeSupSWLPivot.GetAge() >= pivotVerifications; + if (has) + { + // + XBoxZone iBox; + has = valeSupSWLPivot.AsBox(iBox); + if (has) + { + // + newValeSupSWLPivotDetected = AddBox( + iBox, + valeSupSWLPivots // + ); + } + + // + iBox.Clean(); + } + + // + valeSupSWLPivot.Clean(); + } + } + + // + // PEAK Pivot Resistance Swing High ... + if (detectPeakResSWHPivots) + { + // + if (conditions.isPeakFinishedFromPivot) + { + // + peakResSWHPivot.Clean(); + + // + peakResSWHPivot.type = XCA_PEAKSWHRES; + peakResSWHPivot.symbol = conditions.symbol; + peakResSWHPivot.period = conditions.period; + + // + peakResSWHPivot.to = pBar.time; + peakResSWHPivot.from = pBar.time; + peakResSWHPivot.value = conditions.peakBuffer[pIDX]; + peakResSWHPivot.reserve = conditions.peakGoldenBuffer[pIDX]; + } + + // + if (conditions.isPeakIsPivot) + { + // + peakResSWHPivot.from = pBar.time; + + // + peakResSWHPivot.reserve = + peakResSWHPivot.reserve == 0 + ? conditions.peakGoldenBuffer[cIDX] + : MathMax(peakResSWHPivot.reserve, conditions.peakGoldenBuffer[cIDX]); + } + + // + if (conditions.isPeakSwitchedToPivot) + { + // + has = + peakResSWHPivot.IsValid() && + peakResSWHPivot.GetAge() >= pivotVerifications; + if (has) + { + // + XBoxZone iBox; + has = peakResSWHPivot.AsBox(iBox); + if (has) + { + // + newPeakResSWHPivotDetected = AddBox( + iBox, + peakResSWHPivots // + ); + } + + // + iBox.Clean(); + } + + // + peakResSWHPivot.Clean(); + } + } + + // + // TREND Bullish ... + if (detectTrendBullishPivots) + { + // + if (trendBullishStartPivotCondition) + { + // + Clean(trendBullishFVGs); + trendBullishPivot.Clean(); + + // + trendBullishPivot.type = XCA_TREND_BULL; + trendBullishPivot.symbol = conditions.symbol; + trendBullishPivot.period = conditions.period; + + // + trendBullishPivot.to = pBar.time; + trendBullishPivot.from = pBar.time; + trendBullishPivot.value = p3MasMin; + trendBullishPivot.reserve = p3MasMax; + } + + // + if (trendBullishPivotContinuationCondition) + { + // + trendBullishPivot.from = pBar.time; + + // + Add( + p3MasMin, + trendBullishPivot.values // + ); + Add( + p3MasMax, + trendBullishPivot.values // + ); + + // + trendBullishPivot.reserve = + trendBullishPivot.reserve == 0 + ? p3MasMax + : MathMax(trendBullishPivot.reserve, p3MasMax); + + // + // Handling FVGs Here ... + if (isBullishFVG) + { + // + fvgBox.type = GetBoxType(XCA_FVG_BULL); + + // + AddBox( + fvgBox, + trendBullishFVGs // + ); + } + } + + // + if (trendBullisPivothFinishedCondition) + { + // + // Update Values ... + trendBullishPivot.value = GetMin(trendBullishPivot.values); + trendBullishPivot.reserve = GetMax(trendBullishPivot.values); + + // + has = + trendBullishPivot.IsValid() && + trendBullishPivot.GetAge() >= pivotVerifications; + if (has) + { + // + XBoxZone iBox; + has = trendBullishPivot.AsBox(iBox); + if (has) + { + // + XCATRENDFVG iTrendFVG; + + // + iTrendFVG.trend = iBox; + Copy( + trendBullishFVGs, + iTrendFVG.fvgs // + ); + + // + newTrendBullishPivotDetected = iTrendFVG.IsValid(); + if (newTrendBullishPivotDetected) + { + // + AddRef( + iTrendFVG, + trendBullishPivots // + ); + } + + // + iTrendFVG.Clean(); + } + + // + iBox.Clean(); + } + + // + Clean(trendBullishFVGs); + trendBullishPivot.Clean(); + } + } + + // + // TREND Bearish ... + if (detectTrendBearishPivots) + { + // + if (trendBearishStartPivotCondition) + { + // + Clean(trendBearishFVGs); + trendBearishPivot.Clean(); + + // + trendBearishPivot.type = XCA_TREND_BEAR; + trendBearishPivot.symbol = conditions.symbol; + trendBearishPivot.period = conditions.period; + + // + trendBearishPivot.to = pBar.time; + trendBearishPivot.from = pBar.time; + trendBearishPivot.value = p3MasMax; + trendBearishPivot.reserve = p3MasMin; + } + + // + if (trendBearishPivotContinuationCondition) + { + // + trendBearishPivot.from = pBar.time; + + // + Add( + p3MasMin, + trendBearishPivot.values // + ); + Add( + p3MasMax, + trendBearishPivot.values // + ); + + // + trendBearishPivot.reserve = + trendBearishPivot.reserve == 0 + ? p3MasMin + : MathMin(trendBearishPivot.reserve, p3MasMin); + + // + // Handling FVGs Here ... + if (isBearishFVG) + { + // + fvgBox.type = GetBoxType(XCA_FVG_BEAR); + + // + AddBox( + fvgBox, + trendBearishFVGs // + ); + } + } + + // + if (trendBearishivothFinishedCondition) + { + // + // Update Values ... + trendBearishPivot.value = GetMax(trendBearishPivot.values); + trendBearishPivot.reserve = GetMin(trendBearishPivot.values); + + // + has = + trendBearishPivot.IsValid() && + trendBearishPivot.GetAge() >= pivotVerifications; + if (has) + { + // + XBoxZone iBox; + has = trendBearishPivot.AsBox(iBox); + if (has) + { + // + XCATRENDFVG iTrendFVG; + + // + iTrendFVG.trend = iBox; + Copy( + trendBearishFVGs, + iTrendFVG.fvgs // + ); + + // + newTrendBearishPivotDetected = iTrendFVG.IsValid(); + if (newTrendBearishPivotDetected) + { + // + AddRef( + iTrendFVG, + trendBearishPivots // + ); + } + + // + iTrendFVG.Clean(); + } + + // + iBox.Clean(); + } + + // + Clean(trendBearishFVGs); + trendBearishPivot.Clean(); + } + } + + // + // RSI Crossed Over OS ... + if (detectRSICrossedOverOSPivots) + { + // + bool checkingCondition = + // isRSIVale && + // isCBarHasBullishPower && + conditions.isRSICrossedOverOS; + + // + if (checkingCondition) + { + // + XCAPivot iPivot; + + // + iPivot.to = cBar.time; + iPivot.value = pBar.low; + iPivot.from = p2Bar.time; + iPivot.type = XCA_RSI_COOS; + 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.low, + iPivot.values // + ); + Add( + pBar.low, + iPivot.values // + ); + Add( + p2Bar.low, + iPivot.values // + ); + + // + iPivot.value = GetMin(iPivot.values); + iPivot.reserve = GetMax(iPivot.values); + + // + XBoxZone iBox; + has = iPivot.IsValid(); + if (has) + { + // + has = iPivot.AsBox(iBox); + if (has) + { + // + newRSICrossedOverOSPivotDetected = AddBox( + iBox, + rsiCrossedOverOSPivots // + ); + } + } + + // + iBox.Clean(); + iPivot.Clean(); + } + } + + // + // RSI Crossed Under OB ... + if (detectRSICrossedUnderOBPivots) + { + // + bool checkingCondition = + // isRSIPeak && + // isCBarHasBearishPower && + conditions.isRSICrossedUnderOB; + + // + if (checkingCondition) + { + // + 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.low, + iPivot.values // + ); + Add( + pBar.low, + iPivot.values // + ); + Add( + p2Bar.low, + iPivot.values // + ); + + // + iPivot.value = GetMax(iPivot.values); + iPivot.reserve = GetMin(iPivot.values); + + // + XBoxZone iBox; + has = iPivot.IsValid(); + if (has) + { + // + has = iPivot.AsBox(iBox); + if (has) + { + // + newRSICrossedUnderOBPivotDetected = AddBox( + iBox, + rsiCrossedUnderOBPivots // + ); + } + } + + // + iBox.Clean(); + iPivot.Clean(); + } + } + + // + // CCI Crossed Over OS ... + if (detectCCICrossedOverOSPivots) + { + // + bool checkingCondition = + isCCIVale && + // isCBarHasBullishPower && + conditions.isCCICrossedOverOS; + + // + if (checkingCondition) + { + // + XCAPivot iPivot; + + // + iPivot.to = cBar.time; + iPivot.value = pBar.low; + iPivot.from = p2Bar.time; + iPivot.type = XCA_CCI_COOS; + 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.low, + iPivot.values // + ); + Add( + pBar.low, + iPivot.values // + ); + Add( + p2Bar.low, + iPivot.values // + ); + + // + iPivot.value = GetMin(iPivot.values); + iPivot.reserve = GetMax(iPivot.values); + + // + XBoxZone iBox; + has = iPivot.IsValid(); + if (has) + { + // + has = iPivot.AsBox(iBox); + if (has) + { + // + newCCICrossedOverOSPivotDetected = AddBox( + iBox, + cciCrossedOverOSPivots // + ); + } + } + + // + iBox.Clean(); + iPivot.Clean(); + } + } + + // + // CCI Crossed Under OB ... + if (detectCCICrossedUnderOBPivots) + { + // + bool checkingCondition = + isCCIPeak && + // isCBarHasBearishPower && + conditions.isCCICrossedUnderOB; + + // + if (checkingCondition) + { + // + 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.low, + iPivot.values // + ); + Add( + pBar.low, + iPivot.values // + ); + Add( + p2Bar.low, + iPivot.values // + ); + + // + iPivot.value = GetMax(iPivot.values); + iPivot.reserve = GetMin(iPivot.values); + + // + XBoxZone iBox; + has = iPivot.IsValid(); + if (has) + { + // + has = iPivot.AsBox(iBox); + if (has) + { + // + newCCICrossedUnderOBPivotDetected = AddBox( + iBox, + cciCrossedUnderOBPivots // + ); + } + } + + // + iBox.Clean(); + iPivot.Clean(); + } + } + + // + // SPIKE Bullish ... + + // + bool detectSpikeBullisPivots = true; + if (detectSpikeBullisPivots) + { + // + // For Spike Detection ... + // [] 80% of Bars Must be Same as Direction ... + // [] Price Range of Bars Must be Passed of atr mult ... + // [] Required Volume Processing if Neccessary ... + + // + bool startCondition = false; + bool continuationCondition = false; + bool endCondition = false; + + // + // TODO: Complete this ... + } + + // + start++; + + // + Clean(z3Mas); + Clean(c3Mas); + Clean(p3Mas); + Clean(p23Mas); + + // + zBar.Clean(); + cBar.Clean(); + pBar.Clean(); + p2Bar.Clean(); + fvgBox.Clean(); + conditions.Clean(); + } + + // + SortPivots(); + } + + // + void Validate( + XBoxZone &unAvailableBoxes[], + int barIndex = 0 // + ) + { + // + // Do All Pivots Validation ... + + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + bool has = false; + + // + int zIDX = 0; + int cIDX = zIDX + 1; + int pIDX = cIDX + 1; + int p2IDX = pIDX + 1; + + // + // Retrieve Conditions ... + XCAEAConditions conditions; + has = helper.GetConditions( + conditions, + barIndex, + 5 // + ); + if (!has) + { + conditions.Clean(); + return; + } + + // + // Implement Validation Senarios ... + + // + // TICK Pivots ... + + // + // TODO: Complete this ... + has = HasTickPivots(); + if (has) + { + // + } + + // + // VOLUME Pivots ... + + // + // TODO: Complete this ... + has = HasVolumePivots(); + if (has) + { + // + } + + // + // RSI Peak Pivot ... + + // + has = HasRSIPeakPivots(); + if (has) + { + // + ApplyValidationOnBox( + rsiPeakPivots, + unAvailableBoxes, + barIndex // + ); + } + + // + // RSI Vale Pivot ... + + // + has = HasRSIValePivots(); + if (has) + { + // + ApplyValidationOnBox( + rsiValePivots, + unAvailableBoxes, + barIndex // + ); + } + + // + // CCI Peak Pivot ... + + // + has = HasCCIPeakPivots(); + if (has) + { + // + ApplyValidationOnBox( + cciPeakPivots, + unAvailableBoxes, + barIndex // + ); + } + + // + // CCI Vale Pivot ... + + // + has = HasCCIValePivots(); + if (has) + { + // + ApplyValidationOnBox( + cciValePivots, + unAvailableBoxes, + barIndex // + ); + } + + // + // FVG Bullish ... + + // + has = HasFVGBullishPivots(); + if (has) + { + // + ApplyValidationOnBox( + fvgBullishPivots, + unAvailableBoxes, + barIndex // + ); + + // + // Validate FVG Ages ... + if (maxAllowedFVGsAge > 0) + { + // + ApplyAgeVerification( + fvgBullishPivots, + maxAllowedFVGsAge // + ); + } + + // + // Validate FVG using PV ... + if (validateFVGsUsingPV) + { + // + ApplyFVGPVValidation( + fvgBullishPivots, + conditions // + ); + } + + // + // Validating FVGs using MANALYSER ... + // if (validateFVGsUsingMANALYSER) + // { + // // + // ApplyManalyswerValidation( + // fvgBullishPivots, + // barIndex // + // ); + // } + } + + // + // FVG Bearish ... + + // + has = HasFVGBearishPivots(); + if (has) + { + // + ApplyValidationOnBox( + fvgBearishPivots, + unAvailableBoxes, + barIndex // + ); + + // + // Validate FVG Ages ... + if (maxAllowedFVGsAge > 0) + { + // + ApplyAgeVerification( + fvgBearishPivots, + maxAllowedFVGsAge // + ); + } + + // + // Validate FVG using PV ... + if (validateFVGsUsingPV) + { + // + ApplyFVGPVValidation( + fvgBearishPivots, + conditions // + ); + } + + // + // Validating FVGs using MANALYSER ... + // if (validateFVGsUsingMANALYSER) + // { + // // + // ApplyManalyswerValidation( + // fvgBearishPivots, + // barIndex // + // ); + // } + } + + // + // VALE Pivot Support Swing Low ... + + // + has = HasValeSupSWLPivots(); + if (has) + { + // + ApplyValidationOnBox( + valeSupSWLPivots, + unAvailableBoxes, + barIndex // + ); + } + + // + // PEAK Pivot Resistance Swing High ... + + // + has = HasPeakResSWHPivots(); + if (has) + { + // + ApplyValidationOnBox( + peakResSWHPivots, + unAvailableBoxes, + barIndex // + ); + } + + // + // TREND Bullish ... + + // + has = HasTrendBullishPivots(); + if (has) + { + // + ApplyValidationOnTrendFVG( + trendBullishPivots, + unAvailableBoxes, + barIndex // + ); + } + + // + // TREND Bearish ... + + // + has = HasTrendBearishPivots(); + if (has) + { + // + ApplyValidationOnTrendFVG( + trendBearishPivots, + unAvailableBoxes, + barIndex // + ); + } + + // + // RSI Crossed Over OS ... + + // + has = HasRSICrossedOverOSPivots(); + if (has) + { + // + ApplyValidationOnBox( + rsiCrossedOverOSPivots, + unAvailableBoxes, + barIndex // + ); + } + + // + // RSI Crossed Under OB ... + + // + has = HasRSICrossedUnderOBPivots(); + if (has) + { + // + ApplyValidationOnBox( + rsiCrossedUnderOBPivots, + unAvailableBoxes, + barIndex // + ); + } + + // + // CCI Crossed Over OS ... + + // + has = HasCCICrossedOverOSPivots(); + if (has) + { + // + ApplyValidationOnBox( + cciCrossedOverOSPivots, + unAvailableBoxes, + barIndex // + ); + } + + // + // CCI Crossed Under OB ... + + // + has = HasCCICrossedUnderOBPivots(); + if (has) + { + // + ApplyValidationOnBox( + cciCrossedUnderOBPivots, + unAvailableBoxes, + barIndex // + ); + } + + // + conditions.Clean(); + + // + SortPivots(); + } + + // + int FillPivots( + XBoxZone &pivots[], + ENUM_X_DIRECTION forDir = X_DIRECTION_ALL // + ) + { + // + int result = 0; + + // + Clean(pivots); + + // + if (forDir == X_DIRECTION_NONE) + { + return result; + } + + // + int count = 0; + bool has = false; + + // + bool canFillBullish = + forDir == X_DIRECTION_ALL || + forDir == X_DIRECTION_BULLISH; + + // + bool canFillBearish = + forDir == X_DIRECTION_ALL || + forDir == X_DIRECTION_BEARISH; + + // + // Bullish ... + if (canFillBullish) + { + // + Copy( + rsiValePivots, + pivots, + false // + ); + + // + Copy( + cciValePivots, + pivots, + false // + ); + + // + Copy( + fvgBullishPivots, + pivots, + false // + ); + + // + Copy( + valeSupSWLPivots, + pivots, + false // + ); + + // + Copy( + rsiCrossedOverOSPivots, + pivots, + false // + ); + + // + Copy( + cciCrossedOverOSPivots, + pivots, + false // + ); + + // + has = HasTrendBullishPivots(); + if (has) + { + // + count = CountTrendBullishPivots(); + for (int i = 0; i < count; i++) + { + // + AddRef( + trendBullishPivots[i].trend, + pivots // + ); + + // + XBoxZone iBox; + has = trendBullishPivots[i].GetSelectedFVG(iBox); + if (has) + { + // + AddRef( + iBox, + pivots // + ); + } + + // + iBox.Clean(); + } + } + } + + // + // Bearish ... + if (canFillBearish) + { + // + Copy( + rsiPeakPivots, + pivots, + false // + ); + + // + Copy( + cciPeakPivots, + pivots, + false // + ); + + // + Copy( + fvgBearishPivots, + pivots, + false // + ); + + // + Copy( + peakResSWHPivots, + pivots, + false // + ); + + // + Copy( + rsiCrossedUnderOBPivots, + pivots, + false // + ); + + // + Copy( + cciCrossedUnderOBPivots, + pivots, + false // + ); + + // + has = HasTrendBearishPivots(); + if (has) + { + // + count = CountTrendBearishPivots(); + for (int i = 0; i < count; i++) + { + // + AddRef( + trendBearishPivots[i].trend, + pivots // + ); + + // + XBoxZone iBox; + has = trendBearishPivots[i].GetSelectedFVG(iBox); + if (has) + { + // + AddRef( + iBox, + pivots // + ); + } + + // + iBox.Clean(); + } + } + } + + // + result = ArraySize(pivots); + + // + return result; + } + + // + bool MarketTrend(ENUM_X_DIRECTION &trend) + { + // + bool result = false; + + // + // Update Market Trend ... + DetectMarketTrend(); + + // + trend = trendDir; + result = HasDirection(trend); + + // + return result; + } + + // + // Counters ... + + // + // INVALID Pivots ... + + // + bool HasInvalidPivots() + { + return HasChild(invalidPivots); + } + + // + int CountInvalidPivots() + { + return ArraySize(invalidPivots); + } + + // + // TICK Pivot ... + + // + bool HasTickPivots() + { + return HasChild(tickPivots); + } + + // + int CountTickPivots() + { + return ArraySize(tickPivots); + } + + // + // VOLUME Pivots ... + + // + bool HasVolumePivots() + { + return HasChild(volumePivots); + } + + // + int CountVolumePivots() + { + return ArraySize(volumePivots); + } + + // + // RSI Peak Pivot ... + + // + bool HasRSIPeakPivots() + { + return HasChild(rsiPeakPivots); + } + + // + int CountRSIPeakPivots() + { + return ArraySize(rsiPeakPivots); + } + + // + // RSI Vale Pivot ... + + // + bool HasRSIValePivots() + { + return HasChild(rsiValePivots); + } + + // + int CountRSIValePivots() + { + return ArraySize(rsiValePivots); + } + + // + // CCI Peak Pivot ... + + // + bool HasCCIPeakPivots() + { + return HasChild(cciPeakPivots); + } + + // + int CountCCIPeakPivots() + { + return ArraySize(cciPeakPivots); + } + + // + // CCI Vale Pivot ... + + // + bool HasCCIValePivots() + { + return HasChild(cciValePivots); + } + + // + int CountCCIValePivots() + { + return ArraySize(cciValePivots); + } + + // + // FVG Bullish ... + + // + bool HasFVGBullishPivots() + { + return HasChild(fvgBullishPivots); + } + + // + int CountFVGBullishPivots() + { + return ArraySize(fvgBullishPivots); + } + + // + // FVG Bearish ... + + // + bool HasFVGBearishPivots() + { + return HasChild(fvgBearishPivots); + } + + // + int CountFVGBearishPivots() + { + return ArraySize(fvgBearishPivots); + } + + // + // VALE Pivot Support Swing Low ... + + // + bool HasValeSupSWLPivots() + { + return HasChild(valeSupSWLPivots); + } + + // + int CountValeSupSWLPivots() + { + return ArraySize(valeSupSWLPivots); + } + + // + // PEAK Pivot Resistance Swing High ... + + // + bool HasPeakResSWHPivots() + { + return HasChild(peakResSWHPivots); + } + + // + int CountPeakResSWHPivots() + { + return ArraySize(peakResSWHPivots); + } + + // + // TREND Bullish ... + + // + bool HasTrendBullishPivots() + { + return HasChild(trendBullishPivots); + } + + // + int CountTrendBullishPivots() + { + return ArraySize(trendBullishPivots); + } + + // + // TREND Bearish ... + + // + bool HasTrendBearishPivots() + { + return HasChild(trendBearishPivots); + } + + // + int CountTrendBearishPivots() + { + return ArraySize(trendBearishPivots); + } + + // + // RSI Crossed Over OS Pivots ... + + // + bool HasRSICrossedOverOSPivots() + { + return HasChild(rsiCrossedOverOSPivots); + } + + // + int CountRSICrossedOverOSPivots() + { + return ArraySize(rsiCrossedOverOSPivots); + } + + // + // RSI Crossed Under OB Pivots ... + + // + bool HasRSICrossedUnderOBPivots() + { + return HasChild(rsiCrossedUnderOBPivots); + } + + // + int CountRSICrossedUnderOBPivots() + { + return ArraySize(rsiCrossedUnderOBPivots); + } + + // + // CCI Crossed Over OS Pivots ... + + // + bool HasCCICrossedOverOSPivots() + { + return HasChild(cciCrossedOverOSPivots); + } + + // + int CountCCICrossedOverOSPivots() + { + return ArraySize(rsiCrossedOverOSPivots); + } + + // + // CCI Crossed Under OB Pivots ... + + // + bool HasCCICrossedUnderOBPivots() + { + return HasChild(cciCrossedUnderOBPivots); + } + + // + int CountCCICrossedUnderOBPivots() + { + return ArraySize(cciCrossedUnderOBPivots); + } + + // + // Protected ... + protected: + // + // Props ... + + // + // Prrivate ... + private: + // + // Props ... + + // + XCPOIDrawer *drawer; + XCXCAEAHelper *helper; + XCBarAnalyser *barAnalyser; + + // + bool AddBox( + XBoxZone &box, + XBoxZone &boxes[] // + ) + { + // + bool result = false; + + // + result = box.IsValid(); + if (!result) + { + return result; + } + + // + int idx = -1; + bool isExists = FindBoxIndex( + idx, + box, + boxes // + ); + result = !isExists; + if (!result) + { + return result; + } + + // + int before = ArraySize(boxes); + + // + AddRef( + box, + boxes // + ); + + // + int after = ArraySize(boxes); + + // + result = after > before; + + // + return result; + } + + // + bool ValidateBox( + XBoxZone &box, + XBoxZone &unAvailableBoxes[], + int barIndex = 0 // + ) + { + // + bool result = false; + + // + // Normalize Bar Index ... + barIndex = NormalizeInt(barIndex, 0); + + // + // Ceck Input Box is Valid ... + result = box.IsValid(); + if (!result) + { + 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(); + 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 + ? box.lower + : box.upper; + + // + // for validating Box Break we have to wait At Least 3 Bars Close + // out of Box Boundary ... + int barsLength = 3; + + // + // Calculate Start Checking Bar Index ... + int startCheckBreaktionBarIndex = toIDX - barsLength; + 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++) + { + // + // Initialize Bars ... + isValid = cBar.Init( + box.symbol, + box.period, + i + 1 // + ); + isValid = + result && + cBar.GetPreviousBar(pBar); + isValid = + result && + pBar.GetPreviousBar(p2Bar); + if (!isValid) + { + // + cBar.Clean(); + pBar.Clean(); + p2Bar.Clean(); + + // + result = false; + + // + break; + } + + // + // Preparing Conditions ... + + // + bool isBullishBreaked = + isBullish && + cBar.close < boundary && + pBar.close < boundary && + p2Bar.close < boundary; + + // + bool isBearishBreaked = + !isBullish && + cBar.close > boundary && + pBar.close > boundary && + p2Bar.close > boundary; + + // + // Calculate Result ... + isBreaked = isBullishBreaked || + isBearishBreaked; + if (isBreaked) + { + // + cBar.Clean(); + pBar.Clean(); + p2Bar.Clean(); + + // + result = false; + + // + break; + } + + // + cBar.Clean(); + pBar.Clean(); + p2Bar.Clean(); + } + + // + result = isValid && + !isBreaked; + + // + // Cleanup Resource ... + + // + cBar.Clean(); + pBar.Clean(); + p2Bar.Clean(); + + // + return result; + } + + // + void CleanPivots() + { + // + Clean(invalidPivots); + + // + Clean(tickPivots); + Clean(volumePivots); + Clean(rsiPeakPivots); + Clean(rsiValePivots); + Clean(cciPeakPivots); + Clean(cciValePivots); + Clean(fvgBullishPivots); + Clean(fvgBearishPivots); + Clean(valeSupSWLPivots); + Clean(peakResSWHPivots); + Clean(trendBullishPivots); + Clean(trendBearishPivots); + Clean(rsiCrossedOverOSPivots); + Clean(rsiCrossedUnderOBPivots); + Clean(cciCrossedOverOSPivots); + Clean(cciCrossedUnderOBPivots); + } + + // + void SortPivots() + { + // + bool has = false; + + // + // RSI Peak ... + has = HasRSIPeakPivots(); + if (has) + { + ApplySortOnBox(rsiPeakPivots); + } + + // + // RSI Vale ... + has = HasRSIValePivots(); + if (has) + { + ApplySortOnBox(rsiValePivots); + } + + // + // CCI Peak ... + has = HasCCIPeakPivots(); + if (has) + { + ApplySortOnBox(cciPeakPivots); + } + + // + // CCI Vale ... + has = HasCCIValePivots(); + if (has) + { + ApplySortOnBox(cciValePivots); + } + + // + // FVG Bullish ... + has = HasFVGBullishPivots(); + if (has) + { + ApplySortOnBox(fvgBullishPivots); + } + + // + // FVG Bearish ... + has = HasFVGBearishPivots(); + if (has) + { + ApplySortOnBox(fvgBearishPivots); + } + + // + // VALE SUP SWL ... + has = HasValeSupSWLPivots(); + if (has) + { + ApplySortOnBox(valeSupSWLPivots); + } + + // + // PEAK REs SWH ... + has = HasPeakResSWHPivots(); + if (has) + { + ApplySortOnBox(peakResSWHPivots); + } + + // + // PVFVG Bullish ... + has = HasTrendBullishPivots(); + if (has) + { + ApplySortOnTrendFVG(trendBullishPivots); + } + + // + // PVFVG Bearish ... + has = HasTrendBearishPivots(); + if (has) + { + ApplySortOnTrendFVG(trendBearishPivots); + } + + // + // RSI Crossed Over OS ... + has = HasRSICrossedOverOSPivots(); + if (has) + { + ApplySortOnBox(rsiCrossedOverOSPivots); + } + + // + // RSI Crossed Under OB ... + has = HasRSICrossedUnderOBPivots(); + if (has) + { + ApplySortOnBox(rsiCrossedUnderOBPivots); + } + + // + // CCI Crossed Over OS ... + has = HasCCICrossedOverOSPivots(); + if (has) + { + ApplySortOnBox(cciCrossedOverOSPivots); + } + + // + // CCI Crossed Under OB ... + has = HasCCICrossedUnderOBPivots(); + if (has) + { + ApplySortOnBox(cciCrossedUnderOBPivots); + } + + // + // INVALID Pivots ... + has = HasInvalidPivots(); + if (has) + { + ApplySortOnBox(invalidPivots); + } + } + + // + // Sorting ... + + // + void ApplySortOnBox( + XBoxZone &items[] // + ) + { + // + int idx = -1; + bool has = false; + + // + has = HasChild(items); + if (!has) + { + return; + } + + // + XBoxZone tmp[]; + Copy( + items, + tmp // + ); + Clean(items); + + // + while (HasChild(tmp)) + { + // + idx = GetOldest(tmp); + has = IsValidIndex(idx); + if (!has) + { + break; + } + + // + XBoxZone iBox = tmp[idx]; + ArrayRemove( + tmp, + idx, + 1 // + ); + + // + AddRef( + iBox, + items // + ); + } + + // + CleanupArray( + items, + maxAllowedPivots // + ); + + // + Clean(tmp); + } + + // + void ApplySortOnTrendFVG( + XCATRENDFVG &items[] // + ) + { + // + int idx = -1; + bool has = false; + + // + has = HasChild(items); + if (!has) + { + return; + } + + // + XCATRENDFVG tmp[]; + Copy( + items, + tmp // + ); + Clean(items); + + // + while (HasChild(tmp)) + { + // + idx = GetOldest(tmp); + has = IsValidIndex(idx); + if (!has) + { + break; + } + + // + XCATRENDFVG iTrendFVG = tmp[idx]; + ArrayRemove( + tmp, + idx, + 1 // + ); + + // + AddRef( + iTrendFVG, + items // + ); + } + + // + CleanupArray( + items, + maxAllowedPivots // + ); + + // + Clean(tmp); + } + + // + // Validators ... + + // + void ApplyValidationOnBox( + XBoxZone &items[], + XBoxZone &unAvailableItems[], + int barIndex = 0 // + ) + { + // + bool has = false; + + // + has = HasChild(items); + if (!has) + { + return; + } + + // + XBoxZone tmp[]; + Copy( + items, + tmp // + ); + Clean(items); + while (HasChild(tmp)) + { + // + XBoxZone iBox = tmp[0]; + ArrayRemove( + tmp, + 0, + 1 // + ); + + // + has = ValidateBox( + iBox, + unAvailableItems, + barIndex // + ); + if (has) + { + // + AddRef( + iBox, + items // + ); + } + + // + iBox.Clean(); + // + } + + // + Clean(tmp); + } + + // + void ApplyAgeVerification( + XBoxZone &pivots[], + int maxAllowedAge // + ) + { + // + bool has = HasChild(pivots) && + maxAllowedAge > 0; + if (!has) + { + return; + } + + // + XBoxZone tmp[]; + Copy( + pivots, + tmp // + ); + Clean(pivots); + + // + while (HasChild(tmp)) + { + // + XBoxZone iPivot = tmp[0]; + ArrayRemove( + tmp, + 0, + 1 // + ); + + // + iPivot.to = TimeCurrent(); + + // + int iAge = iPivot.GetAge(); + has = iAge <= maxAllowedAge; + if (has) + { + // + AddRef( + iPivot, + pivots // + ); + } + + // + iPivot.Clean(); + } + + // + Clean(tmp); + } + + // + void ApplyFVGPVValidation( + XBoxZone &fvgs[], + XCAEAConditions &conditions // + ) + { + // + int zIDX = 0; + int cIDX = zIDX + 1; + int pIDX = cIDX + 1; + int p2IDX = pIDX + 1; + + // + bool has = HasChild(fvgs); + if (!has) + { + return; + } + + // + // Reading Values ... + + // + // PEAK ... + double zPeak = conditions.peakBuffer[zIDX]; + double cPeak = conditions.peakBuffer[cIDX]; + double pPeak = conditions.peakBuffer[pIDX]; + double p2Peak = conditions.peakBuffer[p2IDX]; + + // + // VALE ... + double zVale = conditions.valeBuffer[zIDX]; + double cVale = conditions.valeBuffer[cIDX]; + double pVale = conditions.valeBuffer[pIDX]; + double p2Vale = conditions.valeBuffer[p2IDX]; + + // + XBoxZone tmp[]; + Copy( + fvgs, + tmp // + ); + Clean(fvgs); + while (HasChild(tmp)) + { + // + XBoxZone iBox = tmp[0]; + ArrayRemove( + tmp, + 0, + 1 // + ); + + // + bool isBullish = iBox.IsBullish(); + + // + bool isPVBreaked = + isBullish + ? cVale > iBox.upper + : cPeak < iBox.lower; + + // + has = !isPVBreaked; + if (has) + { + // + AddRef( + iBox, + fvgs // + ); + } + + // + iBox.Clean(); + } + + // + Clean(tmp); + } + + // + void ApplyValidationOnTrendFVG( + XCATRENDFVG &items[], + XBoxZone &unAvailableItems[], + int barIndex = 0 // + ) + { + // + bool has = false; + + // + has = HasChild(items); + if (!has) + { + return; + } + + // + XCATRENDFVG tmp[]; + Copy( + items, + tmp // + ); + Clean(items); + while (HasChild(tmp)) + { + // + XCATRENDFVG iTrendFVG = tmp[0]; + ArrayRemove( + tmp, + 0, + 1 // + ); + + // + // Validate TMP Trend Box ... + has = ValidateBox( + iTrendFVG.trend, + unAvailableItems, + barIndex // + ); + if (has) + { + // + // Now we Have to Validate FVGS ... + ApplyValidationOnBox( + iTrendFVG.fvgs, + unAvailableItems, + barIndex // + ); + + // + has = iTrendFVG.IsValid(); + if (has) + { + // + AddRef( + iTrendFVG, + items // + ); + } + } + + // + iTrendFVG.Clean(); + } + + // + Clean(tmp); + } + + // + // + // + + // + bool IsExistsTickPivot( + datetime to, + datetime from // + ) + { + // + bool result = false; + + // + // Validate Args ... + result = IsValid(to) && + IsValid(from) && + to > from; + if (!result) + { + return result; + } + + // + result = HasTickPivots(); + if (!result) + { + return result; + } + + // + int idx = -1; + int count = CountTickPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox = tickPivots[i]; + + // + result = iBox.to == to && + iBox.from == from; + if (result) + { + // + idx = i; + iBox.Clean(); + + // + break; + } + + // + iBox.Clean(); + } + + // + result = IsValidIndex(idx); + + // + return result; + } + + // + bool IsExistsVolumePivot( + datetime to, + datetime from // + ) + { + // + bool result = false; + + // + // Validate Args ... + result = IsValid(to) && + IsValid(from) && + to > from; + if (!result) + { + return result; + } + + // + result = HasVolumePivots(); + if (!result) + { + return result; + } + + // + int idx = -1; + int count = CountVolumePivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox = volumePivots[i]; + + // + result = iBox.to == to && + iBox.from == from; + if (result) + { + // + idx = i; + iBox.Clean(); + + // + break; + } + + // + iBox.Clean(); + } + + // + result = IsValidIndex(idx); + + // + return result; + } + + // + bool InitializeTicksZone( + XCTicksZone *&zone, + XOHCL &toBar, + XOHCL &fromBar // + ) + { + // + bool result = false; + + // + result = zone == NULL; + if (!result) + { + return result; + } + + // + int toIDX = toBar.Index(); + int fromIDX = fromBar.Index(); + int rangeLength = fromIDX - toIDX; + double rangeDivider = ticksDividerInPoints * GetPoints(toBar.symbol); + double rangeL = toBar.FindLowest(rangeLength, MODE_LOW); + double rangeH = toBar.FindHighest(rangeLength, MODE_HIGH); + double rangeDiff = (rangeH - rangeL); + int zoneLevels = (int)(rangeDiff / rangeDivider); + + // + zone = new XCTicksZone(); + zone.Levels(zoneLevels); + + // + result = zone.Init( + fromBar, + toBar // + ); + if (!result) + { + ZeroMemory(zone); + } + + // + return result; + } + + // + void DetectMarketTrend() + { + // + int idx = -1; + int count = 0; + bool has = false; + + // + XBoxZone tmp[]; + has = HasPeakResSWHPivots(); + if (has) + { + // + Copy( + peakResSWHPivots, + tmp, + false // + ); + } + has = HasValeSupSWLPivots(); + if (has) + { + // + Copy( + valeSupSWLPivots, + tmp, + false // + ); + } + count = ArraySize(tmp); + has = HasChild(tmp); + if (!has) + { + return; + } + + // + has = HasDirection(trendDir); + if (!has) + { + // + trendPivotC.Clean(); + trendPivotP.Clean(); + } + + // + XBoxZone cPivot; + XBoxZone pPivot; + ENUM_X_DIRECTION dir = X_DIRECTION_NONE; + while (HasChild(tmp)) + { + // + XBoxZone iPivot; + idx = GetYoungest(tmp); + has = IsValidIndex(idx); + if (!has) + { + // + iPivot.Clean(); + break; + } + + // + iPivot = tmp[idx]; + ArrayRemove( + tmp, + idx, + 1 // + ); + + // + // Check Can Set CPivot ... + bool canSetCPivot = + !cPivot.IsValid() + ? true + : iPivot.from > cPivot.from; + if (canSetCPivot) + { + // + if (cPivot.IsValid()) + { + pPivot = cPivot; + } + + // + cPivot = iPivot; + } + + // + // Check Can Set PPivot ... + bool canSetPPivot = + !cPivot.IsValid() + ? false + : iPivot.from < cPivot.from + ? !pPivot.IsValid() + ? true + : iPivot.from > pPivot.from + : false; + if (canSetPPivot) + { + pPivot = iPivot; + } + + // + has = cPivot.IsValid() && + pPivot.IsValid(); + if (has) + { + // + iPivot.Clean(); + break; + } + + // + iPivot.Clean(); + } + + // + // Check Resources for Detecting Conditions ... + bool hasTrend = + // + cPivot.IsValid() && + pPivot.IsValid() && + cPivot.dir == pPivot.dir && + cPivot.from > pPivot.from && + (IsBullish(cPivot.dir) + ? cPivot.lower > pPivot.lower + : cPivot.upper < pPivot.upper); + // + ; + if (hasTrend) + { + // + trendPivotC = cPivot; + trendPivotP = pPivot; + trendDir = cPivot.dir; + } + + // + Clean(tmp); + cPivot.Clean(); + pPivot.Clean(); + + // + } + + // +}; + +// \ No newline at end of file diff --git a/Documents/BKP/xcaea.x-poi.drawer.class.bkp.mq5 b/Documents/BKP/xcaea.x-poi.drawer.class.bkp.mq5 new file mode 100644 index 00000000..f0f59a75 --- /dev/null +++ b/Documents/BKP/xcaea.x-poi.drawer.class.bkp.mq5 @@ -0,0 +1,2329 @@ +/////////////////////////////////////////////////////// +// +// 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 ignoreUpdateOSCTos; + bool drawTrendPivotsOnlySelectedFVG; + + // + // Drawers ... + bool drawTrendLine; + bool drawTickPivots; + bool drawVolumePivots; + bool drawRSIPeakPivots; + bool drawRSIValePivots; + bool drawCCIPeakPivots; + bool drawCCIValePivots; + bool drawFVGBullishPivots; + bool drawFVGBearishPivots; + bool drawValeSupSWLPivots; + bool drawPeakResSWHPivots; + bool drawTrendBullishPivots; + bool drawTrendBearishPivots; + bool drawRSICrossedOverOSPivots; + bool drawRSICrossedUnderOBPivots; + bool drawCCICrossedOverOSPivots; + bool drawCCICrossedUnderOBPivots; + + // + // Colors ... + + // + color defaultBullishColor; + color defaultBearishColor; + + // + color tickPivotsColor; + color volumePivotsColor; + color rsiPeakPivotsColor; + color rsiValePivotsColor; + color cciPeakPivotsColor; + color cciValePivotsColor; + color fvgBullishPivotsColor; + color fvgBearishPivotsColor; + color valeSupSWLPivotsColor; + color peakResSWHPivotsColor; + color trendLineBullishColor; + color trendLineBearishColor; + color trendBullishPivotsColor; + color trendBearishPivotsColor; + color rsiCrossedOverOSPivotsColor; + color rsiCrossedUnderOBPivotsColor; + color cciCrossedOverOSPivotsColor; + color cciCrossedUnderOBPivotsColor; + + // + // Width ... + + // + int defaultBullishWidth; + int defaultBearishWidth; + + // + int tickPivotsWidth; + int volumePivotsWidth; + int rsiPeakPivotsWidth; + int rsiValePivotsWidth; + int cciPeakPivotsWidth; + int cciValePivotsWidth; + int fvgBullishPivotsWidth; + int fvgBearishPivotsWidth; + int valeSupSWLPivotsWidth; + int peakResSWHPivotsWidth; + int trendLineBullishWidth; + int trendLineBearishWidth; + int trendBullishPivotsWidth; + int trendBearishPivotsWidth; + int rsiCrossedOverOSPivotsWidth; + int rsiCrossedUnderOBPivotsWidth; + int cciCrossedOverOSPivotsWidth; + int cciCrossedUnderOBPivotsWidth; + + // + // Style ... + + // + ENUM_LINE_STYLE defaultBullishStyle; + ENUM_LINE_STYLE defaultBearishStyle; + + // + ENUM_LINE_STYLE tickPivotsStyle; + ENUM_LINE_STYLE volumePivotsStyle; + 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; + ENUM_LINE_STYLE trendLineBullishStyle; + ENUM_LINE_STYLE trendLineBearishStyle; + ENUM_LINE_STYLE trendBullishPivotsStyle; + ENUM_LINE_STYLE trendBearishPivotsStyle; + ENUM_LINE_STYLE rsiCrossedOverOSPivotsStyle; + ENUM_LINE_STYLE rsiCrossedUnderOBPivotsStyle; + ENUM_LINE_STYLE cciCrossedOverOSPivotsStyle; + ENUM_LINE_STYLE cciCrossedUnderOBPivotsStyle; + + // + // Colorize Props ... + + // + // Width Props ... + + // + // Style Props ... + + // + // Constructors ... + XCXCAEAPOIDrawer( + XCXCAEAPOIDetector *_detector // + ) + { + // + detector = _detector; + drawer = new XCPOIDrawer(); + + // + Default(); + } + + // + // De Constructors ... + ~XCXCAEAPOIDrawer() + { + // + Clear(); + + // + ZeroMemory(drawer); + ZeroMemory(detector); + } + + // + // Properties ... + + // + // Tools ... + + // + virtual void Default() + { + // + ignoreUpdateOSCTos = true; + drawTrendPivotsOnlySelectedFVG = true; + + // + drawTrendLine = false; + drawTickPivots = false; + drawVolumePivots = false; + drawRSIPeakPivots = false; + drawRSIValePivots = false; + drawCCIPeakPivots = false; + drawCCIValePivots = false; + drawFVGBullishPivots = false; + drawFVGBearishPivots = false; + drawValeSupSWLPivots = false; + drawPeakResSWHPivots = false; + drawTrendBullishPivots = false; + drawTrendBearishPivots = false; + drawRSICrossedOverOSPivots = false; + drawRSICrossedUnderOBPivots = false; + drawCCICrossedOverOSPivots = false; + drawCCICrossedUnderOBPivots = false; + + // + defaultBullishColor = clrLime; + defaultBearishColor = clrRed; + + // + tickPivotsColor = defaultBullishColor; + volumePivotsColor = defaultBearishColor; + + // + rsiValePivotsColor = defaultBullishColor; + cciValePivotsColor = defaultBullishColor; + fvgBullishPivotsColor = defaultBullishColor; + valeSupSWLPivotsColor = defaultBullishColor; + trendLineBullishColor = defaultBullishColor; + trendBullishPivotsColor = defaultBullishColor; + rsiCrossedOverOSPivotsColor = defaultBullishColor; + cciCrossedOverOSPivotsColor = defaultBullishColor; + + // + rsiPeakPivotsColor = defaultBearishColor; + cciPeakPivotsColor = defaultBearishColor; + fvgBearishPivotsColor = defaultBearishColor; + peakResSWHPivotsColor = defaultBearishColor; + trendLineBearishColor = defaultBearishColor; + trendBearishPivotsColor = defaultBearishColor; + rsiCrossedUnderOBPivotsColor = defaultBearishColor; + cciCrossedUnderOBPivotsColor = defaultBearishColor; + + // + defaultBullishWidth = 1; + defaultBearishWidth = 1; + + // + tickPivotsWidth = defaultBullishWidth; + volumePivotsWidth = defaultBearishWidth; + + // + rsiValePivotsWidth = defaultBullishWidth; + cciValePivotsWidth = defaultBullishWidth; + fvgBullishPivotsWidth = defaultBullishWidth; + valeSupSWLPivotsWidth = defaultBullishWidth; + trendLineBullishWidth = defaultBullishWidth; + trendBullishPivotsWidth = defaultBullishWidth; + rsiCrossedOverOSPivotsWidth = defaultBullishWidth; + cciCrossedOverOSPivotsWidth = defaultBullishWidth; + + // + rsiPeakPivotsWidth = defaultBearishWidth; + cciPeakPivotsWidth = defaultBearishWidth; + fvgBearishPivotsWidth = defaultBearishWidth; + peakResSWHPivotsWidth = defaultBearishWidth; + trendLineBearishWidth = defaultBearishWidth; + trendBearishPivotsWidth = defaultBearishWidth; + rsiCrossedUnderOBPivotsWidth = defaultBearishWidth; + cciCrossedUnderOBPivotsWidth = defaultBearishWidth; + + // + defaultBullishStyle = STYLE_SOLID; + defaultBearishStyle = STYLE_SOLID; + + // + tickPivotsStyle = defaultBullishStyle; + volumePivotsStyle = defaultBearishStyle; + + // + rsiValePivotsStyle = defaultBullishStyle; + cciValePivotsStyle = defaultBullishStyle; + fvgBullishPivotsStyle = defaultBullishStyle; + valeSupSWLPivotsStyle = defaultBullishStyle; + trendLineBullishStyle = defaultBullishStyle; + trendBullishPivotsStyle = defaultBullishStyle; + rsiCrossedOverOSPivotsStyle = defaultBullishStyle; + cciCrossedOverOSPivotsStyle = defaultBullishStyle; + + // + rsiPeakPivotsStyle = defaultBearishStyle; + cciPeakPivotsStyle = defaultBearishStyle; + fvgBearishPivotsStyle = defaultBearishStyle; + peakResSWHPivotsStyle = defaultBearishStyle; + trendLineBearishStyle = defaultBearishStyle; + trendBearishPivotsStyle = defaultBearishStyle; + rsiCrossedUnderOBPivotsStyle = defaultBearishStyle; + cciCrossedUnderOBPivotsStyle = defaultBearishStyle; + } + + // + void Draw(datetime to = NULL) + { + // + DrawTrendLine(); + DrawTickPivots(to); + DrawVolumePivots(to); + DrawRSIPeakPivots(to); + DrawRSIValePivots(to); + DrawCCIPeakPivots(to); + DrawCCIValePivots(to); + DrawFVGBullishPivots(to); + DrawFVGBearishPivots(to); + DrawValeSupSWLPivots(to); + DrawPeakResSWHPivots(to); + DrawTrendBullishPivots(to); + DrawTrendBearishPivots(to); + DrawRSICrossedOverOSPivots(to); + DrawRSICrossedUnderOBPivots(to); + DrawCCICrossedOverOSPivots(to); + DrawCCICrossedUnderOBPivots(to); + } + + // + void DrawBox( + XBoxZone &box, + datetime to = NULL // + ) + { + // + bool has = box.IsValid(); + if (!has) + { + return; + } + // + // Detect Pivot Type ... + ENUM_XCA_PIVOTS iType = GetPivotType(box); + has = IsValid(iType); + if (!has) + { + return; + } + + // + switch (iType) + { + // + case XCA_TICK: + // + DrawTickPivot( + box, + to // + ); + break; + + // + case XCA_VOLUME: + // + DrawVolumePivot( + box, + to // + ); + break; + + // + case XCA_FVG_BULL: + // + DrawFVGBullishPivot( + box, + to // + ); + break; + + // + case XCA_FVG_BEAR: + // + DrawFVGBearishPivot( + box, + to // + ); + break; + + // + case XCA_RSI_COOS: + // + DrawRSICrossedOverOSPivot( + box, + to // + ); + break; + + // + case XCA_RSI_CUOB: + // + DrawRSICrossedUnderOBPivot( + box, + to // + ); + break; + + // + case XCA_RSI_PEAK: + // + DrawRSIPeakPivot( + box, + to // + ); + break; + + // + case XCA_RSI_VALE: + // + DrawRSIValePivot( + box, + to // + ); + break; + + // + case XCA_CCI_COOS: + // + DrawCCICrossedOverOSPivot( + box, + to // + ); + break; + + // + case XCA_CCI_CUOB: + // + DrawCCICrossedUnderOBPivot( + box, + to // + ); + break; + + // + case XCA_CCI_PEAK: + // + DrawCCIPeakPivot( + box, + to // + ); + break; + + // + case XCA_CCI_VALE: + // + DrawCCIValePivot( + box, + to // + ); + break; + + // + case XCA_PEAKSWHRES: + // + DrawPeakResSWHPivot( + box, + to // + ); + break; + + // + case XCA_VALESWLSUP: + // + DrawValeSupSWLPivot( + box, + to // + ); + break; + } + } + + // + void DrawBoxes( + XBoxZone &boxes[], + datetime to = NULL // + ) + { + // + bool has = HasChild(boxes); + if (!has) + { + return; + } + + // + int count = ArraySize(boxes); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox = boxes[i]; + + // + // Detect Pivot Type ... + DrawBox( + iBox, + to // + ); + + // + iBox.Clean(); + }; + + // + // Trend Items ... + XCATRENDFVG trendFVGs[]; + count = ExtractTrendPivots( + trendFVGs, + boxes // + ); + has = IsValidSize(count); + if (!has) + { + return; + } + + // + for (int i = 0; i < count; i++) + { + // + XCATRENDFVG iTrendFVG = trendFVGs[i]; + + // + bool isBullish = iTrendFVG.IsBullish(); + if (isBullish) + { + // + DrawTrendBullishPivot( + iTrendFVG, + to // + ); + } + else + { + // + DrawTrendBearishPivot( + iTrendFVG, + to // + ); + } + + // + iTrendFVG.Clean(); + } + + // + Clean(trendFVGs); + } + + // + void Clear() + { + // + mTrendLineObjects.Clear(); + mTickPivotObjects.Clear(); + mVolumePivotObjects.Clear(); + mRSIPeakPivotObjects.Clear(); + mRSIValePivotObjects.Clear(); + mCCIPeakPivotObjects.Clear(); + mCCIValePivotObjects.Clear(); + mFVGBullishPivotObjects.Clear(); + mFVGBearishPivotObjects.Clear(); + mValeSupSWLPivotObjects.Clear(); + mPeakResSWHPivotObjects.Clear(); + mTrendBullishPivotObjects.Clear(); + mTrendBearishPivotObjects.Clear(); + mRSICrossedOverOSPivotObjects.Clear(); + mRSICrossedUnderOBPivotObjects.Clear(); + mCCICrossedOverOSPivotObjects.Clear(); + mCCICrossedUnderOBPivotObjects.Clear(); + } + + // + // Collection Drawers ... + + // + void DrawTrendLine() + { + // + if (!drawTrendLine) + { + return; + } + + // + mTrendLineObjects.Clear(); + + // + ENUM_X_DIRECTION trend = X_DIRECTION_NONE; + bool has = detector.MarketTrend(trend); + if (!has) + { + return; + } + + // + long chartID = drawer.ChartIdentification(); + int subWindow = drawer.SubWindowIdentification(); + + // + bool hasBullishTrend = IsBullish(trend); + + // + double pPrice = hasBullishTrend + ? detector.trendPivotP.lower + : detector.trendPivotP.upper; + + // + datetime pTime = detector.trendPivotP.from; + + // + double cPrice = hasBullishTrend + ? detector.trendPivotC.lower + : detector.trendPivotC.upper; + + // + datetime cTime = detector.trendPivotC.from; + + // + string tlName = ToString(trend) + + "_TL_" + + ToString(pPrice) + + "_" + + ToString(cPrice); + + // + int tlWidth = hasBullishTrend + ? trendLineBullishWidth + : trendLineBearishWidth; + + // + color tlColor = hasBullishTrend + ? trendLineBullishColor + : trendLineBearishColor; + + // + ENUM_LINE_STYLE tlStyle = hasBullishTrend + ? trendLineBullishStyle + : trendLineBearishStyle; + + // + CChartObjectTrend *iObj; + iObj = new CChartObjectTrend(); + has = iObj.Create( + chartID, + tlName, + subWindow, + pTime, + pPrice, + cTime, + cPrice // + ); + if (has) + { + // + // Style Object ... + iObj.Color(tlColor); + iObj.Width(tlWidth); + iObj.Style(tlStyle); + iObj.RayRight(true); + + // + // Store Object ... + mTrendLineObjects.Add(iObj); + } + + // + ZeroMemory(iObj); + } + + // + void DrawTickPivots(datetime to = NULL) + { + // + bool has = drawTickPivots; + if (!has) + { + return; + } + + // + has = detector.HasTickPivots(); + if (!has) + { + return; + } + + // + int count = detector.CountTickPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox = detector.tickPivots[i]; + + // + DrawTickPivot( + iBox, + to // + ); + + // + iBox.Clean(); + } + } + + // + void DrawVolumePivots(datetime to = NULL) + { + // + bool has = drawVolumePivots; + if (!has) + { + return; + } + + // + has = detector.HasVolumePivots(); + if (!has) + { + return; + } + + // + int count = detector.CountVolumePivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox = detector.volumePivots[i]; + + // + DrawVolumePivot( + iBox, + to // + ); + + // + iBox.Clean(); + } + } + + // + void DrawRSIPeakPivots(datetime to = NULL) + { + // + bool has = drawRSIPeakPivots; + if (!has) + { + return; + } + + // + has = detector.HasRSIPeakPivots(); + if (!has) + { + return; + } + + // + int count = detector.CountRSIPeakPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox = detector.rsiPeakPivots[i]; + + // + DrawRSIPeakPivot( + iBox, + to // + ); + + // + iBox.Clean(); + } + } + + // + void DrawRSIValePivots(datetime to = NULL) + { + // + bool has = drawRSIValePivots; + if (!has) + { + return; + } + + // + has = detector.HasRSIValePivots(); + if (!has) + { + return; + } + + // + int count = detector.CountRSIValePivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox = detector.rsiValePivots[i]; + + // + DrawRSIValePivot( + iBox, + to // + ); + + // + iBox.Clean(); + } + } + + // + void DrawCCIPeakPivots(datetime to = NULL) + { + // + bool has = drawCCIPeakPivots; + if (!has) + { + return; + } + + // + has = detector.HasCCIPeakPivots(); + if (!has) + { + return; + } + + // + int count = detector.CountCCIPeakPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox = detector.cciPeakPivots[i]; + + // + DrawCCIPeakPivot( + iBox, + to // + ); + + // + iBox.Clean(); + } + } + + // + void DrawCCIValePivots(datetime to = NULL) + { + // + bool has = drawCCIValePivots; + if (!has) + { + return; + } + + // + has = detector.HasCCIValePivots(); + if (!has) + { + return; + } + + // + int count = detector.CountCCIValePivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox = detector.cciValePivots[i]; + + // + DrawCCIValePivot( + iBox, + to // + ); + + // + iBox.Clean(); + } + } + + // + void DrawFVGBullishPivots(datetime to = NULL) + { + // + bool has = drawFVGBullishPivots; + if (!has) + { + return; + } + + // + has = detector.HasFVGBullishPivots(); + if (!has) + { + return; + } + + // + int count = detector.CountFVGBullishPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox = detector.fvgBullishPivots[i]; + + // + DrawFVGBullishPivot( + iBox, + to // + ); + + // + iBox.Clean(); + } + } + + // + void DrawFVGBearishPivots(datetime to = NULL) + { + // + bool has = drawFVGBearishPivots; + if (!has) + { + return; + } + + // + has = detector.HasFVGBearishPivots(); + if (!has) + { + return; + } + + // + int count = detector.CountFVGBearishPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox = detector.fvgBearishPivots[i]; + + // + DrawFVGBearishPivot( + iBox, + to // + ); + + // + iBox.Clean(); + } + } + + // + void DrawValeSupSWLPivots(datetime to = NULL) + { + // + bool has = drawValeSupSWLPivots; + if (!has) + { + return; + } + + // + has = detector.HasValeSupSWLPivots(); + if (!has) + { + return; + } + + // + int count = detector.CountValeSupSWLPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox = detector.valeSupSWLPivots[i]; + + // + DrawValeSupSWLPivot( + iBox, + to // + ); + + // + iBox.Clean(); + } + } + + // + void DrawPeakResSWHPivots(datetime to = NULL) + { + // + bool has = drawPeakResSWHPivots; + if (!has) + { + return; + } + + // + has = detector.HasPeakResSWHPivots(); + if (!has) + { + return; + } + + // + int count = detector.CountPeakResSWHPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox = detector.peakResSWHPivots[i]; + + // + DrawPeakResSWHPivot( + iBox, + to // + ); + + // + iBox.Clean(); + } + } + + // + void DrawTrendBullishPivots(datetime to = NULL) + { + // + bool has = drawTrendBullishPivots; + if (!has) + { + return; + } + + // + has = detector.HasTrendBullishPivots(); + if (!has) + { + return; + } + + // + bool canUpdateTo = IsValid(to); + + // + int count = detector.CountTrendBullishPivots(); + for (int i = 0; i < count; i++) + { + // + XCATRENDFVG iTrendFVG = detector.trendBullishPivots[i]; + + // + DrawTrendBullishPivot( + iTrendFVG, + to // + ); + + // + iTrendFVG.Clean(); + } + } + + // + void DrawTrendBearishPivots(datetime to = NULL) + { + // + bool has = drawTrendBearishPivots; + if (!has) + { + return; + } + + // + has = detector.HasTrendBearishPivots(); + if (!has) + { + return; + } + + // + int count = detector.CountTrendBearishPivots(); + for (int i = 0; i < count; i++) + { + // + XCATRENDFVG iTrendFVG = detector.trendBearishPivots[i]; + + // + DrawTrendBearishPivot( + iTrendFVG, + to // + ); + + // + iTrendFVG.Clean(); + } + } + + // + void DrawRSICrossedOverOSPivots(datetime to = NULL) + { + // + bool has = drawRSICrossedOverOSPivots; + if (!has) + { + return; + } + + // + has = detector.HasRSICrossedOverOSPivots(); + if (!has) + { + return; + } + + // + int count = detector.CountRSICrossedOverOSPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox = detector.rsiCrossedOverOSPivots[i]; + + // + DrawRSICrossedOverOSPivot( + iBox, + to // + ); + + // + iBox.Clean(); + } + } + + // + void DrawRSICrossedUnderOBPivots(datetime to = NULL) + { + // + bool has = drawRSICrossedUnderOBPivots; + if (!has) + { + return; + } + + // + has = detector.HasRSICrossedUnderOBPivots(); + if (!has) + { + return; + } + + // + int count = detector.CountRSICrossedUnderOBPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox = detector.rsiCrossedUnderOBPivots[i]; + + // + DrawRSICrossedUnderOBPivot( + iBox, + to // + ); + + // + iBox.Clean(); + } + } + + // + void DrawCCICrossedOverOSPivots(datetime to = NULL) + { + // + bool has = drawCCICrossedOverOSPivots; + if (!has) + { + return; + } + + // + has = detector.HasCCICrossedOverOSPivots(); + if (!has) + { + return; + } + + // + int count = detector.CountCCICrossedOverOSPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox = detector.cciCrossedOverOSPivots[i]; + + // + DrawCCICrossedOverOSPivot( + iBox, + to // + ); + + // + iBox.Clean(); + } + } + + // + void DrawCCICrossedUnderOBPivots(datetime to = NULL) + { + // + bool has = drawCCICrossedUnderOBPivots; + if (!has) + { + return; + } + + // + has = detector.HasCCICrossedUnderOBPivots(); + if (!has) + { + return; + } + + // + int count = detector.CountCCICrossedUnderOBPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox = detector.cciCrossedUnderOBPivots[i]; + + // + DrawCCICrossedUnderOBPivot( + iBox, + to // + ); + + // + iBox.Clean(); + } + } + + // + // One Item Drawers ... + + // + void DrawTickPivot( + XBoxZone &item, + datetime to = NULL // + ) + { + // + bool has = drawTickPivots; + if (!has) + { + return; + } + + // + has = item.IsValid() && + item.type == GetBoxType(XCA_TICK); + if (!has) + { + return; + } + + // + bool canUpdateTo = IsValid(to); + if (canUpdateTo) + { + item.to = to; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + item, + iObj // + ); + if (has) + { + // + // Style Pivot ... + iObj.BoxColor(tickPivotsColor); + iObj.BoxWidth(tickPivotsWidth); + iObj.BoxStyle(tickPivotsStyle); + + // + // Store Pivot ... + mTickPivotObjects.Add(iObj); + } + + // + ZeroMemory(iObj); + } + + // + void DrawVolumePivot( + XBoxZone &item, + datetime to = NULL // + ) + { + // + bool has = drawVolumePivots; + if (!has) + { + return; + } + + // + has = item.IsValid() && + item.type == GetBoxType(XCA_VOLUME); + if (!has) + { + return; + } + + // + bool canUpdateTo = IsValid(to); + if (canUpdateTo) + { + item.to = to; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + item, + iObj // + ); + if (has) + { + // + // Style Pivot ... + iObj.BoxColor(volumePivotsColor); + iObj.BoxWidth(volumePivotsWidth); + iObj.BoxStyle(volumePivotsStyle); + + // + // Store Pivot ... + mVolumePivotObjects.Add(iObj); + } + + // + ZeroMemory(iObj); + } + + // + void DrawRSIPeakPivot( + XBoxZone &item, + datetime to = NULL // + ) + { + // + bool has = drawRSIPeakPivots; + if (!has) + { + return; + } + + // + has = item.IsValid() && + item.type == GetBoxType(XCA_RSI_PEAK) && + item.dir == GetDirection(XCA_RSI_PEAK); + if (!has) + { + return; + } + + // + if (ignoreUpdateOSCTos) + { + to = NULL; + } + bool canUpdateTo = IsValid(to); + if (canUpdateTo) + { + item.to = to; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + item, + iObj // + ); + if (has) + { + // + // Style Object ... + iObj.BoxColor(rsiPeakPivotsColor); + iObj.BoxWidth(rsiPeakPivotsWidth); + iObj.BoxStyle(rsiPeakPivotsStyle); + + // + // Store Object ... + mRSIPeakPivotObjects.Add(iObj); + } + + // + ZeroMemory(iObj); + } + + // + void DrawRSIValePivot( + XBoxZone &item, + datetime to = NULL // + ) + { + // + bool has = drawRSIValePivots; + if (!has) + { + return; + } + + // + has = item.IsValid() && + item.type == GetBoxType(XCA_RSI_VALE) && + item.dir == GetDirection(XCA_RSI_VALE); + if (!has) + { + return; + } + + // + if (ignoreUpdateOSCTos) + { + to = NULL; + } + bool canUpdateTo = IsValid(to); + if (canUpdateTo) + { + item.to = to; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + item, + iObj // + ); + if (has) + { + // + // Style Object ... + iObj.BoxColor(rsiValePivotsColor); + iObj.BoxWidth(rsiValePivotsWidth); + iObj.BoxStyle(rsiValePivotsStyle); + + // + // Store Object ... + mRSIValePivotObjects.Add(iObj); + } + + // + ZeroMemory(iObj); + } + + // + void DrawCCIPeakPivot( + XBoxZone &item, + datetime to = NULL // + ) + { + // + bool has = drawCCIPeakPivots; + if (!has) + { + return; + } + + // + has = item.IsValid() && + item.type == GetBoxType(XCA_CCI_PEAK) && + item.dir == GetDirection(XCA_CCI_PEAK); + if (!has) + { + return; + } + + // + if (ignoreUpdateOSCTos) + { + to = NULL; + } + bool canUpdateTo = IsValid(to); + if (canUpdateTo) + { + item.to = to; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + item, + iObj // + ); + if (has) + { + // + // Style Object ... + iObj.BoxColor(cciPeakPivotsColor); + iObj.BoxWidth(cciPeakPivotsWidth); + iObj.BoxStyle(cciPeakPivotsStyle); + + // + // Store Object ... + mCCIPeakPivotObjects.Add(iObj); + } + + // + ZeroMemory(iObj); + } + + // + void DrawCCIValePivot( + XBoxZone &item, + datetime to = NULL // + ) + { + // + bool has = drawCCIValePivots; + if (!has) + { + return; + } + + // + has = item.IsValid() && + item.type == GetBoxType(XCA_CCI_VALE) && + item.dir == GetDirection(XCA_CCI_VALE); + if (!has) + { + return; + } + + // + if (ignoreUpdateOSCTos) + { + to = NULL; + } + bool canUpdateTo = IsValid(to); + if (canUpdateTo) + { + item.to = to; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + item, + iObj // + ); + if (has) + { + // + // Style Object ... + iObj.BoxColor(cciValePivotsColor); + iObj.BoxWidth(cciValePivotsWidth); + iObj.BoxStyle(cciValePivotsStyle); + + // + // Store Object ... + mCCIValePivotObjects.Add(iObj); + } + + // + ZeroMemory(iObj); + } + + // + void DrawFVGBullishPivot( + XBoxZone &item, + datetime to = NULL // + ) + { + // + bool has = drawFVGBullishPivots; + if (!has) + { + return; + } + + // + has = item.IsValid() && + item.type == GetBoxType(XCA_FVG_BULL) && + item.dir == GetDirection(XCA_FVG_BULL); + if (!has) + { + return; + } + + // + bool canUpdateTo = IsValid(to); + if (canUpdateTo) + { + item.to = to; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + item, + iObj // + ); + if (has) + { + // + // Style Object ... + iObj.BoxColor(fvgBullishPivotsColor); + iObj.BoxWidth(fvgBullishPivotsWidth); + iObj.BoxStyle(fvgBullishPivotsStyle); + + // + // Store Object ... + mFVGBullishPivotObjects.Add(iObj); + } + + // + ZeroMemory(iObj); + } + + // + void DrawFVGBearishPivot( + XBoxZone &item, + datetime to = NULL // + ) + { + // + bool has = drawFVGBearishPivots; + if (!has) + { + return; + } + + // + has = item.IsValid() && + item.type == GetBoxType(XCA_FVG_BEAR) && + item.dir == GetDirection(XCA_FVG_BEAR); + if (!has) + { + return; + } + + // + bool canUpdateTo = IsValid(to); + if (canUpdateTo) + { + item.to = to; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + item, + iObj // + ); + if (has) + { + // + // Style Object ... + iObj.BoxColor(fvgBearishPivotsColor); + iObj.BoxWidth(fvgBearishPivotsWidth); + iObj.BoxStyle(fvgBearishPivotsStyle); + + // + // Store Object ... + mFVGBearishPivotObjects.Add(iObj); + } + + // + ZeroMemory(iObj); + } + + // + void DrawValeSupSWLPivot( + XBoxZone &item, + datetime to = NULL // + ) + { + // + bool has = drawValeSupSWLPivots; + if (!has) + { + return; + } + + // + has = item.IsValid() && + item.type == GetBoxType(XCA_VALESWLSUP) && + item.dir == GetDirection(XCA_VALESWLSUP); + if (!has) + { + return; + } + + // + bool canUpdateTo = IsValid(to); + if (canUpdateTo) + { + item.to = to; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + item, + iObj // + ); + if (has) + { + // + // Style Object ... + iObj.BoxColor(valeSupSWLPivotsColor); + iObj.BoxWidth(valeSupSWLPivotsWidth); + iObj.BoxStyle(valeSupSWLPivotsStyle); + + // + // Store Object ... + mValeSupSWLPivotObjects.Add(iObj); + } + + // + ZeroMemory(iObj); + } + + // + void DrawPeakResSWHPivot( + XBoxZone &item, + datetime to = NULL // + ) + { + // + bool has = drawPeakResSWHPivots; + if (!has) + { + return; + } + + // + has = item.IsValid() && + item.type == GetBoxType(XCA_PEAKSWHRES) && + item.dir == GetDirection(XCA_PEAKSWHRES); + if (!has) + { + return; + } + + // + bool canUpdateTo = IsValid(to); + if (canUpdateTo) + { + item.to = to; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + item, + iObj // + ); + if (has) + { + // + // Style Object ... + iObj.BoxColor(peakResSWHPivotsColor); + iObj.BoxWidth(peakResSWHPivotsWidth); + iObj.BoxStyle(peakResSWHPivotsStyle); + + // + // Store Object ... + mPeakResSWHPivotObjects.Add(iObj); + } + + // + ZeroMemory(iObj); + } + + // + void DrawTrendBullishPivot( + XCATRENDFVG &item, + datetime to = NULL // + ) + { + // + bool has = drawTrendBullishPivots; + if (!has) + { + return; + } + + // + has = item.IsValid() && + item.trend.type == GetBoxType(XCA_TREND_BULL) && + item.trend.dir == GetDirection(XCA_TREND_BULL); + if (!has) + { + return; + } + + // + bool canUpdateTo = IsValid(to); + + // + // Draw Trend Box ... + + // + if (canUpdateTo) + { + item.trend.to = to; + } + + // + XCBoxObject *iTrendBoxObj; + has = drawer.DrawBox( + item.trend, + iTrendBoxObj // + ); + if (has) + { + // + // Style Object ... + iTrendBoxObj.BoxColor(trendBullishPivotsColor); + iTrendBoxObj.BoxWidth(trendBullishPivotsWidth); + iTrendBoxObj.BoxStyle(trendBullishPivotsStyle); + + // + // Store Object ... + mTrendBullishPivotObjects.Add(iTrendBoxObj); + } + + // + // Draw ITrendFVG FVGS ... + if (drawTrendPivotsOnlySelectedFVG) + { + // + XBoxZone iBox; + has = item.GetSelectedFVG(iBox); + if (!has) + { + // + iBox.Clean(); + return; + } + + // + if (canUpdateTo) + { + iBox.to = to; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + iBox, + iObj // + ); + + // + if (has) + { + // + // Style Object ... + iObj.BoxColor(fvgBullishPivotsColor); + iObj.BoxWidth(fvgBullishPivotsWidth); + iObj.BoxStyle(fvgBullishPivotsStyle); + + // + // Store Object ... + mTrendBullishPivotObjects.Add(iObj); + } + + // + iBox.Clean(); + ZeroMemory(iObj); + } + else + { + // + // Draw All FVGs ... + has = HasChild(item.fvgs); + if (has) + { + // + int jCount = ArraySize(item.fvgs); + for (int j = 0; j < jCount; j++) + { + // + XBoxZone iBox = item.fvgs[j]; + + // + if (canUpdateTo) + { + iBox.to = to; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + iBox, + iObj // + ); + if (has) + { + // + // Style Object ... + iObj.BoxColor(fvgBullishPivotsColor); + iObj.BoxWidth(fvgBullishPivotsWidth); + iObj.BoxStyle(fvgBullishPivotsStyle); + + // + // Store Object ... + mTrendBullishPivotObjects.Add(iObj); + } + + // + iBox.Clean(); + ZeroMemory(iObj); + } + } + } + + // + ZeroMemory(iTrendBoxObj); + } + + // + void DrawTrendBearishPivot( + XCATRENDFVG &item, + datetime to = NULL // + ) + { + // + bool has = drawTrendBearishPivots; + if (!has) + { + return; + } + + // + has = item.IsValid() && + item.trend.type == GetBoxType(XCA_TREND_BEAR) && + item.trend.dir == GetDirection(XCA_TREND_BEAR); + if (!has) + { + return; + } + + // + bool canUpdateTo = IsValid(to); + + // + // Draw Trend Box ... + + // + if (canUpdateTo) + { + item.trend.to = to; + } + + // + XCBoxObject *iTrendBoxObj; + has = drawer.DrawBox( + item.trend, + iTrendBoxObj // + ); + if (has) + { + // + // Style Object ... + iTrendBoxObj.BoxColor(trendBearishPivotsColor); + iTrendBoxObj.BoxWidth(trendBearishPivotsWidth); + iTrendBoxObj.BoxStyle(trendBearishPivotsStyle); + + // + // Store Object ... + mTrendBearishPivotObjects.Add(iTrendBoxObj); + } + + // + // Draw ITrendFVG FVGS ... + if (drawTrendPivotsOnlySelectedFVG) + { + // + XBoxZone iBox; + has = item.GetSelectedFVG(iBox); + if (!has) + { + // + iBox.Clean(); + return; + } + + // + if (canUpdateTo) + { + iBox.to = to; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + iBox, + iObj // + ); + + // + if (has) + { + // + // Style Object ... + iObj.BoxColor(fvgBearishPivotsColor); + iObj.BoxWidth(fvgBearishPivotsWidth); + iObj.BoxStyle(fvgBearishPivotsStyle); + + // + // Store Object ... + mTrendBearishPivotObjects.Add(iObj); + } + + // + iBox.Clean(); + ZeroMemory(iObj); + } + else + { + // + // Draw All FVGs ... + has = HasChild(item.fvgs); + if (has) + { + // + int jCount = ArraySize(item.fvgs); + for (int j = 0; j < jCount; j++) + { + // + XBoxZone iBox = item.fvgs[j]; + + // + if (canUpdateTo) + { + iBox.to = to; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + iBox, + iObj // + ); + if (has) + { + // + // Style Object ... + iObj.BoxColor(fvgBearishPivotsColor); + iObj.BoxWidth(fvgBearishPivotsWidth); + iObj.BoxStyle(fvgBearishPivotsStyle); + + // + // Store Object ... + mTrendBearishPivotObjects.Add(iObj); + } + + // + iBox.Clean(); + ZeroMemory(iObj); + } + } + } + + // + ZeroMemory(iTrendBoxObj); + } + + // + void DrawRSICrossedOverOSPivot( + XBoxZone &item, + datetime to = NULL // + ) + { + // + bool has = drawRSICrossedOverOSPivots; + if (!has) + { + return; + } + + // + has = item.IsValid() && + item.type == GetBoxType(XCA_RSI_COOS) && + item.dir == GetDirection(XCA_RSI_COOS); + if (!has) + { + return; + } + + // + if (ignoreUpdateOSCTos) + { + to = NULL; + } + bool canUpdateTo = IsValid(to); + if (canUpdateTo) + { + item.to = to; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + item, + iObj // + ); + if (has) + { + // + // Style Object ... + iObj.BoxColor(rsiCrossedOverOSPivotsColor); + iObj.BoxWidth(rsiCrossedOverOSPivotsWidth); + iObj.BoxStyle(rsiCrossedOverOSPivotsStyle); + + // + // Store Object ... + mRSICrossedOverOSPivotObjects.Add(iObj); + } + + // + ZeroMemory(iObj); + } + + // + void DrawRSICrossedUnderOBPivot( + XBoxZone &item, + datetime to = NULL // + ) + { + // + bool has = drawRSICrossedUnderOBPivots; + if (!has) + { + return; + } + + // + has = item.IsValid() && + item.type == GetBoxType(XCA_RSI_CUOB) && + item.dir == GetDirection(XCA_RSI_CUOB); + if (!has) + { + return; + } + + // + if (ignoreUpdateOSCTos) + { + to = NULL; + } + bool canUpdateTo = IsValid(to); + if (canUpdateTo) + { + item.to = to; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + item, + iObj // + ); + if (has) + { + // + // Style Object ... + iObj.BoxColor(rsiCrossedUnderOBPivotsColor); + iObj.BoxWidth(rsiCrossedUnderOBPivotsWidth); + iObj.BoxStyle(rsiCrossedUnderOBPivotsStyle); + + // + // Store Object ... + mRSICrossedUnderOBPivotObjects.Add(iObj); + } + + // + ZeroMemory(iObj); + } + + // + void DrawCCICrossedOverOSPivot( + XBoxZone &item, + datetime to = NULL // + ) + { + // + bool has = drawCCICrossedOverOSPivots; + if (!has) + { + return; + } + + // + has = item.IsValid() && + item.type == GetBoxType(XCA_CCI_COOS) && + item.dir == GetDirection(XCA_CCI_COOS); + if (!has) + { + return; + } + + // + if (ignoreUpdateOSCTos) + { + to = NULL; + } + bool canUpdateTo = IsValid(to); + if (canUpdateTo) + { + item.to = to; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + item, + iObj // + ); + if (has) + { + // + // Style Object ... + iObj.BoxColor(cciCrossedOverOSPivotsColor); + iObj.BoxWidth(cciCrossedOverOSPivotsWidth); + iObj.BoxStyle(cciCrossedOverOSPivotsStyle); + + // + // Store Object ... + mCCICrossedOverOSPivotObjects.Add(iObj); + } + + // + ZeroMemory(iObj); + } + + // + void DrawCCICrossedUnderOBPivot( + XBoxZone &item, + datetime to = NULL // + ) + { + // + bool has = drawCCICrossedUnderOBPivots; + if (!has) + { + return; + } + + // + has = item.IsValid() && + item.type == GetBoxType(XCA_CCI_CUOB) && + item.dir == GetDirection(XCA_CCI_CUOB); + if (!has) + { + return; + } + + // + if (ignoreUpdateOSCTos) + { + to = NULL; + } + bool canUpdateTo = IsValid(to); + if (canUpdateTo) + { + item.to = to; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + item, + iObj // + ); + if (has) + { + // + // Style Object ... + iObj.BoxColor(cciCrossedUnderOBPivotsColor); + iObj.BoxWidth(cciCrossedUnderOBPivotsWidth); + iObj.BoxStyle(cciCrossedUnderOBPivotsStyle); + + // + // Store Object ... + mCCICrossedUnderOBPivotObjects.Add(iObj); + } + + // + ZeroMemory(iObj); + } + + // + // Protected ... + protected: + // + // Props ... + + // + // Prrivate ... + private: + // + // Props ... + + // + XCPOIDrawer *drawer; + XCXCAEAPOIDetector *detector; + + // + CArrayObj mTickPivotObjects; + CArrayObj mTrendLineObjects; + CArrayObj mVolumePivotObjects; + CArrayObj mRSIPeakPivotObjects; + CArrayObj mRSIValePivotObjects; + CArrayObj mCCIPeakPivotObjects; + CArrayObj mCCIValePivotObjects; + CArrayObj mFVGBullishPivotObjects; + CArrayObj mFVGBearishPivotObjects; + CArrayObj mValeSupSWLPivotObjects; + CArrayObj mPeakResSWHPivotObjects; + CArrayObj mTrendBullishPivotObjects; + CArrayObj mTrendBearishPivotObjects; + CArrayObj mRSICrossedOverOSPivotObjects; + CArrayObj mRSICrossedUnderOBPivotObjects; + CArrayObj mCCICrossedOverOSPivotObjects; + CArrayObj mCCICrossedUnderOBPivotObjects; + + // +}; + +// \ No newline at end of file diff --git a/Documents/Temlates/temp.pivot.detect.mq5 b/Documents/Temlates/temp.pivot.detect.mq5 new file mode 100644 index 00000000..21040848 --- /dev/null +++ b/Documents/Temlates/temp.pivot.detect.mq5 @@ -0,0 +1,83 @@ + + // + bool DetectPivot( + int barIndex, + XOHCL &zBar, + XOHCL &cBar, + XOHCL &pBar, + XOHCL &p2Bar, + XCAEAConditions &conditions // + ) + { + // + bool result = false; + + // + // Validate Args ... + result = + // + barIndex >= 0 && + zBar.IsValid() && + cBar.IsValid() && + pBar.IsValid() && + p2Bar.IsValid() && + // + ; + if (!result) + { + return result; + } + + // + // Define Requirements ... + + // + int zIDX = 0; + int cIDX = zIDX + 1; + int pIDX = cIDX + 1; + int p2IDX = pIDX + 1; + + // + XCAPviot pivot; + datetime cTime = zBar.time; + string symbol = zBar.symbol; + string period = zBar.period; + + // + // Reading Conditional Values ... + + // + // Prepare Conditinal Conditions ... + + // + bool hasStartCondition = false; + bool hasContinuationCondition = false; + bool hasEndCondition = false; + + // + // ReInstance Pivot ... + if (hasStartConditions) + { + // + } + + // + // Calculate and Fill Pivot Requirements ... + if (hasContinuationCondition) + { + // + } + + // + // End up Pivot and Store it ... + if (hasEndCondition) + { + // + } + + // + pivot.Clean(); + + // + return result; + } diff --git a/XCAEA/Classes/xcaea.x-poi.detector.class.mq5 b/XCAEA/Classes/xcaea.x-poi.detector.class.mq5 index 82bd3a89..46524d71 100644 --- a/XCAEA/Classes/xcaea.x-poi.detector.class.mq5 +++ b/XCAEA/Classes/xcaea.x-poi.detector.class.mq5 @@ -33,20 +33,12 @@ enum ENUM_XCA_PIVOTS { XCA_NONE, // None - XCA_TICK, // Tick - XCA_VOLUME, // Volume + XCA_PEAK, // Peak + XCA_VALE, // Vale 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_PEAKSWHRES, // PeakSWHRes - XCA_VALESWLSUP, // ValeSWLSup XCA_TREND_BULL, // TrendBull XCA_TREND_BEAR, // TrendBear }; @@ -87,24 +79,18 @@ ENUM_X_DIRECTION GetDirection(ENUM_XCA_PIVOTS value) switch (value) { // + case XCA_VALE: case XCA_FVG_BULL: case XCA_RSI_COOS: - case XCA_RSI_VALE: - case XCA_CCI_COOS: - case XCA_CCI_VALE: case XCA_TREND_BULL: - case XCA_VALESWLSUP: result = X_DIRECTION_BULLISH; break; // + case XCA_PEAK: case XCA_FVG_BEAR: case XCA_RSI_CUOB: - case XCA_RSI_PEAK: - case XCA_CCI_CUOB: - case XCA_CCI_PEAK: case XCA_TREND_BEAR: - case XCA_PEAKSWHRES: result = X_DIRECTION_BEARISH; break; } @@ -123,18 +109,10 @@ string GetBoxType(ENUM_XCA_PIVOTS value) switch (value) { // - case XCA_TICK: - case XCA_VOLUME: + case XCA_VALE: + case XCA_PEAK: case XCA_RSI_COOS: - case XCA_RSI_VALE: - case XCA_CCI_COOS: - case XCA_CCI_VALE: case XCA_RSI_CUOB: - case XCA_RSI_PEAK: - case XCA_CCI_CUOB: - case XCA_CCI_PEAK: - case XCA_VALESWLSUP: - case XCA_PEAKSWHRES: result = ToString(value); break; // @@ -168,45 +146,31 @@ ENUM_XCA_PIVOTS GetPivotType(XBoxZone &value) } // - bool isTick = value.type == GetBoxType(XCA_TICK); - bool isVolume = value.type == GetBoxType(XCA_VOLUME); + bool isPeak = value.type == GetBoxType(XCA_PEAK) && + value.dir == GetDirection(XCA_PEAK); + bool isVale = value.type == GetBoxType(XCA_VALE) && + value.dir == GetDirection(XCA_VALE); bool isFVGBull = value.type == GetBoxType(XCA_FVG_BULL) && value.dir == GetDirection(XCA_FVG_BULL); bool isFVGBear = value.type == GetBoxType(XCA_FVG_BEAR) && value.dir == GetDirection(XCA_FVG_BEAR); - bool isRSIPeak = value.type == GetBoxType(XCA_RSI_PEAK) && - value.dir == GetDirection(XCA_RSI_PEAK); - bool isRSIVale = value.type == GetBoxType(XCA_RSI_VALE) && - value.dir == GetDirection(XCA_RSI_VALE); - bool isCCIPeak = value.type == GetBoxType(XCA_CCI_PEAK) && - value.dir == GetDirection(XCA_CCI_PEAK); - bool isCCIVale = value.type == GetBoxType(XCA_CCI_VALE) && - value.dir == GetDirection(XCA_CCI_VALE); bool isRSICrossedOverOS = value.type == GetBoxType(XCA_RSI_COOS) && value.dir == GetDirection(XCA_RSI_COOS); bool isRSICrossedUnderOB = value.type == GetBoxType(XCA_RSI_CUOB) && value.dir == GetDirection(XCA_RSI_CUOB); - bool isCCICrossedOverOS = value.type == GetBoxType(XCA_CCI_COOS) && - value.dir == GetDirection(XCA_CCI_COOS); - bool isCCICrossedUnderOB = value.type == GetBoxType(XCA_CCI_CUOB) && - value.dir == GetDirection(XCA_CCI_CUOB); bool isTrendBullish = value.type == GetBoxType(XCA_TREND_BULL) && value.dir == GetDirection(XCA_TREND_BULL); bool isTrendBearish = value.type == GetBoxType(XCA_TREND_BEAR) && value.dir == GetDirection(XCA_TREND_BEAR); - bool isPeakSWHRes = value.type == GetBoxType(XCA_PEAKSWHRES) && - value.dir == GetDirection(XCA_PEAKSWHRES); - bool isValeSWLSup = value.type == GetBoxType(XCA_VALESWLSUP) && - value.dir == GetDirection(XCA_VALESWLSUP); // - if (isTick) + if (isPeak) { - result = XCA_TICK; + result = XCA_PEAK; } - else if (isVolume) + else if (isVale) { - result = XCA_VOLUME; + result = XCA_VALE; } else if (isFVGBull) { @@ -216,22 +180,6 @@ ENUM_XCA_PIVOTS GetPivotType(XBoxZone &value) { result = XCA_FVG_BEAR; } - else if (isRSIPeak) - { - result = XCA_RSI_PEAK; - } - else if (isRSIVale) - { - result = XCA_RSI_VALE; - } - else if (isCCIPeak) - { - result = XCA_CCI_PEAK; - } - else if (isCCIVale) - { - result = XCA_CCI_VALE; - } else if (isRSICrossedOverOS) { result = XCA_RSI_COOS; @@ -240,14 +188,6 @@ ENUM_XCA_PIVOTS GetPivotType(XBoxZone &value) { result = XCA_RSI_CUOB; } - else if (isCCICrossedOverOS) - { - result = XCA_CCI_COOS; - } - else if (isCCICrossedUnderOB) - { - result = XCA_CCI_CUOB; - } else if (isTrendBullish) { result = XCA_TREND_BULL; @@ -256,14 +196,6 @@ ENUM_XCA_PIVOTS GetPivotType(XBoxZone &value) { result = XCA_TREND_BEAR; } - else if (isPeakSWHRes) - { - result = XCA_PEAKSWHRES; - } - else if (isValeSWLSup) - { - result = XCA_VALESWLSUP; - } // return result; @@ -626,392 +558,6 @@ struct XCAPivot // }; -// -struct XCATRENDFVG -{ - // - XBoxZone trend; - XBoxZone fvgs[]; - - // - XCATRENDFVG() - { - Clean(); - } - - // - // Tools ... - - // - void Clean() - { - // - Clean(fvgs); - trend.Clean(); - - // - ZeroMemory(this); - } - - // - bool IsValid() - { - // - bool result = false; - - // - result = trend.IsValid(); - - // - return result; - } - - // - void AddFVG(XBoxZone &fvg) - { - // - bool has = trend.IsValid() && - fvg.IsValid() && - fvg.dir == trend.dir; - if (!has) - { - return; - } - - // - int idx = -1; - has = FindBoxIndex( - idx, - fvg, - fvgs // - ); - if (has) - { - return; - } - - // - AddRef( - fvg, - fvgs // - ); - } - - // - bool IsBullish() - { - return IsValid() && - trend.IsBullish(); - } - - // - bool IsBearish() - { - return IsValid() && - trend.IsBearish(); - } - - // - bool GetSelectedFVG(XBoxZone &fvg) - { - // - bool result = false; - - // - fvg.Clean(); - - // - result = IsValid(); - if (!result) - { - return result; - } - - // - int idx = -1; - if (IsBullish()) - { - idx = GetLowest(fvgs); - } - else if (IsBearish()) - { - idx = GetHighest(fvgs); - } - result = IsValidIndex(idx); - if (!result) - { - return result; - } - - // - fvg = fvgs[idx]; - - // - result = fvg.IsValid(); - - // - return result; - } - - // -}; - -// -int ExtractTrendFVGs( - XBoxZone &extracteds[], - XBoxZone &trend, - XBoxZone &fvgs[] // -) -{ - // - int result = 0; - - // - Clean(extracteds); - - // - bool has = HasChild(fvgs) && - trend.IsValid(); - if (!has) - { - return result; - } - - // - // Check Trend Box Pivot is Valid Trend ... - ENUM_XCA_PIVOTS iType = GetPivotType(trend); - has = iType == XCA_TREND_BULL || - iType == XCA_TREND_BEAR; - if (!has) - { - return result; - } - - // - int count = ArraySize(fvgs); - for (int i = 0; i < count; i++) - { - // - XBoxZone iFVG = fvgs[i]; - - // - bool isDirPassed = iFVG.dir == trend.dir; - bool isPricePassed = iFVG.upper <= trend.upper && - iFVG.lower >= trend.lower; - bool isFromPassed = iFVG.from > trend.from; - has = - isDirPassed && - isFromPassed && - isPricePassed; - if (has) - { - // - AddRef( - iFVG, - extracteds // - ); - } - - // - iFVG.Clean(); - } - - // - result = ArraySize(extracteds); - - // - return result; -} - -// -int ExtractTrendPivots( - XCATRENDFVG &items[], - XBoxZone &boxes[] // -) -{ - // - int result = 0; - - // - Clean(items); - - // - bool has = HasChild(boxes); - if (!has) - { - return result; - } - - // - // Extract Trend Boxes ... - XBoxZone tmp[]; - XBoxZone trendBoxes[]; - ExtractPivots( - tmp, - XCA_TREND_BULL, - boxes // - ); - Copy( - tmp, - trendBoxes, - false // - ); - Clean(tmp); - ExtractPivots( - tmp, - XCA_TREND_BEAR, - boxes // - ); - Copy( - tmp, - trendBoxes, - false // - ); - Clean(tmp); - - // - // Check Trend Boxes Exists ... - has = HasChild(trendBoxes); - if (!has) - { - // - Clean(trendBoxes); - return result; - } - - // - // Extract FVG Boxes ... - XBoxZone fvgBoxes[]; - - // - ExtractPivots( - tmp, - XCA_FVG_BULL, - boxes // - ); - Copy( - tmp, - fvgBoxes, - false // - ); - Clean(tmp); - ExtractPivots( - tmp, - XCA_FVG_BEAR, - boxes // - ); - Copy( - tmp, - fvgBoxes, - false // - ); - Clean(tmp); - bool hasFVGs = HasChild(fvgBoxes); - int fvgsCount = ArraySize(fvgBoxes); - - // - // Loop through Trend Boxes to Extract XCATRENDFVG Models ... - int count = ArraySize(trendBoxes); - for (int i = 0; i < count; i++) - { - // - XBoxZone iTrendBox = trendBoxes[i]; - - // - XCATRENDFVG iTrendFVG; - iTrendFVG.trend = iTrendBox; - - // - XBoxZone fvgs[]; - if (hasFVGs) - { - // - int fvgsCount = ExtractTrendFVGs( - fvgs, - iTrendBox, - fvgBoxes // - ); - - // - Copy( - fvgs, - iTrendFVG.fvgs // - ); - } - - // - has = iTrendFVG.IsValid(); - if (has) - { - // - AddRef( - iTrendFVG, - items // - ); - } - - // - iTrendBox.Clean(); - iTrendFVG.Clean(); - } - - // - Clean(tmp); - Clean(fvgBoxes); - Clean(trendBoxes); - - // - result = ArraySize(items); - - // - return result; -} - -// -int GetOldest(XCATRENDFVG &items[]) -{ - // - int result = -1; - - // - bool has = HasChild(items); - if (!has) - { - return result; - } - - // - XCATRENDFVG item; - int count = ArraySize(items); - for (int i = 0; i < count; i++) - { - // - XCATRENDFVG iTrendFVG = items[i]; - - // - bool canSet = - !item.IsValid() - ? true - : item.trend.from > iTrendFVG.trend.from; - if (canSet) - { - // - result = i; - item = iTrendFVG; - } - - // - iTrendFVG.Clean(); - } - - // - has = IsValidIndex(result); - item.Clean(); - - // - return result; -} - // // Implementations ... class XCXCAEAPOIDetector : public XCBase @@ -1024,11 +570,10 @@ class XCXCAEAPOIDetector : public XCBase // // Pivot Verifications and Max Allowed Holding Items ... - int maxAllowedPivots; // Max Allowed Holding Pibots ... - int pivotVerifications; // Pivots Verifications ... - int pivotDetectionLoopbac; // Pivots Detection Loopback ... - double ticksDividerInPoints; // Ticks and Volume Detection Divider in Point ... - ENUM_TIMEFRAMES ticksDetectionPerid; // Ticks and Volume Detection Loopback ... + int maxAllowedPivots; // Max Allowed Holding Pibots ... + int pivotVerifications; // Pivots Verifications ... + int pivotDetectionLoopbac; // Pivots Detection Loopback ... + double ticksDividerInPoints; // Ticks and Volume Detection Divider in Point ... // // TREND ... @@ -1040,138 +585,6 @@ class XCXCAEAPOIDetector : public XCBase // Breaked Pivots ... XBoxZone invalidPivots[]; - // - // TICK Pivots ... - - // - bool detectTickPivots; - XBoxZone tickPivots[]; - - // - // VOLUME Pivots ... - - // - bool detectVolumePivots; - XBoxZone volumePivots[]; - - // - // RSI Peak Pivot ... - - // - bool detectRSIPeakPivots; - XBoxZone rsiPeakPivots[]; - bool newRSIPeakPivotDetected; - - // - // RSI Vale Pivot ... - - // - bool detectRSIValePivots; - XBoxZone rsiValePivots[]; - bool newRSIValePivotDetected; - - // - // CCI Peak Pivot ... - - // - bool detectCCIPeakPivots; - XBoxZone cciPeakPivots[]; - bool newCCIPeakPivotDetected; - - // - // CCI Vale Pivot ... - - // - bool detectCCIValePivots; - XBoxZone cciValePivots[]; - bool newCCIValePivotDetected; - - // - // FVG Bullish Pivots ... - - // - bool detectFVGBullishPivots; - XBoxZone fvgBullishPivots[]; - bool newFVGBullishPivotDetected; - - // - // FVG Bearish Pivots ... - - // - bool detectFVGBearishPivots; - XBoxZone fvgBearishPivots[]; - bool newFVGBearishPivotDetected; - - // - // 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; - - // - // TREND Bullish ... - - // - XCAPivot trendBullishPivot; - XBoxZone trendBullishFVGs[]; - bool detectTrendBullishPivots; - XCATRENDFVG trendBullishPivots[]; - bool newTrendBullishPivotDetected; - - // - // TREND Bearish ... - - // - XCAPivot trendBearishPivot; - XBoxZone trendBearishFVGs[]; - bool detectTrendBearishPivots; - XCATRENDFVG trendBearishPivots[]; - bool newTrendBearishPivotDetected; - - // - // RSI Crossed Over OS Pivot ... - - // - bool detectRSICrossedOverOSPivots; - XBoxZone rsiCrossedOverOSPivots[]; - bool newRSICrossedOverOSPivotDetected; - - // - // RSI Crossed Under OB Pivot ... - - // - bool detectRSICrossedUnderOBPivots; - XBoxZone rsiCrossedUnderOBPivots[]; - bool newRSICrossedUnderOBPivotDetected; - - // - // CCI Crossed Over OS Pivot ... - - // - bool detectCCICrossedOverOSPivots; - XBoxZone cciCrossedOverOSPivots[]; - bool newCCICrossedOverOSPivotDetected; - - // - // CCI Crossed Under OB Pivot ... - - // - bool detectCCICrossedUnderOBPivots; - XBoxZone cciCrossedUnderOBPivots[]; - bool newCCICrossedUnderOBPivotDetected; - // // Constructors ... XCXCAEAPOIDetector( @@ -1191,23 +604,6 @@ class XCXCAEAPOIDetector : public XCBase // De Constructors ... ~XCXCAEAPOIDetector() { - // - valeSupSWLPivot.Clean(); - peakResSWHPivot.Clean(); - - // - Clean(trendBullishFVGs); - trendBullishPivot.Clean(); - - // - Clean(trendBearishFVGs); - trendBearishPivot.Clean(); - - // - trendPivotP.Clean(); - trendPivotC.Clean(); - trendDir = X_DIRECTION_NONE; - // CleanPivots(); @@ -1231,32 +627,31 @@ class XCXCAEAPOIDetector : public XCBase pivotVerifications = 5; ticksDividerInPoints = 15; pivotDetectionLoopbac = 100; - ticksDetectionPerid = PERIOD_D1; // - detectTickPivots = true; - detectVolumePivots = true; - detectRSIPeakPivots = true; - detectRSIValePivots = true; - detectCCIPeakPivots = true; - detectCCIValePivots = true; - detectFVGBullishPivots = true; - detectFVGBearishPivots = true; - detectValeSupSWLPivots = true; - detectPeakResSWHPivots = true; - detectTrendBullishPivots = true; - detectTrendBearishPivots = true; - detectRSICrossedOverOSPivots = true; - detectRSICrossedUnderOBPivots = true; - detectCCICrossedOverOSPivots = true; - detectCCICrossedUnderOBPivots = true; + // PEAK ... + detectPeakPivots = false; + + // + // VALES ... + detectValePivots = false; + + // + // FVG ... + maxAllowedFVGLife = 0; + detectFVGTypeOne = false; + detectFVGTypeTwo = false; + applyPVToFVGBoundary = false; + detectFVGBullishPivots = false; + detectFVGBearishPivots = false; + applyLastBarToFVGBoundary = false; + selectOnlyFVGWhichHasIndirectionalLastBar = false; // - trendDir = X_DIRECTION_NONE; } // - void Update( + void Detect( int barIndex = 0 // ) { @@ -1275,22 +670,6 @@ 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; - newTrendBullishPivotDetected = false; - newTrendBearishPivotDetected = false; - newRSICrossedOverOSPivotDetected = false; - newRSICrossedUnderOBPivotDetected = false; - newCCICrossedOverOSPivotDetected = false; - newCCICrossedUnderOBPivotDetected = false; - // int zIDX = 0; int cIDX = zIDX + 1; @@ -1298,6 +677,12 @@ class XCXCAEAPOIDetector : public XCBase int p2IDX = pIDX + 1; int p3IDX = p2IDX + 1; + // + newPeakPivotDetected = false; + newValePivotDetected = false; + newFVGBullishPivotDetected = false; + newFVGBearishPivotDetected = false; + // int index = barIndex; int start = index; @@ -1351,866 +736,59 @@ class XCXCAEAPOIDetector : public XCBase continue; } - // - // Bars Conditions ... - - // - // Bars Conditions ... - - // - ENUM_X_DIRECTION cBarDir; - - // - // Hammer ... - bool isCBarHammer = helper - .barAnalyser - .IsHammer( - cBar, - cBarDir // - ); - bool isCBarBullishHammer = - isCBarHammer && - IsBullish(cBarDir); - bool isCBarBearishHammer = - isCBarHammer && - IsBearish(cBarDir); - - // - // Rejected ... - bool isCBarRejected = helper - .barAnalyser - .IsRejected( - cBar, - cBarDir, - false, // Force Type ... - true // Force Fibo Pressure ... - ); - bool isCBarBullishRejected = - isCBarRejected && - IsBullish(cBarDir); - bool isCBarBearishRejected = - isCBarRejected && - IsBearish(cBarDir); - - // - // Engulfed ... - bool isCBarEngulfed = helper - .barAnalyser - .IsEngulfed( - cBar, - cBarDir // - ); - bool isCBarBullishEngulfed = - isCBarEngulfed && - IsBullish(cBarDir); - bool isCBarBearishEngulfed = - isCBarEngulfed && - IsBearish(cBarDir); - - // - // Momentum ... - bool isCBarMomentum = helper - .barAnalyser - .IsMomentum( - cBar, - cBarDir, - 1 // - ); - bool isCBarBullishMomentum = - isCBarMomentum && - IsBullish(cBarDir); - bool isCBarBearishMomentum = - isCBarMomentum && - IsBearish(cBarDir); - - // - // FVG ... - - // - XBoxZone fvgBox; - bool isFVG = barAnalyser.IsFVG( - cBar, - fvgBox // - ); - bool isBullishFVG = - isFVG && - fvgBox.IsBullish(); - bool isBearishFVG = - isFVG && - fvgBox.IsBearish(); - - // - bool isCBarHasBullishPower = isBullishFVG || - isCBarBullishRejected || - isCBarBullishEngulfed || - isCBarBullishMomentum; - - // - bool isCBarHasBearishPower = isBearishFVG || - isCBarBearishRejected || - isCBarBearishEngulfed || - isCBarBearishMomentum; - - // - // Reading Values from Conditions and - // Create Customized Conditions if required ... - - // - // PEAK ... - double zPeak = conditions.peakBuffer[zIDX]; - double cPeak = conditions.peakBuffer[cIDX]; - double pPeak = conditions.peakBuffer[pIDX]; - double p2Peak = conditions.peakBuffer[p2IDX]; - - // - // VALE ... - double zVale = conditions.valeBuffer[zIDX]; - double cVale = conditions.valeBuffer[cIDX]; - double pVale = conditions.valeBuffer[pIDX]; - double p2Vale = conditions.valeBuffer[p2IDX]; - - // - // RSI ... - - // - double zRSI = conditions.rsiBuffer[zIDX]; - double cRSI = conditions.rsiBuffer[cIDX]; - double pRSI = conditions.rsiBuffer[pIDX]; - double p2RSI = conditions.rsiBuffer[p2IDX]; - - // - bool isRSIPeak = - pRSI > cRSI && - pRSI > p2RSI && - pRSI > zRSI; - - // - bool isRSIVale = - pRSI < cRSI && - pRSI < p2RSI && - pRSI < zRSI; - - // - // CCI ... - - // - double zCCI = conditions.cciBuffer[zIDX]; - double cCCI = conditions.cciBuffer[cIDX]; - double pCCI = conditions.cciBuffer[pIDX]; - double p2CCI = conditions.cciBuffer[p2IDX]; - - // - bool isCCIPeak = - pCCI > cCCI && - pCCI > p2CCI && - pCCI > zCCI; - - // - bool isCCIVale = - pCCI < cCCI && - pCCI < p2CCI && - pCCI < zCCI; - - // - // ATR ... - double zATR = conditions.atrBuffer[zIDX]; - double cATR = conditions.atrBuffer[cIDX]; - double pATR = conditions.atrBuffer[pIDX]; - double p2ATR = conditions.atrBuffer[p2IDX]; - - // - double atrSum = GetSum(conditions.atrBuffer); - double atrMax = GetMax(conditions.atrBuffer); - double atrMin = GetMin(conditions.atrBuffer); - double atrAvg = GetAverage(conditions.atrBuffer); - - // - // Extracting Required Data about Trending ... - - // - double zFast = conditions.fastBuffer[zIDX]; - double cFast = conditions.fastBuffer[cIDX]; - double pFast = conditions.fastBuffer[pIDX]; - double p2Fast = conditions.fastBuffer[p2IDX]; - - // - double zMedium = conditions.mediumBuffer[zIDX]; - double cMedium = conditions.mediumBuffer[cIDX]; - double pMedium = conditions.mediumBuffer[pIDX]; - double p2Medium = conditions.mediumBuffer[p2IDX]; - - // - double zSlow = conditions.slowBuffer[zIDX]; - double cSlow = conditions.slowBuffer[cIDX]; - double pSlow = conditions.slowBuffer[pIDX]; - double p2Slow = conditions.slowBuffer[p2IDX]; - - // - double z3Mas[] = { - zFast, - zMedium, - zSlow, - }; - double z3MasMin = GetMin(z3Mas); - double z3MasMax = GetMax(z3Mas); - - // - double c3Mas[] = { - cFast, - cMedium, - cSlow, - }; - double c3MasMin = GetMin(c3Mas); - double c3MasMax = GetMax(c3Mas); - - // - double p3Mas[] = { - pFast, - pMedium, - pSlow, - }; - double p3MasMin = GetMin(p3Mas); - double p3MasMax = GetMax(p3Mas); - - // - double p23Mas[] = { - p2Fast, - p2Medium, - p2Slow, - }; - double p23MasMin = GetMin(p23Mas); - double p23MasMax = GetMax(p23Mas); - - // - // Try to Custom Mechanism for Trend Detection ... - - // - bool is3MaBullish = - cFast > cSlow && - cMedium > cSlow; - bool is3MaBullishPrev = - pFast > pSlow && - pMedium > pSlow; - - // - bool is3MaBearish = - cFast < cSlow && - cMedium < cSlow; - bool is3MaBearishPrev = - pFast < pSlow && - pMedium < pSlow; - - // - bool is3MaSwitchedToBullish = is3MaBullish && - !is3MaBullishPrev; - bool is3MaSwitchedToBearish = is3MaBearish && - !is3MaBearishPrev; - - // - bool is3MaFinishedFromBullish = !is3MaBullish && - is3MaBullishPrev; - bool is3MaFinishedFromBearish = !is3MaBearish && - is3MaBearishPrev; - - // - // TREND BULLISH Conditions ... - - // - bool trendBullishStartPivotCondition = - // - // One ... - // conditions.is3MaFinishedFromBullish - // // - // || - // - // Two ... - is3MaFinishedFromBullish - // - ; - - // - bool trendBullishPivotContinuationCondition = - // - // One ... - // conditions.is3MaBullish - // // - // || - // - // Two ... - is3MaBullish - // - ; - - // - bool trendBullisPivothFinishedCondition = - // - // One ... - // conditions.is3MaSwitchedToBullish - // // - // || - // - // Two ... - is3MaSwitchedToBullish - // - ; - - // - // TREND BEARISH Conditions ... - - // - bool trendBearishStartPivotCondition = - // - // One ... - // conditions.is3MaFinishedFromBearish - // // - // || - // - // Two ... - is3MaFinishedFromBearish - // - ; - - // - bool trendBearishPivotContinuationCondition = - // - // One ... - // conditions.is3MaBearish - // // - // || - // - // Two ... - is3MaBearish - // - ; - - // - bool trendBearishivothFinishedCondition = - // - // One ... - // conditions.is3MaSwitchedToBearish - // // - // || - // - // Two ... - is3MaSwitchedToBearish - // - ; - // // Checking Pivots ... // - // Detect TICK and VOLUME Pivots ... - if (detectTickPivots || detectVolumePivots) + // PV ... + + // + // PEAK ... + if (detectPeakPivots) { // - XOHCL ticksToBar; - XOHCL ticksFromBar; - XCTicksZone *ticksZone = NULL; - - // - datetime ticksTo = GetPeriodStartTime( - zBar.symbol, - ticksDetectionPerid, - zBar.time // + newPeakPivotDetected = DetectPeakPivot( + barIndex, + zBar, + cBar, + pBar, + p2Bar, + conditions // ); - bool isTicksBarInited = ticksToBar.Init( - zBar.symbol, - zBar.period, - ticksTo // + } + + // + // VALE ... + if (detectValePivots) + { + // + newValePivotDetected = DetectValePivot( + barIndex, + zBar, + cBar, + pBar, + p2Bar, + conditions // ); - datetime ticksFrom = ticksTo - PeriodSeconds(ticksDetectionPerid); - isTicksBarInited = isTicksBarInited && - ticksFromBar.Init( - zBar.symbol, - zBar.period, - ticksFrom // - ); - bool hasValidTicksTimeRange = IsValid(ticksTo) && - isTicksBarInited && - IsValid(ticksFrom) && - ticksFrom < ticksTo; - - // - bool isTickPivotExists = - hasValidTicksTimeRange && - IsExistsTickPivot( - ticksTo, - ticksFrom // - ); - - // - bool isVolumePivotExists = - hasValidTicksTimeRange && - IsExistsVolumePivot( - ticksTo, - ticksFrom // - ); - - // - bool isInitializedZone = !isTickPivotExists || - !isVolumePivotExists; - if (isInitializedZone) - { - // - isInitializedZone = InitializeTicksZone( - ticksZone, - ticksToBar, - ticksFromBar // - ); - } - - // - // TICK Pivots ... - if (detectTickPivots) - { - // - // Check Current Zone Exists or Not ... - if (isInitializedZone && !isTickPivotExists) - { - // - XBoxZone iBox; - XCTickZone *iZone; - has = ticksZone.GetMaxTickZone(iZone); - if (has) - { - // - // Try to Converts a Tick Zone to XBoxZone ... - iBox.to = ticksTo; - iBox.from = ticksFrom; - iBox.lower = iZone.low; - iBox.upper = iZone.high; - iBox.symbol = iZone.symbol; - iBox.period = iZone.period; - iBox.type = GetBoxType(XCA_TICK); - iBox.dir = X_DIRECTION_BULLISH; // Temparory ... - - // - has = iBox.IsValid(); - if (has) - { - // - AddBox( - iBox, - tickPivots // - ); - } - } - - // - iBox.Clean(); - ZeroMemory(iZone); - } - } - - // - // VOLUME Pivots ... - if (detectVolumePivots) - { - // - // Check Current Zone Exists or Not ... - if (isInitializedZone && !isVolumePivotExists) - { - // - XBoxZone iBox; - XCTickZone *iZone; - has = ticksZone.GetMaxVolumeZone(iZone); - if (has) - { - // - // Try to Converts a Tick Zone to XBoxZone ... - iBox.to = ticksTo; - iBox.from = ticksFrom; - iBox.lower = iZone.low; - iBox.upper = iZone.high; - iBox.symbol = iZone.symbol; - iBox.period = iZone.period; - iBox.type = GetBoxType(XCA_VOLUME); - iBox.dir = X_DIRECTION_BULLISH; // Temparory ... - - // - has = iBox.IsValid(); - if (has) - { - // - AddBox( - iBox, - volumePivots // - ); - } - } - - // - iBox.Clean(); - ZeroMemory(iZone); - } - } - - // - ticksToBar.Clean(); - ticksFromBar.Clean(); - ZeroMemory(ticksZone); - - // } // - // RSI Peak Pivot ... - if (detectRSIPeakPivots) - { - // - bool checkingCondition = - isRSIPeak && - isCBarHasBearishPower // && - // conditions.isRSICrossedUnderOB - ; - - // - if (checkingCondition) - { - // - 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); - - // - XBoxZone iBox; - has = iPivot.IsValid(); - if (has) - { - // - has = iPivot.AsBox(iBox); - if (has) - { - // - newRSIPeakPivotDetected = AddBox( - iBox, - rsiPeakPivots // - ); - } - } - - // - iBox.Clean(); - iPivot.Clean(); - } - } - - // - // RSI Vale Pivot ... - if (detectRSIValePivots) - { - // - bool checkingCondition = - isRSIVale && - isCBarHasBullishPower // && - // conditions.isRSICrossedOverOS - ; - - // - if (checkingCondition) - { - // - 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); - - // - XBoxZone iBox; - has = iPivot.IsValid(); - if (has) - { - // - has = iPivot.AsBox(iBox); - if (has) - { - // - newRSIValePivotDetected = AddBox( - iBox, - rsiValePivots // - ); - } - } - - // - iBox.Clean(); - iPivot.Clean(); - } - } - - // - // CCI Peak Pivot ... - if (detectCCIPeakPivots) - { - // - bool checkingCondition = - isCCIPeak && - isCBarHasBearishPower // && - // conditions.isCCICrossedUnderOB - ; - - // - if (checkingCondition) - { - // - 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); - - // - XBoxZone iBox; - has = iPivot.IsValid(); - if (has) - { - // - has = iPivot.AsBox(iBox); - if (has) - { - // - newCCIPeakPivotDetected = AddBox( - iBox, - cciPeakPivots // - ); - } - } - - // - iBox.Clean(); - iPivot.Clean(); - } - } - - // - // CCI Vale Pivot ... - if (detectCCIValePivots) - { - // - bool checkingCondition = - isCCIVale && - isCBarHasBullishPower // && - // conditions.isCCICrossedOverOS - ; - - // - if (checkingCondition) - { - // - 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); - - // - XBoxZone iBox; - has = iPivot.IsValid(); - if (has) - { - // - has = iPivot.AsBox(iBox); - if (has) - { - // - newCCIValePivotDetected = AddBox( - iBox, - cciValePivots // - ); - } - } - - // - iBox.Clean(); - iPivot.Clean(); - } - } + // FVG ... // // FVG Bullish ... if (detectFVGBullishPivots) { // - bool checkingCondition = - // - isBullishFVG && - (cPeak > pPeak || - pPeak > p2Peak) - // - ; - - // - if (checkingCondition) - { - // - XBoxZone iBox; - 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; - - // - has = iPivot.IsValid(); - if (has) - { - // - has = iPivot.AsBox(iBox); - if (has) - { - // - newFVGBullishPivotDetected = AddBox( - iBox, - fvgBullishPivots // - ); - } - } - - // - iBox.Clean(); - iPivot.Clean(); - } + newFVGBullishPivotDetected = DetectFVGPivot( + barIndex, + X_DIRECTION_BULLISH, + zBar, + cBar, + pBar, + p2Bar, + conditions // + ); } // @@ -2218,752 +796,28 @@ class XCXCAEAPOIDetector : public XCBase if (detectFVGBearishPivots) { // - bool checkingCondition = - // - isBearishFVG && - (cVale < pVale || - pVale < p2Vale) - // - ; - - // - if (checkingCondition) - { - // - XBoxZone iBox; - 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; - - // - has = iPivot.IsValid(); - if (has) - { - // - has = iPivot.AsBox(iBox); - if (has) - { - // - newFVGBearishPivotDetected = AddBox( - iBox, - fvgBearishPivots // - ); - } - } - - // - iBox.Clean(); - iPivot.Clean(); - } + newFVGBearishPivotDetected = DetectFVGPivot( + barIndex, + X_DIRECTION_BEARISH, + zBar, + cBar, + pBar, + p2Bar, + conditions // + ); } // - // VALE Pivot Support Swing Low ... - if (detectValeSupSWLPivots) - { - // - if (conditions.isValeFinishedFromPivot) - { - // - valeSupSWLPivot.Clean(); - - // - valeSupSWLPivot.type = XCA_VALESWLSUP; - valeSupSWLPivot.symbol = conditions.symbol; - valeSupSWLPivot.period = conditions.period; - - // - valeSupSWLPivot.to = pBar.time; - valeSupSWLPivot.from = pBar.time; - valeSupSWLPivot.value = conditions.valeBuffer[pIDX]; - valeSupSWLPivot.reserve = conditions.valeGoldenBuffer[pIDX]; - } - - // - if (conditions.isValeIsPivot) - { - // - valeSupSWLPivot.from = pBar.time; - - // - valeSupSWLPivot.reserve = - valeSupSWLPivot.reserve == 0 - ? conditions.valeGoldenBuffer[cIDX] - : MathMin(valeSupSWLPivot.reserve, conditions.valeGoldenBuffer[cIDX]); - } - - // - if (conditions.isValeSwitchedToPivot) - { - // - has = - valeSupSWLPivot.IsValid() && - valeSupSWLPivot.GetAge() >= pivotVerifications; - if (has) - { - // - XBoxZone iBox; - has = valeSupSWLPivot.AsBox(iBox); - if (has) - { - // - newValeSupSWLPivotDetected = AddBox( - iBox, - valeSupSWLPivots // - ); - } - - // - iBox.Clean(); - } - - // - valeSupSWLPivot.Clean(); - } - } - - // - // PEAK Pivot Resistance Swing High ... - if (detectPeakResSWHPivots) - { - // - if (conditions.isPeakFinishedFromPivot) - { - // - peakResSWHPivot.Clean(); - - // - peakResSWHPivot.type = XCA_PEAKSWHRES; - peakResSWHPivot.symbol = conditions.symbol; - peakResSWHPivot.period = conditions.period; - - // - peakResSWHPivot.to = pBar.time; - peakResSWHPivot.from = pBar.time; - peakResSWHPivot.value = conditions.peakBuffer[pIDX]; - peakResSWHPivot.reserve = conditions.peakGoldenBuffer[pIDX]; - } - - // - if (conditions.isPeakIsPivot) - { - // - peakResSWHPivot.from = pBar.time; - - // - peakResSWHPivot.reserve = - peakResSWHPivot.reserve == 0 - ? conditions.peakGoldenBuffer[cIDX] - : MathMax(peakResSWHPivot.reserve, conditions.peakGoldenBuffer[cIDX]); - } - - // - if (conditions.isPeakSwitchedToPivot) - { - // - has = - peakResSWHPivot.IsValid() && - peakResSWHPivot.GetAge() >= pivotVerifications; - if (has) - { - // - XBoxZone iBox; - has = peakResSWHPivot.AsBox(iBox); - if (has) - { - // - newPeakResSWHPivotDetected = AddBox( - iBox, - peakResSWHPivots // - ); - } - - // - iBox.Clean(); - } - - // - peakResSWHPivot.Clean(); - } - } - - // - // TREND Bullish ... - if (detectTrendBullishPivots) - { - // - if (trendBullishStartPivotCondition) - { - // - Clean(trendBullishFVGs); - trendBullishPivot.Clean(); - - // - trendBullishPivot.type = XCA_TREND_BULL; - trendBullishPivot.symbol = conditions.symbol; - trendBullishPivot.period = conditions.period; - - // - trendBullishPivot.to = pBar.time; - trendBullishPivot.from = pBar.time; - trendBullishPivot.value = p3MasMin; - trendBullishPivot.reserve = p3MasMax; - } - - // - if (trendBullishPivotContinuationCondition) - { - // - trendBullishPivot.from = pBar.time; - - // - Add( - p3MasMin, - trendBullishPivot.values // - ); - Add( - p3MasMax, - trendBullishPivot.values // - ); - - // - trendBullishPivot.reserve = - trendBullishPivot.reserve == 0 - ? p3MasMax - : MathMax(trendBullishPivot.reserve, p3MasMax); - - // - // Handling FVGs Here ... - if (isBullishFVG) - { - // - fvgBox.type = GetBoxType(XCA_FVG_BULL); - - // - AddBox( - fvgBox, - trendBullishFVGs // - ); - } - } - - // - if (trendBullisPivothFinishedCondition) - { - // - // Update Values ... - trendBullishPivot.value = GetMin(trendBullishPivot.values); - trendBullishPivot.reserve = GetMax(trendBullishPivot.values); - - // - has = - trendBullishPivot.IsValid() && - trendBullishPivot.GetAge() >= pivotVerifications; - if (has) - { - // - XBoxZone iBox; - has = trendBullishPivot.AsBox(iBox); - if (has) - { - // - XCATRENDFVG iTrendFVG; - - // - iTrendFVG.trend = iBox; - Copy( - trendBullishFVGs, - iTrendFVG.fvgs // - ); - - // - newTrendBullishPivotDetected = iTrendFVG.IsValid(); - if (newTrendBullishPivotDetected) - { - // - AddRef( - iTrendFVG, - trendBullishPivots // - ); - } - - // - iTrendFVG.Clean(); - } - - // - iBox.Clean(); - } - - // - Clean(trendBullishFVGs); - trendBullishPivot.Clean(); - } - } - - // - // TREND Bearish ... - if (detectTrendBearishPivots) - { - // - if (trendBearishStartPivotCondition) - { - // - Clean(trendBearishFVGs); - trendBearishPivot.Clean(); - - // - trendBearishPivot.type = XCA_TREND_BEAR; - trendBearishPivot.symbol = conditions.symbol; - trendBearishPivot.period = conditions.period; - - // - trendBearishPivot.to = pBar.time; - trendBearishPivot.from = pBar.time; - trendBearishPivot.value = p3MasMax; - trendBearishPivot.reserve = p3MasMin; - } - - // - if (trendBearishPivotContinuationCondition) - { - // - trendBearishPivot.from = pBar.time; - - // - Add( - p3MasMin, - trendBearishPivot.values // - ); - Add( - p3MasMax, - trendBearishPivot.values // - ); - - // - trendBearishPivot.reserve = - trendBearishPivot.reserve == 0 - ? p3MasMin - : MathMin(trendBearishPivot.reserve, p3MasMin); - - // - // Handling FVGs Here ... - if (isBearishFVG) - { - // - fvgBox.type = GetBoxType(XCA_FVG_BEAR); - - // - AddBox( - fvgBox, - trendBearishFVGs // - ); - } - } - - // - if (trendBearishivothFinishedCondition) - { - // - // Update Values ... - trendBearishPivot.value = GetMax(trendBearishPivot.values); - trendBearishPivot.reserve = GetMin(trendBearishPivot.values); - - // - has = - trendBearishPivot.IsValid() && - trendBearishPivot.GetAge() >= pivotVerifications; - if (has) - { - // - XBoxZone iBox; - has = trendBearishPivot.AsBox(iBox); - if (has) - { - // - XCATRENDFVG iTrendFVG; - - // - iTrendFVG.trend = iBox; - Copy( - trendBearishFVGs, - iTrendFVG.fvgs // - ); - - // - newTrendBearishPivotDetected = iTrendFVG.IsValid(); - if (newTrendBearishPivotDetected) - { - // - AddRef( - iTrendFVG, - trendBearishPivots // - ); - } - - // - iTrendFVG.Clean(); - } - - // - iBox.Clean(); - } - - // - Clean(trendBearishFVGs); - trendBearishPivot.Clean(); - } - } - - // - // RSI Crossed Over OS ... - if (detectRSICrossedOverOSPivots) - { - // - bool checkingCondition = - // isRSIVale && - // isCBarHasBullishPower && - conditions.isRSICrossedOverOS; - - // - if (checkingCondition) - { - // - XCAPivot iPivot; - - // - iPivot.to = cBar.time; - iPivot.value = pBar.low; - iPivot.from = p2Bar.time; - iPivot.type = XCA_RSI_COOS; - 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.low, - iPivot.values // - ); - Add( - pBar.low, - iPivot.values // - ); - Add( - p2Bar.low, - iPivot.values // - ); - - // - iPivot.value = GetMin(iPivot.values); - iPivot.reserve = GetMax(iPivot.values); - - // - XBoxZone iBox; - has = iPivot.IsValid(); - if (has) - { - // - has = iPivot.AsBox(iBox); - if (has) - { - // - newRSICrossedOverOSPivotDetected = AddBox( - iBox, - rsiCrossedOverOSPivots // - ); - } - } - - // - iBox.Clean(); - iPivot.Clean(); - } - } - - // - // RSI Crossed Under OB ... - if (detectRSICrossedUnderOBPivots) - { - // - bool checkingCondition = - // isRSIPeak && - // isCBarHasBearishPower && - conditions.isRSICrossedUnderOB; - - // - if (checkingCondition) - { - // - 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.low, - iPivot.values // - ); - Add( - pBar.low, - iPivot.values // - ); - Add( - p2Bar.low, - iPivot.values // - ); - - // - iPivot.value = GetMax(iPivot.values); - iPivot.reserve = GetMin(iPivot.values); - - // - XBoxZone iBox; - has = iPivot.IsValid(); - if (has) - { - // - has = iPivot.AsBox(iBox); - if (has) - { - // - newRSICrossedUnderOBPivotDetected = AddBox( - iBox, - rsiCrossedUnderOBPivots // - ); - } - } - - // - iBox.Clean(); - iPivot.Clean(); - } - } - - // - // CCI Crossed Over OS ... - if (detectCCICrossedOverOSPivots) - { - // - bool checkingCondition = - isCCIVale && - // isCBarHasBullishPower && - conditions.isCCICrossedOverOS; - - // - if (checkingCondition) - { - // - XCAPivot iPivot; - - // - iPivot.to = cBar.time; - iPivot.value = pBar.low; - iPivot.from = p2Bar.time; - iPivot.type = XCA_CCI_COOS; - 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.low, - iPivot.values // - ); - Add( - pBar.low, - iPivot.values // - ); - Add( - p2Bar.low, - iPivot.values // - ); - - // - iPivot.value = GetMin(iPivot.values); - iPivot.reserve = GetMax(iPivot.values); - - // - XBoxZone iBox; - has = iPivot.IsValid(); - if (has) - { - // - has = iPivot.AsBox(iBox); - if (has) - { - // - newCCICrossedOverOSPivotDetected = AddBox( - iBox, - cciCrossedOverOSPivots // - ); - } - } - - // - iBox.Clean(); - iPivot.Clean(); - } - } - - // - // CCI Crossed Under OB ... - if (detectCCICrossedUnderOBPivots) - { - // - bool checkingCondition = - isCCIPeak && - // isCBarHasBearishPower && - conditions.isCCICrossedUnderOB; - - // - if (checkingCondition) - { - // - 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.low, - iPivot.values // - ); - Add( - pBar.low, - iPivot.values // - ); - Add( - p2Bar.low, - iPivot.values // - ); - - // - iPivot.value = GetMax(iPivot.values); - iPivot.reserve = GetMin(iPivot.values); - - // - XBoxZone iBox; - has = iPivot.IsValid(); - if (has) - { - // - has = iPivot.AsBox(iBox); - if (has) - { - // - newCCICrossedUnderOBPivotDetected = AddBox( - iBox, - cciCrossedUnderOBPivots // - ); - } - } - - // - iBox.Clean(); - iPivot.Clean(); - } - } - - // - bool detectBullishSpikePivots = true; - if (detectBullishSpikePivots) - { - // - // For Spike Detection ... - // [] 80% of Bars Must be Same as Direction ... - // [] Price Range of Bars Must be Passed of atr mult ... - // [] Required Volume Processing if Neccessary ... - - // - bool startCondition = false; - bool continuationCondition = false; - bool endCondition = false; - - // - // TODO: Complete this ... - } + // Others ... // start++; - // - Clean(z3Mas); - Clean(c3Mas); - Clean(p3Mas); - Clean(p23Mas); - // zBar.Clean(); cBar.Clean(); pBar.Clean(); p2Bar.Clean(); - fvgBox.Clean(); conditions.Clean(); } @@ -2973,300 +827,26 @@ class XCXCAEAPOIDetector : public XCBase // void Validate( - XBoxZone &unAvailableBoxes[], - int barIndex = 0, - bool validateFVGsUsingPV = false // + XBoxZone &unavailables[], + int barIndex = 0 // ) { - // - // Do All Pivots Validation ... - - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - bool has = false; - - // - int zIDX = 0; - int cIDX = zIDX + 1; - int pIDX = cIDX + 1; - int p2IDX = pIDX + 1; - - // - // Retrieve Conditions ... - XCAEAConditions conditions; - has = helper.GetConditions( - conditions, - barIndex, - 5 // - ); - if (!has) - { - conditions.Clean(); - return; - } - // // Implement Validation Senarios ... // - // TICK Pivots ... + // PV ... + ValidatePeakVales( + unavailables, + barIndex // + ); // - // TODO: Complete this ... - has = HasTickPivots(); - if (has) - { - // - } - - // - // VOLUME Pivots ... - - // - // TODO: Complete this ... - has = HasVolumePivots(); - if (has) - { - // - } - - // - // RSI Peak Pivot ... - - // - has = HasRSIPeakPivots(); - if (has) - { - // - ApplyValidationOnBox( - rsiPeakPivots, - unAvailableBoxes, - barIndex // - ); - } - - // - // RSI Vale Pivot ... - - // - has = HasRSIValePivots(); - if (has) - { - // - ApplyValidationOnBox( - rsiValePivots, - unAvailableBoxes, - barIndex // - ); - } - - // - // CCI Peak Pivot ... - - // - has = HasCCIPeakPivots(); - if (has) - { - // - ApplyValidationOnBox( - cciPeakPivots, - unAvailableBoxes, - barIndex // - ); - } - - // - // CCI Vale Pivot ... - - // - has = HasCCIValePivots(); - if (has) - { - // - ApplyValidationOnBox( - cciValePivots, - unAvailableBoxes, - barIndex // - ); - } - - // - // FVG Bullish ... - - // - has = HasFVGBullishPivots(); - if (has) - { - // - ApplyValidationOnBox( - fvgBullishPivots, - unAvailableBoxes, - barIndex // - ); - - // - if (validateFVGsUsingPV) - { - // - ApplyFVGPVValidation( - fvgBullishPivots, - conditions // - ); - } - } - - // - // FVG Bearish ... - - // - has = HasFVGBearishPivots(); - if (has) - { - // - ApplyValidationOnBox( - fvgBearishPivots, - unAvailableBoxes, - barIndex // - ); - - // - if (validateFVGsUsingPV) - { - // - ApplyFVGPVValidation( - fvgBearishPivots, - conditions // - ); - } - } - - // - // VALE Pivot Support Swing Low ... - - // - has = HasValeSupSWLPivots(); - if (has) - { - // - ApplyValidationOnBox( - valeSupSWLPivots, - unAvailableBoxes, - barIndex // - ); - } - - // - // PEAK Pivot Resistance Swing High ... - - // - has = HasPeakResSWHPivots(); - if (has) - { - // - ApplyValidationOnBox( - peakResSWHPivots, - unAvailableBoxes, - barIndex // - ); - } - - // - // TREND Bullish ... - - // - has = HasTrendBullishPivots(); - if (has) - { - // - ApplyValidationOnTrendFVG( - trendBullishPivots, - unAvailableBoxes, - barIndex // - ); - } - - // - // TREND Bearish ... - - // - has = HasTrendBearishPivots(); - if (has) - { - // - ApplyValidationOnTrendFVG( - trendBearishPivots, - unAvailableBoxes, - barIndex // - ); - } - - // - // RSI Crossed Over OS ... - - // - has = HasRSICrossedOverOSPivots(); - if (has) - { - // - ApplyValidationOnBox( - rsiCrossedOverOSPivots, - unAvailableBoxes, - barIndex // - ); - } - - // - // RSI Crossed Under OB ... - - // - has = HasRSICrossedUnderOBPivots(); - if (has) - { - // - ApplyValidationOnBox( - rsiCrossedUnderOBPivots, - unAvailableBoxes, - barIndex // - ); - } - - // - // CCI Crossed Over OS ... - - // - has = HasCCICrossedOverOSPivots(); - if (has) - { - // - ApplyValidationOnBox( - cciCrossedOverOSPivots, - unAvailableBoxes, - barIndex // - ); - } - - // - // CCI Crossed Under OB ... - - // - has = HasCCICrossedUnderOBPivots(); - if (has) - { - // - ApplyValidationOnBox( - cciCrossedUnderOBPivots, - unAvailableBoxes, - barIndex // - ); - } - - // - conditions.Clean(); + // FVG ... + ValidateFVGs( + unavailables, + barIndex // + ); // SortPivots(); @@ -3310,14 +890,7 @@ class XCXCAEAPOIDetector : public XCBase { // Copy( - rsiValePivots, - pivots, - false // - ); - - // - Copy( - cciValePivots, + valePivots, pivots, false // ); @@ -3328,58 +901,6 @@ class XCXCAEAPOIDetector : public XCBase pivots, false // ); - - // - Copy( - valeSupSWLPivots, - pivots, - false // - ); - - // - Copy( - rsiCrossedOverOSPivots, - pivots, - false // - ); - - // - Copy( - cciCrossedOverOSPivots, - pivots, - false // - ); - - // - has = HasTrendBullishPivots(); - if (has) - { - // - count = CountTrendBullishPivots(); - for (int i = 0; i < count; i++) - { - // - AddRef( - trendBullishPivots[i].trend, - pivots // - ); - - // - XBoxZone iBox; - has = trendBullishPivots[i].GetSelectedFVG(iBox); - if (has) - { - // - AddRef( - iBox, - pivots // - ); - } - - // - iBox.Clean(); - } - } } // @@ -3388,14 +909,7 @@ class XCXCAEAPOIDetector : public XCBase { // Copy( - rsiPeakPivots, - pivots, - false // - ); - - // - Copy( - cciPeakPivots, + peakPivots, pivots, false // ); @@ -3406,58 +920,6 @@ class XCXCAEAPOIDetector : public XCBase pivots, false // ); - - // - Copy( - peakResSWHPivots, - pivots, - false // - ); - - // - Copy( - rsiCrossedUnderOBPivots, - pivots, - false // - ); - - // - Copy( - cciCrossedUnderOBPivots, - pivots, - false // - ); - - // - has = HasTrendBearishPivots(); - if (has) - { - // - count = CountTrendBearishPivots(); - for (int i = 0; i < count; i++) - { - // - AddRef( - trendBearishPivots[i].trend, - pivots // - ); - - // - XBoxZone iBox; - has = trendBearishPivots[i].GetSelectedFVG(iBox); - if (has) - { - // - AddRef( - iBox, - pivots // - ); - } - - // - iBox.Clean(); - } - } } // @@ -3468,25 +930,7 @@ class XCXCAEAPOIDetector : public XCBase } // - bool MarketTrend(ENUM_X_DIRECTION &trend) - { - // - bool result = false; - - // - // Update Market Trend ... - DetectMarketTrend(); - - // - trend = trendDir; - result = HasDirection(trend); - - // - return result; - } - - // - // Counters ... + // Pivots ... // // INVALID Pivots ... @@ -3504,97 +948,879 @@ class XCXCAEAPOIDetector : public XCBase } // - // TICK Pivot ... + // PV ... // - bool HasTickPivots() + void ValidatePeakVales( + XBoxZone &unavailables[], + int barIndex = 0 // + ) { - return HasChild(tickPivots); + // + bool has = false; + + // + // PEAK ... + has = HasPeakPivots(); + if (has) + { + // + ApplyValidationOnBoxes( + peakPivots, + unavailables, + barIndex // + ); + } + + // + // VALE ... + has = HasValePivots(); + if (has) + { + // + ApplyValidationOnBoxes( + valePivots, + unavailables, + barIndex // + ); + } } // - int CountTickPivots() + // PEAK ... + + // + XCAPivot peakPivot; + bool detectPeakPivots; + XBoxZone peakPivots[]; + bool newPeakPivotDetected; + + // + bool HasPeakPivots() { - return ArraySize(tickPivots); + return HasChild(peakPivots); } // - // VOLUME Pivots ... - - // - bool HasVolumePivots() + int CountPeakPivots() { - return HasChild(volumePivots); + return ArraySize(peakPivots); } // - int CountVolumePivots() + bool DetectPeakPivot( + int barIndex, + XOHCL &zBar, + XOHCL &cBar, + XOHCL &pBar, + XOHCL &p2Bar, + XCAEAConditions &conditions // + ) { - return ArraySize(volumePivots); + // + bool result = false; + + // + // Validate Args ... + result = + // + barIndex >= 0 && + zBar.IsValid() && + cBar.IsValid() && + pBar.IsValid() && + p2Bar.IsValid() && + detectPeakPivots + // + ; + if (!result) + { + return result; + } + + // + // Define Requirements ... + + // + int zIDX = 0; + int cIDX = zIDX + 1; + int pIDX = cIDX + 1; + int p2IDX = pIDX + 1; + + // + datetime cTime = zBar.time; + string symbol = zBar.symbol; + ENUM_TIMEFRAMES period = zBar.period; + double points = GetPoints(symbol); + + // + // Reading Conditional Values ... + + // + // PEAK ... + double zPeak = conditions.peakBuffer[zIDX]; + double cPeak = conditions.peakBuffer[cIDX]; + double pPeak = conditions.peakBuffer[pIDX]; + double p2Peak = conditions.peakBuffer[p2IDX]; + + // + // PEAK Golden ... + double zPeakGolden = conditions.peakGoldenBuffer[zIDX]; + double cPeakGolden = conditions.peakGoldenBuffer[cIDX]; + double pPeakGolden = conditions.peakGoldenBuffer[pIDX]; + double p2PeakGolden = conditions.peakGoldenBuffer[p2IDX]; + + // + // VALE ... + double zVale = conditions.valeBuffer[zIDX]; + double cVale = conditions.valeBuffer[cIDX]; + double pVale = conditions.valeBuffer[pIDX]; + double p2Vale = conditions.valeBuffer[p2IDX]; + + // + // VALE Golden ... + double zValeGolden = conditions.valeGoldenBuffer[zIDX]; + double cValeGolden = conditions.valeGoldenBuffer[cIDX]; + double pValeGolden = conditions.valeGoldenBuffer[pIDX]; + double p2ValeGolden = conditions.valeGoldenBuffer[p2IDX]; + + // + // Prepare Conditinal Conditions ... + + // + bool isPeakSameLast = cPeak == pPeak; + bool isPeakSameLastPrev = pPeak == p2Peak; + + // + bool isPeakSwitchedToSameLast = isPeakSameLast && + !isPeakSameLastPrev; + bool isPeakFinishedFromSameLast = !isPeakSameLast && + isPeakSameLastPrev; + + // + // ZERO ... + // Default Peak and Vale Selection ... + bool isTypeZeroStart = isPeakFinishedFromSameLast; + bool isTypeZeroContinue = isPeakSameLast; + bool isTypeZeroFinished = isPeakSwitchedToSameLast; + + // + // Summarizing Conditions ... + + // + result = false; + + // + bool hasStartCondition = + // + isTypeZeroStart + // + ; + bool hasContinuationCondition = + // + isTypeZeroContinue + // + ; + bool hasEndCondition = + // + isTypeZeroFinished + // + ; + + // + // ReInstance Pivot ... + if (hasStartCondition) + { + // + peakPivot.Clean(); + + // + peakPivot.type = XCA_PEAK; + peakPivot.symbol = symbol; + peakPivot.period = period; + + // + peakPivot.to = pBar.time; + peakPivot.from = pBar.time; + peakPivot.value = pPeak; + peakPivot.reserve = pPeakGolden; + } + + // + // Calculate and Fill Pivot Requirements ... + if (hasContinuationCondition) + { + // + peakPivot.from = pBar.time; + + // + peakPivot.reserve = + peakPivot.reserve == 0 + ? pPeakGolden + : MathMax(peakPivot.reserve, pPeakGolden); + } + + // + // End up Pivot and Store it ... + if (hasEndCondition) + { + // + result = + peakPivot.IsValid() && + peakPivot.GetAge() >= pivotVerifications; + if (result) + { + // + XBoxZone iBox; + result = peakPivot.AsBox(iBox); + if (result) + { + // + newPeakPivotDetected = AddBox( + iBox, + peakPivots // + ); + } + + // + iBox.Clean(); + } + + // + peakPivot.Clean(); + } + + // + return result; } // - // RSI Peak Pivot ... + // VALE ... // - bool HasRSIPeakPivots() + XCAPivot valePivot; + bool detectValePivots; + XBoxZone valePivots[]; + bool newValePivotDetected; + + // + bool HasValePivots() { - return HasChild(rsiPeakPivots); + return HasChild(valePivots); } // - int CountRSIPeakPivots() + int CountValePivots() { - return ArraySize(rsiPeakPivots); + return ArraySize(valePivots); } // - // RSI Vale Pivot ... - - // - bool HasRSIValePivots() + bool DetectValePivot( + int barIndex, + XOHCL &zBar, + XOHCL &cBar, + XOHCL &pBar, + XOHCL &p2Bar, + XCAEAConditions &conditions // + ) { - return HasChild(rsiValePivots); + // + bool result = false; + + // + // Validate Args ... + result = + // + barIndex >= 0 && + zBar.IsValid() && + cBar.IsValid() && + pBar.IsValid() && + p2Bar.IsValid() && + detectValePivots + // + ; + if (!result) + { + return result; + } + + // + // Define Requirements ... + + // + int zIDX = 0; + int cIDX = zIDX + 1; + int pIDX = cIDX + 1; + int p2IDX = pIDX + 1; + + // + datetime cTime = zBar.time; + string symbol = zBar.symbol; + ENUM_TIMEFRAMES period = zBar.period; + double points = GetPoints(symbol); + + // + // Reading Conditional Values ... + + // + // PEAK ... + double zPeak = conditions.peakBuffer[zIDX]; + double cPeak = conditions.peakBuffer[cIDX]; + double pPeak = conditions.peakBuffer[pIDX]; + double p2Peak = conditions.peakBuffer[p2IDX]; + + // + // PEAK Golden ... + double zPeakGolden = conditions.peakGoldenBuffer[zIDX]; + double cPeakGolden = conditions.peakGoldenBuffer[cIDX]; + double pPeakGolden = conditions.peakGoldenBuffer[pIDX]; + double p2PeakGolden = conditions.peakGoldenBuffer[p2IDX]; + + // + // VALE ... + double zVale = conditions.valeBuffer[zIDX]; + double cVale = conditions.valeBuffer[cIDX]; + double pVale = conditions.valeBuffer[pIDX]; + double p2Vale = conditions.valeBuffer[p2IDX]; + + // + // VALE Golden ... + double zValeGolden = conditions.valeGoldenBuffer[zIDX]; + double cValeGolden = conditions.valeGoldenBuffer[cIDX]; + double pValeGolden = conditions.valeGoldenBuffer[pIDX]; + double p2ValeGolden = conditions.valeGoldenBuffer[p2IDX]; + + // + // Prepare Conditinal Conditions ... + + // + bool isValeSameLast = cVale == pVale; + bool isValeSameLastPrev = pVale == p2Vale; + + // + bool isValeSwitchedToSameLast = isValeSameLast && + !isValeSameLastPrev; + bool isValeFinishedFromSameLast = !isValeSameLast && + isValeSameLastPrev; + + // + // ZERO ... + // Default Peak and Vale Selection ... + bool isTypeZeroStart = isValeFinishedFromSameLast; + bool isTypeZeroContinue = isValeSameLast; + bool isTypeZeroFinished = isValeSwitchedToSameLast; + + // + // Summarizing Conditions ... + + // + result = false; + + // + bool hasStartCondition = + // + isTypeZeroStart + // + ; + bool hasContinuationCondition = + // + isTypeZeroContinue + // + ; + bool hasEndCondition = + // + isTypeZeroFinished + // + ; + + // + // ReInstance Pivot ... + if (hasStartCondition) + { + // + valePivot.Clean(); + + // + valePivot.type = XCA_VALE; + valePivot.symbol = symbol; + valePivot.period = period; + + // + valePivot.to = pBar.time; + valePivot.from = pBar.time; + valePivot.value = pVale; + valePivot.reserve = pValeGolden; + } + + // + // Calculate and Fill Pivot Requirements ... + if (hasContinuationCondition) + { + // + valePivot.from = pBar.time; + + // + valePivot.reserve = + valePivot.reserve == 0 + ? pValeGolden + : MathMin(valePivot.reserve, pValeGolden); + } + + // + // End up Pivot and Store it ... + if (hasEndCondition) + { + // + result = + valePivot.IsValid() && + valePivot.GetAge() >= pivotVerifications; + if (result) + { + // + XBoxZone iBox; + result = valePivot.AsBox(iBox); + if (result) + { + // + newPeakPivotDetected = AddBox( + iBox, + valePivots // + ); + } + + // + iBox.Clean(); + } + + // + valePivot.Clean(); + } + + // + return result; } // - int CountRSIValePivots() + // FVG ... + + // + bool maxAllowedFVGLife; // Max Allowed FVG Life ... + bool detectFVGTypeOne; // Detect FVG Type One ( Validating Using MAnalyser ) ... + bool detectFVGTypeTwo; // Detect FVG Type Two ( Validating Using PV ) ... + bool applyPVToFVGBoundary; // Apply PV to FVG Boundary ... + bool applyLastBarToFVGBoundary; // Apply Last Bar to FVG Boundary ... + bool selectOnlyFVGWhichHasIndirectionalLastBar; // Select Only FVGs which has Indirectionsl Last Bar, uses to Order Block ... + + // + bool DetectFVGPivot( + int barIndex, + ENUM_X_DIRECTION forDir, + XOHCL &zBar, + XOHCL &cBar, + XOHCL &pBar, + XOHCL &p2Bar, + XCAEAConditions &conditions // + ) { - return ArraySize(rsiValePivots); + // + bool result = false; + + // + // Checking Direction ... + result = HasDirection(forDir); + if (!result) + { + return result; + } + + // + bool forBullish = IsBullish(forDir); + bool forBearish = IsBearish(forDir); + + // + // Check Allowed ... + result = + forBullish + ? detectFVGBullishPivots + : detectFVGBearishPivots; + if (!result) + { + return result; + } + + // + // Validate Args ... + result = + // + barIndex >= 0 && + zBar.IsValid() && + cBar.IsValid() && + pBar.IsValid() && + p2Bar.IsValid() + // + ; + if (!result) + { + return result; + } + + // + // Define Requirements ... + + // + int zIDX = 0; + int cIDX = zIDX + 1; + int pIDX = cIDX + 1; + int p2IDX = pIDX + 1; + + // + datetime cTime = zBar.time; + string symbol = zBar.symbol; + ENUM_TIMEFRAMES period = zBar.period; + double points = GetPoints(symbol); + + // + // Reading Conditional Values ... + + // + // PEAK ... + double zPeak = conditions.peakBuffer[zIDX]; + double cPeak = conditions.peakBuffer[cIDX]; + double pPeak = conditions.peakBuffer[pIDX]; + double p2Peak = conditions.peakBuffer[p2IDX]; + + // + // VALE ... + double zVale = conditions.valeBuffer[zIDX]; + double cVale = conditions.valeBuffer[cIDX]; + double pVale = conditions.valeBuffer[pIDX]; + double p2Vale = conditions.valeBuffer[p2IDX]; + + // + // MANALYSER ... + + // + // MAH ... + double zMAH = conditions.mahBuffer[zIDX]; + double cMAH = conditions.mahBuffer[cIDX]; + double pMAH = conditions.mahBuffer[pIDX]; + double p2MAH = conditions.mahBuffer[p2IDX]; + + // + // MAL ... + double zMAL = conditions.malBuffer[zIDX]; + double cMAL = conditions.malBuffer[cIDX]; + double pMAL = conditions.malBuffer[pIDX]; + double p2MAL = conditions.malBuffer[p2IDX]; + + // + // MAC ... + double zMAC = conditions.macBuffer[zIDX]; + double cMAC = conditions.macBuffer[cIDX]; + double pMAC = conditions.macBuffer[pIDX]; + double p2MAC = conditions.macBuffer[p2IDX]; + + // + // + // + + // + XBoxZone fvgBox; + bool isFVG = barAnalyser.IsFVG( + cBar, + fvgBox // + ); + bool isBullishFVG = + isFVG && + fvgBox.IsBullish(); + bool isBearishFVG = + isFVG && + fvgBox.IsBearish(); + + // + // Prepare Conditinal Conditions ... + + // + // ZERO ... + // --------- + // Pure FVG Detected ... + bool canDetectPureFVG = + !detectFVGTypeOne && + !detectFVGTypeTwo; + + // + bool isPureFVGBullish = + canDetectPureFVG && + isBullishFVG; + + // + bool isPureFVGBearish = + canDetectPureFVG && + isBearishFVG; + + // + // ONE: + // ------- + // Type One Using MAL and MAH in + // Manalyser for Validating FVG(s) ... + + // + bool isFVGTypeOneBullish = + forBullish && + isBullishFVG && + detectFVGTypeOne && + fvgBox.upper <= cMAL; + + // + bool isFVGTypeOneBearish = + forBearish && + isBearishFVG && + detectFVGTypeOne && + fvgBox.lower >= cMAH; + + // + // TWO: + // ----- + // Type Two Using PV for Validating FVG(s) ... + + // + bool isFVGTypeTwoBullish = + forBullish && + isBullishFVG && + detectFVGTypeTwo && + // + (p2Peak < pPeak || + pPeak < cPeak) + // + ; + + // + bool isFVGTypeTwoBearish = + forBearish && + isBearishFVG && + detectFVGTypeTwo && + // + (p2Vale > pVale || + pVale > cVale) + // + ; + + // + // Summarizing Conditions ... + + // + result = false; + + // + bool hasStartCondition = false; + bool hasContinuationCondition = false; + bool hasEndCondition = + forBullish + ? + // + (isPureFVGBullish || + isFVGTypeOneBullish || + isFVGTypeTwoBullish) + // + : + // + (isPureFVGBearish || + isFVGTypeOneBearish || + isFVGTypeTwoBearish) + // + ; + + // + // Validate FVG Selection ... + if (hasEndCondition && + selectOnlyFVGWhichHasIndirectionalLastBar) + { + // + XOHCL p3Bar; + p2Bar.GetPreviousBar(p3Bar); + + // + hasEndCondition = + p3Bar.IsValid() && + hasEndCondition && + (forBullish + ? p3Bar.IsBearish() + : p3Bar.IsBullish()); + + // + p3Bar.Clean(); + } + + // + // ReInstance Pivot ... + if (hasStartCondition) + { + // + } + + // + // Calculate and Fill Pivot Requirements ... + if (hasContinuationCondition) + { + // + } + + // + // End up Pivot and Store it ... + if (hasEndCondition) + { + // + XBoxZone iBox; + XCAPivot iPivot; + + // + iPivot.to = fvgBox.to; + iPivot.from = fvgBox.from; + iPivot.symbol = fvgBox.symbol; + iPivot.period = fvgBox.period; + iPivot.type = forBullish + ? XCA_FVG_BULL + : XCA_FVG_BEAR; + iPivot.value = forBullish + ? fvgBox.lower + : fvgBox.upper; + iPivot.reserve = forBullish + ? fvgBox.upper + : fvgBox.lower; + + // + if (applyLastBarToFVGBoundary) + { + // + XOHCL p3Bar; + p2Bar.GetPreviousBar(p3Bar); + + // + double iBoundary = + forBullish + ? cBar.low + : cBar.high; + + // + double values[] = { + iBoundary, + pBar.high, + pBar.low, + p2Bar.high, + p2Bar.low // + }; + + // + double minValue = GetMin(values); + double maxValue = GetMax(values); + + // + iPivot.value = + forBullish + ? minValue + : maxValue; + + // + iPivot.reserve = + forBullish + ? maxValue + : minValue; + + // + Clean(values); + p3Bar.Clean(); + } + + // + if (applyPVToFVGBoundary) + { + // + iPivot.value = + forBullish + ? MathMin(iPivot.value, cVale) + : MathMax(iPivot.value, cPeak); + } + + // + result = iPivot.IsValid(); + if (result) + { + // + result = iPivot.AsBox(iBox); + if (result) + { + // + if (forBullish) + { + // + result = AddBox( + iBox, + fvgBullishPivots // + ); + } + else + { + // + result = AddBox( + iBox, + fvgBearishPivots // + ); + } + } + } + + // + iBox.Clean(); + iPivot.Clean(); + } + + // + return result; } // - // CCI Peak Pivot ... - - // - bool HasCCIPeakPivots() + void ValidateFVGs( + XBoxZone &unavailables[], + int barIndex = 0 // + ) { - return HasChild(cciPeakPivots); + // + bool has = false; + + // + // Bullish ... + has = HasFVGBullishPivots(); + if (has) + { + // + ApplyValidationOnBoxes( + fvgBullishPivots, + unavailables, + barIndex // + ); + } + + // + // Bearish ... + has = HasFVGBearishPivots(); + if (has) + { + // + ApplyValidationOnBoxes( + fvgBearishPivots, + unavailables, + barIndex // + ); + } } // - int CountCCIPeakPivots() - { - return ArraySize(cciPeakPivots); - } + // FVG Bullish Pivots ... // - // CCI Vale Pivot ... - - // - bool HasCCIValePivots() - { - return HasChild(cciValePivots); - } - - // - int CountCCIValePivots() - { - return ArraySize(cciValePivots); - } - - // - // FVG Bullish ... + bool detectFVGBullishPivots; + XBoxZone fvgBullishPivots[]; + bool newFVGBullishPivotDetected; // bool HasFVGBullishPivots() @@ -3609,7 +1835,12 @@ class XCXCAEAPOIDetector : public XCBase } // - // FVG Bearish ... + // FVG Bearish Pivots ... + + // + bool detectFVGBearishPivots; + XBoxZone fvgBearishPivots[]; + bool newFVGBearishPivotDetected; // bool HasFVGBearishPivots() @@ -3623,126 +1854,6 @@ class XCXCAEAPOIDetector : public XCBase return ArraySize(fvgBearishPivots); } - // - // VALE Pivot Support Swing Low ... - - // - bool HasValeSupSWLPivots() - { - return HasChild(valeSupSWLPivots); - } - - // - int CountValeSupSWLPivots() - { - return ArraySize(valeSupSWLPivots); - } - - // - // PEAK Pivot Resistance Swing High ... - - // - bool HasPeakResSWHPivots() - { - return HasChild(peakResSWHPivots); - } - - // - int CountPeakResSWHPivots() - { - return ArraySize(peakResSWHPivots); - } - - // - // TREND Bullish ... - - // - bool HasTrendBullishPivots() - { - return HasChild(trendBullishPivots); - } - - // - int CountTrendBullishPivots() - { - return ArraySize(trendBullishPivots); - } - - // - // TREND Bearish ... - - // - bool HasTrendBearishPivots() - { - return HasChild(trendBearishPivots); - } - - // - int CountTrendBearishPivots() - { - return ArraySize(trendBearishPivots); - } - - // - // RSI Crossed Over OS Pivots ... - - // - bool HasRSICrossedOverOSPivots() - { - return HasChild(rsiCrossedOverOSPivots); - } - - // - int CountRSICrossedOverOSPivots() - { - return ArraySize(rsiCrossedOverOSPivots); - } - - // - // RSI Crossed Under OB Pivots ... - - // - bool HasRSICrossedUnderOBPivots() - { - return HasChild(rsiCrossedUnderOBPivots); - } - - // - int CountRSICrossedUnderOBPivots() - { - return ArraySize(rsiCrossedUnderOBPivots); - } - - // - // CCI Crossed Over OS Pivots ... - - // - bool HasCCICrossedOverOSPivots() - { - return HasChild(cciCrossedOverOSPivots); - } - - // - int CountCCICrossedOverOSPivots() - { - return ArraySize(rsiCrossedOverOSPivots); - } - - // - // CCI Crossed Under OB Pivots ... - - // - bool HasCCICrossedUnderOBPivots() - { - return HasChild(cciCrossedUnderOBPivots); - } - - // - int CountCCICrossedUnderOBPivots() - { - return ArraySize(cciCrossedUnderOBPivots); - } - // // Protected ... protected: @@ -3811,7 +1922,7 @@ class XCXCAEAPOIDetector : public XCBase // bool ValidateBox( XBoxZone &box, - XBoxZone &unAvailableBoxes[], + XBoxZone &unavailables[], int barIndex = 0 // ) { @@ -3832,7 +1943,7 @@ class XCXCAEAPOIDetector : public XCBase // // Check Input Box is Available ... - bool canCheckUnAvailableBoxes = HasChild(unAvailableBoxes); + bool canCheckUnAvailableBoxes = HasChild(unavailables); if (canCheckUnAvailableBoxes) { // @@ -3840,7 +1951,7 @@ class XCXCAEAPOIDetector : public XCBase bool isUnAvailable = FindBoxIndex( idx, box, - unAvailableBoxes // + unavailables // ); result = !isUnAvailable; if (!result) @@ -3992,22 +2103,16 @@ class XCXCAEAPOIDetector : public XCBase Clean(invalidPivots); // - Clean(tickPivots); - Clean(volumePivots); - Clean(rsiPeakPivots); - Clean(rsiValePivots); - Clean(cciPeakPivots); - Clean(cciValePivots); + peakPivot.Clean(); + valePivot.Clean(); + + // + Clean(peakPivots); + Clean(valePivots); + + // Clean(fvgBullishPivots); Clean(fvgBearishPivots); - Clean(valeSupSWLPivots); - Clean(peakResSWHPivots); - Clean(trendBullishPivots); - Clean(trendBearishPivots); - Clean(rsiCrossedOverOSPivots); - Clean(rsiCrossedUnderOBPivots); - Clean(cciCrossedOverOSPivots); - Clean(cciCrossedUnderOBPivots); } // @@ -4017,35 +2122,19 @@ class XCXCAEAPOIDetector : public XCBase bool has = false; // - // RSI Peak ... - has = HasRSIPeakPivots(); + // PEAK ... + has = HasPeakPivots(); if (has) { - ApplySortOnBox(rsiPeakPivots); + ApplySortOnBoxes(peakPivots); } // - // RSI Vale ... - has = HasRSIValePivots(); + // VALE ... + has = HasValePivots(); if (has) { - ApplySortOnBox(rsiValePivots); - } - - // - // CCI Peak ... - has = HasCCIPeakPivots(); - if (has) - { - ApplySortOnBox(cciPeakPivots); - } - - // - // CCI Vale ... - has = HasCCIValePivots(); - if (has) - { - ApplySortOnBox(cciValePivots); + ApplySortOnBoxes(valePivots); } // @@ -4053,7 +2142,7 @@ class XCXCAEAPOIDetector : public XCBase has = HasFVGBullishPivots(); if (has) { - ApplySortOnBox(fvgBullishPivots); + ApplySortOnBoxes(fvgBullishPivots); } // @@ -4061,296 +2150,12 @@ class XCXCAEAPOIDetector : public XCBase has = HasFVGBearishPivots(); if (has) { - ApplySortOnBox(fvgBearishPivots); - } - - // - // VALE SUP SWL ... - has = HasValeSupSWLPivots(); - if (has) - { - ApplySortOnBox(valeSupSWLPivots); - } - - // - // PEAK REs SWH ... - has = HasPeakResSWHPivots(); - if (has) - { - ApplySortOnBox(peakResSWHPivots); - } - - // - // PVFVG Bullish ... - has = HasTrendBullishPivots(); - if (has) - { - ApplySortOnTrendFVG(trendBullishPivots); - } - - // - // PVFVG Bearish ... - has = HasTrendBearishPivots(); - if (has) - { - ApplySortOnTrendFVG(trendBearishPivots); - } - - // - // RSI Crossed Over OS ... - has = HasRSICrossedOverOSPivots(); - if (has) - { - ApplySortOnBox(rsiCrossedOverOSPivots); - } - - // - // RSI Crossed Under OB ... - has = HasRSICrossedUnderOBPivots(); - if (has) - { - ApplySortOnBox(rsiCrossedUnderOBPivots); - } - - // - // CCI Crossed Over OS ... - has = HasCCICrossedOverOSPivots(); - if (has) - { - ApplySortOnBox(cciCrossedOverOSPivots); - } - - // - // CCI Crossed Under OB ... - has = HasCCICrossedUnderOBPivots(); - if (has) - { - ApplySortOnBox(cciCrossedUnderOBPivots); - } - - // - // INVALID Pivots ... - has = HasInvalidPivots(); - if (has) - { - ApplySortOnBox(invalidPivots); + ApplySortOnBoxes(fvgBearishPivots); } } // - void ApplyValidationOnBox( - XBoxZone &items[], - XBoxZone &unAvailableItems[], - int barIndex = 0 // - ) - { - // - bool has = false; - - // - has = HasChild(items); - if (!has) - { - return; - } - - // - XBoxZone tmp[]; - Copy( - items, - tmp // - ); - Clean(items); - while (HasChild(tmp)) - { - // - XBoxZone iBox = tmp[0]; - ArrayRemove( - tmp, - 0, - 1 // - ); - - // - has = ValidateBox( - iBox, - unAvailableItems, - barIndex // - ); - if (has) - { - // - AddRef( - iBox, - items // - ); - } - - // - iBox.Clean(); - // - } - - // - Clean(tmp); - } - - // - void ApplyValidationOnTrendFVG( - XCATRENDFVG &items[], - XBoxZone &unAvailableItems[], - int barIndex = 0 // - ) - { - // - bool has = false; - - // - has = HasChild(items); - if (!has) - { - return; - } - - // - XCATRENDFVG tmp[]; - Copy( - items, - tmp // - ); - Clean(items); - while (HasChild(tmp)) - { - // - XCATRENDFVG iTrendFVG = tmp[0]; - ArrayRemove( - tmp, - 0, - 1 // - ); - - // - // Validate TMP Trend Box ... - has = ValidateBox( - iTrendFVG.trend, - unAvailableItems, - barIndex // - ); - if (has) - { - // - // Now we Have to Validate FVGS ... - ApplyValidationOnBox( - iTrendFVG.fvgs, - unAvailableItems, - barIndex // - ); - - // - has = iTrendFVG.IsValid(); - if (has) - { - // - AddRef( - iTrendFVG, - items // - ); - } - } - - // - iTrendFVG.Clean(); - } - - // - Clean(tmp); - } - - // - void ApplyFVGPVValidation( - XBoxZone &fvgs[], - XCAEAConditions &conditions // - ) - { - // - int zIDX = 0; - int cIDX = zIDX + 1; - int pIDX = cIDX + 1; - int p2IDX = pIDX + 1; - - // - bool has = HasChild(fvgs); - if (!has) - { - return; - } - - // - // Reading Values ... - - // - // PEAK ... - double zPeak = conditions.peakBuffer[zIDX]; - double cPeak = conditions.peakBuffer[cIDX]; - double pPeak = conditions.peakBuffer[pIDX]; - double p2Peak = conditions.peakBuffer[p2IDX]; - - // - // VALE ... - double zVale = conditions.valeBuffer[zIDX]; - double cVale = conditions.valeBuffer[cIDX]; - double pVale = conditions.valeBuffer[pIDX]; - double p2Vale = conditions.valeBuffer[p2IDX]; - - // - XBoxZone tmp[]; - Copy( - fvgs, - tmp // - ); - Clean(fvgs); - while (HasChild(tmp)) - { - // - XBoxZone iBox = tmp[0]; - ArrayRemove( - tmp, - 0, - 1 // - ); - - // - bool isBullish = iBox.IsBullish(); - - // - bool isTooOld = iBox.GetAge() > 21; - bool isPVBreaked = - isBullish - ? cVale > iBox.upper - : cPeak < iBox.lower; - - // - has = !isTooOld && - !isPVBreaked; - if (has) - { - // - AddRef( - iBox, - fvgs // - ); - } - - // - iBox.Clean(); - } - - // - Clean(tmp); - } - - // - void ApplySortOnBox( + void ApplySortOnBoxes( XBoxZone &items[] // ) { @@ -4410,12 +2215,13 @@ class XCXCAEAPOIDetector : public XCBase } // - void ApplySortOnTrendFVG( - XCATRENDFVG &items[] // + void ApplyValidationOnBoxes( + XBoxZone &items[], + XBoxZone &unavailables[], + int barIndex = 0 // ) { // - int idx = -1; bool has = false; // @@ -4426,357 +2232,44 @@ class XCXCAEAPOIDetector : public XCBase } // - XCATRENDFVG tmp[]; + XBoxZone tmp[]; Copy( items, tmp // ); Clean(items); - - // while (HasChild(tmp)) { // - idx = GetOldest(tmp); - has = IsValidIndex(idx); - if (!has) - { - break; - } - - // - XCATRENDFVG iTrendFVG = tmp[idx]; + XBoxZone iBox = tmp[0]; ArrayRemove( tmp, - idx, + 0, 1 // ); // - AddRef( - iTrendFVG, - items // + has = ValidateBox( + iBox, + unavailables, + barIndex // ); - } - - // - CleanupArray( - items, - maxAllowedPivots // - ); - - // - Clean(tmp); - } - - // - - // - bool IsExistsTickPivot( - datetime to, - datetime from // - ) - { - // - bool result = false; - - // - // Validate Args ... - result = IsValid(to) && - IsValid(from) && - to > from; - if (!result) - { - return result; - } - - // - result = HasTickPivots(); - if (!result) - { - return result; - } - - // - int idx = -1; - int count = CountTickPivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox = tickPivots[i]; - - // - result = iBox.to == to && - iBox.from == from; - if (result) - { - // - idx = i; - iBox.Clean(); - - // - break; - } - - // - iBox.Clean(); - } - - // - result = IsValidIndex(idx); - - // - return result; - } - - // - bool IsExistsVolumePivot( - datetime to, - datetime from // - ) - { - // - bool result = false; - - // - // Validate Args ... - result = IsValid(to) && - IsValid(from) && - to > from; - if (!result) - { - return result; - } - - // - result = HasVolumePivots(); - if (!result) - { - return result; - } - - // - int idx = -1; - int count = CountVolumePivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox = volumePivots[i]; - - // - result = iBox.to == to && - iBox.from == from; - if (result) - { - // - idx = i; - iBox.Clean(); - - // - break; - } - - // - iBox.Clean(); - } - - // - result = IsValidIndex(idx); - - // - return result; - } - - // - bool InitializeTicksZone( - XCTicksZone *&zone, - XOHCL &toBar, - XOHCL &fromBar // - ) - { - // - bool result = false; - - // - result = zone == NULL; - if (!result) - { - return result; - } - - // - int toIDX = toBar.Index(); - int fromIDX = fromBar.Index(); - int rangeLength = fromIDX - toIDX; - double rangeDivider = ticksDividerInPoints * GetPoints(toBar.symbol); - double rangeL = toBar.FindLowest(rangeLength, MODE_LOW); - double rangeH = toBar.FindHighest(rangeLength, MODE_HIGH); - double rangeDiff = (rangeH - rangeL); - int zoneLevels = (int)(rangeDiff / rangeDivider); - - // - zone = new XCTicksZone(); - zone.Levels(zoneLevels); - - // - result = zone.Init( - fromBar, - toBar // - ); - if (!result) - { - ZeroMemory(zone); - } - - // - return result; - } - - // - void DetectMarketTrend() - { - // - int idx = -1; - int count = 0; - bool has = false; - - // - XBoxZone tmp[]; - has = HasPeakResSWHPivots(); - if (has) - { - // - Copy( - peakResSWHPivots, - tmp, - false // - ); - } - has = HasValeSupSWLPivots(); - if (has) - { - // - Copy( - valeSupSWLPivots, - tmp, - false // - ); - } - count = ArraySize(tmp); - has = HasChild(tmp); - if (!has) - { - return; - } - - // - has = HasDirection(trendDir); - if (!has) - { - // - trendPivotC.Clean(); - trendPivotP.Clean(); - } - - // - XBoxZone cPivot; - XBoxZone pPivot; - ENUM_X_DIRECTION dir = X_DIRECTION_NONE; - while (HasChild(tmp)) - { - // - XBoxZone iPivot; - idx = GetYoungest(tmp); - has = IsValidIndex(idx); - if (!has) - { - // - iPivot.Clean(); - break; - } - - // - iPivot = tmp[idx]; - ArrayRemove( - tmp, - idx, - 1 // - ); - - // - // Check Can Set CPivot ... - bool canSetCPivot = - !cPivot.IsValid() - ? true - : iPivot.from > cPivot.from; - if (canSetCPivot) - { - // - if (cPivot.IsValid()) - { - pPivot = cPivot; - } - - // - cPivot = iPivot; - } - - // - // Check Can Set PPivot ... - bool canSetPPivot = - !cPivot.IsValid() - ? false - : iPivot.from < cPivot.from - ? !pPivot.IsValid() - ? true - : iPivot.from > pPivot.from - : false; - if (canSetPPivot) - { - pPivot = iPivot; - } - - // - has = cPivot.IsValid() && - pPivot.IsValid(); if (has) { // - iPivot.Clean(); - break; + AddRef( + iBox, + items // + ); } // - iPivot.Clean(); - } - - // - // Check Resources for Detecting Conditions ... - bool hasTrend = + iBox.Clean(); // - cPivot.IsValid() && - pPivot.IsValid() && - cPivot.dir == pPivot.dir && - cPivot.from > pPivot.from && - (IsBullish(cPivot.dir) - ? cPivot.lower > pPivot.lower - : cPivot.upper < pPivot.upper); - // - ; - if (hasTrend) - { - // - trendPivotC = cPivot; - trendPivotP = pPivot; - trendDir = cPivot.dir; } // Clean(tmp); - cPivot.Clean(); - pPivot.Clean(); - - // } // diff --git a/XCAEA/Classes/xcaea.x-poi.drawer.class.mq5 b/XCAEA/Classes/xcaea.x-poi.drawer.class.mq5 index f0f59a75..ad3d1ce8 100644 --- a/XCAEA/Classes/xcaea.x-poi.drawer.class.mq5 +++ b/XCAEA/Classes/xcaea.x-poi.drawer.class.mq5 @@ -27,6 +27,47 @@ // // Definitions ... +struct XCAPivotStyle +{ + // + // Properties ... + int width; + color clr; + ENUM_LINE_STYLE style; + + // + // Constructor ... + XCAPivotStyle() + { + Default(); + } + + // + // Tools ... + + // + // Cleanup Model ... + void Clean() + { + // + width = 1; + clr = CLR_NONE; + style = STYLE_SOLID; + + // + ZeroMemory(this); + } + + // + // Default Props ... + void Default() + { + // + width = 1; + clr = CLR_NONE; + style = STYLE_SOLID; + } +}; // // Implementations ... @@ -40,117 +81,28 @@ class XCXCAEAPOIDrawer : public XCBase // bool ignoreUpdateOSCTos; - bool drawTrendPivotsOnlySelectedFVG; // // Drawers ... - bool drawTrendLine; - bool drawTickPivots; - bool drawVolumePivots; - bool drawRSIPeakPivots; - bool drawRSIValePivots; - bool drawCCIPeakPivots; - bool drawCCIValePivots; + bool drawPeakPivots; + bool drawValePivots; bool drawFVGBullishPivots; bool drawFVGBearishPivots; - bool drawValeSupSWLPivots; - bool drawPeakResSWHPivots; - bool drawTrendBullishPivots; - bool drawTrendBearishPivots; - bool drawRSICrossedOverOSPivots; - bool drawRSICrossedUnderOBPivots; - bool drawCCICrossedOverOSPivots; - bool drawCCICrossedUnderOBPivots; // - // Colors ... + // Styling ... // - color defaultBullishColor; - color defaultBearishColor; + XCAPivotStyle defaultBullishStyle; + XCAPivotStyle defaultBearishStyle; // - color tickPivotsColor; - color volumePivotsColor; - color rsiPeakPivotsColor; - color rsiValePivotsColor; - color cciPeakPivotsColor; - color cciValePivotsColor; - color fvgBullishPivotsColor; - color fvgBearishPivotsColor; - color valeSupSWLPivotsColor; - color peakResSWHPivotsColor; - color trendLineBullishColor; - color trendLineBearishColor; - color trendBullishPivotsColor; - color trendBearishPivotsColor; - color rsiCrossedOverOSPivotsColor; - color rsiCrossedUnderOBPivotsColor; - color cciCrossedOverOSPivotsColor; - color cciCrossedUnderOBPivotsColor; + XCAPivotStyle peakPivotStyle; + XCAPivotStyle valePivotStyle; // - // Width ... - - // - int defaultBullishWidth; - int defaultBearishWidth; - - // - int tickPivotsWidth; - int volumePivotsWidth; - int rsiPeakPivotsWidth; - int rsiValePivotsWidth; - int cciPeakPivotsWidth; - int cciValePivotsWidth; - int fvgBullishPivotsWidth; - int fvgBearishPivotsWidth; - int valeSupSWLPivotsWidth; - int peakResSWHPivotsWidth; - int trendLineBullishWidth; - int trendLineBearishWidth; - int trendBullishPivotsWidth; - int trendBearishPivotsWidth; - int rsiCrossedOverOSPivotsWidth; - int rsiCrossedUnderOBPivotsWidth; - int cciCrossedOverOSPivotsWidth; - int cciCrossedUnderOBPivotsWidth; - - // - // Style ... - - // - ENUM_LINE_STYLE defaultBullishStyle; - ENUM_LINE_STYLE defaultBearishStyle; - - // - ENUM_LINE_STYLE tickPivotsStyle; - ENUM_LINE_STYLE volumePivotsStyle; - 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; - ENUM_LINE_STYLE trendLineBullishStyle; - ENUM_LINE_STYLE trendLineBearishStyle; - ENUM_LINE_STYLE trendBullishPivotsStyle; - ENUM_LINE_STYLE trendBearishPivotsStyle; - ENUM_LINE_STYLE rsiCrossedOverOSPivotsStyle; - ENUM_LINE_STYLE rsiCrossedUnderOBPivotsStyle; - ENUM_LINE_STYLE cciCrossedOverOSPivotsStyle; - ENUM_LINE_STYLE cciCrossedUnderOBPivotsStyle; - - // - // Colorize Props ... - - // - // Width Props ... - - // - // Style Props ... + XCAPivotStyle fvgBullishPivotStyle; + XCAPivotStyle fvgBearishPivotStyle; // // Constructors ... @@ -188,134 +140,49 @@ class XCXCAEAPOIDrawer : public XCBase virtual void Default() { // - ignoreUpdateOSCTos = true; - drawTrendPivotsOnlySelectedFVG = true; - - // - drawTrendLine = false; - drawTickPivots = false; - drawVolumePivots = false; - drawRSIPeakPivots = false; - drawRSIValePivots = false; - drawCCIPeakPivots = false; - drawCCIValePivots = false; + // Drawing ... drawFVGBullishPivots = false; drawFVGBearishPivots = false; - drawValeSupSWLPivots = false; - drawPeakResSWHPivots = false; - drawTrendBullishPivots = false; - drawTrendBearishPivots = false; - drawRSICrossedOverOSPivots = false; - drawRSICrossedUnderOBPivots = false; - drawCCICrossedOverOSPivots = false; - drawCCICrossedUnderOBPivots = false; // - defaultBullishColor = clrLime; - defaultBearishColor = clrRed; + // Styling ... // - tickPivotsColor = defaultBullishColor; - volumePivotsColor = defaultBearishColor; + // Bullish ... + defaultBullishStyle.width = 1; + defaultBullishStyle.clr = clrLime; + defaultBullishStyle.style = STYLE_SOLID; // - rsiValePivotsColor = defaultBullishColor; - cciValePivotsColor = defaultBullishColor; - fvgBullishPivotsColor = defaultBullishColor; - valeSupSWLPivotsColor = defaultBullishColor; - trendLineBullishColor = defaultBullishColor; - trendBullishPivotsColor = defaultBullishColor; - rsiCrossedOverOSPivotsColor = defaultBullishColor; - cciCrossedOverOSPivotsColor = defaultBullishColor; + // Bearish ... + defaultBearishStyle.width = 1; + defaultBearishStyle.clr = clrRed; + defaultBearishStyle.style = STYLE_SOLID; // - rsiPeakPivotsColor = defaultBearishColor; - cciPeakPivotsColor = defaultBearishColor; - fvgBearishPivotsColor = defaultBearishColor; - peakResSWHPivotsColor = defaultBearishColor; - trendLineBearishColor = defaultBearishColor; - trendBearishPivotsColor = defaultBearishColor; - rsiCrossedUnderOBPivotsColor = defaultBearishColor; - cciCrossedUnderOBPivotsColor = defaultBearishColor; + // Pivots ... // - defaultBullishWidth = 1; - defaultBearishWidth = 1; + // PV ... + peakPivotStyle = defaultBearishStyle; + valePivotStyle = defaultBullishStyle; // - tickPivotsWidth = defaultBullishWidth; - volumePivotsWidth = defaultBearishWidth; - - // - rsiValePivotsWidth = defaultBullishWidth; - cciValePivotsWidth = defaultBullishWidth; - fvgBullishPivotsWidth = defaultBullishWidth; - valeSupSWLPivotsWidth = defaultBullishWidth; - trendLineBullishWidth = defaultBullishWidth; - trendBullishPivotsWidth = defaultBullishWidth; - rsiCrossedOverOSPivotsWidth = defaultBullishWidth; - cciCrossedOverOSPivotsWidth = defaultBullishWidth; - - // - rsiPeakPivotsWidth = defaultBearishWidth; - cciPeakPivotsWidth = defaultBearishWidth; - fvgBearishPivotsWidth = defaultBearishWidth; - peakResSWHPivotsWidth = defaultBearishWidth; - trendLineBearishWidth = defaultBearishWidth; - trendBearishPivotsWidth = defaultBearishWidth; - rsiCrossedUnderOBPivotsWidth = defaultBearishWidth; - cciCrossedUnderOBPivotsWidth = defaultBearishWidth; - - // - defaultBullishStyle = STYLE_SOLID; - defaultBearishStyle = STYLE_SOLID; - - // - tickPivotsStyle = defaultBullishStyle; - volumePivotsStyle = defaultBearishStyle; - - // - rsiValePivotsStyle = defaultBullishStyle; - cciValePivotsStyle = defaultBullishStyle; - fvgBullishPivotsStyle = defaultBullishStyle; - valeSupSWLPivotsStyle = defaultBullishStyle; - trendLineBullishStyle = defaultBullishStyle; - trendBullishPivotsStyle = defaultBullishStyle; - rsiCrossedOverOSPivotsStyle = defaultBullishStyle; - cciCrossedOverOSPivotsStyle = defaultBullishStyle; - - // - rsiPeakPivotsStyle = defaultBearishStyle; - cciPeakPivotsStyle = defaultBearishStyle; - fvgBearishPivotsStyle = defaultBearishStyle; - peakResSWHPivotsStyle = defaultBearishStyle; - trendLineBearishStyle = defaultBearishStyle; - trendBearishPivotsStyle = defaultBearishStyle; - rsiCrossedUnderOBPivotsStyle = defaultBearishStyle; - cciCrossedUnderOBPivotsStyle = defaultBearishStyle; + // FVG ... + fvgBullishPivotStyle = defaultBullishStyle; + fvgBearishPivotStyle = defaultBearishStyle; } // void Draw(datetime to = NULL) { // - DrawTrendLine(); - DrawTickPivots(to); - DrawVolumePivots(to); - DrawRSIPeakPivots(to); - DrawRSIValePivots(to); - DrawCCIPeakPivots(to); - DrawCCIValePivots(to); + DrawPeakPivots(to); + DrawValePivots(to); + + // DrawFVGBullishPivots(to); DrawFVGBearishPivots(to); - DrawValeSupSWLPivots(to); - DrawPeakResSWHPivots(to); - DrawTrendBullishPivots(to); - DrawTrendBearishPivots(to); - DrawRSICrossedOverOSPivots(to); - DrawRSICrossedUnderOBPivots(to); - DrawCCICrossedOverOSPivots(to); - DrawCCICrossedUnderOBPivots(to); } // @@ -343,18 +210,18 @@ class XCXCAEAPOIDrawer : public XCBase switch (iType) { // - case XCA_TICK: + case XCA_PEAK: // - DrawTickPivot( + DrawPeakPivot( box, to // ); break; - // - case XCA_VOLUME: // - DrawVolumePivot( + case XCA_VALE: + // + DrawValePivot( box, to // ); @@ -377,96 +244,6 @@ class XCXCAEAPOIDrawer : public XCBase to // ); break; - - // - case XCA_RSI_COOS: - // - DrawRSICrossedOverOSPivot( - box, - to // - ); - break; - - // - case XCA_RSI_CUOB: - // - DrawRSICrossedUnderOBPivot( - box, - to // - ); - break; - - // - case XCA_RSI_PEAK: - // - DrawRSIPeakPivot( - box, - to // - ); - break; - - // - case XCA_RSI_VALE: - // - DrawRSIValePivot( - box, - to // - ); - break; - - // - case XCA_CCI_COOS: - // - DrawCCICrossedOverOSPivot( - box, - to // - ); - break; - - // - case XCA_CCI_CUOB: - // - DrawCCICrossedUnderOBPivot( - box, - to // - ); - break; - - // - case XCA_CCI_PEAK: - // - DrawCCIPeakPivot( - box, - to // - ); - break; - - // - case XCA_CCI_VALE: - // - DrawCCIValePivot( - box, - to // - ); - break; - - // - case XCA_PEAKSWHRES: - // - DrawPeakResSWHPivot( - box, - to // - ); - break; - - // - case XCA_VALESWLSUP: - // - DrawValeSupSWLPivot( - box, - to // - ); - break; } } @@ -499,201 +276,61 @@ class XCXCAEAPOIDrawer : public XCBase // iBox.Clean(); - }; - - // - // Trend Items ... - XCATRENDFVG trendFVGs[]; - count = ExtractTrendPivots( - trendFVGs, - boxes // - ); - has = IsValidSize(count); - if (!has) - { - return; } - - // - for (int i = 0; i < count; i++) - { - // - XCATRENDFVG iTrendFVG = trendFVGs[i]; - - // - bool isBullish = iTrendFVG.IsBullish(); - if (isBullish) - { - // - DrawTrendBullishPivot( - iTrendFVG, - to // - ); - } - else - { - // - DrawTrendBearishPivot( - iTrendFVG, - to // - ); - } - - // - iTrendFVG.Clean(); - } - - // - Clean(trendFVGs); } // void Clear() { // - mTrendLineObjects.Clear(); - mTickPivotObjects.Clear(); - mVolumePivotObjects.Clear(); - mRSIPeakPivotObjects.Clear(); - mRSIValePivotObjects.Clear(); - mCCIPeakPivotObjects.Clear(); - mCCIValePivotObjects.Clear(); + // Cleanup Models ... + defaultBullishStyle.Clean(); + defaultBearishStyle.Clean(); + + // + // Cleanup Styles ... + peakPivotStyle.Clean(); + valePivotStyle.Clean(); + fvgBullishPivotStyle.Clean(); + fvgBearishPivotStyle.Clean(); + + // + // Cleanup Pivot Objects Holder ... + mPeakPivotObjects.Clear(); + mValePivotObjects.Clear(); mFVGBullishPivotObjects.Clear(); mFVGBearishPivotObjects.Clear(); - mValeSupSWLPivotObjects.Clear(); - mPeakResSWHPivotObjects.Clear(); - mTrendBullishPivotObjects.Clear(); - mTrendBearishPivotObjects.Clear(); - mRSICrossedOverOSPivotObjects.Clear(); - mRSICrossedUnderOBPivotObjects.Clear(); - mCCICrossedOverOSPivotObjects.Clear(); - mCCICrossedUnderOBPivotObjects.Clear(); } // // Collection Drawers ... // - void DrawTrendLine() + void DrawPeakPivots(datetime to = NULL) { // - if (!drawTrendLine) - { - return; - } - - // - mTrendLineObjects.Clear(); - - // - ENUM_X_DIRECTION trend = X_DIRECTION_NONE; - bool has = detector.MarketTrend(trend); + bool has = drawPeakPivots; if (!has) { return; } // - long chartID = drawer.ChartIdentification(); - int subWindow = drawer.SubWindowIdentification(); - - // - bool hasBullishTrend = IsBullish(trend); - - // - double pPrice = hasBullishTrend - ? detector.trendPivotP.lower - : detector.trendPivotP.upper; - - // - datetime pTime = detector.trendPivotP.from; - - // - double cPrice = hasBullishTrend - ? detector.trendPivotC.lower - : detector.trendPivotC.upper; - - // - datetime cTime = detector.trendPivotC.from; - - // - string tlName = ToString(trend) + - "_TL_" + - ToString(pPrice) + - "_" + - ToString(cPrice); - - // - int tlWidth = hasBullishTrend - ? trendLineBullishWidth - : trendLineBearishWidth; - - // - color tlColor = hasBullishTrend - ? trendLineBullishColor - : trendLineBearishColor; - - // - ENUM_LINE_STYLE tlStyle = hasBullishTrend - ? trendLineBullishStyle - : trendLineBearishStyle; - - // - CChartObjectTrend *iObj; - iObj = new CChartObjectTrend(); - has = iObj.Create( - chartID, - tlName, - subWindow, - pTime, - pPrice, - cTime, - cPrice // - ); - if (has) - { - // - // Style Object ... - iObj.Color(tlColor); - iObj.Width(tlWidth); - iObj.Style(tlStyle); - iObj.RayRight(true); - - // - // Store Object ... - mTrendLineObjects.Add(iObj); - } - - // - ZeroMemory(iObj); - } - - // - void DrawTickPivots(datetime to = NULL) - { - // - bool has = drawTickPivots; + has = detector.HasPeakPivots(); if (!has) { return; } // - has = detector.HasTickPivots(); - if (!has) - { - return; - } - - // - int count = detector.CountTickPivots(); + int count = detector.CountPeakPivots(); for (int i = 0; i < count; i++) { // - XBoxZone iBox = detector.tickPivots[i]; + XBoxZone iBox = detector.peakPivots[i]; // - DrawTickPivot( + DrawPeakPivot( iBox, to // ); @@ -704,171 +341,31 @@ class XCXCAEAPOIDrawer : public XCBase } // - void DrawVolumePivots(datetime to = NULL) + void DrawValePivots(datetime to = NULL) { // - bool has = drawVolumePivots; + bool has = drawValePivots; if (!has) { return; } // - has = detector.HasVolumePivots(); + has = detector.HasValePivots(); if (!has) { return; } // - int count = detector.CountVolumePivots(); + int count = detector.CountValePivots(); for (int i = 0; i < count; i++) { // - XBoxZone iBox = detector.volumePivots[i]; + XBoxZone iBox = detector.valePivots[i]; // - DrawVolumePivot( - iBox, - to // - ); - - // - iBox.Clean(); - } - } - - // - void DrawRSIPeakPivots(datetime to = NULL) - { - // - bool has = drawRSIPeakPivots; - if (!has) - { - return; - } - - // - has = detector.HasRSIPeakPivots(); - if (!has) - { - return; - } - - // - int count = detector.CountRSIPeakPivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox = detector.rsiPeakPivots[i]; - - // - DrawRSIPeakPivot( - iBox, - to // - ); - - // - iBox.Clean(); - } - } - - // - void DrawRSIValePivots(datetime to = NULL) - { - // - bool has = drawRSIValePivots; - if (!has) - { - return; - } - - // - has = detector.HasRSIValePivots(); - if (!has) - { - return; - } - - // - int count = detector.CountRSIValePivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox = detector.rsiValePivots[i]; - - // - DrawRSIValePivot( - iBox, - to // - ); - - // - iBox.Clean(); - } - } - - // - void DrawCCIPeakPivots(datetime to = NULL) - { - // - bool has = drawCCIPeakPivots; - if (!has) - { - return; - } - - // - has = detector.HasCCIPeakPivots(); - if (!has) - { - return; - } - - // - int count = detector.CountCCIPeakPivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox = detector.cciPeakPivots[i]; - - // - DrawCCIPeakPivot( - iBox, - to // - ); - - // - iBox.Clean(); - } - } - - // - void DrawCCIValePivots(datetime to = NULL) - { - // - bool has = drawCCIValePivots; - if (!has) - { - return; - } - - // - has = detector.HasCCIValePivots(); - if (!has) - { - return; - } - - // - int count = detector.CountCCIValePivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox = detector.cciValePivots[i]; - - // - DrawCCIValePivot( + DrawValePivot( iBox, to // ); @@ -948,300 +445,17 @@ class XCXCAEAPOIDrawer : public XCBase } } - // - void DrawValeSupSWLPivots(datetime to = NULL) - { - // - bool has = drawValeSupSWLPivots; - if (!has) - { - return; - } - - // - has = detector.HasValeSupSWLPivots(); - if (!has) - { - return; - } - - // - int count = detector.CountValeSupSWLPivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox = detector.valeSupSWLPivots[i]; - - // - DrawValeSupSWLPivot( - iBox, - to // - ); - - // - iBox.Clean(); - } - } - - // - void DrawPeakResSWHPivots(datetime to = NULL) - { - // - bool has = drawPeakResSWHPivots; - if (!has) - { - return; - } - - // - has = detector.HasPeakResSWHPivots(); - if (!has) - { - return; - } - - // - int count = detector.CountPeakResSWHPivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox = detector.peakResSWHPivots[i]; - - // - DrawPeakResSWHPivot( - iBox, - to // - ); - - // - iBox.Clean(); - } - } - - // - void DrawTrendBullishPivots(datetime to = NULL) - { - // - bool has = drawTrendBullishPivots; - if (!has) - { - return; - } - - // - has = detector.HasTrendBullishPivots(); - if (!has) - { - return; - } - - // - bool canUpdateTo = IsValid(to); - - // - int count = detector.CountTrendBullishPivots(); - for (int i = 0; i < count; i++) - { - // - XCATRENDFVG iTrendFVG = detector.trendBullishPivots[i]; - - // - DrawTrendBullishPivot( - iTrendFVG, - to // - ); - - // - iTrendFVG.Clean(); - } - } - - // - void DrawTrendBearishPivots(datetime to = NULL) - { - // - bool has = drawTrendBearishPivots; - if (!has) - { - return; - } - - // - has = detector.HasTrendBearishPivots(); - if (!has) - { - return; - } - - // - int count = detector.CountTrendBearishPivots(); - for (int i = 0; i < count; i++) - { - // - XCATRENDFVG iTrendFVG = detector.trendBearishPivots[i]; - - // - DrawTrendBearishPivot( - iTrendFVG, - to // - ); - - // - iTrendFVG.Clean(); - } - } - - // - void DrawRSICrossedOverOSPivots(datetime to = NULL) - { - // - bool has = drawRSICrossedOverOSPivots; - if (!has) - { - return; - } - - // - has = detector.HasRSICrossedOverOSPivots(); - if (!has) - { - return; - } - - // - int count = detector.CountRSICrossedOverOSPivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox = detector.rsiCrossedOverOSPivots[i]; - - // - DrawRSICrossedOverOSPivot( - iBox, - to // - ); - - // - iBox.Clean(); - } - } - - // - void DrawRSICrossedUnderOBPivots(datetime to = NULL) - { - // - bool has = drawRSICrossedUnderOBPivots; - if (!has) - { - return; - } - - // - has = detector.HasRSICrossedUnderOBPivots(); - if (!has) - { - return; - } - - // - int count = detector.CountRSICrossedUnderOBPivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox = detector.rsiCrossedUnderOBPivots[i]; - - // - DrawRSICrossedUnderOBPivot( - iBox, - to // - ); - - // - iBox.Clean(); - } - } - - // - void DrawCCICrossedOverOSPivots(datetime to = NULL) - { - // - bool has = drawCCICrossedOverOSPivots; - if (!has) - { - return; - } - - // - has = detector.HasCCICrossedOverOSPivots(); - if (!has) - { - return; - } - - // - int count = detector.CountCCICrossedOverOSPivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox = detector.cciCrossedOverOSPivots[i]; - - // - DrawCCICrossedOverOSPivot( - iBox, - to // - ); - - // - iBox.Clean(); - } - } - - // - void DrawCCICrossedUnderOBPivots(datetime to = NULL) - { - // - bool has = drawCCICrossedUnderOBPivots; - if (!has) - { - return; - } - - // - has = detector.HasCCICrossedUnderOBPivots(); - if (!has) - { - return; - } - - // - int count = detector.CountCCICrossedUnderOBPivots(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox = detector.cciCrossedUnderOBPivots[i]; - - // - DrawCCICrossedUnderOBPivot( - iBox, - to // - ); - - // - iBox.Clean(); - } - } - // // One Item Drawers ... // - void DrawTickPivot( + void DrawPeakPivot( XBoxZone &item, datetime to = NULL // ) { // - bool has = drawTickPivots; + bool has = drawPeakPivots; if (!has) { return; @@ -1249,7 +463,8 @@ class XCXCAEAPOIDrawer : public XCBase // has = item.IsValid() && - item.type == GetBoxType(XCA_TICK); + item.type == GetBoxType(XCA_PEAK) && + item.dir == GetDirection(XCA_PEAK); if (!has) { return; @@ -1262,113 +477,6 @@ class XCXCAEAPOIDrawer : public XCBase item.to = to; } - // - XCBoxObject *iObj; - has = drawer.DrawBox( - item, - iObj // - ); - if (has) - { - // - // Style Pivot ... - iObj.BoxColor(tickPivotsColor); - iObj.BoxWidth(tickPivotsWidth); - iObj.BoxStyle(tickPivotsStyle); - - // - // Store Pivot ... - mTickPivotObjects.Add(iObj); - } - - // - ZeroMemory(iObj); - } - - // - void DrawVolumePivot( - XBoxZone &item, - datetime to = NULL // - ) - { - // - bool has = drawVolumePivots; - if (!has) - { - return; - } - - // - has = item.IsValid() && - item.type == GetBoxType(XCA_VOLUME); - if (!has) - { - return; - } - - // - bool canUpdateTo = IsValid(to); - if (canUpdateTo) - { - item.to = to; - } - - // - XCBoxObject *iObj; - has = drawer.DrawBox( - item, - iObj // - ); - if (has) - { - // - // Style Pivot ... - iObj.BoxColor(volumePivotsColor); - iObj.BoxWidth(volumePivotsWidth); - iObj.BoxStyle(volumePivotsStyle); - - // - // Store Pivot ... - mVolumePivotObjects.Add(iObj); - } - - // - ZeroMemory(iObj); - } - - // - void DrawRSIPeakPivot( - XBoxZone &item, - datetime to = NULL // - ) - { - // - bool has = drawRSIPeakPivots; - if (!has) - { - return; - } - - // - has = item.IsValid() && - item.type == GetBoxType(XCA_RSI_PEAK) && - item.dir == GetDirection(XCA_RSI_PEAK); - if (!has) - { - return; - } - - // - if (ignoreUpdateOSCTos) - { - to = NULL; - } - bool canUpdateTo = IsValid(to); - if (canUpdateTo) - { - item.to = to; - } - // XCBoxObject *iObj; has = drawer.DrawBox( @@ -1379,13 +487,14 @@ class XCXCAEAPOIDrawer : public XCBase { // // Style Object ... - iObj.BoxColor(rsiPeakPivotsColor); - iObj.BoxWidth(rsiPeakPivotsWidth); - iObj.BoxStyle(rsiPeakPivotsStyle); + ApplyPivotStyle( + iObj, + peakPivotStyle // + ); // // Store Object ... - mRSIPeakPivotObjects.Add(iObj); + mPeakPivotObjects.Add(iObj); } // @@ -1393,13 +502,13 @@ class XCXCAEAPOIDrawer : public XCBase } // - void DrawRSIValePivot( + void DrawValePivot( XBoxZone &item, datetime to = NULL // ) { // - bool has = drawRSIValePivots; + bool has = drawValePivots; if (!has) { return; @@ -1407,18 +516,14 @@ class XCXCAEAPOIDrawer : public XCBase // has = item.IsValid() && - item.type == GetBoxType(XCA_RSI_VALE) && - item.dir == GetDirection(XCA_RSI_VALE); + item.type == GetBoxType(XCA_VALE) && + item.dir == GetDirection(XCA_VALE); if (!has) { return; } // - if (ignoreUpdateOSCTos) - { - to = NULL; - } bool canUpdateTo = IsValid(to); if (canUpdateTo) { @@ -1435,125 +540,14 @@ class XCXCAEAPOIDrawer : public XCBase { // // Style Object ... - iObj.BoxColor(rsiValePivotsColor); - iObj.BoxWidth(rsiValePivotsWidth); - iObj.BoxStyle(rsiValePivotsStyle); + ApplyPivotStyle( + iObj, + valePivotStyle // + ); // // Store Object ... - mRSIValePivotObjects.Add(iObj); - } - - // - ZeroMemory(iObj); - } - - // - void DrawCCIPeakPivot( - XBoxZone &item, - datetime to = NULL // - ) - { - // - bool has = drawCCIPeakPivots; - if (!has) - { - return; - } - - // - has = item.IsValid() && - item.type == GetBoxType(XCA_CCI_PEAK) && - item.dir == GetDirection(XCA_CCI_PEAK); - if (!has) - { - return; - } - - // - if (ignoreUpdateOSCTos) - { - to = NULL; - } - bool canUpdateTo = IsValid(to); - if (canUpdateTo) - { - item.to = to; - } - - // - XCBoxObject *iObj; - has = drawer.DrawBox( - item, - iObj // - ); - if (has) - { - // - // Style Object ... - iObj.BoxColor(cciPeakPivotsColor); - iObj.BoxWidth(cciPeakPivotsWidth); - iObj.BoxStyle(cciPeakPivotsStyle); - - // - // Store Object ... - mCCIPeakPivotObjects.Add(iObj); - } - - // - ZeroMemory(iObj); - } - - // - void DrawCCIValePivot( - XBoxZone &item, - datetime to = NULL // - ) - { - // - bool has = drawCCIValePivots; - if (!has) - { - return; - } - - // - has = item.IsValid() && - item.type == GetBoxType(XCA_CCI_VALE) && - item.dir == GetDirection(XCA_CCI_VALE); - if (!has) - { - return; - } - - // - if (ignoreUpdateOSCTos) - { - to = NULL; - } - bool canUpdateTo = IsValid(to); - if (canUpdateTo) - { - item.to = to; - } - - // - XCBoxObject *iObj; - has = drawer.DrawBox( - item, - iObj // - ); - if (has) - { - // - // Style Object ... - iObj.BoxColor(cciValePivotsColor); - iObj.BoxWidth(cciValePivotsWidth); - iObj.BoxStyle(cciValePivotsStyle); - - // - // Store Object ... - mCCIValePivotObjects.Add(iObj); + mValePivotObjects.Add(iObj); } // @@ -1599,9 +593,10 @@ class XCXCAEAPOIDrawer : public XCBase { // // Style Object ... - iObj.BoxColor(fvgBullishPivotsColor); - iObj.BoxWidth(fvgBullishPivotsWidth); - iObj.BoxStyle(fvgBullishPivotsStyle); + ApplyPivotStyle( + iObj, + fvgBullishPivotStyle // + ); // // Store Object ... @@ -1651,9 +646,10 @@ class XCXCAEAPOIDrawer : public XCBase { // // Style Object ... - iObj.BoxColor(fvgBearishPivotsColor); - iObj.BoxWidth(fvgBearishPivotsWidth); - iObj.BoxStyle(fvgBearishPivotsStyle); + ApplyPivotStyle( + iObj, + fvgBearishPivotStyle // + ); // // Store Object ... @@ -1664,636 +660,30 @@ class XCXCAEAPOIDrawer : public XCBase ZeroMemory(iObj); } - // - void DrawValeSupSWLPivot( - XBoxZone &item, - datetime to = NULL // - ) - { - // - bool has = drawValeSupSWLPivots; - if (!has) - { - return; - } - - // - has = item.IsValid() && - item.type == GetBoxType(XCA_VALESWLSUP) && - item.dir == GetDirection(XCA_VALESWLSUP); - if (!has) - { - return; - } - - // - bool canUpdateTo = IsValid(to); - if (canUpdateTo) - { - item.to = to; - } - - // - XCBoxObject *iObj; - has = drawer.DrawBox( - item, - iObj // - ); - if (has) - { - // - // Style Object ... - iObj.BoxColor(valeSupSWLPivotsColor); - iObj.BoxWidth(valeSupSWLPivotsWidth); - iObj.BoxStyle(valeSupSWLPivotsStyle); - - // - // Store Object ... - mValeSupSWLPivotObjects.Add(iObj); - } - - // - ZeroMemory(iObj); - } - - // - void DrawPeakResSWHPivot( - XBoxZone &item, - datetime to = NULL // - ) - { - // - bool has = drawPeakResSWHPivots; - if (!has) - { - return; - } - - // - has = item.IsValid() && - item.type == GetBoxType(XCA_PEAKSWHRES) && - item.dir == GetDirection(XCA_PEAKSWHRES); - if (!has) - { - return; - } - - // - bool canUpdateTo = IsValid(to); - if (canUpdateTo) - { - item.to = to; - } - - // - XCBoxObject *iObj; - has = drawer.DrawBox( - item, - iObj // - ); - if (has) - { - // - // Style Object ... - iObj.BoxColor(peakResSWHPivotsColor); - iObj.BoxWidth(peakResSWHPivotsWidth); - iObj.BoxStyle(peakResSWHPivotsStyle); - - // - // Store Object ... - mPeakResSWHPivotObjects.Add(iObj); - } - - // - ZeroMemory(iObj); - } - - // - void DrawTrendBullishPivot( - XCATRENDFVG &item, - datetime to = NULL // - ) - { - // - bool has = drawTrendBullishPivots; - if (!has) - { - return; - } - - // - has = item.IsValid() && - item.trend.type == GetBoxType(XCA_TREND_BULL) && - item.trend.dir == GetDirection(XCA_TREND_BULL); - if (!has) - { - return; - } - - // - bool canUpdateTo = IsValid(to); - - // - // Draw Trend Box ... - - // - if (canUpdateTo) - { - item.trend.to = to; - } - - // - XCBoxObject *iTrendBoxObj; - has = drawer.DrawBox( - item.trend, - iTrendBoxObj // - ); - if (has) - { - // - // Style Object ... - iTrendBoxObj.BoxColor(trendBullishPivotsColor); - iTrendBoxObj.BoxWidth(trendBullishPivotsWidth); - iTrendBoxObj.BoxStyle(trendBullishPivotsStyle); - - // - // Store Object ... - mTrendBullishPivotObjects.Add(iTrendBoxObj); - } - - // - // Draw ITrendFVG FVGS ... - if (drawTrendPivotsOnlySelectedFVG) - { - // - XBoxZone iBox; - has = item.GetSelectedFVG(iBox); - if (!has) - { - // - iBox.Clean(); - return; - } - - // - if (canUpdateTo) - { - iBox.to = to; - } - - // - XCBoxObject *iObj; - has = drawer.DrawBox( - iBox, - iObj // - ); - - // - if (has) - { - // - // Style Object ... - iObj.BoxColor(fvgBullishPivotsColor); - iObj.BoxWidth(fvgBullishPivotsWidth); - iObj.BoxStyle(fvgBullishPivotsStyle); - - // - // Store Object ... - mTrendBullishPivotObjects.Add(iObj); - } - - // - iBox.Clean(); - ZeroMemory(iObj); - } - else - { - // - // Draw All FVGs ... - has = HasChild(item.fvgs); - if (has) - { - // - int jCount = ArraySize(item.fvgs); - for (int j = 0; j < jCount; j++) - { - // - XBoxZone iBox = item.fvgs[j]; - - // - if (canUpdateTo) - { - iBox.to = to; - } - - // - XCBoxObject *iObj; - has = drawer.DrawBox( - iBox, - iObj // - ); - if (has) - { - // - // Style Object ... - iObj.BoxColor(fvgBullishPivotsColor); - iObj.BoxWidth(fvgBullishPivotsWidth); - iObj.BoxStyle(fvgBullishPivotsStyle); - - // - // Store Object ... - mTrendBullishPivotObjects.Add(iObj); - } - - // - iBox.Clean(); - ZeroMemory(iObj); - } - } - } - - // - ZeroMemory(iTrendBoxObj); - } - - // - void DrawTrendBearishPivot( - XCATRENDFVG &item, - datetime to = NULL // - ) - { - // - bool has = drawTrendBearishPivots; - if (!has) - { - return; - } - - // - has = item.IsValid() && - item.trend.type == GetBoxType(XCA_TREND_BEAR) && - item.trend.dir == GetDirection(XCA_TREND_BEAR); - if (!has) - { - return; - } - - // - bool canUpdateTo = IsValid(to); - - // - // Draw Trend Box ... - - // - if (canUpdateTo) - { - item.trend.to = to; - } - - // - XCBoxObject *iTrendBoxObj; - has = drawer.DrawBox( - item.trend, - iTrendBoxObj // - ); - if (has) - { - // - // Style Object ... - iTrendBoxObj.BoxColor(trendBearishPivotsColor); - iTrendBoxObj.BoxWidth(trendBearishPivotsWidth); - iTrendBoxObj.BoxStyle(trendBearishPivotsStyle); - - // - // Store Object ... - mTrendBearishPivotObjects.Add(iTrendBoxObj); - } - - // - // Draw ITrendFVG FVGS ... - if (drawTrendPivotsOnlySelectedFVG) - { - // - XBoxZone iBox; - has = item.GetSelectedFVG(iBox); - if (!has) - { - // - iBox.Clean(); - return; - } - - // - if (canUpdateTo) - { - iBox.to = to; - } - - // - XCBoxObject *iObj; - has = drawer.DrawBox( - iBox, - iObj // - ); - - // - if (has) - { - // - // Style Object ... - iObj.BoxColor(fvgBearishPivotsColor); - iObj.BoxWidth(fvgBearishPivotsWidth); - iObj.BoxStyle(fvgBearishPivotsStyle); - - // - // Store Object ... - mTrendBearishPivotObjects.Add(iObj); - } - - // - iBox.Clean(); - ZeroMemory(iObj); - } - else - { - // - // Draw All FVGs ... - has = HasChild(item.fvgs); - if (has) - { - // - int jCount = ArraySize(item.fvgs); - for (int j = 0; j < jCount; j++) - { - // - XBoxZone iBox = item.fvgs[j]; - - // - if (canUpdateTo) - { - iBox.to = to; - } - - // - XCBoxObject *iObj; - has = drawer.DrawBox( - iBox, - iObj // - ); - if (has) - { - // - // Style Object ... - iObj.BoxColor(fvgBearishPivotsColor); - iObj.BoxWidth(fvgBearishPivotsWidth); - iObj.BoxStyle(fvgBearishPivotsStyle); - - // - // Store Object ... - mTrendBearishPivotObjects.Add(iObj); - } - - // - iBox.Clean(); - ZeroMemory(iObj); - } - } - } - - // - ZeroMemory(iTrendBoxObj); - } - - // - void DrawRSICrossedOverOSPivot( - XBoxZone &item, - datetime to = NULL // - ) - { - // - bool has = drawRSICrossedOverOSPivots; - if (!has) - { - return; - } - - // - has = item.IsValid() && - item.type == GetBoxType(XCA_RSI_COOS) && - item.dir == GetDirection(XCA_RSI_COOS); - if (!has) - { - return; - } - - // - if (ignoreUpdateOSCTos) - { - to = NULL; - } - bool canUpdateTo = IsValid(to); - if (canUpdateTo) - { - item.to = to; - } - - // - XCBoxObject *iObj; - has = drawer.DrawBox( - item, - iObj // - ); - if (has) - { - // - // Style Object ... - iObj.BoxColor(rsiCrossedOverOSPivotsColor); - iObj.BoxWidth(rsiCrossedOverOSPivotsWidth); - iObj.BoxStyle(rsiCrossedOverOSPivotsStyle); - - // - // Store Object ... - mRSICrossedOverOSPivotObjects.Add(iObj); - } - - // - ZeroMemory(iObj); - } - - // - void DrawRSICrossedUnderOBPivot( - XBoxZone &item, - datetime to = NULL // - ) - { - // - bool has = drawRSICrossedUnderOBPivots; - if (!has) - { - return; - } - - // - has = item.IsValid() && - item.type == GetBoxType(XCA_RSI_CUOB) && - item.dir == GetDirection(XCA_RSI_CUOB); - if (!has) - { - return; - } - - // - if (ignoreUpdateOSCTos) - { - to = NULL; - } - bool canUpdateTo = IsValid(to); - if (canUpdateTo) - { - item.to = to; - } - - // - XCBoxObject *iObj; - has = drawer.DrawBox( - item, - iObj // - ); - if (has) - { - // - // Style Object ... - iObj.BoxColor(rsiCrossedUnderOBPivotsColor); - iObj.BoxWidth(rsiCrossedUnderOBPivotsWidth); - iObj.BoxStyle(rsiCrossedUnderOBPivotsStyle); - - // - // Store Object ... - mRSICrossedUnderOBPivotObjects.Add(iObj); - } - - // - ZeroMemory(iObj); - } - - // - void DrawCCICrossedOverOSPivot( - XBoxZone &item, - datetime to = NULL // - ) - { - // - bool has = drawCCICrossedOverOSPivots; - if (!has) - { - return; - } - - // - has = item.IsValid() && - item.type == GetBoxType(XCA_CCI_COOS) && - item.dir == GetDirection(XCA_CCI_COOS); - if (!has) - { - return; - } - - // - if (ignoreUpdateOSCTos) - { - to = NULL; - } - bool canUpdateTo = IsValid(to); - if (canUpdateTo) - { - item.to = to; - } - - // - XCBoxObject *iObj; - has = drawer.DrawBox( - item, - iObj // - ); - if (has) - { - // - // Style Object ... - iObj.BoxColor(cciCrossedOverOSPivotsColor); - iObj.BoxWidth(cciCrossedOverOSPivotsWidth); - iObj.BoxStyle(cciCrossedOverOSPivotsStyle); - - // - // Store Object ... - mCCICrossedOverOSPivotObjects.Add(iObj); - } - - // - ZeroMemory(iObj); - } - - // - void DrawCCICrossedUnderOBPivot( - XBoxZone &item, - datetime to = NULL // - ) - { - // - bool has = drawCCICrossedUnderOBPivots; - if (!has) - { - return; - } - - // - has = item.IsValid() && - item.type == GetBoxType(XCA_CCI_CUOB) && - item.dir == GetDirection(XCA_CCI_CUOB); - if (!has) - { - return; - } - - // - if (ignoreUpdateOSCTos) - { - to = NULL; - } - bool canUpdateTo = IsValid(to); - if (canUpdateTo) - { - item.to = to; - } - - // - XCBoxObject *iObj; - has = drawer.DrawBox( - item, - iObj // - ); - if (has) - { - // - // Style Object ... - iObj.BoxColor(cciCrossedUnderOBPivotsColor); - iObj.BoxWidth(cciCrossedUnderOBPivotsWidth); - iObj.BoxStyle(cciCrossedUnderOBPivotsStyle); - - // - // Store Object ... - mCCICrossedUnderOBPivotObjects.Add(iObj); - } - - // - ZeroMemory(iObj); - } - // // Protected ... protected: // // Props ... + // + void ApplyPivotStyle( + XCBoxObject *&object, + XCAPivotStyle &style // + ) + { + // + if (object == NULL) + { + return; + } + + // + object.BoxColor(style.clr); + object.BoxWidth(style.width); + object.BoxStyle(style.style); + } + // // Prrivate ... private: @@ -2305,23 +695,12 @@ class XCXCAEAPOIDrawer : public XCBase XCXCAEAPOIDetector *detector; // - CArrayObj mTickPivotObjects; - CArrayObj mTrendLineObjects; - CArrayObj mVolumePivotObjects; - CArrayObj mRSIPeakPivotObjects; - CArrayObj mRSIValePivotObjects; - CArrayObj mCCIPeakPivotObjects; - CArrayObj mCCIValePivotObjects; + CArrayObj mPeakPivotObjects; + CArrayObj mValePivotObjects; + + // CArrayObj mFVGBullishPivotObjects; CArrayObj mFVGBearishPivotObjects; - CArrayObj mValeSupSWLPivotObjects; - CArrayObj mPeakResSWHPivotObjects; - CArrayObj mTrendBullishPivotObjects; - CArrayObj mTrendBearishPivotObjects; - CArrayObj mRSICrossedOverOSPivotObjects; - CArrayObj mRSICrossedUnderOBPivotObjects; - CArrayObj mCCICrossedOverOSPivotObjects; - CArrayObj mCCICrossedUnderOBPivotObjects; // }; diff --git a/XCAEA/Libraries/xcaea.signaller.lib.mq5 b/XCAEA/Libraries/xcaea.signaller.lib.mq5 index 7a703747..f10e2c0c 100644 --- a/XCAEA/Libraries/xcaea.signaller.lib.mq5 +++ b/XCAEA/Libraries/xcaea.signaller.lib.mq5 @@ -466,11 +466,11 @@ bool DetectXCAEAConditions( // // Trend Parsing ... - bool hasTrend = HasDirection(trend); - bool hasBullishTrend = hasTrend && - IsBullish(trend); - bool hasBearishTrend = hasTrend && - IsBearish(trend); + // bool hasTrend = HasDirection(trend); + // bool hasBullishTrend = hasTrend && + // IsBullish(trend); + // bool hasBearishTrend = hasTrend && + // IsBearish(trend); // // Retrieve Previous and Current Bar Conditions ... @@ -663,12 +663,6 @@ bool DetectXCAEAConditions( // bool isScoreNeutural = MathAbs(bullishScore - bearishScore) == 0; - // - // Generating Conditions Summary ... - string summary = - conditions - .GenerateSummary(); - // // Calculating Range Volumes ... @@ -1080,69 +1074,22 @@ bool DetectXCAEAConditions( // ; - // - if (isCBarHasStrongATR) - { - // - Print(ToString(cBar.GetDirection()), " ATR Growing ..."); - } - - // - bool isZeroVScore = isScoreNeutural || - isVolumeNeutural; - - // - bool isBullishTested = - isZeroVScore && - isCBarValidForBullish; - bool isBearishTested = - isZeroVScore && - isCBarValidForBearish; - - // - bool isTested = - // - isBullishTested || - isBearishTested - // - ; - if (isTested) - { - // - Print("Zero Volume ..."); - } - // // Parsing Pivots ... - XBoxZone rciPivot; double providedSL = 0; XBoxZone rejectedPivot; XBoxZone insidePivots[]; - XBoxZone rciContainers[]; int insidePivotsCount = 0; bool isRejectedOnMid = false; bool hasInsidePivots = false; - bool hasRCIContainers = false; bool hasPivots = HasChild(pivots); if (hasPivots) { - // - // drawer.DrawBoxes( - // pivots, - // TimeCurrent() // - // ); - // // Select Inside Boxes ... - - // ENUM_XCA_PIVOTS allowedInsidePivots[] = { XCA_FVG_BULL, XCA_FVG_BEAR, - XCA_PEAKSWHRES, - XCA_VALESWLSUP, - XCA_TREND_BULL, - XCA_TREND_BEAR, }; insidePivotsCount = SelectInsideBoxes( allowedInsidePivots, @@ -1153,25 +1100,14 @@ bool DetectXCAEAConditions( pBar, p2Bar // ); + Clean(allowedInsidePivots); hasInsidePivots = IsValidSize(insidePivotsCount); - if (hasInsidePivots) - { - // - // drawer.DrawBoxes( - // insidePivots, - // zBar.time // - // ); - } // // Detect Rejected Pivot ... ENUM_XCA_PIVOTS allowedRejectedPivots[] = { XCA_FVG_BULL, XCA_FVG_BEAR, - // XCA_PEAKSWHRES, - // XCA_VALESWLSUP, - // XCA_TREND_BULL, - // XCA_TREND_BEAR, }; has = SelectRejectedBox( allowedRejectedPivots, @@ -1186,123 +1122,7 @@ bool DetectXCAEAConditions( true, true // ); - - // - // Select CCI/RSI Cross Object ... - count = ArraySize(pivots); - for (int i = 0; i < count; i++) - { - // - XBoxZone iPivot = pivots[i]; - - // - ENUM_XCA_PIVOTS iType = GetPivotType(iPivot); - - // - // Checking Type is Passed ... - has = - // - iType == XCA_RSI_COOS || - iType == XCA_CCI_COOS || - iType == XCA_RSI_CUOB || - iType == XCA_CCI_CUOB - // - ; - - // - // Checking cBar is Pivots' Last Bar ... - has = - has && - cBar.time <= iPivot.to && - cBar.time > iPivot.from; - if (has) - { - // - rciPivot = iPivot; - - // - iPivot.Clean(); - - // - break; - } - - // - iPivot.Clean(); - } - - // - // Detect RCI Pivot Containers Pivots ... - count = ArraySize(pivots); - has = rciPivot.IsValid(); - if (has) - { - // - for (int i = 0; i < count; i++) - { - // - XBoxZone iPivot = pivots[i]; - - // - ENUM_XCA_PIVOTS iType = GetPivotType(iPivot); - - // - // Checking Type is Passed ... - has = - // - IsValid(iType) && - (iType == XCA_PEAKSWHRES || - iType == XCA_VALESWLSUP) - // - ; - - // - // Check Dir is Passed ... - has = - has && - rciPivot.dir == iPivot.dir; - - // - // Check RCI Pivot is Inside Pivot ... - has = - has && - // - ( - // - (rciPivot.lower >= iPivot.lower && - rciPivot.lower < iPivot.upper) - // - || - // - (rciPivot.upper <= iPivot.upper && - rciPivot.upper > iPivot.lower) - // - || - // - (rciPivot.upper > iPivot.upper && - rciPivot.lower < iPivot.lower) - // - ) - // - ; - - // - if (has) - { - // - AddRef( - iPivot, - rciContainers // - ); - } - - // - iPivot.Clean(); - } - - // - hasRCIContainers = HasChild(rciContainers); - } + Clean(allowedRejectedPivots); } // @@ -1363,55 +1183,15 @@ bool DetectXCAEAConditions( // bool isCond2Bullish = // - false // && + false // - // z3MAFastState > 0 && - // isValeGoldenRejected && - // isCBarBullishRejected && - // conditions.isValeIsPivot - // - // isPCCIOS && - // isRSIBullish && - // conditions.isCloseUnderMal - // rciPivot.IsValid() && - // rciPivot.IsBullish() && - // isCCIBullish && - // cBar.close > c3MAFast - // isADXBullish && - // hasRCIContainers && - // conditions.isValeIsPivot && - // (conditions.isRSICrossedOverOS || - // conditions.isCCICrossedOverOS) // && - // conditions.swingLowBuffer[cIDX] < conditions.fiboLevel3Buffer[cIDX] - // // ; // bool isCond2Bearish = // - false // && + false // - // z3MAFastState < 0 && - // isPeakGoldenRejected && - // isCBarBullishRejected && - // conditions.isPeakIsPivot - // - // isPCCIOB && - // isRSIBearish && - // c3MAFastState < 0 && - // conditions.isCloseOverMah - // rciPivot.IsValid() && - // rciPivot.IsBearish() && - // conditions.isRSIOB && - // isCCIBearish && - // cBar.close < c3MAFast - // isADXBearish && - // hasRCIContainers && - // conditions.isPeakIsPivot && - // (conditions.isRSICrossedUnderOB || - // conditions.isCCICrossedUnderOB) // && - // conditions.swingHighBuffer[cIDX] > conditions.fiboLevel1Buffer[cIDX] - // // ; // @@ -1419,12 +1199,6 @@ bool DetectXCAEAConditions( isCond2Bearish; if (isCond2) { - // - pivotBox = rciPivot; - - // - isCond2Bullish = false; - isCond2Bearish = false; } // @@ -1520,17 +1294,6 @@ bool DetectXCAEAConditions( sls // ); } - - // // - // // X3MA Medium ... - // if (c3MAMedium < entry) - // { - // // - // Add( - // c3MAMedium, - // sls // - // ); - // } } else { @@ -1550,17 +1313,6 @@ bool DetectXCAEAConditions( sls // ); } - - // // - // // X3MA Medium ... - // if (c3MAMedium > entry) - // { - // // - // Add( - // c3MAMedium, - // sls // - // ); - // } } // @@ -1656,12 +1408,10 @@ bool DetectXCAEAConditions( p2Bar.Clean(); p3Bar.Clean(); p4Bar.Clean(); - rciPivot.Clean(); Clean(cTrendValues); Clean(pTrendValues); Clean(insidePivots); pConditions.Clean(); - Clean(rciContainers); rejectedPivot.Clean(); // diff --git a/XCAEA/Signals/xcaea.signaller.class.mq5 b/XCAEA/Signals/xcaea.signaller.class.mq5 index 7f2fbb57..be410006 100644 --- a/XCAEA/Signals/xcaea.signaller.class.mq5 +++ b/XCAEA/Signals/xcaea.signaller.class.mq5 @@ -185,7 +185,7 @@ class XCXCAEASignaller : XCBase // // Detecting Pivots ... - detector.Update( + detector.Detect( zIndex // ); @@ -193,8 +193,7 @@ class XCXCAEASignaller : XCBase // Validate Pivots ... detector.Validate( unAvailableBoxes, - zIndex, - true // Validate FVGs Using PV ... + zIndex // ); // @@ -203,23 +202,21 @@ class XCXCAEASignaller : XCBase detector.pivotDetectionLoopbac = 100; } - // - // Check Market Trend ... - hasTrend = detector.MarketTrend(trend); - // // Draw Founded Pivots ... // drawer.Draw(cTime); // - // drawer.DrawFVGBullishPivots(cTime); - // drawer.DrawFVGBearishPivots(cTime); + drawer.DrawPeakPivots(cTime); + drawer.DrawValePivots(cTime); + drawer.DrawFVGBullishPivots(cTime); + drawer.DrawFVGBearishPivots(cTime); // drawer.DrawRSICrossedOverOSPivots(cTime); // drawer.DrawRSICrossedUnderOBPivots(cTime); - drawer.DrawPeakResSWHPivots(cTime); - drawer.DrawValeSupSWLPivots(cTime); - drawer.DrawRSIPeakPivots(cTime); - drawer.DrawRSIValePivots(cTime); + // drawer.DrawPeakResSWHPivots(cTime); + // drawer.DrawValeSupSWLPivots(cTime); + // drawer.DrawRSIPeakPivots(cTime); + // drawer.DrawRSIValePivots(cTime); // // Retrieve Valid Pviots ... @@ -819,7 +816,7 @@ class XCXCAEASignaller : XCBase inputs.x3maInputs.fastLength = 5; // - inputs.x3maInputs.showFast = true; + inputs.x3maInputs.showFast = false; inputs.x3maInputs.showSlow = false; inputs.x3maInputs.showMedium = false; @@ -828,11 +825,11 @@ class XCXCAEASignaller : XCBase inputs.caInputs.showTKI = false; inputs.caInputs.showSar = false; inputs.caInputs.showMAH = true; - inputs.caInputs.showMAL = true; + inputs.caInputs.showMAL = false; inputs.caInputs.showMAC = true; inputs.caInputs.showVidya = false; inputs.caInputs.showTrend = false; - inputs.caInputs.showSwings = true; + inputs.caInputs.showSwings = false; inputs.caInputs.showLongCycle = false; inputs.caInputs.showHindCycle = false; inputs.caInputs.showFiboLevel1 = false; @@ -841,14 +838,14 @@ class XCXCAEASignaller : XCBase inputs.caInputs.showShortCycle = false; inputs.caInputs.showMediumCycle = false; inputs.caInputs.showPeaksAndVales = true; - inputs.caInputs.showPeakAndValeGolden = true; - inputs.caInputs.showSupportAndResistance = true; + inputs.caInputs.showPeakAndValeGolden = false; + inputs.caInputs.showSupportAndResistance = false; // // XOSCS ... - inputs.oscsInputs.rsiLength = 5; - inputs.oscsInputs.rsiOBLevel = 90; - inputs.oscsInputs.rsiOSLevel = 10; + // inputs.oscsInputs.rsiLength = 5; + // inputs.oscsInputs.rsiOBLevel = 90; + // inputs.oscsInputs.rsiOSLevel = 10; // inputs.oscsInputs.cciLength = 7; // inputs.oscsInputs.cciOBLevel = 130; // inputs.oscsInputs.cciOSLevel = -130; @@ -857,7 +854,7 @@ class XCXCAEASignaller : XCBase // // Oscillators Views ... - inputs.showRSI = true; + inputs.showRSI = false; inputs.showCCI = false; inputs.showMFI = false; inputs.showRVI = false; @@ -882,26 +879,31 @@ class XCXCAEASignaller : XCBase detector.pivotVerifications = 5; detector.ticksDividerInPoints = 15; detector.pivotDetectionLoopbac = 200; - detector.ticksDetectionPerid = PERIOD_D1; // // Configure Detector ... - detector.detectTickPivots = false; - detector.detectVolumePivots = false; - detector.detectRSIPeakPivots = false; - detector.detectRSIValePivots = false; - detector.detectCCIPeakPivots = false; - detector.detectCCIValePivots = false; - detector.detectFVGBullishPivots = false; - detector.detectFVGBearishPivots = false; - detector.detectValeSupSWLPivots = true; - detector.detectPeakResSWHPivots = true; - detector.detectTrendBullishPivots = true; - detector.detectTrendBearishPivots = true; - detector.detectCCICrossedOverOSPivots = false; - detector.detectCCICrossedUnderOBPivots = false; - detector.detectRSICrossedOverOSPivots = false; - detector.detectRSICrossedUnderOBPivots = false; + + // + // PV ... + + // + // PEAK ... + detector.detectPeakPivots = true; + + // + // VALE ... + detector.detectValePivots = true; + + // + // FVG ... + detector.maxAllowedFVGLife = 0; + detector.detectFVGTypeOne = true; + detector.detectFVGTypeTwo = false; + detector.applyPVToFVGBoundary = false; + detector.detectFVGBullishPivots = true; + detector.detectFVGBearishPivots = true; + detector.applyLastBarToFVGBoundary = false; + detector.selectOnlyFVGWhichHasIndirectionalLastBar = true; // // Initialize and Configure Drawer ... @@ -909,90 +911,58 @@ class XCXCAEASignaller : XCBase // drawer.ignoreUpdateOSCTos = true; - drawer.drawTrendPivotsOnlySelectedFVG = true; // // Configure Drawer ... - drawer.drawTrendLine = false; - drawer.drawTickPivots = false; - drawer.drawVolumePivots = false; - drawer.drawRSIPeakPivots = false; - drawer.drawRSIValePivots = false; - drawer.drawCCIPeakPivots = false; - drawer.drawCCIValePivots = false; - drawer.drawFVGBullishPivots = false; - drawer.drawFVGBearishPivots = false; - drawer.drawValeSupSWLPivots = true; - drawer.drawPeakResSWHPivots = true; - drawer.drawTrendBullishPivots = false; - drawer.drawTrendBearishPivots = false; - drawer.drawCCICrossedOverOSPivots = false; - drawer.drawCCICrossedUnderOBPivots = false; - drawer.drawRSICrossedOverOSPivots = false; - drawer.drawRSICrossedUnderOBPivots = false; + drawer.drawPeakPivots = true; + drawer.drawValePivots = true; + drawer.drawFVGBullishPivots = true; + drawer.drawFVGBearishPivots = true; // - // Configure Widths ... - drawer.tickPivotsWidth = 2; - drawer.volumePivotsWidth = 2; - drawer.rsiPeakPivotsWidth = 4; - drawer.rsiValePivotsWidth = 4; - drawer.cciPeakPivotsWidth = 4; - drawer.cciValePivotsWidth = 4; - drawer.fvgBullishPivotsWidth = 2; - drawer.fvgBearishPivotsWidth = 2; - drawer.valeSupSWLPivotsWidth = 1; - drawer.peakResSWHPivotsWidth = 1; - drawer.trendLineBullishWidth = 4; - drawer.trendLineBullishWidth = 4; - drawer.trendBullishPivotsWidth = 1; - drawer.trendBearishPivotsWidth = 1; - drawer.rsiCrossedOverOSPivotsWidth = 4; - drawer.rsiCrossedUnderOBPivotsWidth = 4; - drawer.cciCrossedOverOSPivotsWidth = 4; - drawer.cciCrossedUnderOBPivotsWidth = 4; + // Configure Styles ... // - // Configure Colors ... - drawer.tickPivotsColor = clrYellow; - drawer.volumePivotsColor = clrDodgerBlue; - drawer.rsiPeakPivotsColor = clrMagenta; - drawer.rsiValePivotsColor = clrAqua; - drawer.cciPeakPivotsColor = clrMagenta; - drawer.cciValePivotsColor = clrAqua; - drawer.fvgBullishPivotsColor = clrAqua; - drawer.fvgBearishPivotsColor = clrMagenta; - drawer.valeSupSWLPivotsColor = clrAqua; - drawer.peakResSWHPivotsColor = clrMagenta; - drawer.trendLineBullishColor = clrAqua; - drawer.trendLineBullishColor = clrMagenta; - drawer.trendBullishPivotsColor = clrLime; - drawer.trendBearishPivotsColor = clrRed; - drawer.rsiCrossedOverOSPivotsColor = clrAqua; - drawer.rsiCrossedUnderOBPivotsColor = clrMagenta; - drawer.cciCrossedOverOSPivotsColor = clrAqua; - drawer.cciCrossedUnderOBPivotsColor = clrMagenta; + // PV ... // - // Configures Styles ... - drawer.tickPivotsStyle = STYLE_DOT; - drawer.volumePivotsStyle = STYLE_DOT; - drawer.rsiPeakPivotsStyle = STYLE_DASH; - drawer.rsiValePivotsStyle = STYLE_DASH; - drawer.cciPeakPivotsStyle = STYLE_DASH; - drawer.cciValePivotsStyle = STYLE_DASH; - drawer.fvgBullishPivotsStyle = STYLE_DASHDOTDOT; - drawer.fvgBearishPivotsStyle = STYLE_DASHDOTDOT; - drawer.valeSupSWLPivotsStyle = STYLE_SOLID; - drawer.peakResSWHPivotsStyle = STYLE_SOLID; - drawer.trendLineBullishWidth = STYLE_SOLID; - drawer.trendLineBullishWidth = STYLE_SOLID; - drawer.trendBullishPivotsStyle = STYLE_DASHDOTDOT; - drawer.trendBearishPivotsStyle = STYLE_DASHDOTDOT; - drawer.rsiCrossedOverOSPivotsStyle = STYLE_DASHDOTDOT; - drawer.rsiCrossedUnderOBPivotsStyle = STYLE_DASHDOTDOT; - drawer.cciCrossedOverOSPivotsStyle = STYLE_DASHDOTDOT; - drawer.cciCrossedUnderOBPivotsStyle = STYLE_DASHDOTDOT; + // PEAK ... + XCAPivotStyle peakStyle; + peakStyle.width = 2; + peakStyle.clr = clrMagenta; + peakStyle.style = STYLE_SOLID; + drawer.peakPivotStyle = peakStyle; + peakStyle.Clean(); + + // + // VALE ... + XCAPivotStyle valeStyle; + valeStyle.width = 2; + valeStyle.clr = clrAqua; + valeStyle.style = STYLE_SOLID; + drawer.valePivotStyle = valeStyle; + valeStyle.Clean(); + + // + // FVG ... + + // + // Bullish ... + XCAPivotStyle fvgBullishStyle; + fvgBullishStyle.width = 2; + fvgBullishStyle.clr = clrLime; + fvgBullishStyle.style = STYLE_DASH; + drawer.fvgBullishPivotStyle = fvgBullishStyle; + fvgBullishStyle.Clean(); + + // + // Bearish ... + XCAPivotStyle fvgBearishStyle; + fvgBearishStyle.width = 2; + fvgBearishStyle.clr = clrRed; + fvgBearishStyle.style = STYLE_DASH; + drawer.fvgBearishPivotStyle = fvgBearishStyle; + fvgBearishStyle.Clean(); // }