diff --git a/Documents/BKP/1/xcaea.signaller.class.mq5 b/Documents/BKP/1/xcaea.signaller.class.mq5 new file mode 100644 index 00000000..71f8c5f1 --- /dev/null +++ b/Documents/BKP/1/xcaea.signaller.class.mq5 @@ -0,0 +1,853 @@ +/////////////////////////////////////////////////////// +// +// SaherElm IT Center MQL5 Indicator +// ------------------------------------------------- +// Name: XCXCAEASignaller ... +// Description: Class for XCAEA Signaller ... +// +// +// Maintainer: +// ------------ +// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com) +// +////////////////////////////////////////////////////// +// +// Global Properties ... +#property library +#property copyright "Copyright 2023, SaherElm IT Center" +#property link "https://saherelm.ir" +#property version "1.00" +#property description "SaherElm Class for XCAEA Signaller" +#property strict + +// +// Imports ... +#include "../../Classes/x-saherelm.base.class.mq5" +#include "../../Classes/x-saherelm.x-cobject.class.mq5" +#include "../Classes/xcaea.x-poi.detector.class.mq5" +#include "../Classes/xcaea.x-poi.drawer.class.mq5" +#include "../Helpers/xcaea.helper.mq5" +#include "../Libraries/xcaea.signaller.lib.mq5" + +// +// Definitions ... + +class XCXCAEASignaller : XCBase +{ + // + // Public ... + public: + // + // Props ... + bool useGuards; + XCAEAInputs inputs; + XBarTracker barTraker; + XCXCAEAHelper *helper; + XCXCAEAPOIDrawer *drawer; + bool continuesRFTillTarget; + XBoxZone unAvailableBoxes[]; + XCXCAEAPOIDetector *detector; + XCAEAStrategyConditions mConditions; + XCAEAStrategyConditions mConditionsCollection[]; + + // + // Constructor ... + XCXCAEASignaller( + string _symbol, + ENUM_TIMEFRAMES _period // + ) + { + // + symbol = _symbol; + period = _period; + + // + Init(); + } + + // + // Deconstructor ... + ~XCXCAEASignaller() + { + DeInit(); + } + + // + // Properties ... + + string GetSymbol() + { + return symbol; + } + + ENUM_TIMEFRAMES GetPeriod() + { + return period; + } + + // + // Signaller Tools ... + + /** + * Detect Setup Conditions based on Signalling ... + * + * @param maxAllowedSLDistanceInPoint: int, Max Allowed SL Distance in Points (if Bigger thn Zero Provided) ... + * + * @return ( bool ) + */ + bool DetectSignalSetup( + double tpReward = 3, + double maxAllowedSLDistanceInPoint = 100 // + ) + { + // + bool result = false; + + // + // Check Bar Processing ... + if (!barTraker.CanProcessBar()) + { + return result; + } + + // + bool isBullish = false; + bool isBearish = false; + + // + int zIndex = 0; + int cIndex = zIndex + 1; + int pIndex = cIndex + 1; + int ppIndex = pIndex + 1; + + // + int loopback = 10; + + // + int idx = -1; + int count = 0; + bool has = false; + + // + double ask = GetAsk(symbol); + double bid = GetBid(symbol); + datetime cTime = TimeCurrent(); + double points = GetPoints(symbol); + + // + XOHCL zBar; + XOHCL cBar; + XOHCL pBar; + XOHCL pPBar; + result = zBar.Init( + symbol, + period, + zIndex // + ); + result = + result && + zBar.GetPreviousBar(cBar); + result = + result && + cBar.GetPreviousBar(pBar); + result = + result && + pBar.GetPreviousBar(pPBar); + if (!result) + { + // + zBar.Clean(); + cBar.Clean(); + pBar.Clean(); + pPBar.Clean(); + + // + return result; + } + + // + // Setup Conditions ... + XBoxZone boxes[]; + XBoxZone pivotBox; + XBoxZone signalBox; + double additionalSL = 0; + XBoxZone bullishBoxes[]; + XBoxZone bearishBoxes[]; + bool hasSignalBox = false; + XCAEAConditions conditions; + ENUM_X_DIRECTION signalBoxDir = X_DIRECTION_NONE; + + // + // Detecting Pivots ... + detector.Update( + zIndex // + ); + + // + // Validate Pivots ... + detector.Validate( + unAvailableBoxes, + zIndex // + ); + + // + // Draw Founded Pivots ... + drawer.Draw(cTime); + + // + // Retrieve Valid Boxes ... + + // // + // // Bullish ... + // int bullishBoxesCount = + // detector + // .FillBullishBoxes(bullishBoxes); + + // // + // // Bearish ... + // int bearishBoxesCount = + // detector + // .FillBearishBoxes(bearishBoxes); + + // // + // Copy( + // bullishBoxes, + // boxes, + // false // + // ); + // Copy( + // bearishBoxes, + // boxes, + // false // + // ); + int boxesCount = ArraySize(boxes); + bool hasBoxes = IsValidSize(boxesCount); + + // + // Filter UnAvailable Boxes ... + if (hasBoxes) + { + // + // Remove UnAvailable Boxes ... + has = HasChild(unAvailableBoxes); + if (has) + { + // + count = ArraySize(unAvailableBoxes); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox = unAvailableBoxes[i]; + + // + has = FindBoxIndex( + idx, + iBox, + boxes // + ); + if (has) + { + // + ArrayRemove( + boxes, + idx, + 1 // + ); + } + } + } + + // + hasBoxes = HasChild(boxes); + boxesCount = ArraySize(boxes); + } + + // + // + // + + // + // if (hasBoxes) + // { + // } + + // + // Detect Sinal Box ... + hasSignalBox = DetectXCAEAConditions( + boxes, + conditions, + pivotBox, + signalBox, + additionalSL, + signalBoxDir, + helper, + zIndex, + loopback // + ); + + // + // Make Pivot Box UnAvailable ... + if (pivotBox.IsValid()) + { + // + AddRef( + pivotBox, + unAvailableBoxes // + ); + } + + // + isBullish = hasSignalBox && + IsBullish(signalBoxDir); + + // + isBearish = hasSignalBox && + IsBearish(signalBoxDir); + + // + result = isBullish || + isBearish; + if (result) + { + // + // Do What we Want ... + barTraker.Waits(); + + // + // Draw Signal Box ... + XCBoxObject *iObj; + bool isCreated = helper.poiDrawer.DrawBox( + signalBox, + iObj // + ); + if (isCreated) + { + // + mObjects.Add(iObj); + ZeroMemory(iObj); + + // + Print("Signal Box ..."); + } + + // + // Prepare Conditions ... + mConditions.symbol = symbol; + mConditions.period = period; + + // + double spread = GetSpread(symbol); + + // + double entry = + isBullish + ? signalBox.upper + : signalBox.lower; + + // + double sl = + isBullish + ? signalBox.lower + : signalBox.upper; + if (additionalSL > 0) + { + // + sl = + isBullish + ? sl - additionalSL + : sl + additionalSL; + } + + // + double risk = + isBullish + ? entry - sl + : sl - entry; + risk += spread; + if (risk >= maxAllowedSLDistanceInPoint * points) + { + // + // Fix Risk in Big Distances ... + double hh5 = zBar.FindHighest(5, MODE_HIGH); + double ll5 = zBar.FindLowest(5, MODE_LOW); + + // + double hhll5Delta = hh5 - ll5; + double riskDelta = hhll5Delta / 2; + risk = riskDelta; + } + + // + double rewardTP = risk * tpReward; + + // + double tp = + isBullish + ? entry + rewardTP + : entry - rewardTP; + + // + // Filling ... + mConditions.sl = sl; + mConditions.tp = tp; + mConditions.pivot = + isBullish + ? sl + : entry; + mConditions.point = + isBullish + ? entry + : sl; + mConditions.dir = signalBoxDir; + mConditions.provider = "XCAEA"; + mConditions.signalBox = signalBox; + mConditions.setupTime = zBar.time; + mConditions.conditions = conditions; + + // + // Select RF Rewards ... + if (continuesRFTillTarget) + { + // + double rfReward = 1; + while (rfReward < tpReward) + { + // + double rewardRF = risk * rfReward; + double rfTP = + isBullish + ? entry + rewardRF + : entry - rewardRF; + + // + Add( + rfTP, + mConditions.targets // + ); + + // + rfReward++; + } + } + else + { + // + double rfReward = 1; + + // + double rewardRF = risk * rfReward; + double rfTP = + isBullish + ? entry + rewardRF + : entry - rewardRF; + + // + Add( + rfTP, + mConditions.targets // + ); + } + } + + // + // Cleanup Resource ... + + // + Clean(boxes); + Clean(bullishBoxes); + Clean(bearishBoxes); + + // + zBar.Clean(); + cBar.Clean(); + pBar.Clean(); + pPBar.Clean(); + + // + pivotBox.Clean(); + signalBox.Clean(); + conditions.Clean(); + + // + return result; + } + + /** + * Detect Trigger Conditions for Specified Signal ... + * + * @param conditions: XCAEAStrategyConditions instance Reference, Specified Signal Conditions ... + * @param maxAllowedSetupAge: specified Setup Age for Expiration (if bigger than Zero) ... + * + * @return ( bool ) + */ + bool DetectSignalTrigger( + XCAEAStrategyConditions &conditions, + int maxAllowedSetupAge = 60 // + ) + { + // + bool result = false; + + // + result = conditions.IsSetuped(); + if (!result) + { + return result; + } + + // + datetime setupTime = conditions.setupTime; + ENUM_X_DIRECTION setupDir = conditions.dir; + + // + bool isBullish = IsBullish(setupDir); + bool isBearish = IsBearish(setupDir); + + // + int zIndex = 0; + int cIndex = zIndex + 1; + int pIndex = cIndex + 1; + int ppIndex = pIndex + 1; + + // + int loopback = 10; + + // + double ask = GetAsk(symbol); + double bid = GetBid(symbol); + datetime cTime = TimeCurrent(); + double points = GetPoints(symbol); + + // + // Check Signal Validation ... + // IMPORTANT: since all Validations done in SetUp Process ... + // here we only Execute Signal ... + + // + result = isBullish || + isBearish; + + // + if (result) + { + // + conditions.triggerTime = cTime; + conditions.type = isBullish + ? X_POSITION_TYPE_LONG + : X_POSITION_TYPE_SHORT; + + // + } + + // + // Cleanup ... + + // + return result; + } + + /** + * Detect Guards bsed on Signalling Class ... + * + * @param guards: XCAEAGuard instance Collection, Holds Provided Guards ... + * @param positions: XPosition instance Collection, Provides Signalling Based Positions for Apply Guards on them ... + * @param provider: X121SMCStrategySignalProviderData instance Reference, Specified Data for Cycles ... + * + * @return ( bool ) + */ + bool DetectGuards( + XCAEAGuard &guards[], + const XPosition &positions[] // + ) + { + // + bool result = false; + + // + return result; + } + + /** + * Add Conditions to Conditions Collection if not Exists ... + * + * @param maxAllowed: int, Specified Max Allowed Holding Conditions ... + * + * @return ( int ) + */ + int AddConditionsIfNotExists( + int maxAllowed = 10 // + ) + { + // + int result = 0; + + // + bool isSetuped = IsValid(mConditions.setupTime) && + HasDirection(mConditions.dir); + if (!isSetuped) + { + return result; + } + + // + int count = ArraySize(mConditionsCollection); + if (IsValidSize(count)) + { + // + // Copy Original Items ... + XCAEAStrategyConditions tmpItems[]; + Copy( + mConditionsCollection, + tmpItems // + ); + + // + // Prese Item Data ... + bool isBullish = IsBullish(mConditions.dir); + + // + for (int i = 0; i < count; i++) + { + // + XCAEAStrategyConditions iItem = tmpItems[i]; + + // + bool canRemove = mConditions.dir == iItem.dir && + mConditions.pivot == iItem.pivot; + if (canRemove) + { + // + ArrayRemove( + mConditionsCollection, + i, + 1 // + ); + } + } + + // + Clean(tmpItems); + } + + // + AddRef( + mConditions, + mConditionsCollection // + ); + + // + // Remove Olds ... + CleanupArray( + mConditionsCollection, + maxAllowed // + ); + + // + result = ArraySize(mConditionsCollection); + + // + return result; + } + + // + // Protected ... + protected: + // + + // + // Private ... + private: + // + // Props ... + string symbol; + ENUM_TIMEFRAMES period; + CArrayObj mObjects; + CArrayObj mBarObjects; + + /** + * Initialize ... + */ + void Init() + { + // + useGuards = false; + continuesRFTillTarget = true; + + // + barTraker.Init( + symbol, + period // + ); + + // + inputs.Default(); + + // + // Configure Indicators ... + + // + // XCC ... + inputs.ccInputs.showCandles = true; + + // + // XCT ... + inputs.ctInputs.showCandleTime = true; + + // + // XCA ... + + // + inputs.caInputs.supResSmoothingLength = 7; + inputs.caInputs.supResSmoothingMode = X_MA_MODE_NONE; + + // + inputs.caInputs.showKI = true; + inputs.caInputs.showTKI = false; + inputs.caInputs.showSar = false; + inputs.caInputs.showVidya = true; + inputs.caInputs.showTrend = false; + inputs.caInputs.showSwings = false; + inputs.caInputs.showLongCycle = false; + inputs.caInputs.showHindCycle = false; + inputs.caInputs.showFiboLevel1 = false; + inputs.caInputs.showFiboLevel2 = false; + inputs.caInputs.showFiboLevel3 = false; + inputs.caInputs.showShortCycle = false; + inputs.caInputs.showMediumCycle = false; + inputs.caInputs.showPeaksAndVales = true; + inputs.caInputs.showPeakAndValeGolden = false; + inputs.caInputs.showSupportAndResistance = false; + + // + // XOSCS ... + // inputs.oscsInputs.rsiLength = 5; + // inputs.oscsInputs.cciLength = 5; + // inputs.oscsInputs.mfiLength = 5; + // inputs.oscsInputs.rviLength = 5; + + // + // Oscillators Views ... + inputs.showCCI = false; + inputs.showRSI = false; + inputs.showMFI = false; + inputs.showRVI = false; + inputs.showADX = false; + inputs.showMACD = false; + + // + // XCAEA Helper ... + helper = new XCXCAEAHelper(); + helper.Init( + symbol, + period, + inputs // + ); + + // + // Initialize and Configure Detector ... + detector = new XCXCAEAPOIDetector(helper); + + // + // Configure Detector ... + detector.detectRSIPeakPivots = true; + detector.detectRSIValePivots = true; + detector.detectCCIPeakPivots = true; + detector.detectCCIValePivots = true; + detector.detectFVGBullishPivots = true; + detector.detectFVGBearishPivots = true; + detector.detectValeSupSWLPivots = true; + detector.detectPeakResSWHPivots = true; + detector.detectPVFVGBullishPivots = true; + detector.detectPVFVGBearishPivots = true; + + // + // Initialize and Configure Drawer ... + drawer = new XCXCAEAPOIDrawer(detector); + + // + drawer.ignoreUpdateOSCTos = true; + + // + // Configure Drawer ... + drawer.drawRSIPeakPivots = true; + drawer.drawRSIValePivots = true; + drawer.drawCCIPeakPivots = true; + drawer.drawCCIValePivots = true; + drawer.drawFVGBullishPivots = false; + drawer.drawFVGBearishPivots = false; + drawer.drawValeSupSWLPivots = true; + drawer.drawPeakResSWHPivots = true; + drawer.drawPVFVGBullishPivots = true; + drawer.drawPVFVGBearishPivots = true; + + // + // Configure Widths ... + 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.pvFVGBullishPivotsWidth = 1; + drawer.pvFVGBearishPivotsWidth = 1; + + // + // Configure Colors ... + drawer.rsiPeakPivotsColor = clrMagenta; + drawer.rsiValePivotsColor = clrAqua; + drawer.cciPeakPivotsColor = clrMagenta; + drawer.cciValePivotsColor = clrAqua; + drawer.fvgBullishPivotsColor = clrLime; + drawer.fvgBearishPivotsColor = clrRed; + drawer.valeSupSWLPivotsColor = clrAqua; + drawer.peakResSWHPivotsColor = clrMagenta; + drawer.pvFVGBullishPivotsColor = clrLime; + drawer.pvFVGBearishPivotsColor = clrRed; + + // + // Configures Styles ... + 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.pvFVGBullishPivotsStyle = STYLE_DASHDOTDOT; + drawer.pvFVGBearishPivotsStyle = STYLE_DASHDOTDOT; + + // + } + + /** + * DeInitialize ... + */ + void DeInit() + { + // + inputs.Clean(); + + // + ZeroMemory(drawer); + ZeroMemory(helper); + ZeroMemory(detector); + + // + mConditions.Clean(); + Clean(mConditionsCollection); + + // + mObjects.Clear(); + mBarObjects.Clear(); + + // + barTraker.Clean(); + } + + // +}; + +// \ No newline at end of file diff --git a/Documents/BKP/1/xcaea.signaller.lib.mq5 b/Documents/BKP/1/xcaea.signaller.lib.mq5 new file mode 100644 index 00000000..1a2f09f9 --- /dev/null +++ b/Documents/BKP/1/xcaea.signaller.lib.mq5 @@ -0,0 +1,1277 @@ +/////////////////////////////////////////////////////// +// +// SaherElm IT Center MQL5 Indicator +// ------------------------------------------------- +// Name: XCAEASignaller Lib +// Description: Library for XCAEA Signaller ... +// +// +// Maintainer: +// ------------ +// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com) +// +////////////////////////////////////////////////////// +// +// Global Properties ... +#property library +#property copyright "Copyright 2023, SaherElm IT Center" +#property link "https://saherelm.ir" +#property version "1.00" +#property description "SaherElm Library for XCAEA Signaller" +#property strict + +// +// Imports ... +#include "../../Libraries/x-saherelm.common.lib.mq5" +#include "../../Libraries/x-saherelm.x-poi.lib.mq5" +#include "../../Libraries/x-saherelm.x-trade.lib.mq5" +#include "../Classes/xcaea.x-poi.detector.class.mq5" +#include "../Helpers/xcaea.helper.mq5" + +// +// Enumeration ... + +// +// Guard Actions ... +enum ENUM_GUARD_ACTIONS +{ + X_GUARD_ACTION_NONE, // Nothing to Do + X_GUARD_ACTION_CLOSE, // Close Specified Position + X_GUARD_ACTION_CLOSE_ALL, // Close All Positions + X_GUARD_ACTION_CLOSE_LONGS, // Close All Long Positions + X_GUARD_ACTION_CLOSE_SHORTS, // Close All Short Position + X_GUARD_ACTION_PARTIAL_CLOSE, // Partial Close Specified Position + X_GUARD_ACTION_TRAIL_STOP, // Trail Stop of Specified Position + X_GUARD_ACTION_TRAIL_TARGET, // Trail Target of Specified Position + X_GUARD_ACTION_HEDGE, // Hedge Specified Positions +}; + +// +// Definitions ... + +// +// Conditions Struct ... +struct XCAEAStrategyConditions +{ + // + // Props ... + + // + string symbol; + ENUM_TIMEFRAMES period; + + // + // Setup Props ... + + // + double sl; + double tp; + double pivot; + double point; + string provider; + double targets[]; + + // + datetime time; + datetime setupTime; + datetime triggerTime; + + // + XBoxZone signalBox; + ENUM_X_DIRECTION dir; + ENUM_X_POSITION_TYPES type; + XCAEAConditions conditions; + + // + // Constructor ... + XCAEAStrategyConditions() + { + Clean(); + } + + // + // Tools ... + + /** + * Cleaning Up ... + */ + void Clean() + { + // + sl = 0; + tp = 0; + pivot = 0; + point = 0; + + // + symbol = NULL; + period = NULL; + provider = NULL; + + // + time = NULL; + setupTime = NULL; + triggerTime = NULL; + + // + Clean(targets); + + // + signalBox.Clean(); + conditions.Clean(); + + // + dir = X_DIRECTION_NONE; + type = X_POSITION_TYPE_NONE; + + // + } + + // + // Signalling ... + + /** + * Validate ... + * + * @return ( bool ) + */ + bool IsValid() + { + // + bool result = false; + + // + result = IsSpecifiedValid(symbol) && + IsSpecifiedValid(period) && + IsSpecifiedValid(time); + + // + return result; + } + + /** + * Check Conditions Has Valid Bullish Signal ... + * + * @return ( bool ) + */ + bool HasBullishSignal() + { + // + bool result = false; + + // + result = + (sl > 0 || + tp > 0) && + IsValid() && + HasDirection(dir); + if (!result) + { + return result; + } + + // + result = + IsBullish(dir); + + // + return result; + } + + /** + * Check Conditions Has Valid Bearish Signal ... + * + * @return ( bool ) + */ + bool HasBearishSignal() + { + // + bool result = false; + + // + result = + (sl > 0 || + tp > 0) && + IsValid() && + HasDirection(dir); + if (!result) + { + return result; + } + + // + result = + IsBearish(dir); + + // + return result; + } + + // + // Setting Up and Triggering Up ... + + /** + * Check Condition is Setting Up ... + * + * @param dir: ENUM_X_DIRECTION member, Setting Up Direction ... + * + * @return ( bool ) + */ + bool IsSetuped() + { + // + bool result = false; + + // + result = IsValid(setupTime) && + HasDirection(dir); + if (!result) + { + return result; + } + + // + return result; + } + + /** + * Calculate Setup Age ... + * + * @return ( int ) + */ + int GetSetupAge() + { + // + int result = 0; + + // + if (!IsSetuped()) + { + return result; + } + + // + result = (int)(TimeCurrent() - setupTime) / PeriodSeconds(period); + + // + return result; + } + + /** + * Detect How we Can Trigger Signal ... + * + * @return ( bool ) + */ + bool CanTrigger() + { + // + bool result = false; + + // + result = + // + sl > 0 && + IsValid(symbol) && + IsValid(period) && + IsValid(triggerTime) && + type != X_POSITION_TYPE_ALL && + type != X_POSITION_TYPE_NONE + // + ; + + // + return result; + } + + // +}; + +// +// Model a Guard Action ... +struct XCAEAGuard +{ + // + // Props ... + ENUM_GUARD_ACTIONS action; + datetime time; + + // + string symbol; + string provider; + + // + // Specified Position ... + ulong ticket; + + // + // Partial Close ... + double volumeMultiplier; + + // + // SL Trial ... + double sl; + + // + // TP Trial ... + double tp; + + // + // Constructor ... + XCAEAGuard() + { + Clean(); + } + + // + // Tools ... + + /** + * Cleanup ... + */ + void Clean() + { + // + time = NULL; + action = X_GUARD_ACTION_NONE; + + // + symbol = NULL; + provider = NULL; + + // + ticket = 0; + + // + volumeMultiplier = 0; + + // + sl = 0; + tp = 0; + + // + ZeroMemory(this); + } + + /** + * Validate ... + * + * @return ( bool ) + */ + bool IsValid() + { + // + bool result = false; + + // + result = + // + IsValid(time) && + IsValid(symbol) && + IsValid(provider) && + action != X_GUARD_ACTION_NONE + // + ; + if (!result) + { + return result; + } + + // + // Validate Model Based On Specified Guard Actions ... + + // + return result; + } +}; + +/** + * Add Guard to Collection ... + * + * @param guard: XCAEAGuard instance ... + * @param guards: XCAEAGuard instance Collection ... + * + * @return ( int ) + */ +int AddGuard( + XCAEAGuard &guard, + XCAEAGuard &guards[] // +) +{ + // + int result = 0; + + // + if (!guard.IsValid()) + { + return result; + } + + // + AddRef( + guard, + guards // + ); + + // + result = ArraySize(guards); + + // + return result; +} + +// +bool DetectXCAEAConditions( + XBoxZone &boxes[], + XCAEAConditions &conditions, + XBoxZone &pivotBox, + XBoxZone &box, + double &additionalSL, + ENUM_X_DIRECTION &dir, + XCXCAEAHelper *helper, + int barIndex = 0, + int loopback = 10 // +) +{ + // + bool result = false; + + // + int idx = -1; + int count = 0; + bool has = false; + + // + box.Clean(); + additionalSL = 0; + conditions.Clean(); + dir = X_DIRECTION_NONE; + + // + if (barIndex < 0) + { + barIndex = 0; + } + loopback = NormalizeInt(loopback, 5); + + // + string symbol = helper.GetSymbol(); + ENUM_TIMEFRAMES period = helper.GetPeriod(); + double points = GetPoints(symbol); + + // + XCAEAConditions pConditions; + result = helper.GetConditions( + conditions, + barIndex, + loopback // + ); + result = result && + helper.GetConditions( + pConditions, + barIndex + 1, + loopback // + ); + if (!result) + { + // + conditions.Clean(); + pConditions.Clean(); + + // + return result; + } + + // + int zIDX = barIndex; + int cIDX = zIDX + 1; + int pIDX = cIDX + 1; + int p2IDX = pIDX + 1; + int p3IDX = p2IDX + 1; + int p4IDX = p3IDX + 1; + + // + // Reading Parameters ... + + // + // KI ... + + // + double cKI = conditions.kiBuffer[cIDX]; + double pKI = conditions.kiBuffer[pIDX]; + double p2KI = conditions.kiBuffer[p2IDX]; + + // + double cKIState = conditions.kiStateBuffer[cIDX]; + double pKIState = conditions.kiStateBuffer[pIDX]; + double p2KIState = conditions.kiStateBuffer[p2IDX]; + + // + // TKI ... + + // + double cTKI = conditions.tkiBuffer[cIDX]; + double pTKI = conditions.tkiBuffer[pIDX]; + double p2TKI = conditions.tkiBuffer[p2IDX]; + + // + double cTKIState = conditions.tkiStateBuffer[cIDX]; + double pTKIState = conditions.tkiStateBuffer[pIDX]; + double p2TKIState = conditions.tkiStateBuffer[p2IDX]; + + // + // TREND ... + + // + double cTrend = conditions.trendBuffer[cIDX]; + double pTrend = conditions.trendBuffer[pIDX]; + double p2Trend = conditions.trendBuffer[p2IDX]; + + // + double ctrendState = conditions.trendStateBuffer[cIDX]; + double ptrendState = conditions.trendStateBuffer[pIDX]; + double p2trendState = conditions.trendStateBuffer[p2IDX]; + + // + // SWING Low ... + double cSWL = conditions.swingLowBuffer[cIDX]; + double pSWL = conditions.swingLowBuffer[pIDX]; + double p2SWL = conditions.swingLowBuffer[p2IDX]; + + // + // SWING High ... + double cSWH = conditions.swingHighBuffer[cIDX]; + double pSWH = conditions.swingHighBuffer[pIDX]; + double p2SWH = conditions.swingHighBuffer[p2IDX]; + + // + // PEAK ... + double zPeak = conditions.peakBuffer[zIDX]; + double cPeak = conditions.peakBuffer[cIDX]; + double pPeak = conditions.peakBuffer[pIDX]; + double p2Peak = conditions.peakBuffer[p2IDX]; + double p3Peak = conditions.peakBuffer[p3IDX]; + + // + // VALE ... + double zVale = conditions.valeBuffer[zIDX]; + double cVale = conditions.valeBuffer[cIDX]; + double pVale = conditions.valeBuffer[pIDX]; + double p2Vale = conditions.valeBuffer[p2IDX]; + double p3Vale = conditions.valeBuffer[p3IDX]; + + // + // VIDYA ... + double zVidya = conditions.vidyaBuffer[zIDX]; + double cVidya = conditions.vidyaBuffer[cIDX]; + double pVidya = conditions.vidyaBuffer[pIDX]; + double p2Vidya = conditions.vidyaBuffer[p2IDX]; + double p3Vidya = conditions.vidyaBuffer[p3IDX]; + + // + double zVidyaState = conditions.vidyaStateBuffer[zIDX]; + double cVidyaState = conditions.vidyaStateBuffer[cIDX]; + double pVidyaState = conditions.vidyaStateBuffer[pIDX]; + double p2VidyaState = conditions.vidyaStateBuffer[p2IDX]; + double p3VidyaState = conditions.vidyaStateBuffer[p3IDX]; + + // + // RSI ... + double zRSI = conditions.rsiBuffer[zIDX]; + double cRSI = conditions.rsiBuffer[cIDX]; + double pRSI = conditions.rsiBuffer[pIDX]; + double p2RSI = conditions.rsiBuffer[p2IDX]; + double p3RSI = conditions.rsiBuffer[p3IDX]; + + // + // CCI ... + double zCCI = conditions.cciBuffer[zIDX]; + double cCCI = conditions.cciBuffer[cIDX]; + double pCCI = conditions.cciBuffer[pIDX]; + double p2CCI = conditions.cciBuffer[p2IDX]; + double p3CCI = conditions.cciBuffer[p3IDX]; + + // + // RVI ... + + // + double zRVI = conditions.rviBuffer[zIDX]; + double cRVI = conditions.rviBuffer[cIDX]; + double pRVI = conditions.rviBuffer[pIDX]; + double p2RVI = conditions.rviBuffer[p2IDX]; + double p3RVI = conditions.rviBuffer[p3IDX]; + + // + double zRVISignal = conditions.rviSignalBuffer[zIDX]; + double cRVISignal = conditions.rviSignalBuffer[cIDX]; + double pRVISignal = conditions.rviSignalBuffer[pIDX]; + double p2RVISignal = conditions.rviSignalBuffer[p2IDX]; + double p3RVISignal = conditions.rviSignalBuffer[p3IDX]; + + // + // Reading Bars ... + + // + XOHCL zBar; + XOHCL cBar; + XOHCL pBar; + XOHCL p2Bar; + XOHCL p3Bar; + XOHCL p4Bar; + result = zBar.Init( + symbol, + period, + zIDX // + ); + result = + result && + zBar.GetPreviousBar(cBar); + result = + result && + cBar.GetPreviousBar(pBar); + result = + result && + pBar.GetPreviousBar(p2Bar); + result = + result && + p2Bar.GetPreviousBar(p3Bar); + result = + result && + p3Bar.GetPreviousBar(p4Bar); + if (!result) + { + // + zBar.Clean(); + cBar.Clean(); + pBar.Clean(); + p2Bar.Clean(); + p3Bar.Clean(); + p4Bar.Clean(); + + // + box.Clean(); + conditions.Clean(); + pConditions.Clean(); + + // + return result; + } + + // + // 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); + + // + // Bar Sumarise ... + + // + bool isCBarValidForBullish = + (isCBarBullishHammer || + isCBarBullishRejected || + isCBarBullishMomentum || + isCBarBullishEngulfed); + + // + bool isCBarValidForBearish = + (isCBarBearishHammer || + isCBarBearishRejected || + isCBarBearishMomentum || + isCBarBearishEngulfed); + + // + // Score ... + + // + double bullishScore = 0; + double bearishScore = 0; + conditions.GenerateScore( + bullishScore, + bearishScore // + ); + + // + bool isScoreBullish = + bullishScore > bearishScore; + + // + bool isScoreBearish = + bearishScore > bullishScore; + + // + string summary = + conditions + .GenerateSummary(); + + // + // Conditions ... + + // + bool isRSIBullish = + zRSI >= cRSI && + cRSI > pRSI; + bool isRSIBearish = + zRSI <= cRSI && + cRSI < pRSI; + + // + bool isCCIBullish = + zCCI >= cCCI && + cCCI > pCCI && + (zCCI > conditions.cciOSLevel || + cCCI > conditions.cciOSLevel); + bool isCCIBearish = + zCCI >= cCCI && + cCCI > pCCI && + (zCCI < conditions.cciOBLevel || + cCCI < conditions.cciOBLevel); + + // + // Detect Selected Box ... + XBoxZone oscBoxes[]; + XBoxZone lastOSCBox; + double providedSL = 0; + bool isBoxFVG = false; + bool hasOSCBox = false; + bool hasPivotBox = false; + bool isBoxPeakVale = false; + bool isBoxRejected = false; + bool isBoxActivated = false; + bool isBoxFullSifeRejected = false; + bool hasBoxes = HasChild(boxes); + if (hasBoxes) + { + // + // Detect Selected Boxes ... + XBoxZone tmp[]; + Copy( + boxes, + tmp // + ); + while (HasChild(tmp)) + { + // + idx = GetYoungest(tmp); + has = IsValidIndex(idx); + if (!has) + { + break; + } + + // + XBoxZone iBox; + iBox = tmp[idx]; + ArrayRemove( + tmp, + idx, + 1 // + ); + + // + // Check Selected Box not RSI or CCI ... + isBoxFVG = Contains( + "XCA_FVG", + iBox.type // + ); + isBoxPeakVale = + Contains( + "XCA_PEAKSWHRES", + iBox.type // + ) || + Contains( + "XCA_VALESWLSUP", + iBox.type // + ); + has = isBoxFVG || + isBoxPeakVale; + if (!has) + { + // + bool isOSC = Contains( + "XCA_CCI_VALE", + iBox.type // + ) || + Contains( + "XCA_CCI_PEAK", + iBox.type // + ) || + Contains( + "XCA_RSI_VALE", + iBox.type // + ) || + Contains( + "XCA_RSI_PEAK", + iBox.type // + ); + if (isOSC) + { + // + AddRef( + iBox, + oscBoxes // + ); + } + + // + iBox.Clean(); + + // + continue; + } + + // + bool isBullish = iBox.IsBullish(); + bool isBearish = iBox.IsBearish(); + + // + double rejectedCheckPrice = + isBullish + ? iBox.upper + : iBox.lower; + double rejectedFullCheckPrice = + isBullish + ? iBox.lower + : iBox.upper; + + // + // Check Box Selecting Senarios ... + + // + // Selecting Rejected Boxes ... + isBoxRejected = cBar.IsRejected( + rejectedCheckPrice, + iBox.dir, + false, + false // + ); + + // + // Selecting Rejected Boxes ... + isBoxFullSifeRejected = cBar.IsRejected( + rejectedFullCheckPrice, + iBox.dir, + false, + false // + ); + + // + // Selecting Activation Boxes ... + + // + bool isBullishActivated = + isBullish && + cBar.IsBullish() && + cBar.GetUp() > rejectedCheckPrice && + cBar.GetDown() < rejectedCheckPrice; + + // + bool isBearishActivated = + isBearish && + cBar.IsBearish() && + cBar.GetUp() > rejectedCheckPrice && + cBar.GetDown() < rejectedCheckPrice; + + // + isBoxActivated = isBullishActivated || + isBearishActivated; + + // + // Detect Box is Selected or not ... + has = + isBoxRejected || + isBoxActivated || + isBoxFullSifeRejected; + if (has) + { + // + pivotBox = iBox; + + // + iBox.Clean(); + break; + } + + // + iBox.Clean(); + } + + // + Clean(tmp); + } + + // + // Check OSC Boxes ... + bool hasOSCBoxes = HasChild(oscBoxes); + if (hasOSCBoxes) + { + // + // Detect Newest OSC Box ... + idx = GetYoungest(oscBoxes); + has = IsValidIndex(idx); + if (has) + { + lastOSCBox = oscBoxes[idx]; + } + + // + // Validate OSC Box is Valid or not ... + has = lastOSCBox.IsValid(); + if (has) + { + // + // Check Bar is Inside OSC Box or not ... + has = cBar.time > lastOSCBox.from && + cBar.time <= lastOSCBox.to; + if (!has) + { + lastOSCBox.Clean(); + } + } + + // + hasOSCBox = lastOSCBox.IsValid(); + if (hasOSCBox) + { + // // + // XCBoxObject *iObj; + // has = helper.poiDrawer.DrawBox( + // lastOSCBox, + // iObj // + // ); + // if (has) { + // iObj.BoxWidth(4); + // } + } + } + + // + // Force Conditions to Have Selected Box ... + hasPivotBox = hasBoxes && + pivotBox.IsValid(); + if (hasPivotBox) + { + // // + // pivotBox.to = TimeCurrent(); + + // // + // // Draw Pivot Box Here ... + // if (isBoxPeakVale) + // { + // // + // XCBoxObject *iObj; + // has = helper.poiDrawer.DrawBox( + // pivotBox, + // iObj // + // ); + // if (has) + // { + // // + // iObj.BoxWidth(5); + // iObj.BoxColor(clrDodgerBlue); + // Print("Draw Pivot Box ..."); + // } + // } + } + + // + // If all Conditions required Boxes ... + // if (!result) + // { + // // + // zBar.Clean(); + // cBar.Clean(); + // pBar.Clean(); + // p2Bar.Clean(); + // p3Bar.Clean(); + // p4Bar.Clean(); + + // // + // box.Clean(); + // pivotBox.Clean(); + // conditions.Clean(); + + // // + // return result; + // } + + // + // Signaller Summarization ... + + // + // Cond1 Act Using PEAK VALE Box Activation or Rejection ... + + // + bool isCond1Bullish = + // + false && + hasPivotBox && + isBoxPeakVale && + isScoreBullish && + pivotBox.IsBullish() && + (conditions.isValeUnderLast || + (conditions.isValeSameLast && + pConditions.isValeUnderLast)) && + conditions.isRSICrossedOverOS && + conditions.isCCICrossedOverOS + // + ; + + // + bool isCond1Bearish = + // + false && + hasPivotBox && + isBoxPeakVale && + isScoreBearish && + pivotBox.IsBearish() && + (conditions.isPeakOverLast || + (conditions.isPeakSameLast && + pConditions.isPeakOverLast)) && + conditions.isRSICrossedUnderOB && + conditions.isCCICrossedUnderOB + // + ; + + // + bool isCond1 = isCond1Bullish || + isCond1Bearish; + if (isCond1) + { + // + providedSL = + isCond1Bullish + ? MathMin(pBar.low, pivotBox.lower) + : MathMax(pBar.high, pivotBox.upper); + + // + additionalSL = 0.5 * conditions.atrBuffer[cIDX]; + + // + Print("Cond1"); + } + + // + // Cond2 Act Using OSC Box and Vydia ... + + // + bool isCond2Bullish = + // + hasOSCBox && + // cVidyaState < 0 && + lastOSCBox.IsBullish() // && + // lastOSCBox.upper < cVidya + // + ; + + // + bool isCond2Bearish = + // + hasOSCBox && + // cVidyaState > 0 && + lastOSCBox.IsBearish() // && + // lastOSCBox.lower > cVidya + // + ; + + // + bool isCond2 = isCond2Bullish || + isCond2Bearish; + if (isCond2) + { + // + providedSL = + isCond1Bullish + ? MathMin(pBar.low, pivotBox.lower) + : MathMax(pBar.high, pivotBox.upper); + + // + Print("Cond2"); + isCond2Bullish = false; + isCond2Bearish = false; + } + + // + // Cond3 Act Using CCi Peaks and Vales ... + + // + bool isCond3Bullish = false; + + // + bool isCond3Bearish = false; + + // + bool isCond3 = isCond3Bullish || + isCond3Bearish; + if (isCond3) + { + // + + // + Print("Cond3"); + } + + // + // Summarise Conditions ... + + // + bool isBullish = + // + isCond1Bullish || + isCond2Bullish || + isCond3Bullish; + // + ; + + // + bool isBearish = + // + isCond1Bearish || + isCond2Bearish || + isCond3Bearish + // + ; + + // + result = isBullish || + isBearish; + if (result) + { + // + dir = + isBullish + ? X_DIRECTION_BULLISH + : X_DIRECTION_BEARISH; + + // + double entry = GetEntry( + conditions.symbol, + dir // + ); + + // + double sl = + providedSL > 0 + ? providedSL + : isBullish + ? pivotBox.lower + : pivotBox.upper; + + // + box.dir = dir; + box.symbol = conditions.symbol; + box.period = conditions.period; + + // + box.upper = + isBullish + ? entry + : sl; + + // + box.lower = + isBullish + ? sl + : entry; + + // + box.to = zBar.time; + box.from = p4Bar.time; + + // + box.type = "XCASignal"; + } + + // + result = box.IsValid() && + HasDirection(dir); + + // + // Cleanup Resources ... + + // + if (!result) + { + // + box.Clean(); + pivotBox.Clean(); + conditions.Clean(); + } + + // + zBar.Clean(); + cBar.Clean(); + pBar.Clean(); + p2Bar.Clean(); + p3Bar.Clean(); + p4Bar.Clean(); + Clean(oscBoxes); + pConditions.Clean(); + + // + return result; +} + +// \ No newline at end of file diff --git a/XCAEA/Classes/xcaea.x-poi.detector.class.mq5 b/XCAEA/Classes/xcaea.x-poi.detector.class.mq5 index a74ddeb1..90e98ceb 100644 --- a/XCAEA/Classes/xcaea.x-poi.detector.class.mq5 +++ b/XCAEA/Classes/xcaea.x-poi.detector.class.mq5 @@ -469,6 +469,136 @@ struct XCAPivot // }; +// +struct XCAPVFVG +{ + // + double value; + XBoxZone fvgs[]; + ENUM_X_DIRECTION dir; + + // + XCAPVFVG() + { + Clean(); + } + + // + // Tools ... + + // + void Clean() + { + // + value = 0; + Clean(fvgs); + dir = X_DIRECTION_NONE; + } + + // + bool IsValid() + { + // + bool result = false; + + // + result = value > 0 && + HasChild(fvgs) && + HasDirection(dir); + + // + return result; + } + + // + void AddFVG(XBoxZone &fvg) + { + // + bool has = fvg.IsValid() && + fvg.dir == dir; + if (!has) + { + return; + } + + // + int idx = -1; + has = FindBoxIndex( + idx, + fvg, + fvgs // + ); + if (has) + { + return; + } + + // + AddRef( + fvg, + fvgs // + ); + } + + // + bool IsBullish() + { + return IsValid() && + IsBullish(dir); + } + + // + bool IsBearish() + { + return IsValid() && + IsBearish(dir); + } + + // + 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; + } + + // +}; + // // Implementations ... class XCXCAEAPOIDetector : public XCBase @@ -484,40 +614,6 @@ class XCXCAEAPOIDetector : public XCBase int pivotVerifications; // Pivots Verifications ... int maxAllowedPivots; // Max Allowed Holding Pibots ... - // - // VALE Pivot Support Swing Low ... - - // - XCAPivot valeSupSWLPivot; - bool detectValeSupSWLPivots; - XBoxZone valeSupSWLPivots[]; - bool newValeSupSWLPivotDetected; - - // - // PEAK Pivot Resistance Swing High ... - - // - XCAPivot peakResSWHPivot; - bool detectPeakResSWHPivots; - XBoxZone peakResSWHPivots[]; - bool newPeakResSWHPivotDetected; - - // - // FVG Bullish Pivots ... - - // - bool detectFVGBullishPivots; - XBoxZone fvgBullishPivots[]; - bool newFVGBullishPivotDetected; - - // - // FVG Bearish Pivots ... - - // - bool detectFVGBearishPivots; - XBoxZone fvgBearishPivots[]; - bool newFVGBearishPivotDetected; - // // RSI Peak Pivot ... @@ -555,7 +651,54 @@ class XCXCAEAPOIDetector : public XCBase bool newCCIValePivotDetected; // - // Detector Pivots State Properties ... + // 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; + + // + // XPVFVG Bullish ... + + // + bool detectPVFVGBullishPivots; + XCAPVFVG pvFVGBullishPivots[]; + bool newPVFVGBullishPivotDetected; + + // + // XPVFVG Bearish ... + + // + bool detectPVFVGBearishPivots; + XCAPVFVG pvFVGBearishPivots[]; + bool newPVFVGBearishPivotDetected; // // Constructors ... @@ -585,14 +728,7 @@ class XCXCAEAPOIDetector : public XCBase peakResSWHPivot.Clean(); // - Clean(rsiPeakPivots); - Clean(rsiValePivots); - Clean(cciPeakPivots); - Clean(cciValePivots); - Clean(fvgBullishPivots); - Clean(fvgBearishPivots); - Clean(valeSupSWLPivots); - Clean(peakResSWHPivots); + CleanPivots(); // ZeroMemory(helper); @@ -622,6 +758,8 @@ class XCXCAEAPOIDetector : public XCBase detectFVGBearishPivots = true; detectValeSupSWLPivots = true; detectPeakResSWHPivots = true; + detectPVFVGBullishPivots = true; + detectPVFVGBearishPivots = true; // } @@ -642,6 +780,7 @@ class XCXCAEAPOIDetector : public XCBase loopback = NormalizeInt(loopback, 400); // + int idx = -1; int count = 0; bool has = false; @@ -654,6 +793,8 @@ class XCXCAEAPOIDetector : public XCBase newFVGBearishPivotDetected = false; newValeSupSWLPivotDetected = false; newPeakResSWHPivotDetected = false; + newPVFVGBullishPivotDetected = false; + newPVFVGBearishPivotDetected = false; // int zIDX = 0; @@ -710,36 +851,533 @@ 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(); // - // Provide Some Conditions ... + bool isCBarHasBullishPower = isBullishFVG || + isCBarBullishRejected || + isCBarBullishEngulfed || + isCBarBullishMomentum; // - double points = GetPoints(zBar.symbol); + 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; + // // Checking Pivots ... + // + // RSI Peak Pivot ... + if (detectRSIPeakPivots) + { + // + if (isRSIPeak && isCBarHasBearishPower && conditions.isRSICrossedUnderOB) + { + // + 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) + { + // + if (isRSIVale && isCBarHasBullishPower && conditions.isRSICrossedOverOS) + { + // + 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) + { + // + if (isCCIPeak && isCBarHasBearishPower && conditions.isCCICrossedUnderOB) + { + // + 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) + { + // + if (isCCIVale && isCBarHasBullishPower && conditions.isCCICrossedOverOS) + { + // + 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) + { + // + if (isBullishFVG) + { + // + 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) + { + // + if (isBearishFVG) + { + // + 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) @@ -786,14 +1424,13 @@ class XCXCAEAPOIDetector : public XCBase { // XBoxZone iBox; - newValeSupSWLPivotDetected = valeSupSWLPivot.AsBox(iBox); - if (newValeSupSWLPivotDetected) + has = valeSupSWLPivot.AsBox(iBox); + if (has) { // - AddBox( + newValeSupSWLPivotDetected = AddBox( iBox, - valeSupSWLPivots, - maxAllowedPivots // + valeSupSWLPivots // ); } @@ -810,42 +1447,239 @@ class XCXCAEAPOIDetector : public XCBase // 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(); + } } // - // FVG Bullish ... - if (detectFVGBullishPivots) + // PVFVG Bullish ... + if (detectPVFVGBullishPivots) { + // + if (conditions.isValeIsPivot && isBullishFVG) + { + // + idx = -1; + has = HasPVFVGBullishPivots(); + if (has) + { + // + count = CountPVFVGBullishPivots(); + for (int i = 0; i < count; i++) + { + // + XCAPVFVG iPVFVG = pvFVGBullishPivots[i]; + + // + if (iPVFVG.value == cVale && iPVFVG.IsBullish()) + { + // + idx = i; + iPVFVG.Clean(); + + // + break; + } + + // + iPVFVG.Clean(); + } + } + + // + has = IsValidIndex(idx); + if (has) + { + // + // Add FVG to Exists PVFVG ... + + // + XBoxZone iFVG = fvgBox; + iFVG.type = "XCA_FVG"; + + // + pvFVGBullishPivots[idx].AddFVG(iFVG); + } + else + { + // + // Add New PVFVG ... + + // + newPVFVGBullishPivotDetected = true; + + // + XCAPVFVG iPVFVG; + XBoxZone iFVG = fvgBox; + iFVG.type = "XCA_FVG"; + + // + iPVFVG.value = cVale; + iPVFVG.dir = X_DIRECTION_BULLISH; + + // + iPVFVG.AddFVG(iFVG); + + // + has = iPVFVG.IsValid(); + if (has) + { + // + AddRef( + iPVFVG, + pvFVGBullishPivots // + ); + } + + // + iFVG.Clean(); + iPVFVG.Clean(); + } + } } // - // FVG Bearish ... - if (detectFVGBearishPivots) + // PVFVG Bearish ... + if (detectPVFVGBearishPivots) { - } + // + if (conditions.isPeakIsPivot && isBearishFVG) + { + // + idx = -1; + has = HasPVFVGBearishPivots(); + if (has) + { + // + count = CountPVFVGBearishPivots(); + for (int i = 0; i < count; i++) + { + // + XCAPVFVG iPVFVG = pvFVGBearishPivots[i]; - // - // RSI Peak Pivot ... - if (detectRSIPeakPivots) - { - } + // + if (iPVFVG.value == cPeak && iPVFVG.IsBearish()) + { + // + idx = i; + iPVFVG.Clean(); - // - // RSI Vale Pivot ... - if (detectRSIValePivots) - { - } + // + break; + } - // - // CCI Peak Pivot ... - if (detectCCIPeakPivots) - { - } + // + iPVFVG.Clean(); + } + } - // - // CCI Vale Pivot ... - if (detectCCIValePivots) - { + // + has = IsValidIndex(idx); + if (has) + { + // + // Add FVG to Exists PVFVG ... + + // + XBoxZone iFVG = fvgBox; + iFVG.type = "XCA_FVG"; + + // + pvFVGBearishPivots[idx].AddFVG(iFVG); + } + else + { + // + // Add New PVFVG ... + + // + newPVFVGBearishPivotDetected = true; + + // + XCAPVFVG iPVFVG; + XBoxZone iFVG = fvgBox; + iFVG.type = "XCA_FVG"; + + // + iPVFVG.value = cPeak; + iPVFVG.dir = X_DIRECTION_BEARISH; + + // + iPVFVG.AddFVG(iFVG); + + // + has = iPVFVG.IsValid(); + if (has) + { + // + AddRef( + iPVFVG, + pvFVGBearishPivots // + ); + } + + // + iFVG.Clean(); + iPVFVG.Clean(); + } + } } // @@ -891,206 +1725,6 @@ class XCXCAEAPOIDetector : public XCBase // // Implement Validation Senarios ... - // - // VALE Pivot Support Swing Low ... - - // - has = HasValeSupSWLPivots(); - if (has) - { - // - // Copy Items and Cleanup Collection ... - Copy( - valeSupSWLPivots, - tmp // - ); - Clean(valeSupSWLPivots); - - // - // Do Validation ... - while (HasChild(tmp)) - { - // - XBoxZone iBox = tmp[0]; - ArrayRemove( - tmp, - 0, - 1 // - ); - - // - has = ValidateBox( - iBox, - unAvailableBoxes, - barIndex // - ); - if (has) - { - // - AddRef( - iBox, - valeSupSWLPivots // - ); - } - - // - iBox.Clean(); - } - - // - Clean(tmp); - } - - // - // PEAK Pivot Resistance Swing High ... - - // - has = HasPeakResSWHPivots(); - if (has) - { - // - // Copy Items and Cleanup Collection ... - Copy( - peakResSWHPivots, - tmp // - ); - Clean(peakResSWHPivots); - - // - // Do Validation ... - while (HasChild(tmp)) - { - // - XBoxZone iBox = tmp[0]; - ArrayRemove( - tmp, - 0, - 1 // - ); - - // - has = ValidateBox( - iBox, - unAvailableBoxes, - barIndex // - ); - if (has) - { - // - AddRef( - iBox, - peakResSWHPivots // - ); - } - - // - iBox.Clean(); - } - - // - Clean(tmp); - } - - // - // FVG Bullish ... - - // - has = HasFVGBullishPivots(); - if (has) - { - // - // Copy Items and Cleanup Collection ... - Copy( - fvgBullishPivots, - tmp // - ); - Clean(fvgBullishPivots); - - // - // Do Validation ... - while (HasChild(tmp)) - { - // - XBoxZone iBox = tmp[0]; - ArrayRemove( - tmp, - 0, - 1 // - ); - - // - has = ValidateBox( - iBox, - unAvailableBoxes, - barIndex // - ); - if (has) - { - // - AddRef( - iBox, - fvgBullishPivots // - ); - } - - // - iBox.Clean(); - } - - // - Clean(tmp); - } - - // - // FVG Bearish ... - - // - has = HasFVGBearishPivots(); - if (has) - { - // - // Copy Items and Cleanup Collection ... - Copy( - fvgBearishPivots, - tmp // - ); - Clean(fvgBearishPivots); - - // - // Do Validation ... - while (HasChild(tmp)) - { - // - XBoxZone iBox = tmp[0]; - ArrayRemove( - tmp, - 0, - 1 // - ); - - // - has = ValidateBox( - iBox, - unAvailableBoxes, - barIndex // - ); - if (has) - { - // - AddRef( - iBox, - fvgBearishPivots // - ); - } - - // - iBox.Clean(); - } - - // - Clean(tmp); - } - // // RSI Peak Pivot ... @@ -1291,75 +1925,531 @@ class XCXCAEAPOIDetector : public XCBase Clean(tmp); } + // + // FVG Bullish ... + + // + has = HasFVGBullishPivots(); + if (has) + { + // + // Copy Items and Cleanup Collection ... + Copy( + fvgBullishPivots, + tmp // + ); + Clean(fvgBullishPivots); + + // + // Do Validation ... + while (HasChild(tmp)) + { + // + XBoxZone iBox = tmp[0]; + ArrayRemove( + tmp, + 0, + 1 // + ); + + // + has = ValidateBox( + iBox, + unAvailableBoxes, + barIndex // + ); + if (has) + { + // + AddRef( + iBox, + fvgBullishPivots // + ); + } + + // + iBox.Clean(); + } + + // + Clean(tmp); + } + + // + // FVG Bearish ... + + // + has = HasFVGBearishPivots(); + if (has) + { + // + // Copy Items and Cleanup Collection ... + Copy( + fvgBearishPivots, + tmp // + ); + Clean(fvgBearishPivots); + + // + // Do Validation ... + while (HasChild(tmp)) + { + // + XBoxZone iBox = tmp[0]; + ArrayRemove( + tmp, + 0, + 1 // + ); + + // + has = ValidateBox( + iBox, + unAvailableBoxes, + barIndex // + ); + if (has) + { + // + AddRef( + iBox, + fvgBearishPivots // + ); + } + + // + iBox.Clean(); + } + + // + Clean(tmp); + } + + // + // VALE Pivot Support Swing Low ... + + // + has = HasValeSupSWLPivots(); + if (has) + { + // + // Copy Items and Cleanup Collection ... + Copy( + valeSupSWLPivots, + tmp // + ); + Clean(valeSupSWLPivots); + + // + // Do Validation ... + while (HasChild(tmp)) + { + // + XBoxZone iBox = tmp[0]; + ArrayRemove( + tmp, + 0, + 1 // + ); + + // + has = ValidateBox( + iBox, + unAvailableBoxes, + barIndex // + ); + if (has) + { + // + AddRef( + iBox, + valeSupSWLPivots // + ); + } + + // + iBox.Clean(); + } + + // + Clean(tmp); + } + + // + // PEAK Pivot Resistance Swing High ... + + // + has = HasPeakResSWHPivots(); + if (has) + { + // + // Copy Items and Cleanup Collection ... + Copy( + peakResSWHPivots, + tmp // + ); + Clean(peakResSWHPivots); + + // + // Do Validation ... + while (HasChild(tmp)) + { + // + XBoxZone iBox = tmp[0]; + ArrayRemove( + tmp, + 0, + 1 // + ); + + // + has = ValidateBox( + iBox, + unAvailableBoxes, + barIndex // + ); + if (has) + { + // + AddRef( + iBox, + peakResSWHPivots // + ); + } + + // + iBox.Clean(); + } + + // + Clean(tmp); + } + + // + // PVFVG Bullish ... + + // + has = HasPVFVGBullishPivots(); + if (has) + { + // + XCAPVFVG tmpPVFVG[]; + + // + // Copy Items and Cleanup Collection ... + Copy( + pvFVGBullishPivots, + tmpPVFVG // + ); + Clean(pvFVGBullishPivots); + + // + // Do Validation ... + while (HasChild(tmpPVFVG)) + { + // + XCAPVFVG iPVFVG = tmpPVFVG[0]; + ArrayRemove( + tmpPVFVG, + 0, + 1 // + ); + Copy( + iPVFVG.fvgs, + tmp // + ); + Clean(iPVFVG.fvgs); + while (HasChild(tmp)) + { + // + XBoxZone iBox = tmp[0]; + ArrayRemove( + tmp, + 0, + 1 // + ); + + // + has = ValidateBox( + iBox, + unAvailableBoxes, + barIndex // + ); + if (has) + { + // + AddRef( + iBox, + iPVFVG.fvgs // + ); + } + + // + iBox.Clean(); + } + + // + if (iPVFVG.IsValid()) + { + // + AddRef( + iPVFVG, + pvFVGBullishPivots // + ); + } + } + + // + Clean(tmp); + Clean(tmpPVFVG); + } + + // + // PVFVG Bearish ... + + // + has = HasPVFVGBearishPivots(); + if (has) + { + // + XCAPVFVG tmpPVFVG[]; + + // + // Copy Items and Cleanup Collection ... + Copy( + pvFVGBearishPivots, + tmpPVFVG // + ); + Clean(pvFVGBearishPivots); + + // + // Do Validation ... + while (HasChild(tmpPVFVG)) + { + // + XCAPVFVG iPVFVG = tmpPVFVG[0]; + ArrayRemove( + tmpPVFVG, + 0, + 1 // + ); + Copy( + iPVFVG.fvgs, + tmp // + ); + Clean(iPVFVG.fvgs); + while (HasChild(tmp)) + { + // + XBoxZone iBox = tmp[0]; + ArrayRemove( + tmp, + 0, + 1 // + ); + + // + has = ValidateBox( + iBox, + unAvailableBoxes, + barIndex // + ); + if (has) + { + // + AddRef( + iBox, + iPVFVG.fvgs // + ); + } + + // + iBox.Clean(); + } + + // + if (iPVFVG.IsValid()) + { + // + AddRef( + iPVFVG, + pvFVGBearishPivots // + ); + } + } + + // + Clean(tmp); + Clean(tmpPVFVG); + } + // Clean(tmp); + // + ReversePivots(); + // } + // + 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 // + ); + + // + has = HasPVFVGBullishPivots(); + if (has) + { + // + count = CountPVFVGBullishPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = pvFVGBullishPivots[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 // + ); + + // + has = HasPVFVGBearishPivots(); + if (has) + { + // + count = CountPVFVGBearishPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = pvFVGBearishPivots[i].GetSelectedFVG(iBox); + if (has) + { + // + AddRef( + iBox, + pivots // + ); + } + + // + iBox.Clean(); + } + } + } + + // + result = ArraySize(pivots); + + // + return result; + } + // // Counters ... - // - // 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); - } - - // - // FVG Bullish ... - - // - bool HasFVGBullishPivots() - { - return HasChild(fvgBullishPivots); - } - - // - int CountFVGBullishPivots() - { - return ArraySize(fvgBullishPivots); - } - - // - // FVG Bearish ... - - // - bool HasFVGBearishPivots() - { - return HasChild(fvgBearishPivots); - } - - // - int CountFVGBearishPivots() - { - return ArraySize(fvgBearishPivots); - } - // // RSI Peak Pivot ... @@ -1420,6 +2510,96 @@ class XCXCAEAPOIDetector : public XCBase 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); + } + + // + // PVFVG Bullish ... + + // + bool HasPVFVGBullishPivots() + { + return HasChild(pvFVGBullishPivots); + } + + // + int CountPVFVGBullishPivots() + { + return ArraySize(pvFVGBullishPivots); + } + + // + // PVFVG Bearish ... + + // + bool HasPVFVGBearishPivots() + { + return HasChild(pvFVGBearishPivots); + } + + // + int CountPVFVGBearishPivots() + { + return ArraySize(pvFVGBearishPivots); + } + // // Protected ... protected: @@ -1441,12 +2621,18 @@ class XCXCAEAPOIDetector : public XCBase bool AddBox( XBoxZone &box, XBoxZone &boxes[], - int maxAllowedPivots // + int maxAllowed = 0 // ) { // bool result = false; + // + if (maxAllowed <= 0) + { + maxAllowed = maxAllowedPivots; + } + // result = box.IsValid(); if (!result) @@ -1491,7 +2677,7 @@ class XCXCAEAPOIDetector : public XCBase // CleanupArray( boxes, - maxAllowedPivots // + maxAllowed // ); } @@ -1663,7 +2849,7 @@ class XCXCAEAPOIDetector : public XCBase // result = isValid && !isBreaked; - + // // Cleanup Resource ... @@ -1676,6 +2862,38 @@ class XCXCAEAPOIDetector : public XCBase return result; } + // + void CleanPivots() + { + // + Clean(rsiPeakPivots); + Clean(rsiValePivots); + Clean(cciPeakPivots); + Clean(cciValePivots); + Clean(fvgBullishPivots); + Clean(fvgBearishPivots); + Clean(valeSupSWLPivots); + Clean(peakResSWHPivots); + Clean(pvFVGBullishPivots); + Clean(pvFVGBearishPivots); + } + + // + void ReversePivots() + { + // + ArrayReverse(rsiPeakPivots); + ArrayReverse(rsiValePivots); + ArrayReverse(cciPeakPivots); + ArrayReverse(cciValePivots); + ArrayReverse(fvgBullishPivots); + ArrayReverse(fvgBearishPivots); + ArrayReverse(valeSupSWLPivots); + ArrayReverse(peakResSWHPivots); + ArrayReverse(pvFVGBullishPivots); + ArrayReverse(pvFVGBearishPivots); + } + // }; diff --git a/XCAEA/Classes/xcaea.x-poi.drawer.class.mq5 b/XCAEA/Classes/xcaea.x-poi.drawer.class.mq5 index 173f6dfa..852e771a 100644 --- a/XCAEA/Classes/xcaea.x-poi.drawer.class.mq5 +++ b/XCAEA/Classes/xcaea.x-poi.drawer.class.mq5 @@ -38,6 +38,9 @@ class XCXCAEAPOIDrawer : public XCBase // // Props ... + // + bool ignoreUpdateOSCTos; + // // Drawers ... bool drawRSIPeakPivots; @@ -48,6 +51,8 @@ class XCXCAEAPOIDrawer : public XCBase bool drawFVGBearishPivots; bool drawValeSupSWLPivots; bool drawPeakResSWHPivots; + bool drawPVFVGBullishPivots; + bool drawPVFVGBearishPivots; // // Colors ... @@ -65,6 +70,8 @@ class XCXCAEAPOIDrawer : public XCBase color fvgBearishPivotsColor; color valeSupSWLPivotsColor; color peakResSWHPivotsColor; + color pvFVGBullishPivotsColor; + color pvFVGBearishPivotsColor; // // Width ... @@ -82,6 +89,8 @@ class XCXCAEAPOIDrawer : public XCBase int fvgBearishPivotsWidth; int valeSupSWLPivotsWidth; int peakResSWHPivotsWidth; + int pvFVGBullishPivotsWidth; + int pvFVGBearishPivotsWidth; // // Style ... @@ -99,6 +108,8 @@ class XCXCAEAPOIDrawer : public XCBase ENUM_LINE_STYLE fvgBearishPivotsStyle; ENUM_LINE_STYLE valeSupSWLPivotsStyle; ENUM_LINE_STYLE peakResSWHPivotsStyle; + ENUM_LINE_STYLE pvFVGBullishPivotsStyle; + ENUM_LINE_STYLE pvFVGBearishPivotsStyle; // // Colorize Props ... @@ -144,6 +155,9 @@ class XCXCAEAPOIDrawer : public XCBase // virtual void Default() { + // + ignoreUpdateOSCTos = true; + // drawRSIPeakPivots = false; drawRSIValePivots = false; @@ -153,6 +167,8 @@ class XCXCAEAPOIDrawer : public XCBase drawFVGBearishPivots = false; drawValeSupSWLPivots = false; drawPeakResSWHPivots = false; + drawPVFVGBullishPivots = false; + drawPVFVGBearishPivots = false; // defaultBullishColor = clrLime; @@ -163,12 +179,14 @@ class XCXCAEAPOIDrawer : public XCBase cciValePivotsColor = defaultBullishColor; fvgBullishPivotsColor = defaultBullishColor; valeSupSWLPivotsColor = defaultBullishColor; + pvFVGBullishPivotsColor = defaultBullishColor; // rsiPeakPivotsColor = defaultBearishColor; cciPeakPivotsColor = defaultBearishColor; fvgBearishPivotsColor = defaultBearishColor; peakResSWHPivotsColor = defaultBearishColor; + pvFVGBearishPivotsColor = defaultBearishColor; // defaultBullishWidth = 1; @@ -179,12 +197,14 @@ class XCXCAEAPOIDrawer : public XCBase cciValePivotsWidth = defaultBullishWidth; fvgBullishPivotsWidth = defaultBullishWidth; valeSupSWLPivotsWidth = defaultBullishWidth; + pvFVGBullishPivotsWidth = defaultBullishWidth; // rsiPeakPivotsWidth = defaultBearishWidth; cciPeakPivotsWidth = defaultBearishWidth; fvgBearishPivotsWidth = defaultBearishWidth; peakResSWHPivotsWidth = defaultBearishWidth; + pvFVGBearishPivotsWidth = defaultBearishWidth; // defaultBullishStyle = STYLE_SOLID; @@ -195,12 +215,14 @@ class XCXCAEAPOIDrawer : public XCBase cciValePivotsStyle = defaultBullishStyle; fvgBullishPivotsStyle = defaultBullishStyle; valeSupSWLPivotsStyle = defaultBullishStyle; + pvFVGBullishPivotsStyle = defaultBullishStyle; // rsiPeakPivotsStyle = defaultBearishStyle; cciPeakPivotsStyle = defaultBearishStyle; fvgBearishPivotsStyle = defaultBearishStyle; peakResSWHPivotsStyle = defaultBearishStyle; + pvFVGBearishPivotsStyle = defaultBearishStyle; } // @@ -215,6 +237,8 @@ class XCXCAEAPOIDrawer : public XCBase DrawFVGBearishPivots(to); DrawValeSupSWLPivots(to); DrawPeakResSWHPivots(to); + DrawPVFVGBullishPivots(to); + DrawPVFVGBearishPivots(to); } // @@ -229,6 +253,8 @@ class XCXCAEAPOIDrawer : public XCBase mFVGBearishPivotObjects.Clear(); mValeSupSWLPivotObjects.Clear(); mPeakResSWHPivotObjects.Clear(); + mPVFVGBullishPivotObjects.Clear(); + mPVFVGBearishPivotObjects.Clear(); } // @@ -253,6 +279,10 @@ class XCXCAEAPOIDrawer : public XCBase } // + if (ignoreUpdateOSCTos) + { + to = NULL; + } bool canUpdateTo = IsValid(to); // @@ -311,6 +341,10 @@ class XCXCAEAPOIDrawer : public XCBase } // + if (ignoreUpdateOSCTos) + { + to = NULL; + } bool canUpdateTo = IsValid(to); // @@ -369,6 +403,10 @@ class XCXCAEAPOIDrawer : public XCBase } // + if (ignoreUpdateOSCTos) + { + to = NULL; + } bool canUpdateTo = IsValid(to); // @@ -427,6 +465,10 @@ class XCXCAEAPOIDrawer : public XCBase } // + if (ignoreUpdateOSCTos) + { + to = NULL; + } bool canUpdateTo = IsValid(to); // @@ -699,6 +741,140 @@ class XCXCAEAPOIDrawer : public XCBase } } + // + void DrawPVFVGBullishPivots(datetime to = NULL) + { + // + bool has = drawPVFVGBullishPivots; + if (!has) + { + return; + } + + // + has = detector.HasPVFVGBullishPivots(); + if (!has) + { + return; + } + + // + bool canUpdateTo = IsValid(to); + + // + int count = detector.CountPVFVGBullishPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = detector.pvFVGBullishPivots[i].GetSelectedFVG(iBox); + if (!has) + { + // + iBox.Clean(); + continue; + } + + // + if (canUpdateTo) + { + iBox.to = to; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + iBox, + iObj // + ); + + // + if (has) + { + // + // Style Object ... + iObj.BoxColor(pvFVGBullishPivotsColor); + iObj.BoxWidth(pvFVGBullishPivotsWidth); + iObj.BoxStyle(pvFVGBullishPivotsStyle); + + // + // Store Object ... + mPVFVGBullishPivotObjects.Add(iObj); + } + + // + iBox.Clean(); + ZeroMemory(iObj); + } + } + + // + void DrawPVFVGBearishPivots(datetime to = NULL) + { + // + bool has = drawPVFVGBearishPivots; + if (!has) + { + return; + } + + // + has = detector.HasPVFVGBearishPivots(); + if (!has) + { + return; + } + + // + bool canUpdateTo = IsValid(to); + + // + int count = detector.CountPVFVGBearishPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + has = detector.pvFVGBearishPivots[i].GetSelectedFVG(iBox); + if (!has) + { + // + iBox.Clean(); + continue; + } + + // + if (canUpdateTo) + { + iBox.to = to; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + iBox, + iObj // + ); + + // + if (has) + { + // + // Style Object ... + iObj.BoxColor(pvFVGBearishPivotsColor); + iObj.BoxWidth(pvFVGBearishPivotsWidth); + iObj.BoxStyle(pvFVGBearishPivotsStyle); + + // + // Store Object ... + mPVFVGBearishPivotObjects.Add(iObj); + } + + // + iBox.Clean(); + ZeroMemory(iObj); + } + } + // // Protected ... protected: @@ -724,6 +900,8 @@ class XCXCAEAPOIDrawer : public XCBase CArrayObj mFVGBearishPivotObjects; CArrayObj mValeSupSWLPivotObjects; CArrayObj mPeakResSWHPivotObjects; + CArrayObj mPVFVGBullishPivotObjects; + CArrayObj mPVFVGBearishPivotObjects; // }; diff --git a/XCAEA/Libraries/xcaea.signaller.lib.mq5 b/XCAEA/Libraries/xcaea.signaller.lib.mq5 index 1a2f09f9..ba75987a 100644 --- a/XCAEA/Libraries/xcaea.signaller.lib.mq5 +++ b/XCAEA/Libraries/xcaea.signaller.lib.mq5 @@ -421,7 +421,7 @@ int AddGuard( // bool DetectXCAEAConditions( - XBoxZone &boxes[], + XBoxZone &pivots[], XCAEAConditions &conditions, XBoxZone &pivotBox, XBoxZone &box, @@ -492,121 +492,6 @@ bool DetectXCAEAConditions( // // Reading Parameters ... - // - // KI ... - - // - double cKI = conditions.kiBuffer[cIDX]; - double pKI = conditions.kiBuffer[pIDX]; - double p2KI = conditions.kiBuffer[p2IDX]; - - // - double cKIState = conditions.kiStateBuffer[cIDX]; - double pKIState = conditions.kiStateBuffer[pIDX]; - double p2KIState = conditions.kiStateBuffer[p2IDX]; - - // - // TKI ... - - // - double cTKI = conditions.tkiBuffer[cIDX]; - double pTKI = conditions.tkiBuffer[pIDX]; - double p2TKI = conditions.tkiBuffer[p2IDX]; - - // - double cTKIState = conditions.tkiStateBuffer[cIDX]; - double pTKIState = conditions.tkiStateBuffer[pIDX]; - double p2TKIState = conditions.tkiStateBuffer[p2IDX]; - - // - // TREND ... - - // - double cTrend = conditions.trendBuffer[cIDX]; - double pTrend = conditions.trendBuffer[pIDX]; - double p2Trend = conditions.trendBuffer[p2IDX]; - - // - double ctrendState = conditions.trendStateBuffer[cIDX]; - double ptrendState = conditions.trendStateBuffer[pIDX]; - double p2trendState = conditions.trendStateBuffer[p2IDX]; - - // - // SWING Low ... - double cSWL = conditions.swingLowBuffer[cIDX]; - double pSWL = conditions.swingLowBuffer[pIDX]; - double p2SWL = conditions.swingLowBuffer[p2IDX]; - - // - // SWING High ... - double cSWH = conditions.swingHighBuffer[cIDX]; - double pSWH = conditions.swingHighBuffer[pIDX]; - double p2SWH = conditions.swingHighBuffer[p2IDX]; - - // - // PEAK ... - double zPeak = conditions.peakBuffer[zIDX]; - double cPeak = conditions.peakBuffer[cIDX]; - double pPeak = conditions.peakBuffer[pIDX]; - double p2Peak = conditions.peakBuffer[p2IDX]; - double p3Peak = conditions.peakBuffer[p3IDX]; - - // - // VALE ... - double zVale = conditions.valeBuffer[zIDX]; - double cVale = conditions.valeBuffer[cIDX]; - double pVale = conditions.valeBuffer[pIDX]; - double p2Vale = conditions.valeBuffer[p2IDX]; - double p3Vale = conditions.valeBuffer[p3IDX]; - - // - // VIDYA ... - double zVidya = conditions.vidyaBuffer[zIDX]; - double cVidya = conditions.vidyaBuffer[cIDX]; - double pVidya = conditions.vidyaBuffer[pIDX]; - double p2Vidya = conditions.vidyaBuffer[p2IDX]; - double p3Vidya = conditions.vidyaBuffer[p3IDX]; - - // - double zVidyaState = conditions.vidyaStateBuffer[zIDX]; - double cVidyaState = conditions.vidyaStateBuffer[cIDX]; - double pVidyaState = conditions.vidyaStateBuffer[pIDX]; - double p2VidyaState = conditions.vidyaStateBuffer[p2IDX]; - double p3VidyaState = conditions.vidyaStateBuffer[p3IDX]; - - // - // RSI ... - double zRSI = conditions.rsiBuffer[zIDX]; - double cRSI = conditions.rsiBuffer[cIDX]; - double pRSI = conditions.rsiBuffer[pIDX]; - double p2RSI = conditions.rsiBuffer[p2IDX]; - double p3RSI = conditions.rsiBuffer[p3IDX]; - - // - // CCI ... - double zCCI = conditions.cciBuffer[zIDX]; - double cCCI = conditions.cciBuffer[cIDX]; - double pCCI = conditions.cciBuffer[pIDX]; - double p2CCI = conditions.cciBuffer[p2IDX]; - double p3CCI = conditions.cciBuffer[p3IDX]; - - // - // RVI ... - - // - double zRVI = conditions.rviBuffer[zIDX]; - double cRVI = conditions.rviBuffer[cIDX]; - double pRVI = conditions.rviBuffer[pIDX]; - double p2RVI = conditions.rviBuffer[p2IDX]; - double p3RVI = conditions.rviBuffer[p3IDX]; - - // - double zRVISignal = conditions.rviSignalBuffer[zIDX]; - double cRVISignal = conditions.rviSignalBuffer[cIDX]; - double pRVISignal = conditions.rviSignalBuffer[pIDX]; - double p2RVISignal = conditions.rviSignalBuffer[p2IDX]; - double p3RVISignal = conditions.rviSignalBuffer[p3IDX]; - // // Reading Bars ... @@ -770,293 +655,17 @@ bool DetectXCAEAConditions( // Conditions ... // - bool isRSIBullish = - zRSI >= cRSI && - cRSI > pRSI; - bool isRSIBearish = - zRSI <= cRSI && - cRSI < pRSI; - - // - bool isCCIBullish = - zCCI >= cCCI && - cCCI > pCCI && - (zCCI > conditions.cciOSLevel || - cCCI > conditions.cciOSLevel); - bool isCCIBearish = - zCCI >= cCCI && - cCCI > pCCI && - (zCCI < conditions.cciOBLevel || - cCCI < conditions.cciOBLevel); - - // - // Detect Selected Box ... - XBoxZone oscBoxes[]; - XBoxZone lastOSCBox; + // Detect Selected Pivot ... + XBoxZone oscPivots[]; + XBoxZone lastOSCPivot; double providedSL = 0; - bool isBoxFVG = false; - bool hasOSCBox = false; - bool hasPivotBox = false; - bool isBoxPeakVale = false; - bool isBoxRejected = false; - bool isBoxActivated = false; - bool isBoxFullSifeRejected = false; - bool hasBoxes = HasChild(boxes); - if (hasBoxes) + bool hasPivots = HasChild(pivots); + if (hasPivots) { // // Detect Selected Boxes ... - XBoxZone tmp[]; - Copy( - boxes, - tmp // - ); - while (HasChild(tmp)) - { - // - idx = GetYoungest(tmp); - has = IsValidIndex(idx); - if (!has) - { - break; - } - - // - XBoxZone iBox; - iBox = tmp[idx]; - ArrayRemove( - tmp, - idx, - 1 // - ); - - // - // Check Selected Box not RSI or CCI ... - isBoxFVG = Contains( - "XCA_FVG", - iBox.type // - ); - isBoxPeakVale = - Contains( - "XCA_PEAKSWHRES", - iBox.type // - ) || - Contains( - "XCA_VALESWLSUP", - iBox.type // - ); - has = isBoxFVG || - isBoxPeakVale; - if (!has) - { - // - bool isOSC = Contains( - "XCA_CCI_VALE", - iBox.type // - ) || - Contains( - "XCA_CCI_PEAK", - iBox.type // - ) || - Contains( - "XCA_RSI_VALE", - iBox.type // - ) || - Contains( - "XCA_RSI_PEAK", - iBox.type // - ); - if (isOSC) - { - // - AddRef( - iBox, - oscBoxes // - ); - } - - // - iBox.Clean(); - - // - continue; - } - - // - bool isBullish = iBox.IsBullish(); - bool isBearish = iBox.IsBearish(); - - // - double rejectedCheckPrice = - isBullish - ? iBox.upper - : iBox.lower; - double rejectedFullCheckPrice = - isBullish - ? iBox.lower - : iBox.upper; - - // - // Check Box Selecting Senarios ... - - // - // Selecting Rejected Boxes ... - isBoxRejected = cBar.IsRejected( - rejectedCheckPrice, - iBox.dir, - false, - false // - ); - - // - // Selecting Rejected Boxes ... - isBoxFullSifeRejected = cBar.IsRejected( - rejectedFullCheckPrice, - iBox.dir, - false, - false // - ); - - // - // Selecting Activation Boxes ... - - // - bool isBullishActivated = - isBullish && - cBar.IsBullish() && - cBar.GetUp() > rejectedCheckPrice && - cBar.GetDown() < rejectedCheckPrice; - - // - bool isBearishActivated = - isBearish && - cBar.IsBearish() && - cBar.GetUp() > rejectedCheckPrice && - cBar.GetDown() < rejectedCheckPrice; - - // - isBoxActivated = isBullishActivated || - isBearishActivated; - - // - // Detect Box is Selected or not ... - has = - isBoxRejected || - isBoxActivated || - isBoxFullSifeRejected; - if (has) - { - // - pivotBox = iBox; - - // - iBox.Clean(); - break; - } - - // - iBox.Clean(); - } - - // - Clean(tmp); } - // - // Check OSC Boxes ... - bool hasOSCBoxes = HasChild(oscBoxes); - if (hasOSCBoxes) - { - // - // Detect Newest OSC Box ... - idx = GetYoungest(oscBoxes); - has = IsValidIndex(idx); - if (has) - { - lastOSCBox = oscBoxes[idx]; - } - - // - // Validate OSC Box is Valid or not ... - has = lastOSCBox.IsValid(); - if (has) - { - // - // Check Bar is Inside OSC Box or not ... - has = cBar.time > lastOSCBox.from && - cBar.time <= lastOSCBox.to; - if (!has) - { - lastOSCBox.Clean(); - } - } - - // - hasOSCBox = lastOSCBox.IsValid(); - if (hasOSCBox) - { - // // - // XCBoxObject *iObj; - // has = helper.poiDrawer.DrawBox( - // lastOSCBox, - // iObj // - // ); - // if (has) { - // iObj.BoxWidth(4); - // } - } - } - - // - // Force Conditions to Have Selected Box ... - hasPivotBox = hasBoxes && - pivotBox.IsValid(); - if (hasPivotBox) - { - // // - // pivotBox.to = TimeCurrent(); - - // // - // // Draw Pivot Box Here ... - // if (isBoxPeakVale) - // { - // // - // XCBoxObject *iObj; - // has = helper.poiDrawer.DrawBox( - // pivotBox, - // iObj // - // ); - // if (has) - // { - // // - // iObj.BoxWidth(5); - // iObj.BoxColor(clrDodgerBlue); - // Print("Draw Pivot Box ..."); - // } - // } - } - - // - // If all Conditions required Boxes ... - // if (!result) - // { - // // - // zBar.Clean(); - // cBar.Clean(); - // pBar.Clean(); - // p2Bar.Clean(); - // p3Bar.Clean(); - // p4Bar.Clean(); - - // // - // box.Clean(); - // pivotBox.Clean(); - // conditions.Clean(); - - // // - // return result; - // } - // // Signaller Summarization ... @@ -1066,32 +675,14 @@ bool DetectXCAEAConditions( // bool isCond1Bullish = // - false && - hasPivotBox && - isBoxPeakVale && - isScoreBullish && - pivotBox.IsBullish() && - (conditions.isValeUnderLast || - (conditions.isValeSameLast && - pConditions.isValeUnderLast)) && - conditions.isRSICrossedOverOS && - conditions.isCCICrossedOverOS + false // ; // bool isCond1Bearish = // - false && - hasPivotBox && - isBoxPeakVale && - isScoreBearish && - pivotBox.IsBearish() && - (conditions.isPeakOverLast || - (conditions.isPeakSameLast && - pConditions.isPeakOverLast)) && - conditions.isRSICrossedUnderOB && - conditions.isCCICrossedUnderOB + false // ; @@ -1119,20 +710,14 @@ bool DetectXCAEAConditions( // bool isCond2Bullish = // - hasOSCBox && - // cVidyaState < 0 && - lastOSCBox.IsBullish() // && - // lastOSCBox.upper < cVidya + false // ; // bool isCond2Bearish = // - hasOSCBox && - // cVidyaState > 0 && - lastOSCBox.IsBearish() // && - // lastOSCBox.lower > cVidya + false // ; @@ -1143,24 +728,30 @@ bool DetectXCAEAConditions( { // providedSL = - isCond1Bullish + isCond2Bullish ? MathMin(pBar.low, pivotBox.lower) : MathMax(pBar.high, pivotBox.upper); // Print("Cond2"); - isCond2Bullish = false; - isCond2Bearish = false; } // // Cond3 Act Using CCi Peaks and Vales ... // - bool isCond3Bullish = false; + bool isCond3Bullish = + // + false + // + ; // - bool isCond3Bearish = false; + bool isCond3Bearish = + // + false + // + ; // bool isCond3 = isCond3Bullish || @@ -1168,6 +759,10 @@ bool DetectXCAEAConditions( if (isCond3) { // + providedSL = + isCond3Bullish + ? MathMin(pBar.low, pivotBox.lower) + : MathMax(pBar.high, pivotBox.upper); // Print("Cond3"); @@ -1267,7 +862,6 @@ bool DetectXCAEAConditions( p2Bar.Clean(); p3Bar.Clean(); p4Bar.Clean(); - Clean(oscBoxes); pConditions.Clean(); // diff --git a/XCAEA/Signals/xcaea.signaller.class.mq5 b/XCAEA/Signals/xcaea.signaller.class.mq5 index 8dc9e21c..26aa94a8 100644 --- a/XCAEA/Signals/xcaea.signaller.class.mq5 +++ b/XCAEA/Signals/xcaea.signaller.class.mq5 @@ -167,12 +167,12 @@ class XCXCAEASignaller : XCBase // // Setup Conditions ... - XBoxZone boxes[]; + XBoxZone pivots[]; XBoxZone pivotBox; XBoxZone signalBox; + int pivotsCount = 0; + bool hasPivots = false; double additionalSL = 0; - XBoxZone bullishBoxes[]; - XBoxZone bearishBoxes[]; bool hasSignalBox = false; XCAEAConditions conditions; ENUM_X_DIRECTION signalBoxDir = X_DIRECTION_NONE; @@ -182,11 +182,6 @@ class XCXCAEASignaller : XCBase detector.Update( zIndex // ); - - // - if (detector.newValeSupSWLPivotDetected) { - Print("Salam"); - } // // Validate Pivots ... @@ -201,36 +196,12 @@ class XCXCAEASignaller : XCBase // // Retrieve Valid Boxes ... - - // // - // // Bullish ... - // int bullishBoxesCount = - // detector - // .FillBullishBoxes(bullishBoxes); - - // // - // // Bearish ... - // int bearishBoxesCount = - // detector - // .FillBearishBoxes(bearishBoxes); - - // // - // Copy( - // bullishBoxes, - // boxes, - // false // - // ); - // Copy( - // bearishBoxes, - // boxes, - // false // - // ); - int boxesCount = ArraySize(boxes); - bool hasBoxes = IsValidSize(boxesCount); + pivotsCount = detector.FillPivots(pivots); + hasPivots = IsValidSize(pivotsCount); // // Filter UnAvailable Boxes ... - if (hasBoxes) + if (hasPivots) { // // Remove UnAvailable Boxes ... @@ -248,13 +219,13 @@ class XCXCAEASignaller : XCBase has = FindBoxIndex( idx, iBox, - boxes // + pivots // ); if (has) { // ArrayRemove( - boxes, + pivots, idx, 1 // ); @@ -263,23 +234,18 @@ class XCXCAEASignaller : XCBase } // - hasBoxes = HasChild(boxes); - boxesCount = ArraySize(boxes); + hasPivots = HasChild(pivots); + pivotsCount = ArraySize(pivots); } // // // - // - // if (hasBoxes) - // { - // } - // // Detect Sinal Box ... hasSignalBox = DetectXCAEAConditions( - boxes, + pivots, conditions, pivotBox, signalBox, @@ -301,6 +267,17 @@ class XCXCAEASignaller : XCBase ); } + // + // Make Signal Box UnAvailable ... + if (signalBox.IsValid()) + { + // + AddRef( + signalBox, + unAvailableBoxes // + ); + } + // isBullish = hasSignalBox && IsBullish(signalBoxDir); @@ -458,9 +435,7 @@ class XCXCAEASignaller : XCBase // Cleanup Resource ... // - Clean(boxes); - Clean(bullishBoxes); - Clean(bearishBoxes); + Clean(pivots); // zBar.Clean(); @@ -762,24 +737,69 @@ class XCXCAEASignaller : XCBase detector.detectFVGBearishPivots = true; detector.detectValeSupSWLPivots = true; detector.detectPeakResSWHPivots = true; + detector.detectPVFVGBullishPivots = true; + detector.detectPVFVGBearishPivots = true; // // Initialize and Configure Drawer ... drawer = new XCXCAEAPOIDrawer(detector); + // + drawer.ignoreUpdateOSCTos = true; + // // Configure Drawer ... drawer.drawRSIPeakPivots = true; drawer.drawRSIValePivots = true; drawer.drawCCIPeakPivots = true; drawer.drawCCIValePivots = true; - drawer.drawFVGBullishPivots = true; - drawer.drawFVGBearishPivots = true; + drawer.drawFVGBullishPivots = false; + drawer.drawFVGBearishPivots = false; drawer.drawValeSupSWLPivots = true; drawer.drawPeakResSWHPivots = true; + drawer.drawPVFVGBullishPivots = true; + drawer.drawPVFVGBearishPivots = true; + + // + // Configure Widths ... + 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.pvFVGBullishPivotsWidth = 1; + drawer.pvFVGBearishPivotsWidth = 1; + + // + // Configure Colors ... + drawer.rsiPeakPivotsColor = clrMagenta; + drawer.rsiValePivotsColor = clrAqua; + drawer.cciPeakPivotsColor = clrMagenta; + drawer.cciValePivotsColor = clrAqua; + drawer.fvgBullishPivotsColor = clrLime; + drawer.fvgBearishPivotsColor = clrRed; + drawer.valeSupSWLPivotsColor = clrAqua; + drawer.peakResSWHPivotsColor = clrMagenta; + drawer.pvFVGBullishPivotsColor = clrLime; + drawer.pvFVGBearishPivotsColor = clrRed; + + // + // Configures Styles ... + 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.pvFVGBullishPivotsStyle = STYLE_DASHDOTDOT; + drawer.pvFVGBearishPivotsStyle = STYLE_DASHDOTDOT; // - // UnActive Pivots ... } /**