From 5534bde7e5c2dc17582c79b80e95469e4575d23a Mon Sep 17 00:00:00 2001 From: Hadi Khazaee Asl Date: Fri, 7 Mar 2025 03:56:11 +0330 Subject: [PATCH] last ... --- Classes/x-saherelm.x-poi.drawer.class.mq5 | 155 +- Documents/BKP/1.mq5 | 5670 +++++++++-------- Documents/BKP/Test.mq5 | 245 +- Libraries/x-saherelm.x-poi.state.lib.mq5 | 171 +- .../Signals/x-121.smc.xwz.signal.class.mq5 | 123 +- .../Signals/x-121.smc.xwz.signal.lib.mq5 | 398 +- 6 files changed, 3636 insertions(+), 3126 deletions(-) diff --git a/Classes/x-saherelm.x-poi.drawer.class.mq5 b/Classes/x-saherelm.x-poi.drawer.class.mq5 index 8b3d51d6..29c9f881 100644 --- a/Classes/x-saherelm.x-poi.drawer.class.mq5 +++ b/Classes/x-saherelm.x-poi.drawer.class.mq5 @@ -4585,6 +4585,7 @@ class XCPOIDrawer : public XCBase // bool drawOrderBlock = true, bool drawFairValueGaps = true, + bool drawAllFVGs = true, // bool drawOBStartedBar = true, bool drawOBActivatedBar = true, @@ -4695,87 +4696,93 @@ class XCPOIDrawer : public XCBase // // Fair Value Gap ... - XCFVG *fvg; - has = item.GetMainFVG(fvg); - if (has) + if (!drawAllFVGs) { - // - Clean(tmpObjects); - int fvgsCount = DrawFairValueGap( - fvg, - tmpObjects, - drawFVGStartedBar, - drawFVGActivatedBar, - drawFVGBreakedBar, - drawFVGWorkedBar, - widthFVGStartedBar, - clrFVGStartedBar, - styleFVGStartedBar, - widthFVGActivatedBar, - clrFVGActivatedBar, - styleFVGActivatedBar, - widthFVGBreakedBar, - clrFVGBreakedBar, - styleFVGBreakedBar, - widthFVGWorkedBar, - clrFVGWorkedBar, - styleFVGWorkedBar // - ); - has = IsValidSize(fvgsCount); - if (has) + XCFVG *fvg; + has = item.GetMainFVG(fvg); + if (has && + drawFairValueGaps) { // - Copy( + Clean(tmpObjects); + int fvgsCount = DrawFairValueGap( + fvg, tmpObjects, - objects, - false // + drawFVGStartedBar, + drawFVGActivatedBar, + drawFVGBreakedBar, + drawFVGWorkedBar, + widthFVGStartedBar, + clrFVGStartedBar, + styleFVGStartedBar, + widthFVGActivatedBar, + clrFVGActivatedBar, + styleFVGActivatedBar, + widthFVGBreakedBar, + clrFVGBreakedBar, + styleFVGBreakedBar, + widthFVGWorkedBar, + clrFVGWorkedBar, + styleFVGWorkedBar // ); + has = IsValidSize(fvgsCount); + if (has) + { + // + Copy( + tmpObjects, + objects, + false // + ); + } + } + } + else + { + // + has = item.HasFVGs(); + if (has && + drawFairValueGaps) + { + // + count = item.CountFVGs(); + for (int i = 0; i < count; i++) + { + // + Clean(tmpObjects); + int fvgsCount = DrawFairValueGap( + item.fvgs[i], + tmpObjects, + drawFVGStartedBar, + drawFVGActivatedBar, + drawFVGBreakedBar, + drawFVGWorkedBar, + widthFVGStartedBar, + clrFVGStartedBar, + styleFVGStartedBar, + widthFVGActivatedBar, + clrFVGActivatedBar, + styleFVGActivatedBar, + widthFVGBreakedBar, + clrFVGBreakedBar, + styleFVGBreakedBar, + widthFVGWorkedBar, + clrFVGWorkedBar, + styleFVGWorkedBar // + ); + has = IsValidSize(fvgsCount); + if (has) + { + // + Copy( + tmpObjects, + objects, + false // + ); + } + } } } - - // // - // has = item.HasFVGs(); - // if (has && - // drawFairValueGaps) - // { - // // - // count = item.CountFVGs(); - // for (int i = 0; i < count; i++) - // { - // // - // Clean(tmpObjects); - // int fvgsCount = DrawFairValueGap( - // item.fvgs[i], - // tmpObjects, - // drawFVGStartedBar, - // drawFVGActivatedBar, - // drawFVGBreakedBar, - // drawFVGWorkedBar, - // widthFVGStartedBar, - // clrFVGStartedBar, - // styleFVGStartedBar, - // widthFVGActivatedBar, - // clrFVGActivatedBar, - // styleFVGActivatedBar, - // widthFVGBreakedBar, - // clrFVGBreakedBar, - // styleFVGBreakedBar, - // widthFVGWorkedBar, - // clrFVGWorkedBar, - // styleFVGWorkedBar // - // ); - // has = IsValidSize(fvgsCount); - // if (has) - // { - // // - // Copy( - // tmpObjects, - // objects, - // false // - // ); - // } - // } - // } // Clean(tmpObjects); diff --git a/Documents/BKP/1.mq5 b/Documents/BKP/1.mq5 index e15df54d..fd7da809 100644 --- a/Documents/BKP/1.mq5 +++ b/Documents/BKP/1.mq5 @@ -1333,101 +1333,98 @@ if (isPassed) //////////////////////////////////////////////////////////////////////////// +// // +// XOHCL zBar; +// result = zBar.Init( +// symbol, +// period, +// zIndex // +// ); +// if (!result) +// { +// // +// result = HasChild(guards); +// return result; +// } - // // - // XOHCL zBar; - // result = zBar.Init( - // symbol, - // period, - // zIndex // - // ); - // if (!result) - // { - // // - // result = HasChild(guards); - // return result; - // } +// // +// XOHCL cBar; +// result = cBar.Init( +// symbol, +// period, +// cIndex // +// ); +// if (!result) +// { +// // +// zBar.Clean(); +// result = HasChild(guards); +// return result; +// } - // // - // XOHCL cBar; - // result = cBar.Init( - // symbol, - // period, - // cIndex // - // ); - // if (!result) - // { - // // - // zBar.Clean(); - // result = HasChild(guards); - // return result; - // } +// // +// XOHCL pBar; +// result = pBar.Init( +// symbol, +// period, +// pIndex // +// ); +// if (!result) +// { +// // +// zBar.Clean(); +// cBar.Clean(); +// result = HasChild(guards); +// return result; +// } - // // - // XOHCL pBar; - // result = pBar.Init( - // symbol, - // period, - // pIndex // - // ); - // if (!result) - // { - // // - // zBar.Clean(); - // cBar.Clean(); - // result = HasChild(guards); - // return result; - // } +// // +// XOHCL ppBar; +// result = ppBar.Init( +// symbol, +// period, +// ppIndex // +// ); +// if (!result) +// { +// // +// zBar.Clean(); +// cBar.Clean(); +// pBar.Clean(); +// result = HasChild(guards); +// return result; +// } - // // - // XOHCL ppBar; - // result = ppBar.Init( - // symbol, - // period, - // ppIndex // - // ); - // if (!result) - // { - // // - // zBar.Clean(); - // cBar.Clean(); - // pBar.Clean(); - // result = HasChild(guards); - // return result; - // } - - // - // zBar.Clean(); - // cBar.Clean(); - // pBar.Clean(); - // ppBar.Clean(); - - - // - // Detect High Probability Swings ... - // bool isSwingLow = - // // - // cBar.low > pBar.low && - // ppBar.low > pBar.low && - // // - // zBar.low > pBar.low - // // - // ; - // bool isSwingHigh = - // // - // cBar.high < pBar.high && - // ppBar.high < pBar.high && - // // - // zBar.high < pBar.high - // // - // ; - // bool isStrongSwingLow = - // pBar.IsBullish() && - // pBar.GetLowShadow() >= pBar.GetBody() * 2; - // bool isStrongSwingHigh = - // pBar.IsBearish() && - // pBar.GetHighShadow() >= pBar.GetBody() * 2; +// +// zBar.Clean(); +// cBar.Clean(); +// pBar.Clean(); +// ppBar.Clean(); +// +// Detect High Probability Swings ... +// bool isSwingLow = +// // +// cBar.low > pBar.low && +// ppBar.low > pBar.low && +// // +// zBar.low > pBar.low +// // +// ; +// bool isSwingHigh = +// // +// cBar.high < pBar.high && +// ppBar.high < pBar.high && +// // +// zBar.high < pBar.high +// // +// ; +// bool isStrongSwingLow = +// pBar.IsBullish() && +// pBar.GetLowShadow() >= pBar.GetBody() * 2; +// bool isStrongSwingHigh = +// pBar.IsBearish() && +// pBar.GetHighShadow() >= pBar.GetBody() * 2; /////////////////////////////////////////////////////////////////////////////// @@ -1517,10 +1514,8 @@ bool DetectX121Conditions( return result; } - ////////////////////////////////////////////////////////////////////////// - /** * Check an XOBFVG instance has Required Conditions ... * @@ -1769,82 +1764,79 @@ bool DetectSelectedBoxConditions( /////////////////////////////////////////////////////////////////////////////// +// if (hasWaitingZones) +// { +// // +// int idx = -1; +// int count = 0; +// XOBFVG youngest; +// bool has = false; +// XCFVG *selectedFVG; +// XCFVG *unActivatedFVGs[]; - // if (hasWaitingZones) - // { - // // - // int idx = -1; - // int count = 0; - // XOBFVG youngest; - // bool has = false; - // XCFVG *selectedFVG; - // XCFVG *unActivatedFVGs[]; +// // +// idx = GetYoungest(workingZone.waitingZones); +// has = IsValidIndex(idx); +// if (has) +// { +// // +// youngest = workingZone.waitingZones[idx]; +// selectedZoneDir = youngest.GetDirection(); - // // - // idx = GetYoungest(workingZone.waitingZones); - // has = IsValidIndex(idx); - // if (has) - // { - // // - // youngest = workingZone.waitingZones[idx]; - // selectedZoneDir = youngest.GetDirection(); +// // +// if (IsBullish(selectedZoneDir)) +// { +// // +// Copy( +// analyseState.bullishFairValueGaps, +// unActivatedFVGs // +// ); +// } +// else +// { +// // +// Copy( +// analyseState.bearishFairValueGaps, +// unActivatedFVGs // +// ); +// } +// } - // // - // if (IsBullish(selectedZoneDir)) - // { - // // - // Copy( - // analyseState.bullishFairValueGaps, - // unActivatedFVGs // - // ); - // } - // else - // { - // // - // Copy( - // analyseState.bearishFairValueGaps, - // unActivatedFVGs // - // ); - // } - // } +// // +// count = ArraySize(unActivatedFVGs); +// has = IsValidSize(count); +// if (has) +// { +// // +// idx = GetYoungest(unActivatedFVGs); +// has = IsValidIndex(idx); +// if (has) +// { +// selectedFVG = unActivatedFVGs[idx]; +// } +// } - // // - // count = ArraySize(unActivatedFVGs); - // has = IsValidSize(count); - // if (has) - // { - // // - // idx = GetYoungest(unActivatedFVGs); - // has = IsValidIndex(idx); - // if (has) - // { - // selectedFVG = unActivatedFVGs[idx]; - // } - // } - - // // - // has = selectedFVG != NULL; - // if (has) - // { - // // - // XCBaseObject *iObj; - // bool isCreated = drawer.CreateFairValueGap( - // selectedFVG, - // iObj // - // ); - - // // - // if (isCreated) - // { - // Print("Salam"); - // } - // } - // } +// // +// has = selectedFVG != NULL; +// if (has) +// { +// // +// XCBaseObject *iObj; +// bool isCreated = drawer.CreateFairValueGap( +// selectedFVG, +// iObj // +// ); +// // +// if (isCreated) +// { +// Print("Salam"); +// } +// } +// } ////////////////////////////////////////////////////////////////////////////////////////// - /** * Check an XOBFVG instance has Required Conditions ... * @@ -3831,7 +3823,6 @@ bool DetectSelectedZoneSLCandidates( //////////////////////////////////////////////////////////////////////////////// - /** * Detect Targets Based on Selected Zone for Specified type of Directions ... * @@ -4312,7 +4303,6 @@ bool DetectSelectedZonesTargets( /////////////////////////////////////////////////////////////////////// - // struct X121SMCStrategyXWZWorkingZone { @@ -6314,7 +6304,6 @@ struct X121SMCStrategyXWZWorkingZone ////////////////////////////////////////////////////// - /** * Detect Targets Based on Selected Zone for Specified type of Directions ... * @@ -7637,2677 +7626,2663 @@ bool DetectSelectedZoneSLCandidates( ///////////////////////////////////////////////////////////////////////// +// +// Support Zones ... +// has = HasSupportZones(); +// if (has) +// { +// // +// int removeIDXs[]; +// count = CountSupportZones(); +// for (int i = 0; i < count; i++) +// { +// // +// XCSupportZone *iZone = supportZones[i]; +// ENUM_X_DIRECTION iDir = X_DIRECTION_BULLISH; + +// // +// XBoxZone iBox; +// bool hasBox = ToBox( +// iBox, +// iZone // +// ); +// if (!hasBox) +// { +// // +// iBox.Clean(); +// continue; +// } + +// // +// XOHCL passedBar; +// bool isBodyIn = false; +// bool isBodyOut = false; + +// // +// // Check Activation ... +// bool isActivated = iZone.IsActivated( +// iDir, +// passedBar, +// isBodyIn, +// true, +// period // +// ); +// if (isActivated) +// { +// // +// // AddRef( +// // iBox, +// // insideBoxes // +// // ); + +// // +// Add( +// i, +// removeIDXs // +// ); + +// // +// iBox.Clean(); +// passedBar.Clean(); +// continue; +// } + +// // +// // Checking Breaked ... +// bool isBreaked = iZone.IsBreaked( +// iDir, +// passedBar, +// isBodyOut, +// false, +// true, +// period // +// ); +// if (isBreaked) +// { +// // // +// // AddRef( +// // iBox, +// // breakedBoxes // +// // ); + +// // +// Add( +// i, +// removeIDXs // +// ); + +// // +// iBox.Clean(); +// passedBar.Clean(); +// continue; +// } + +// // +// passedBar.Clean(); +// } + +// // +// count = ArraySize(removeIDXs); +// has = IsValidSize(count); +// if (has) +// { +// // +// CleanupArray( +// removeIDXs, +// supportZones // +// ); +// } + +// // +// Clean(removeIDXs); +// } + +// +// Resistance Zones ... +// has = HasResistanceZones(); +// if (has) +// { +// // +// int removeIDXs[]; +// count = CountResistanceZones(); +// for (int i = 0; i < count; i++) +// { +// // +// XCResistanceZone *iZone = resistanceZones[i]; +// ENUM_X_DIRECTION iDir = X_DIRECTION_BEARISH; + +// // +// XBoxZone iBox; +// bool hasBox = ToBox( +// iBox, +// iZone // +// ); +// if (!hasBox) +// { +// // +// iBox.Clean(); +// continue; +// } + +// // +// XOHCL passedBar; +// bool isBodyIn = false; +// bool isBodyOut = false; + +// // +// // Check Activation ... +// bool isActivated = iZone.IsActivated( +// iDir, +// passedBar, +// isBodyIn, +// true, +// period // +// ); +// if (isActivated) +// { +// // +// // AddRef( +// // iBox, +// // insideBoxes // +// // ); + +// // +// Add( +// i, +// removeIDXs // +// ); + +// // +// iBox.Clean(); +// passedBar.Clean(); +// continue; +// } + +// // +// // Checking Breaked ... +// bool isBreaked = iZone.IsBreaked( +// iDir, +// passedBar, +// isBodyOut, +// false, +// true, +// period // +// ); +// if (isBreaked) +// { +// // // +// // AddRef( +// // iBox, +// // breakedBoxes // +// // ); + +// // +// Add( +// i, +// removeIDXs // +// ); + +// // +// iBox.Clean(); +// passedBar.Clean(); +// continue; +// } + +// // +// passedBar.Clean(); +// } + +// // +// count = ArraySize(removeIDXs); +// has = IsValidSize(count); +// if (has) +// { +// // +// CleanupArray( +// removeIDXs, +// resistanceZones // +// ); +// } + +// // +// Clean(removeIDXs); +// } + +//////////////////////////////////////////////////////// + +// +// Waiting Zone Detection ... +// XPOIState iState = mtfState; + +// +// Detect Waiting Zones ... + +// // +// // Using Order Blocks ... +// if (mUseOrderBlocks) +// { +// // +// has = iState.HasOrderBlocks(); +// if (has) +// { +// // +// XCOrderBlock *obs[]; +// count = iState.FilterOrderBlocks( +// obs, +// period, +// XZONE_STATE_PASSED, +// false, +// XZONE_STATE_FAILED, +// false, +// XZONE_STATE_FAILED, +// false, +// XZONE_STATE_IGNORED, +// false // +// ); + +// // +// has = IsValidSize(count); +// if (has) +// { +// // +// ToBox( +// obs, +// waitingBoxes // +// ); +// } + +// // +// Clean(obs); +// } +// } + +// // +// // Using Fair Value Gaps ... +// if (mUseFairValueGaps) +// { +// // +// has = iState.HasFairValueGaps(); +// if (has) +// { +// // +// XBoxZone boxes[]; +// XCFVG *fvgs[]; +// count = iState.FilterFairValueGaps( +// fvgs, +// period, +// XZONE_STATE_PASSED, +// false, +// XZONE_STATE_FAILED, +// false, +// XZONE_STATE_FAILED, +// false, +// XZONE_STATE_IGNORED, +// false // +// ); + +// // +// has = IsValidSize(count); +// if (has) +// { +// // +// count = ToBox( +// fvgs, +// boxes // +// ); + +// // +// for (int i = 0; i < count; i++) +// { +// // +// XBoxZone iBox = boxes[i]; + +// // +// int idx = FindIndex( +// iBox, +// waitingBoxes // +// ); +// has = !IsValidIndex(idx); +// if (has) +// { +// // +// AddRef( +// iBox, +// waitingBoxes // +// ); +// } + +// // +// iBox.Clean(); +// } +// } + +// // +// Clean(fvgs); +// Clean(boxes); +// } +// } + +// +// Cleaning State ... +// iState.Clean(); + +/////////////////////////////////////////////////////////////////////////// + +// +// Waiting Box Detected ... +bool hasWaitingBoxes = hasWorkingZone && + workingZone.HasWaitingBoxes(); +if (hasWaitingBoxes) +{ + // + XOHCL zBar; + XOHCL cBar; + XOHCL pBar; + int count = 0; + int idx = -1; + bool has = false; + + // + bool isInited = zBar.Init( + symbol, + period, + zIndex // + ); + isInited = + isInited && + zBar.GetPreviousBar(cBar); + isInited = + isInited && + cBar.GetPreviousBar(pBar); + + // + count = workingZone.CountWaitingBoxes(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox = workingZone.waitingBoxes[i]; + ENUM_X_DIRECTION iDir = iBox.dir; + bool isBullish = IsBullish(iDir); // - // Support Zones ... - // has = HasSupportZones(); - // if (has) - // { - // // - // int removeIDXs[]; - // count = CountSupportZones(); - // for (int i = 0; i < count; i++) - // { - // // - // XCSupportZone *iZone = supportZones[i]; - // ENUM_X_DIRECTION iDir = X_DIRECTION_BULLISH; - - // // - // XBoxZone iBox; - // bool hasBox = ToBox( - // iBox, - // iZone // - // ); - // if (!hasBox) - // { - // // - // iBox.Clean(); - // continue; - // } - - // // - // XOHCL passedBar; - // bool isBodyIn = false; - // bool isBodyOut = false; - - // // - // // Check Activation ... - // bool isActivated = iZone.IsActivated( - // iDir, - // passedBar, - // isBodyIn, - // true, - // period // - // ); - // if (isActivated) - // { - // // - // // AddRef( - // // iBox, - // // insideBoxes // - // // ); - - // // - // Add( - // i, - // removeIDXs // - // ); - - // // - // iBox.Clean(); - // passedBar.Clean(); - // continue; - // } - - // // - // // Checking Breaked ... - // bool isBreaked = iZone.IsBreaked( - // iDir, - // passedBar, - // isBodyOut, - // false, - // true, - // period // - // ); - // if (isBreaked) - // { - // // // - // // AddRef( - // // iBox, - // // breakedBoxes // - // // ); - - // // - // Add( - // i, - // removeIDXs // - // ); - - // // - // iBox.Clean(); - // passedBar.Clean(); - // continue; - // } - - // // - // passedBar.Clean(); - // } - - // // - // count = ArraySize(removeIDXs); - // has = IsValidSize(count); - // if (has) - // { - // // - // CleanupArray( - // removeIDXs, - // supportZones // - // ); - // } - - // // - // Clean(removeIDXs); - // } + // Check Price Rejection ... // - // Resistance Zones ... - // has = HasResistanceZones(); - // if (has) - // { - // // - // int removeIDXs[]; - // count = CountResistanceZones(); - // for (int i = 0; i < count; i++) - // { - // // - // XCResistanceZone *iZone = resistanceZones[i]; - // ENUM_X_DIRECTION iDir = X_DIRECTION_BEARISH; - - // // - // XBoxZone iBox; - // bool hasBox = ToBox( - // iBox, - // iZone // - // ); - // if (!hasBox) - // { - // // - // iBox.Clean(); - // continue; - // } - - // // - // XOHCL passedBar; - // bool isBodyIn = false; - // bool isBodyOut = false; - - // // - // // Check Activation ... - // bool isActivated = iZone.IsActivated( - // iDir, - // passedBar, - // isBodyIn, - // true, - // period // - // ); - // if (isActivated) - // { - // // - // // AddRef( - // // iBox, - // // insideBoxes // - // // ); - - // // - // Add( - // i, - // removeIDXs // - // ); - - // // - // iBox.Clean(); - // passedBar.Clean(); - // continue; - // } - - // // - // // Checking Breaked ... - // bool isBreaked = iZone.IsBreaked( - // iDir, - // passedBar, - // isBodyOut, - // false, - // true, - // period // - // ); - // if (isBreaked) - // { - // // // - // // AddRef( - // // iBox, - // // breakedBoxes // - // // ); - - // // - // Add( - // i, - // removeIDXs // - // ); - - // // - // iBox.Clean(); - // passedBar.Clean(); - // continue; - // } - - // // - // passedBar.Clean(); - // } - - // // - // count = ArraySize(removeIDXs); - // has = IsValidSize(count); - // if (has) - // { - // // - // CleanupArray( - // removeIDXs, - // resistanceZones // - // ); - // } - - // // - // Clean(removeIDXs); - // } - - //////////////////////////////////////////////////////// - - - // - // Waiting Zone Detection ... - // XPOIState iState = mtfState; + bool hasBullishFiboPressure = + decisionCycleHelper + .mBarAnalyser + .HasFiboPressure( + cBar, + X_DIRECTION_BULLISH, + X_FIBO_LEVEL_382 // + ); // - // Detect Waiting Zones ... - - // // - // // Using Order Blocks ... - // if (mUseOrderBlocks) - // { - // // - // has = iState.HasOrderBlocks(); - // if (has) - // { - // // - // XCOrderBlock *obs[]; - // count = iState.FilterOrderBlocks( - // obs, - // period, - // XZONE_STATE_PASSED, - // false, - // XZONE_STATE_FAILED, - // false, - // XZONE_STATE_FAILED, - // false, - // XZONE_STATE_IGNORED, - // false // - // ); - - // // - // has = IsValidSize(count); - // if (has) - // { - // // - // ToBox( - // obs, - // waitingBoxes // - // ); - // } - - // // - // Clean(obs); - // } - // } - - // // - // // Using Fair Value Gaps ... - // if (mUseFairValueGaps) - // { - // // - // has = iState.HasFairValueGaps(); - // if (has) - // { - // // - // XBoxZone boxes[]; - // XCFVG *fvgs[]; - // count = iState.FilterFairValueGaps( - // fvgs, - // period, - // XZONE_STATE_PASSED, - // false, - // XZONE_STATE_FAILED, - // false, - // XZONE_STATE_FAILED, - // false, - // XZONE_STATE_IGNORED, - // false // - // ); - - // // - // has = IsValidSize(count); - // if (has) - // { - // // - // count = ToBox( - // fvgs, - // boxes // - // ); - - // // - // for (int i = 0; i < count; i++) - // { - // // - // XBoxZone iBox = boxes[i]; - - // // - // int idx = FindIndex( - // iBox, - // waitingBoxes // - // ); - // has = !IsValidIndex(idx); - // if (has) - // { - // // - // AddRef( - // iBox, - // waitingBoxes // - // ); - // } - - // // - // iBox.Clean(); - // } - // } - - // // - // Clean(fvgs); - // Clean(boxes); - // } - // } + bool hasBearishFiboPressure = + decisionCycleHelper + .mBarAnalyser + .HasFiboPressure( + cBar, + X_DIRECTION_BEARISH, + X_FIBO_LEVEL_382 // + ); // - // Cleaning State ... - // iState.Clean(); - - /////////////////////////////////////////////////////////////////////////// - + // Bullish Rejection ... + bool isBullishRejected = + // + isInited && + isBullish && + cBar.low < pBar.low && + zBar.low > iBox.upper && + cBar.low <= iBox.upper && + zBar.open > iBox.upper && + hasBullishFiboPressure && + cBar.GetLowShadow() > pBar.GetLowShadow() + // + ; // - // Waiting Box Detected ... - bool hasWaitingBoxes = hasWorkingZone && - workingZone.HasWaitingBoxes(); - if (hasWaitingBoxes) + // Bearish Rejection ... + bool isBearishhRejected = + // + isInited && + !isBullish && + cBar.high > pBar.high && + zBar.open < iBox.lower && + zBar.high < iBox.lower && + hasBearishFiboPressure && + cBar.high >= iBox.lower && + cBar.GetHighShadow() > pBar.GetHighShadow() + // + ; + + // + has = isBullishRejected || + isBearishhRejected; + if (has) { // - XOHCL zBar; - XOHCL cBar; - XOHCL pBar; - int count = 0; - int idx = -1; - bool has = false; + idx = i; + signalBox = iBox; + hasSignalBox = has; + signalBox.to = cTime; + signalBoxDir = iBox.dir; + isSignalBoxReversal = false; + provider = X121SMC_XWZ_PROVIDER_ACTIVATED_ZONE; + } + // + iBox.Clean(); + } + + // + // Remove Signal Box from Waiting Boxes of + // Working Zone ... + if (hasSignalBox) + { + // + if (IsValidIndex(idx)) + { // - bool isInited = zBar.Init( - symbol, - period, - zIndex // + ArrayRemove( + workingZone.waitingBoxes, + idx, + 1 // ); - isInited = - isInited && - zBar.GetPreviousBar(cBar); - isInited = - isInited && - cBar.GetPreviousBar(pBar); + } + } + + // + // Ignore Zone's Signals ... + hasSignalBox = false; + + // + // Cleanup Resources ... + + // + zBar.Clean(); + cBar.Clean(); + pBar.Clean(); +} + +// +// Check Conditions if Has Inside Boxes ... +bool hasInsideBoxes = hasWorkingZone && + workingZone.HasInsideBoxes(); +if (hasInsideBoxes) +{ +} + +// +// Check Conditions if has Breaked Boxes ... +bool hasBreakedBoxes = hasWorkingZone && + workingZone.HasBreakedBoxes(); +if (hasBreakedBoxes) +{ +} + +// +// Checking Other Conditions ... +if (!hasSignalBox) +{ + // + // Senari A ... + // hasSignalBox = hasWorkingZone && + // workingZone.DetectSenarioASignalBox( + // signalBox, + // signalBoxDir, + // decisionXConditions, + // analyseXConditions, + // decisionCycleHelper, + // drawer, + // zIndex // + // ); + // if (hasSignalBox) + // { + // // + // signalBox.to = cTime; + // isSignalBoxReversal = false; + // provider = X121SMC_XWZ_PROVIDER_PV_ZONE; + // } + + // // + // // Validating Signal Box if Exists ... + // if (hasSignalBox) + // { + // // + // // Validate Signal Boxes using Inside Box ... + // if (hasInsideBoxes) + // { + // // + // int idx = -1; + // bool has = false; + + // // + // idx = + // IsBullish(signalBoxDir) + // ? GetLowest(workingZone.insideBoxes) + // : GetHighest(workingZone.insideBoxes); + // has = IsValidIndex(idx); + // if (has) + // { + // // + // hasSignalBox = + // signalBoxDir == workingZone.insideBoxes[idx].dir; + // } + // } + + // // + // // Validate Signal Box Using Overal Trend ... + // if (hasWorkingZoneOveralDirection) + // { + // // + // hasSignalBox = + // signalBoxDir == wzOveralDir; + // } + // } +} + +////////////////////////////////////////////////////////////////////////////////// + +// +// +// + +// +// Supply Zones ... +has = HasSupplyZones(); +if (has) +{ + // + int removeIDXs[]; + count = CountSupplyZones(); + for (int i = 0; i < count; i++) + { + // + XCSupplyZone *iZone = supplyZones[i]; + ENUM_X_DIRECTION iDir = X_DIRECTION_BEARISH; + + // + XBoxZone iBox; + bool hasBox = ToBox( + iBox, + iZone // + ); + if (!hasBox) + { + // + iBox.Clean(); + continue; + } + + // + XOHCL passedBar; + bool isBodyIn = false; + bool isBodyOut = false; + + // + // Check Activation ... + bool isActivated = iZone.IsActivated( + iDir, + passedBar, + isBodyIn, + true, + period // + ); + if (isActivated) + { + // + // AddRef( + // iBox, + // insideBoxes // + // ); // - count = workingZone.CountWaitingBoxes(); + Add( + i, + removeIDXs // + ); + + // + iBox.Clean(); + passedBar.Clean(); + continue; + } + + // + // Checking Breaked ... + bool isBreaked = iZone.IsBreaked( + iDir, + passedBar, + isBodyOut, + false, + true, + period // + ); + if (isBreaked) + { + // // + // AddRef( + // iBox, + // breakedBoxes // + // ); + + // + Add( + i, + removeIDXs // + ); + + // + iBox.Clean(); + passedBar.Clean(); + continue; + } + + // + passedBar.Clean(); + } + + // + count = ArraySize(removeIDXs); + has = IsValidSize(count); + if (has) + { + // + CleanupArray( + removeIDXs, + supplyZones // + ); + } + + // + Clean(removeIDXs); +} + +// +// Demand Zones ... +has = HasDemandZones(); +if (has) +{ + // + int removeIDXs[]; + count = CountDemandZones(); + for (int i = 0; i < count; i++) + { + // + XCDemandZone *iZone = demandZones[i]; + ENUM_X_DIRECTION iDir = X_DIRECTION_BULLISH; + + // + XBoxZone iBox; + bool hasBox = ToBox( + iBox, + iZone // + ); + if (!hasBox) + { + // + iBox.Clean(); + continue; + } + + // + XOHCL passedBar; + bool isBodyIn = false; + bool isBodyOut = false; + + // + // Check Activation ... + bool isActivated = iZone.IsActivated( + iDir, + passedBar, + isBodyIn, + true, + period // + ); + if (isActivated) + { + // + // AddRef( + // iBox, + // insideBoxes // + // ); + + // + Add( + i, + removeIDXs // + ); + + // + iBox.Clean(); + passedBar.Clean(); + continue; + } + + // + // Checking Breaked ... + bool isBreaked = iZone.IsBreaked( + iDir, + passedBar, + isBodyOut, + false, + true, + period // + ); + if (isBreaked) + { + // // + // AddRef( + // iBox, + // breakedBoxes // + // ); + + // + Add( + i, + removeIDXs // + ); + + // + iBox.Clean(); + passedBar.Clean(); + continue; + } + + // + passedBar.Clean(); + } + + // + count = ArraySize(removeIDXs); + has = IsValidSize(count); + if (has) + { + // + CleanupArray( + removeIDXs, + demandZones // + ); + } + + // + Clean(removeIDXs); +} + +// +// Update Boxes ... + +// +// Waiting Boxes ... +has = HasWaitingBoxes(); +if (has) +{ + // + int removeIDXs[]; + count = CountWaitingBoxes(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox = waitingBoxes[i]; + ENUM_X_DIRECTION iDir = iBox.dir; + bool isBullish = IsBullish(iDir); + + // + bool isInside = + // + zBar.low < iBox.upper && + zBar.low > iBox.lower + // + ; + if (isInside) + { + // + AddRef( + iBox, + insideBoxes // + ); + + // + Add( + i, + removeIDXs // + ); + + // + iBox.Clean(); + break; + } + + // + bool isBreakedUpper = + // + cBar.low < iBox.upper && + cBar.low > iBox.lower && + zBar.low > iBox.upper + // + ; + + // + bool isBreakedLower = + // + cBar.high > iBox.lower && + cBar.high < iBox.upper && + zBar.high < iBox.lower + // + ; + + // + bool isBreaked = + (isBullish && + isBreakedLower) || + (!isBullish && + isBreakedUpper); + + // + if (isBreaked) + { + // + AddRef( + iBox, + breakedBoxes // + ); + + // + Add( + i, + removeIDXs // + ); + + // + iBox.Clean(); + break; + } + } + + // + count = ArraySize(removeIDXs); + has = IsValidSize(count); + if (has) + { + // + CleanupArray( + removeIDXs, + waitingBoxes // + ); + } + + // + Clean(removeIDXs); +} + +// +// Inside Boxes ... +has = HasInsideBoxes(); +if (has) +{ + // + int removeIDXs[]; + count = CountInsideBoxes(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox = insideBoxes[i]; + ENUM_X_DIRECTION iDir = iBox.dir; + bool isBullish = IsBullish(iDir); + + // + bool isBreakedUpper = + // + cBar.low < iBox.upper && + cBar.low > iBox.lower && + zBar.low > iBox.upper + // + ; + + // + bool isBreakedLower = + // + cBar.high > iBox.lower && + cBar.high < iBox.upper && + zBar.high < iBox.lower + // + ; + + // + bool isBreaked = + (isBullish && + isBreakedLower) || + (!isBullish && + isBreakedUpper); + + // + if (isBreaked) + { + // + AddRef( + iBox, + breakedBoxes // + ); + + // + Add( + i, + removeIDXs // + ); + + // + iBox.Clean(); + break; + } + } + + // + count = ArraySize(removeIDXs); + has = IsValidSize(count); + if (has) + { + // + CleanupArray( + removeIDXs, + insideBoxes // + ); + } + + // + Clean(removeIDXs); +} + +// +has = HasBreakedBoxes(); +if (has) +{ + // + int removeIDXs[]; + count = CountBreakedBoxes(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox = breakedBoxes[i]; + ENUM_X_DIRECTION iDir = iBox.dir; + bool isBullish = IsBullish(iDir); + + // + bool isInside = false; + + // + if (isInside) + { + // + AddRef( + iBox, + breakedInsideBoxes // + ); + + // + Add( + i, + removeIDXs // + ); + + // + iBox.Clean(); + break; + } + } + + // + count = ArraySize(removeIDXs); + has = IsValidSize(count); + if (has) + { + // + CleanupArray( + removeIDXs, + breakedBoxes // + ); + } + + // + Clean(removeIDXs); +} + +// +// Update Waiting Boxes ... + +// +XPOIState iState = mtfState; + +// +// Use Order Blocks ... +if (mUseOrderBlocks) +{ + // + has = iState.HasOrderBlocks(); + if (has) + { + // + XCOrderBlock *obs[]; + count = iState.FilterOrderBlocks( + obs, + period, + XZONE_STATE_PASSED, + false, + XZONE_STATE_FAILED, + false, + XZONE_STATE_FAILED, + false, + XZONE_STATE_IGNORED, + false // + ); + + // + has = IsValidSize(count); + if (has) + { + // + // Try to Add new OBs into Waiting Zones ... + // if it's not exists ... for (int i = 0; i < count; i++) { // - XBoxZone iBox = workingZone.waitingBoxes[i]; - ENUM_X_DIRECTION iDir = iBox.dir; - bool isBullish = IsBullish(iDir); - - // - // Check Price Rejection ... - - // - bool hasBullishFiboPressure = - decisionCycleHelper - .mBarAnalyser - .HasFiboPressure( - cBar, - X_DIRECTION_BULLISH, - X_FIBO_LEVEL_382 // - ); - - // - bool hasBearishFiboPressure = - decisionCycleHelper - .mBarAnalyser - .HasFiboPressure( - cBar, - X_DIRECTION_BEARISH, - X_FIBO_LEVEL_382 // - ); - - // - // Bullish Rejection ... - bool isBullishRejected = - // - isInited && - isBullish && - cBar.low < pBar.low && - zBar.low > iBox.upper && - cBar.low <= iBox.upper && - zBar.open > iBox.upper && - hasBullishFiboPressure && - cBar.GetLowShadow() > pBar.GetLowShadow() - // - ; - - // - // Bearish Rejection ... - bool isBearishhRejected = - // - isInited && - !isBullish && - cBar.high > pBar.high && - zBar.open < iBox.lower && - zBar.high < iBox.lower && - hasBearishFiboPressure && - cBar.high >= iBox.lower && - cBar.GetHighShadow() > pBar.GetHighShadow() - // - ; - - // - has = isBullishRejected || - isBearishhRejected; - if (has) + XBoxZone iBox; + bool hasBox = ToBox( + iBox, + obs[i] // + ); + if (!hasBox) { // - idx = i; - signalBox = iBox; - hasSignalBox = has; - signalBox.to = cTime; - signalBoxDir = iBox.dir; - isSignalBoxReversal = false; - provider = X121SMC_XWZ_PROVIDER_ACTIVATED_ZONE; + iBox.Clean(); + continue; } + // + // Check Index in Waiting Boxes ... + idx = FindIndex( + iBox, + waitingBoxes // + ); + has = !IsValidIndex(idx); + if (!has) + { + // + iBox.Clean(); + continue; + } + + // + // Check Index in Inside Boxes ... + idx = FindIndex( + iBox, + insideBoxes // + ); + has = !IsValidIndex(idx); + if (!has) + { + // + iBox.Clean(); + continue; + } + + // + // Check Index in Breaked Boxes ... + idx = FindIndex( + iBox, + breakedBoxes // + ); + has = !IsValidIndex(idx); + if (!has) + { + // + iBox.Clean(); + continue; + } + + // + AddRef( + iBox, + waitingBoxes // + ); + } + } + + // + Clean(obs); + } +} + +// +// Use Fair Value Gaps ... +if (mUseFairValueGaps) +{ + // + has = iState.HasFairValueGaps(); + if (has) + { + // + XCFVG *fvgs[]; + count = iState.FilterFairValueGaps( + fvgs, + period, + XZONE_STATE_PASSED, + false, + XZONE_STATE_FAILED, + false, + XZONE_STATE_FAILED, + false, + XZONE_STATE_IGNORED, + false // + ); + + // + has = IsValidSize(count); + if (has) + { + // + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox; + bool hasBox = ToBox( + iBox, + fvgs[i] // + ); + if (!hasBox) + { + // + iBox.Clean(); + continue; + } + + // + // Check Index in Waiting Boxes ... + idx = FindIndex( + iBox, + waitingBoxes // + ); + has = !IsValidIndex(idx); + if (!has) + { + // + iBox.Clean(); + continue; + } + + // + // Check Index in Inside Boxes ... + idx = FindIndex( + iBox, + insideBoxes // + ); + has = !IsValidIndex(idx); + if (!has) + { + // + iBox.Clean(); + continue; + } + + // + // Check Index in Breaked Boxes ... + idx = FindIndex( + iBox, + breakedBoxes // + ); + has = !IsValidIndex(idx); + if (!has) + { + // + iBox.Clean(); + continue; + } + + // + AddRef( + iBox, + waitingBoxes // + ); + // iBox.Clean(); } - - // - // Remove Signal Box from Waiting Boxes of - // Working Zone ... - if (hasSignalBox) - { - // - if (IsValidIndex(idx)) - { - // - ArrayRemove( - workingZone.waitingBoxes, - idx, - 1 // - ); - } - } - - // - // Ignore Zone's Signals ... - hasSignalBox = false; - - // - // Cleanup Resources ... - - // - zBar.Clean(); - cBar.Clean(); - pBar.Clean(); } // - // Check Conditions if Has Inside Boxes ... - bool hasInsideBoxes = hasWorkingZone && - workingZone.HasInsideBoxes(); - if (hasInsideBoxes) - { - } + Clean(fvgs); + } +} - // - // Check Conditions if has Breaked Boxes ... - bool hasBreakedBoxes = hasWorkingZone && - workingZone.HasBreakedBoxes(); - if (hasBreakedBoxes) - { - } - - // - // Checking Other Conditions ... - if (!hasSignalBox) - { - // - // Senari A ... - // hasSignalBox = hasWorkingZone && - // workingZone.DetectSenarioASignalBox( - // signalBox, - // signalBoxDir, - // decisionXConditions, - // analyseXConditions, - // decisionCycleHelper, - // drawer, - // zIndex // - // ); - // if (hasSignalBox) - // { - // // - // signalBox.to = cTime; - // isSignalBoxReversal = false; - // provider = X121SMC_XWZ_PROVIDER_PV_ZONE; - // } - - // // - // // Validating Signal Box if Exists ... - // if (hasSignalBox) - // { - // // - // // Validate Signal Boxes using Inside Box ... - // if (hasInsideBoxes) - // { - // // - // int idx = -1; - // bool has = false; - - // // - // idx = - // IsBullish(signalBoxDir) - // ? GetLowest(workingZone.insideBoxes) - // : GetHighest(workingZone.insideBoxes); - // has = IsValidIndex(idx); - // if (has) - // { - // // - // hasSignalBox = - // signalBoxDir == workingZone.insideBoxes[idx].dir; - // } - // } - - // // - // // Validate Signal Box Using Overal Trend ... - // if (hasWorkingZoneOveralDirection) - // { - // // - // hasSignalBox = - // signalBoxDir == wzOveralDir; - // } - // } - } - -////////////////////////////////////////////////////////////////////////////////// - - - // - // - // - - // - // Supply Zones ... - has = HasSupplyZones(); - if (has) - { - // - int removeIDXs[]; - count = CountSupplyZones(); - for (int i = 0; i < count; i++) - { - // - XCSupplyZone *iZone = supplyZones[i]; - ENUM_X_DIRECTION iDir = X_DIRECTION_BEARISH; - - // - XBoxZone iBox; - bool hasBox = ToBox( - iBox, - iZone // - ); - if (!hasBox) - { - // - iBox.Clean(); - continue; - } - - // - XOHCL passedBar; - bool isBodyIn = false; - bool isBodyOut = false; - - // - // Check Activation ... - bool isActivated = iZone.IsActivated( - iDir, - passedBar, - isBodyIn, - true, - period // - ); - if (isActivated) - { - // - // AddRef( - // iBox, - // insideBoxes // - // ); - - // - Add( - i, - removeIDXs // - ); - - // - iBox.Clean(); - passedBar.Clean(); - continue; - } - - // - // Checking Breaked ... - bool isBreaked = iZone.IsBreaked( - iDir, - passedBar, - isBodyOut, - false, - true, - period // - ); - if (isBreaked) - { - // // - // AddRef( - // iBox, - // breakedBoxes // - // ); - - // - Add( - i, - removeIDXs // - ); - - // - iBox.Clean(); - passedBar.Clean(); - continue; - } - - // - passedBar.Clean(); - } - - // - count = ArraySize(removeIDXs); - has = IsValidSize(count); - if (has) - { - // - CleanupArray( - removeIDXs, - supplyZones // - ); - } - - // - Clean(removeIDXs); - } - - // - // Demand Zones ... - has = HasDemandZones(); - if (has) - { - // - int removeIDXs[]; - count = CountDemandZones(); - for (int i = 0; i < count; i++) - { - // - XCDemandZone *iZone = demandZones[i]; - ENUM_X_DIRECTION iDir = X_DIRECTION_BULLISH; - - // - XBoxZone iBox; - bool hasBox = ToBox( - iBox, - iZone // - ); - if (!hasBox) - { - // - iBox.Clean(); - continue; - } - - // - XOHCL passedBar; - bool isBodyIn = false; - bool isBodyOut = false; - - // - // Check Activation ... - bool isActivated = iZone.IsActivated( - iDir, - passedBar, - isBodyIn, - true, - period // - ); - if (isActivated) - { - // - // AddRef( - // iBox, - // insideBoxes // - // ); - - // - Add( - i, - removeIDXs // - ); - - // - iBox.Clean(); - passedBar.Clean(); - continue; - } - - // - // Checking Breaked ... - bool isBreaked = iZone.IsBreaked( - iDir, - passedBar, - isBodyOut, - false, - true, - period // - ); - if (isBreaked) - { - // // - // AddRef( - // iBox, - // breakedBoxes // - // ); - - // - Add( - i, - removeIDXs // - ); - - // - iBox.Clean(); - passedBar.Clean(); - continue; - } - - // - passedBar.Clean(); - } - - // - count = ArraySize(removeIDXs); - has = IsValidSize(count); - if (has) - { - // - CleanupArray( - removeIDXs, - demandZones // - ); - } - - // - Clean(removeIDXs); - } - - // - // Update Boxes ... - - // - // Waiting Boxes ... - has = HasWaitingBoxes(); - if (has) - { - // - int removeIDXs[]; - count = CountWaitingBoxes(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox = waitingBoxes[i]; - ENUM_X_DIRECTION iDir = iBox.dir; - bool isBullish = IsBullish(iDir); - - // - bool isInside = - // - zBar.low < iBox.upper && - zBar.low > iBox.lower - // - ; - if (isInside) - { - // - AddRef( - iBox, - insideBoxes // - ); - - // - Add( - i, - removeIDXs // - ); - - // - iBox.Clean(); - break; - } - - // - bool isBreakedUpper = - // - cBar.low < iBox.upper && - cBar.low > iBox.lower && - zBar.low > iBox.upper - // - ; - - // - bool isBreakedLower = - // - cBar.high > iBox.lower && - cBar.high < iBox.upper && - zBar.high < iBox.lower - // - ; - - // - bool isBreaked = - (isBullish && - isBreakedLower) || - (!isBullish && - isBreakedUpper); - - // - if (isBreaked) - { - // - AddRef( - iBox, - breakedBoxes // - ); - - // - Add( - i, - removeIDXs // - ); - - // - iBox.Clean(); - break; - } - } - - // - count = ArraySize(removeIDXs); - has = IsValidSize(count); - if (has) - { - // - CleanupArray( - removeIDXs, - waitingBoxes // - ); - } - - // - Clean(removeIDXs); - } - - // - // Inside Boxes ... - has = HasInsideBoxes(); - if (has) - { - // - int removeIDXs[]; - count = CountInsideBoxes(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox = insideBoxes[i]; - ENUM_X_DIRECTION iDir = iBox.dir; - bool isBullish = IsBullish(iDir); - - // - bool isBreakedUpper = - // - cBar.low < iBox.upper && - cBar.low > iBox.lower && - zBar.low > iBox.upper - // - ; - - // - bool isBreakedLower = - // - cBar.high > iBox.lower && - cBar.high < iBox.upper && - zBar.high < iBox.lower - // - ; - - // - bool isBreaked = - (isBullish && - isBreakedLower) || - (!isBullish && - isBreakedUpper); - - // - if (isBreaked) - { - // - AddRef( - iBox, - breakedBoxes // - ); - - // - Add( - i, - removeIDXs // - ); - - // - iBox.Clean(); - break; - } - } - - // - count = ArraySize(removeIDXs); - has = IsValidSize(count); - if (has) - { - // - CleanupArray( - removeIDXs, - insideBoxes // - ); - } - - // - Clean(removeIDXs); - } - - // - has = HasBreakedBoxes(); - if (has) - { - // - int removeIDXs[]; - count = CountBreakedBoxes(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox = breakedBoxes[i]; - ENUM_X_DIRECTION iDir = iBox.dir; - bool isBullish = IsBullish(iDir); - - // - bool isInside = false; - - // - if (isInside) - { - // - AddRef( - iBox, - breakedInsideBoxes // - ); - - // - Add( - i, - removeIDXs // - ); - - // - iBox.Clean(); - break; - } - } - - // - count = ArraySize(removeIDXs); - has = IsValidSize(count); - if (has) - { - // - CleanupArray( - removeIDXs, - breakedBoxes // - ); - } - - // - Clean(removeIDXs); - } - - // - // Update Waiting Boxes ... - - // - XPOIState iState = mtfState; - - // - // Use Order Blocks ... - if (mUseOrderBlocks) - { - // - has = iState.HasOrderBlocks(); - if (has) - { - // - XCOrderBlock *obs[]; - count = iState.FilterOrderBlocks( - obs, - period, - XZONE_STATE_PASSED, - false, - XZONE_STATE_FAILED, - false, - XZONE_STATE_FAILED, - false, - XZONE_STATE_IGNORED, - false // - ); - - // - has = IsValidSize(count); - if (has) - { - // - // Try to Add new OBs into Waiting Zones ... - // if it's not exists ... - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox; - bool hasBox = ToBox( - iBox, - obs[i] // - ); - if (!hasBox) - { - // - iBox.Clean(); - continue; - } - - // - // Check Index in Waiting Boxes ... - idx = FindIndex( - iBox, - waitingBoxes // - ); - has = !IsValidIndex(idx); - if (!has) - { - // - iBox.Clean(); - continue; - } - - // - // Check Index in Inside Boxes ... - idx = FindIndex( - iBox, - insideBoxes // - ); - has = !IsValidIndex(idx); - if (!has) - { - // - iBox.Clean(); - continue; - } - - // - // Check Index in Breaked Boxes ... - idx = FindIndex( - iBox, - breakedBoxes // - ); - has = !IsValidIndex(idx); - if (!has) - { - // - iBox.Clean(); - continue; - } - - // - AddRef( - iBox, - waitingBoxes // - ); - } - } - - // - Clean(obs); - } - } - - // - // Use Fair Value Gaps ... - if (mUseFairValueGaps) - { - // - has = iState.HasFairValueGaps(); - if (has) - { - // - XCFVG *fvgs[]; - count = iState.FilterFairValueGaps( - fvgs, - period, - XZONE_STATE_PASSED, - false, - XZONE_STATE_FAILED, - false, - XZONE_STATE_FAILED, - false, - XZONE_STATE_IGNORED, - false // - ); - - // - has = IsValidSize(count); - if (has) - { - // - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox; - bool hasBox = ToBox( - iBox, - fvgs[i] // - ); - if (!hasBox) - { - // - iBox.Clean(); - continue; - } - - // - // Check Index in Waiting Boxes ... - idx = FindIndex( - iBox, - waitingBoxes // - ); - has = !IsValidIndex(idx); - if (!has) - { - // - iBox.Clean(); - continue; - } - - // - // Check Index in Inside Boxes ... - idx = FindIndex( - iBox, - insideBoxes // - ); - has = !IsValidIndex(idx); - if (!has) - { - // - iBox.Clean(); - continue; - } - - // - // Check Index in Breaked Boxes ... - idx = FindIndex( - iBox, - breakedBoxes // - ); - has = !IsValidIndex(idx); - if (!has) - { - // - iBox.Clean(); - continue; - } - - // - AddRef( - iBox, - waitingBoxes // - ); - - // - iBox.Clean(); - } - } - - // - Clean(fvgs); - } - } - - // - iState.Clean(); +// +iState.Clean(); ///////////////////////////////////////////////////////////////////////////// - - // - // Update Working Zone ... - // workingZone.Update( - // zIndex, - // visionState, - // consolidationState, - // analyseState, - // decisionState // - // ); +// +// Update Working Zone ... +// workingZone.Update( +// zIndex, +// visionState, +// consolidationState, +// analyseState, +// decisionState // +// ); ////////////////////////////////////////////////////////////////////////////////// +// +// +// - // - // - // - - // - // Supply Zones ... - if (drawSupplyZones) - { - // - has = HasSupplyZones(); - if (has) - { - // - count = CountSupplyZones(); - for (int i = 0; i < count; i++) - { - // - XCSupplyZoneObject *iObj; - isCreated = drawer.CreateSupplyZone( - supplyZones[i], - iObj // - ); - - // - if (isCreated) - { - mWorkingZoneObjects.Add(iObj); - } - } - } - } - - // - // Demand Zones ... - if (drawDemandZones) - { - // - has = HasDemandZones(); - if (has) - { - // - count = CountDemandZones(); - for (int i = 0; i < count; i++) - { - // - XCDemandZoneObject *iObj; - isCreated = drawer.CreateDemandZone( - demandZones[i], - iObj // - ); - - // - if (isCreated) - { - mWorkingZoneObjects.Add(iObj); - } - } - } - } - - // - // Support Zones ... - if (drawSupportZones) - { - // - has = HasSupportZones(); - if (has) - { - // - count = CountSupportZones(); - for (int i = 0; i < count; i++) - { - // - XCSupportZoneObject *iObj; - isCreated = drawer.CreateSupportZone( - supportZones[i], - iObj // - ); - - // - if (isCreated) - { - mWorkingZoneObjects.Add(iObj); - } - } - } - } - - // - // Resistance Zones ... - if (drawResistanceZones) - { - // - has = HasResistanceZones(); - if (has) - { - // - count = CountResistanceZones(); - for (int i = 0; i < count; i++) - { - // - XCResistanceZoneObject *iObj; - isCreated = drawer.CreateResistanceZone( - resistanceZones[i], - iObj // - ); - - // - if (isCreated) - { - mWorkingZoneObjects.Add(iObj); - } - } - } - } - - // - // - // - - // - // Waiting Boxes ... - if (drawWaitingBoxes) - { - // - has = HasWaitingBoxes(); - if (has) - { - // - count = CountWaitingBoxes(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox = waitingBoxes[i]; - - // - XCBoxObject *iObj; - bool isCreated = drawer.DrawBox( - iBox, - iObj // - ); - - // - if (isCreated) - { - mWorkingZoneObjects.Add(iObj); - } - - // - iBox.Clean(); - } - } - } - - // - // Inside Boxes ... - if (drawInsideBoxes) - { - // - has = HasInsideBoxes(); - if (has) - { - } - } - - // - // Breaked Boxes ... - if (drawBreakedBoxes) - { - // - has = HasBreakedBoxes(); - if (has) - { - // - } - } - - // - // Breaked Inside Boxes ... - if (drawBreakedInsideBoxes) - { - // - has = HasBreakedInsideBoxes(); - if (has) - { - // - count = CountBreakedInsideBoxes(); - for (int i = 0; i < count; i++) - { - // - XBoxZone iBox = breakedInsideBoxes[i]; - XCBoxObject *iObj; - has = drawer.DrawBox( - iBox, - iObj // - ); - if (has) - { - // - iObj.BoxWidth(1); - mBreakedInsideZoneObjects.Add(iObj); - } - } - } - } - - -////////////////////////////////////////////////////////////////////////////////// - +// +// Supply Zones ... +if (drawSupplyZones) +{ // - XCSupplyZone *supplyZone; - XCDemandZone *demandZone; - - // - XCSupplyZone *supplyZones[]; - XCDemandZone *demandZones[]; - - // - XCSupportZone *supportZones[]; - XCResistanceZone *resistanceZones[]; - - // - XBoxZone insideBoxes[]; - XBoxZone breakedBoxes[]; - XBoxZone waitingBoxes[]; - XBoxZone breakedInsideBoxes[]; - XConsolidationZone consolidationZones[]; - - // - bool mUseSupDems; - bool mUseOrderBlocks; - bool mUseFairValueGaps; - - - // - // - // - - // // - // // Supply Zones ... - // has = HasSupplyZones(); - // if (!has) - // { - // // - // count = mtfState.FilterSupplyZones( - // supplyZones, - // period, - // XZONE_STATE_PASSED, - // false, - // XZONE_STATE_FAILED, - // false, - // XZONE_STATE_FAILED, - // false, - // XZONE_STATE_IGNORED, - // false // - // ); - // } - - // // - // // Demand Zones ... - // has = HasDemandZones(); - // if (!has) - // { - // // - // count = mtfState.FilterDemandZones( - // demandZones, - // period, - // XZONE_STATE_PASSED, - // false, - // XZONE_STATE_FAILED, - // false, - // XZONE_STATE_FAILED, - // false, - // XZONE_STATE_IGNORED, - // false // - // ); - // } - - // - // Support Zones ... - // has = HasSupportZones(); - // if (!has) - // { - // // - // count = mtfState.FilterSupportZones( - // supportZones, - // period, - // XZONE_STATE_PASSED, - // false, - // XZONE_STATE_FAILED, - // false, - // XZONE_STATE_FAILED, - // false, - // XZONE_STATE_IGNORED, - // false // - // ); - // } - - // - // Resistance Zones ... - // has = HasResistanceZones(); - // if (!has) - // { - // // - // count = mtfState.FilterResistanceZones( - // resistanceZones, - // period, - // XZONE_STATE_PASSED, - // false, - // XZONE_STATE_FAILED, - // false, - // XZONE_STATE_FAILED, - // false, - // XZONE_STATE_IGNORED, - // false // - // ); - // } - - - // - // Update Exists Zones ... - - // - // Supply Zones ... - has = mtfState.HasSupplyZones(); - if (has) - { - // - XCSupplyZone *zone; - idx = GetYoungest(mtfState.supplyZones); - has = IsValidIndex(idx); - if (has) - { - // - zone = mtfState.supplyZones[idx]; - has = IsSupplyExists(zone); - if (!has) - { - // - Add( - zone, - supplyZones // - ); - } - else - { - ZeroMemory(zone); - } - } - } - - // - // Demand Zones ... - has = mtfState.HasDemandZones(); - if (has) - { - // - XCDemandZone *zone; - idx = GetYoungest(mtfState.demandZones); - has = IsValidIndex(idx); - if (has) - { - // - zone = mtfState.demandZones[idx]; - has = IsDemandExists(zone); - if (!has) - { - // - Add( - zone, - demandZones // - ); - } - else - { - ZeroMemory(zone); - } - } - } - -/////////////////////////////////////////////////////////////////////////// - - // - bool IsExists(XBoxZone &box) + has = HasSupplyZones(); + if (has) { // - bool result = false; - - // - result = box.IsValid(); - if (!result) - { - return result; - } - - // - int idx = -1; - bool has = false; - - // - // Checking Index Waiting Box ... - has = HasWaitingBoxes(); - if (has) + count = CountSupplyZones(); + for (int i = 0; i < count; i++) { // - idx = FindIndex( - box, - waitingBoxes // + XCSupplyZoneObject *iObj; + isCreated = drawer.CreateSupplyZone( + supplyZones[i], + iObj // ); - result = !IsValidIndex(idx); - if (!result) - { - return result; - } - } - // - // Checking Index Inside Boxes ... - has = HasInsideBoxes(); - if (has) - { // - idx = FindIndex( - box, - insideBoxes // - ); - result = !IsValidIndex(idx); - if (!result) + if (isCreated) { - return result; + mWorkingZoneObjects.Add(iObj); } } - - // - // Checking Index Breaked Boxes ... - has = HasBreakedBoxes(); - if (has) - { - // - idx = FindIndex( - box, - breakedBoxes // - ); - result = !IsValidIndex(idx); - if (!result) - { - return result; - } - } - - // - // Checking Index BreakedInside Boxes ... - has = HasBreakedInsideBoxes(); - if (has) - { - // - idx = FindIndex( - box, - breakedInsideBoxes // - ); - result = !IsValidIndex(idx); - if (!result) - { - return result; - } - } - - // - return result; } +} +// +// Demand Zones ... +if (drawDemandZones) +{ // - bool IsSupplyExists(XCSupplyZone *zone) + has = HasDemandZones(); + if (has) { // - bool result = false; - - // - result = zone != NULL && - zone.IsValid(); - if (!result) - { - return result; - } - - // - // Converts Zone to Box ... - XBoxZone box; - result = ToBox( - box, - zone // - ); - if (!result) + count = CountDemandZones(); + for (int i = 0; i < count; i++) { // - box.Clean(); - return result; - } - - // - // Checking Index in SupplyZones ... - int idx = FindIndex( - zone, - supplyZones // - ); - result = !IsValidIndex(idx); - if (!result) - { - // - box.Clean(); - return result; - } - - // - result = IsExists(box); - - // - box.Clean(); - - // - return result; - } - - // - bool IsDemandExists(XCDemandZone *zone) - { - // - bool result = false; - - // - result = zone != NULL && - zone.IsValid(); - if (!result) - { - return result; - } - - // - // Converts Zone to Box ... - XBoxZone box; - result = ToBox( - box, - zone // - ); - if (!result) - { - // - box.Clean(); - return result; - } - - // - // Checking Index in SupplyZones ... - int idx = FindIndex( - zone, - demandZones // - ); - result = !IsValidIndex(idx); - if (!result) - { - // - box.Clean(); - return result; - } - - // - result = IsExists(box); - - // - box.Clean(); - - // - return result; - } - -////////////////////////////////////////////////////////////////////////////// - - - // - Clean(supplyZones); - Clean(demandZones); - - // - Clean(insideBoxes); - Clean(breakedBoxes); - Clean(waitingBoxes); - - // - Clean(supportZones); - Clean(resistanceZones); - - // - mUseSupDems = false; - mUseOrderBlocks = true; - mUseFairValueGaps = true; - -///////////////////////////////////////////////////////////////////////////// - - - // - bool HasInsideBox( - XBoxZone &box // - ) - { - // - bool result = false; - - // - int index = -1; - - // - result = box.IsValid(); - if (!result) - { - return result; - } - - // - int count = 0; - bool has = false; - - // - has = HasWaitingBoxes(); - if (has) - { - // - result = HasInsideBox( - index, - box, - waitingBoxes // + XCDemandZoneObject *iObj; + isCreated = drawer.CreateDemandZone( + demandZones[i], + iObj // ); - } - // - // Supply Zones ... - if (!result) - { // - has = HasSupplyZones(); - if (has) + if (isCreated) { - // - XBoxZone tmpBoxes[]; - count = ToBox( - supplyZones, - tmpBoxes // - ); - - // - has = IsValidSize(count); - if (has) - { - // - result = HasInsideBox( - index, - box, - tmpBoxes // - ); - } - - // - Clean(tmpBoxes); + mWorkingZoneObjects.Add(iObj); } } - - // - // Demand Zones ... - if (!result) - { - // - has = HasDemandZones(); - if (has) - { - // - XBoxZone tmpBoxes[]; - count = ToBox( - demandZones, - tmpBoxes // - ); - - // - has = IsValidSize(count); - if (has) - { - // - result = HasInsideBox( - index, - box, - tmpBoxes // - ); - } - - // - Clean(tmpBoxes); - } - } - - // - result = IsValidIndex(index); - - // - return result; } +} - +// +// Support Zones ... +if (drawSupportZones) +{ // - bool DetectSenarioASignalBox( - XBoxZone &signalBox, - ENUM_X_DIRECTION &signalDir, - X121Conditions &decisionXConditions, - X121Conditions &analyseXConditions, - XC121SMCCycleHelper *decisionCycleHelper, - XCPOIDrawer *drawer = NULL, - int barIndex = 0 // - ) + has = HasSupportZones(); + if (has) { // - bool result = false; - - // - signalBox.Clean(); - signalDir = X_DIRECTION_NONE; - - // - if (barIndex < 0) + count = CountSupportZones(); + for (int i = 0; i < count; i++) { - barIndex = 0; + // + XCSupportZoneObject *iObj; + isCreated = drawer.CreateSupportZone( + supportZones[i], + iObj // + ); + + // + if (isCreated) + { + mWorkingZoneObjects.Add(iObj); + } } + } +} +// +// Resistance Zones ... +if (drawResistanceZones) +{ + // + has = HasResistanceZones(); + if (has) + { // - result = decisionCycleHelper != NULL; - if (!result) + count = CountResistanceZones(); + for (int i = 0; i < count; i++) { - return result; + // + XCResistanceZoneObject *iObj; + isCreated = drawer.CreateResistanceZone( + resistanceZones[i], + iObj // + ); + + // + if (isCreated) + { + mWorkingZoneObjects.Add(iObj); + } } + } +} - // - // Decision ... - double decisionBullishScore = 0; - double decisionBearishScore = 0; - decisionXConditions.GenerateScore( - decisionBullishScore, - decisionBearishScore // - ); +// +// +// +// +// Waiting Boxes ... +if (drawWaitingBoxes) +{ + // + has = HasWaitingBoxes(); + if (has) + { // - // Analyse ... - double analyseBullishScore = 0; - double analyseBearishScore = 0; - analyseXConditions.GenerateScore( - analyseBullishScore, - analyseBearishScore // - ); - - // - // Score Conditions ... - double scoreMultiplier = 3; - bool isBullishScorePassed = - // - analyseBullishScore > (analyseBearishScore * scoreMultiplier) && - decisionBullishScore > (decisionBearishScore * scoreMultiplier) - // - ; - bool isBearishScorePassed = - // - analyseBearishScore > (analyseBullishScore * scoreMultiplier) && - decisionBearishScore > (decisionBullishScore * scoreMultiplier) - // - ; - - // - // Checking Other Conditions - - // - bool isCommonBullish = - // - decisionXConditions.isSarBullish && - decisionXConditions.isStrBullish && - decisionXConditions.isCheBullish && - decisionXConditions.isSMHKBullish && - decisionXConditions.isRawHKBullish && - decisionXConditions.isRawHKClosedOverSMHK - // - ; - - // - bool isCommonBearish = - // - decisionXConditions.isSarBearish && - decisionXConditions.isStrBearish && - decisionXConditions.isCheBearish && - decisionXConditions.isSMHKBearish && - decisionXConditions.isRawHKBearish && - decisionXConditions.isRawHKClosedUnderSMHK - // - ; - - // - // X3Ma ... - - // - // X3Ma Bullish ... - bool isX3MaBullish = - // - decisionXConditions.isX3MaBullishState && - decisionXConditions.isX3MaSwitchedToBullishOrdered && - decisionXConditions.x3maMidBuffer[1] > decisionXConditions.x3maSlowBuffer[1] - // - ; - - // - // X3Ma Bearish ... - bool isX3MaBearish = - // - decisionXConditions.isX3MaBearishState && - decisionXConditions.isX3MaSwitchedToBearishOrdered && - decisionXConditions.x3maMidBuffer[1] < decisionXConditions.x3maSlowBuffer[1] - // - ; - - // - bool isX3MaHasCondition = - (isX3MaBullish && - isCommonBullish && - isBullishScorePassed) || - (isX3MaBearish && - isCommonBearish && - isBearishScorePassed); - - // - // VWap ... - - // - // VWap Bullish ... - bool isVWapBullish = - // - decisionXConditions.isVWapBullishState && - decisionXConditions.isVWapSwitchedToBullishOrdered && - decisionXConditions.vwapMidBuffer[1] > decisionXConditions.vwapSlowBuffer[1] - // - ; - - // - // VWap Bearish ... - bool isVWapBearish = - // - decisionXConditions.isVWapBearishState && - decisionXConditions.isVWapSwitchedToBearishOrdered && - decisionXConditions.vwapMidBuffer[1] < decisionXConditions.vwapSlowBuffer[1] - // - ; - - // - bool isVWapHasCondition = - (isVWapBullish && - isBullishScorePassed) || - (isVWapBearish && - isBearishScorePassed); - - // - // Senario .... - // - a vale Under X3MA Slow when X3MA Bullish Ordered ... - - // - bool isX3MASenarioBBullish = - // - decisionXConditions.isX3MaBullishOrdered && - decisionXConditions.valesBuffer[1] < decisionXConditions.x3maSlowBuffer[1] && - decisionXConditions.valesBuffer[2] >= decisionXConditions.x3maSlowBuffer[2] - // - ; - if (isX3MASenarioBBullish) - { - } - - // - bool isX3MASenarioBBearish = - // - decisionXConditions.isX3MaBearishOrdered && - decisionXConditions.peaksBuffer[1] > decisionXConditions.x3maSlowBuffer[1] && - decisionXConditions.peaksBuffer[2] <= decisionXConditions.x3maSlowBuffer[2] - // - ; - if (isX3MASenarioBBearish) - { - } - - // - // Checking Other Conditions XWZ Reject on EMA 20 ... - - // - // Check Has Conditions ... - bool hasXConditions = - (isX3MaHasCondition || - isVWapHasCondition); - - // - result = hasXConditions; - if (!result) - { - return result; - } - - // - if (isX3MaHasCondition) + count = CountWaitingBoxes(); + for (int i = 0; i < count; i++) { // - signalDir = - isX3MaBullish - ? X_DIRECTION_BULLISH - : isX3MaBearish - ? X_DIRECTION_BEARISH - : X_DIRECTION_NONE; - } + XBoxZone iBox = waitingBoxes[i]; - // - if (isVWapHasCondition) - { - // - signalDir = - isVWapBullish - ? X_DIRECTION_BULLISH - : isVWapBearish - ? X_DIRECTION_BEARISH - : X_DIRECTION_NONE; - } - - // - // Creating SignalBox ... - - // - // Detect Box based on PV ... - bool hasSignalBox = decisionCycleHelper.GeneratePVBox( - signalBox, - barIndex // - ); - - // - result = - hasSignalBox && - signalDir == signalBox.dir; - - // - if (result) - { // XCBoxObject *iObj; bool isCreated = drawer.DrawBox( - signalBox, + iBox, iObj // ); + + // if (isCreated) { - // - iObj.BoxWidth(1); - iObj.BoxColor(clrYellow); - iObj.BoxStyle(STYLE_SOLID); + mWorkingZoneObjects.Add(iObj); } // - Print("Senario A ..."); + iBox.Clean(); } + } +} +// +// Inside Boxes ... +if (drawInsideBoxes) +{ + // + has = HasInsideBoxes(); + if (has) + { + } +} + +// +// Breaked Boxes ... +if (drawBreakedBoxes) +{ + // + has = HasBreakedBoxes(); + if (has) + { // + } +} + +// +// Breaked Inside Boxes ... +if (drawBreakedInsideBoxes) +{ + // + has = HasBreakedInsideBoxes(); + if (has) + { + // + count = CountBreakedInsideBoxes(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox = breakedInsideBoxes[i]; + XCBoxObject *iObj; + has = drawer.DrawBox( + iBox, + iObj // + ); + if (has) + { + // + iObj.BoxWidth(1); + mBreakedInsideZoneObjects.Add(iObj); + } + } + } +} + +////////////////////////////////////////////////////////////////////////////////// + +// +XCSupplyZone *supplyZone; +XCDemandZone *demandZone; + +// +XCSupplyZone *supplyZones[]; +XCDemandZone *demandZones[]; + +// +XCSupportZone *supportZones[]; +XCResistanceZone *resistanceZones[]; + +// +XBoxZone insideBoxes[]; +XBoxZone breakedBoxes[]; +XBoxZone waitingBoxes[]; +XBoxZone breakedInsideBoxes[]; +XConsolidationZone consolidationZones[]; + +// +bool mUseSupDems; +bool mUseOrderBlocks; +bool mUseFairValueGaps; + +// +// +// + +// // +// // Supply Zones ... +// has = HasSupplyZones(); +// if (!has) +// { +// // +// count = mtfState.FilterSupplyZones( +// supplyZones, +// period, +// XZONE_STATE_PASSED, +// false, +// XZONE_STATE_FAILED, +// false, +// XZONE_STATE_FAILED, +// false, +// XZONE_STATE_IGNORED, +// false // +// ); +// } + +// // +// // Demand Zones ... +// has = HasDemandZones(); +// if (!has) +// { +// // +// count = mtfState.FilterDemandZones( +// demandZones, +// period, +// XZONE_STATE_PASSED, +// false, +// XZONE_STATE_FAILED, +// false, +// XZONE_STATE_FAILED, +// false, +// XZONE_STATE_IGNORED, +// false // +// ); +// } + +// +// Support Zones ... +// has = HasSupportZones(); +// if (!has) +// { +// // +// count = mtfState.FilterSupportZones( +// supportZones, +// period, +// XZONE_STATE_PASSED, +// false, +// XZONE_STATE_FAILED, +// false, +// XZONE_STATE_FAILED, +// false, +// XZONE_STATE_IGNORED, +// false // +// ); +// } + +// +// Resistance Zones ... +// has = HasResistanceZones(); +// if (!has) +// { +// // +// count = mtfState.FilterResistanceZones( +// resistanceZones, +// period, +// XZONE_STATE_PASSED, +// false, +// XZONE_STATE_FAILED, +// false, +// XZONE_STATE_FAILED, +// false, +// XZONE_STATE_IGNORED, +// false // +// ); +// } + +// +// Update Exists Zones ... + +// +// Supply Zones ... +has = mtfState.HasSupplyZones(); +if (has) +{ + // + XCSupplyZone *zone; + idx = GetYoungest(mtfState.supplyZones); + has = IsValidIndex(idx); + if (has) + { + // + zone = mtfState.supplyZones[idx]; + has = IsSupplyExists(zone); + if (!has) + { + // + Add( + zone, + supplyZones // + ); + } + else + { + ZeroMemory(zone); + } + } +} + +// +// Demand Zones ... +has = mtfState.HasDemandZones(); +if (has) +{ + // + XCDemandZone *zone; + idx = GetYoungest(mtfState.demandZones); + has = IsValidIndex(idx); + if (has) + { + // + zone = mtfState.demandZones[idx]; + has = IsDemandExists(zone); + if (!has) + { + // + Add( + zone, + demandZones // + ); + } + else + { + ZeroMemory(zone); + } + } +} + +/////////////////////////////////////////////////////////////////////////// + +// +bool IsExists(XBoxZone &box) +{ + // + bool result = false; + + // + result = box.IsValid(); + if (!result) + { return result; } // - bool DetetctSenarioBSignalBox( - XBoxZone &signalBox, - ENUM_X_DIRECTION &signalDir, - X121Conditions &decisionXConditions, - X121Conditions &analyseXConditions, - XC121SMCCycleHelper *decisionCycleHelper, - int barIndex = 0 // - ) + int idx = -1; + bool has = false; + + // + // Checking Index Waiting Box ... + has = HasWaitingBoxes(); + if (has) { // - bool result = false; - - // - signalBox.Clean(); - signalDir = X_DIRECTION_NONE; - - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - result = decisionCycleHelper != NULL; + idx = FindIndex( + box, + waitingBoxes // + ); + result = !IsValidIndex(idx); if (!result) { return result; } + } + // + // Checking Index Inside Boxes ... + has = HasInsideBoxes(); + if (has) + { // - // Decision ... - double decisionBullishScore = 0; - double decisionBearishScore = 0; - decisionXConditions.GenerateScore( - decisionBullishScore, - decisionBearishScore // + idx = FindIndex( + box, + insideBoxes // ); + result = !IsValidIndex(idx); + if (!result) + { + return result; + } + } + // + // Checking Index Breaked Boxes ... + has = HasBreakedBoxes(); + if (has) + { // - // Analyse ... - double analyseBullishScore = 0; - double analyseBearishScore = 0; - analyseXConditions.GenerateScore( - analyseBullishScore, - analyseBearishScore // + idx = FindIndex( + box, + breakedBoxes // ); - - // - // Score Conditions ... - double scoreMultiplier = 3; - bool isBullishScorePassed = - // - analyseBullishScore > (analyseBearishScore * scoreMultiplier) && - decisionBullishScore > (decisionBearishScore * scoreMultiplier) - // - ; - bool isBearishScorePassed = - // - analyseBearishScore > (analyseBullishScore * scoreMultiplier) && - decisionBearishScore > (decisionBullishScore * scoreMultiplier) - // - ; - - // - // Senario .... - // - a vale Under X3MA Slow when X3MA Bullish Ordered ... - - // - bool isX3MASenarioBBullish = - // - decisionXConditions.isX3MaBullishOrdered && - decisionXConditions.valesBuffer[1] < decisionXConditions.x3maSlowBuffer[1] && - decisionXConditions.valesBuffer[2] >= decisionXConditions.x3maSlowBuffer[2] - // - ; - if (isX3MASenarioBBullish) + result = !IsValidIndex(idx); + if (!result) { + return result; } + } + // + // Checking Index BreakedInside Boxes ... + has = HasBreakedInsideBoxes(); + if (has) + { // - bool isX3MASenarioBBearish = - // - decisionXConditions.isX3MaBearishOrdered && - decisionXConditions.peaksBuffer[1] > decisionXConditions.x3maSlowBuffer[1] && - decisionXConditions.peaksBuffer[2] <= decisionXConditions.x3maSlowBuffer[2] - // - ; - if (isX3MASenarioBBearish) + idx = FindIndex( + box, + breakedInsideBoxes // + ); + result = !IsValidIndex(idx); + if (!result) { + return result; } + } - // + // + return result; +} + +// +bool IsSupplyExists(XCSupplyZone *zone) +{ + // + bool result = false; + + // + result = zone != NULL && + zone.IsValid(); + if (!result) + { return result; } - // - bool HasSupplyZones() + // Converts Zone to Box ... + XBoxZone box; + result = ToBox( + box, + zone // + ); + if (!result) { - return HasChild(supplyZones); - } - - // - int CountSupplyZones() - { - return ArraySize(supplyZones); - } - - // - bool HasDemandZones() - { - return HasChild(demandZones); - } - - // - int CountDemandZones() - { - return ArraySize(demandZones); - } - - // - bool HasSupportZones() - { - return HasChild(supportZones); - } - - // - int CountSupportZones() - { - return ArraySize(supportZones); - } - - // - bool HasResistanceZones() - { - return HasChild(resistanceZones); - } - - // - int CountResistanceZones() - { - return ArraySize(resistanceZones); - } - - // - bool HasConsolidationZones() - { - return HasChild(consolidationZones); - } - - // - int CountConsolidationZones() - { - return ArraySize(consolidationZones); - } - - // - bool HasWaitingBoxes() - { - return HasChild(waitingBoxes); - } - - // - int CountWaitingBoxes() - { - return ArraySize(waitingBoxes); - } - - // - bool HasInsideBoxes() - { - return HasChild(insideBoxes); - } - - // - int CountInsideBoxes() - { - return ArraySize(insideBoxes); - } - - // - bool HasBreakedBoxes() - { - return HasChild(breakedBoxes); - } - - // - int CountBreakedBoxes() - { - return ArraySize(breakedBoxes); - } - - // - bool HasBreakedInsideBoxes() - { - return HasChild(breakedInsideBoxes); - } - - // - int CountBreakedInsideBoxes() - { - return ArraySize(breakedInsideBoxes); - } - -/////////////////////////////////////////////////////////////////////////////////// - // - has = ttfState.HasConsolidationZones(); - if (has) - { - // - Copy( - ttfState.consolidationZones, - consolidationZones // - ); - CleanupArray( - consolidationZones, - 50 // - ); - } + box.Clean(); + return result; + } + // + // Checking Index in SupplyZones ... + int idx = FindIndex( + zone, + supplyZones // + ); + result = !IsValidIndex(idx); + if (!result) + { + // + box.Clean(); + return result; + } + // + result = IsExists(box); + + // + box.Clean(); + + // + return result; +} + +// +bool IsDemandExists(XCDemandZone *zone) +{ + // + bool result = false; + + // + result = zone != NULL && + zone.IsValid(); + if (!result) + { + return result; + } + + // + // Converts Zone to Box ... + XBoxZone box; + result = ToBox( + box, + zone // + ); + if (!result) + { + // + box.Clean(); + return result; + } + + // + // Checking Index in SupplyZones ... + int idx = FindIndex( + zone, + demandZones // + ); + result = !IsValidIndex(idx); + if (!result) + { + // + box.Clean(); + return result; + } + + // + result = IsExists(box); + + // + box.Clean(); + + // + return result; +} + +////////////////////////////////////////////////////////////////////////////// + +// +Clean(supplyZones); +Clean(demandZones); + +// +Clean(insideBoxes); +Clean(breakedBoxes); +Clean(waitingBoxes); + +// +Clean(supportZones); +Clean(resistanceZones); + +// +mUseSupDems = false; +mUseOrderBlocks = true; +mUseFairValueGaps = true; + +///////////////////////////////////////////////////////////////////////////// + +// +bool HasInsideBox( + XBoxZone &box // +) +{ + // + bool result = false; + + // + int index = -1; + + // + result = box.IsValid(); + if (!result) + { + return result; + } + + // + int count = 0; + bool has = false; + + // + has = HasWaitingBoxes(); + if (has) + { + // + result = HasInsideBox( + index, + box, + waitingBoxes // + ); + } + + // + // Supply Zones ... + if (!result) + { // has = HasSupplyZones(); if (has) { // - count = CountSupplyZones(); - for (int i = 0; i < count; i++) - { - supplyZones[i].To(value); - } - } + XBoxZone tmpBoxes[]; + count = ToBox( + supplyZones, + tmpBoxes // + ); + // + has = IsValidSize(count); + if (has) + { + // + result = HasInsideBox( + index, + box, + tmpBoxes // + ); + } + + // + Clean(tmpBoxes); + } + } + + // + // Demand Zones ... + if (!result) + { // has = HasDemandZones(); if (has) { // - count = CountDemandZones(); - for (int i = 0; i < count; i++) - { - demandZones[i].To(value); - } - } - - // - has = HasSupportZones(); - if (has) - { - // - count = CountSupportZones(); - for (int i = 0; i < count; i++) - { - supportZones[i].To(value); - } - } - - // - has = HasResistanceZones(); - if (has) - { - // - count = CountResistanceZones(); - for (int i = 0; i < count; i++) - { - resistanceZones[i].To(value); - } - } - - // - // - // - - // - has = HasWaitingBoxes(); - if (has) - { - // - count = ArraySize(waitingBoxes); - for (int i = 0; i < count; i++) - { - waitingBoxes[i].to = value; - } - } - - // - has = HasInsideBoxes(); - if (has) - { - // - count = CountInsideBoxes(); - for (int i = 0; i < count; i++) - { - insideBoxes[i].to = value; - } - } - - // - has = HasBreakedBoxes(); - if (has) - { - } - - // - has = HasBreakedInsideBoxes(); - if (has) - { - // - count = CountBreakedInsideBoxes(); - for (int i = 0; i < count; i++) - { - breakedInsideBoxes[i].to = value; - } - } - -/////////////////////////////////////////////////////////////////////////////////// + XBoxZone tmpBoxes[]; + count = ToBox( + demandZones, + tmpBoxes // + ); // - XBoxZone waitingBoxes[]; - has = workingZone.HasWaitingBoxes(); + has = IsValidSize(count); if (has) { // - Copy( - workingZone.waitingBoxes, - waitingBoxes // + result = HasInsideBox( + index, + box, + tmpBoxes // ); - - // - while (HasChild(waitingBoxes)) - { - // - XBoxZone iBox; - idx = GetYoungest(waitingBoxes); - has = IsValidIndex(idx); - if (!has) - { - // - iBox.Clean(); - continue; - } - - // - iBox = waitingBoxes[idx]; - ArrayRemove( - waitingBoxes, - idx, - 1 // - ); - - // - bool hasInside = workingZone.HasInsideBox(iBox); - if (!hasInside) - { - continue; - } - - // - double iTarget = - IsBullish(signalBoxDir) - ? iBox.lower - : iBox.upper; - - // - Add( - iTarget, - targets // - ); - - // - iBox.Clean(); - } } + // + Clean(tmpBoxes); + } + } + + // + result = IsValidIndex(index); + + // + return result; +} + +// +bool DetectSenarioASignalBox( + XBoxZone &signalBox, + ENUM_X_DIRECTION &signalDir, + X121Conditions &decisionXConditions, + X121Conditions &analyseXConditions, + XC121SMCCycleHelper *decisionCycleHelper, + XCPOIDrawer *drawer = NULL, + int barIndex = 0 // +) +{ + // + bool result = false; + + // + signalBox.Clean(); + signalDir = X_DIRECTION_NONE; + + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + result = decisionCycleHelper != NULL; + if (!result) + { + return result; + } + + // + // Decision ... + double decisionBullishScore = 0; + double decisionBearishScore = 0; + decisionXConditions.GenerateScore( + decisionBullishScore, + decisionBearishScore // + ); + + // + // Analyse ... + double analyseBullishScore = 0; + double analyseBearishScore = 0; + analyseXConditions.GenerateScore( + analyseBullishScore, + analyseBearishScore // + ); + + // + // Score Conditions ... + double scoreMultiplier = 3; + bool isBullishScorePassed = + // + analyseBullishScore > (analyseBearishScore * scoreMultiplier) && + decisionBullishScore > (decisionBearishScore * scoreMultiplier) + // + ; + bool isBearishScorePassed = + // + analyseBearishScore > (analyseBullishScore * scoreMultiplier) && + decisionBearishScore > (decisionBullishScore * scoreMultiplier) + // + ; + + // + // Checking Other Conditions + + // + bool isCommonBullish = + // + decisionXConditions.isSarBullish && + decisionXConditions.isStrBullish && + decisionXConditions.isCheBullish && + decisionXConditions.isSMHKBullish && + decisionXConditions.isRawHKBullish && + decisionXConditions.isRawHKClosedOverSMHK + // + ; + + // + bool isCommonBearish = + // + decisionXConditions.isSarBearish && + decisionXConditions.isStrBearish && + decisionXConditions.isCheBearish && + decisionXConditions.isSMHKBearish && + decisionXConditions.isRawHKBearish && + decisionXConditions.isRawHKClosedUnderSMHK + // + ; + + // + // X3Ma ... + + // + // X3Ma Bullish ... + bool isX3MaBullish = + // + decisionXConditions.isX3MaBullishState && + decisionXConditions.isX3MaSwitchedToBullishOrdered && + decisionXConditions.x3maMidBuffer[1] > decisionXConditions.x3maSlowBuffer[1] + // + ; + + // + // X3Ma Bearish ... + bool isX3MaBearish = + // + decisionXConditions.isX3MaBearishState && + decisionXConditions.isX3MaSwitchedToBearishOrdered && + decisionXConditions.x3maMidBuffer[1] < decisionXConditions.x3maSlowBuffer[1] + // + ; + + // + bool isX3MaHasCondition = + (isX3MaBullish && + isCommonBullish && + isBullishScorePassed) || + (isX3MaBearish && + isCommonBearish && + isBearishScorePassed); + + // + // VWap ... + + // + // VWap Bullish ... + bool isVWapBullish = + // + decisionXConditions.isVWapBullishState && + decisionXConditions.isVWapSwitchedToBullishOrdered && + decisionXConditions.vwapMidBuffer[1] > decisionXConditions.vwapSlowBuffer[1] + // + ; + + // + // VWap Bearish ... + bool isVWapBearish = + // + decisionXConditions.isVWapBearishState && + decisionXConditions.isVWapSwitchedToBearishOrdered && + decisionXConditions.vwapMidBuffer[1] < decisionXConditions.vwapSlowBuffer[1] + // + ; + + // + bool isVWapHasCondition = + (isVWapBullish && + isBullishScorePassed) || + (isVWapBearish && + isBearishScorePassed); + + // + // Senario .... + // - a vale Under X3MA Slow when X3MA Bullish Ordered ... + + // + bool isX3MASenarioBBullish = + // + decisionXConditions.isX3MaBullishOrdered && + decisionXConditions.valesBuffer[1] < decisionXConditions.x3maSlowBuffer[1] && + decisionXConditions.valesBuffer[2] >= decisionXConditions.x3maSlowBuffer[2] + // + ; + if (isX3MASenarioBBullish) + { + } + + // + bool isX3MASenarioBBearish = + // + decisionXConditions.isX3MaBearishOrdered && + decisionXConditions.peaksBuffer[1] > decisionXConditions.x3maSlowBuffer[1] && + decisionXConditions.peaksBuffer[2] <= decisionXConditions.x3maSlowBuffer[2] + // + ; + if (isX3MASenarioBBearish) + { + } + + // + // Checking Other Conditions XWZ Reject on EMA 20 ... + + // + // Check Has Conditions ... + bool hasXConditions = + (isX3MaHasCondition || + isVWapHasCondition); + + // + result = hasXConditions; + if (!result) + { + return result; + } + + // + if (isX3MaHasCondition) + { + // + signalDir = + isX3MaBullish + ? X_DIRECTION_BULLISH + : isX3MaBearish + ? X_DIRECTION_BEARISH + : X_DIRECTION_NONE; + } + + // + if (isVWapHasCondition) + { + // + signalDir = + isVWapBullish + ? X_DIRECTION_BULLISH + : isVWapBearish + ? X_DIRECTION_BEARISH + : X_DIRECTION_NONE; + } + + // + // Creating SignalBox ... + + // + // Detect Box based on PV ... + bool hasSignalBox = decisionCycleHelper.GeneratePVBox( + signalBox, + barIndex // + ); + + // + result = + hasSignalBox && + signalDir == signalBox.dir; + + // + if (result) + { + // + XCBoxObject *iObj; + bool isCreated = drawer.DrawBox( + signalBox, + iObj // + ); + if (isCreated) + { + // + iObj.BoxWidth(1); + iObj.BoxColor(clrYellow); + iObj.BoxStyle(STYLE_SOLID); + } + + // + Print("Senario A ..."); + } + + // + return result; +} + +// +bool DetetctSenarioBSignalBox( + XBoxZone &signalBox, + ENUM_X_DIRECTION &signalDir, + X121Conditions &decisionXConditions, + X121Conditions &analyseXConditions, + XC121SMCCycleHelper *decisionCycleHelper, + int barIndex = 0 // +) +{ + // + bool result = false; + + // + signalBox.Clean(); + signalDir = X_DIRECTION_NONE; + + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + result = decisionCycleHelper != NULL; + if (!result) + { + return result; + } + + // + // Decision ... + double decisionBullishScore = 0; + double decisionBearishScore = 0; + decisionXConditions.GenerateScore( + decisionBullishScore, + decisionBearishScore // + ); + + // + // Analyse ... + double analyseBullishScore = 0; + double analyseBearishScore = 0; + analyseXConditions.GenerateScore( + analyseBullishScore, + analyseBearishScore // + ); + + // + // Score Conditions ... + double scoreMultiplier = 3; + bool isBullishScorePassed = + // + analyseBullishScore > (analyseBearishScore * scoreMultiplier) && + decisionBullishScore > (decisionBearishScore * scoreMultiplier) + // + ; + bool isBearishScorePassed = + // + analyseBearishScore > (analyseBullishScore * scoreMultiplier) && + decisionBearishScore > (decisionBullishScore * scoreMultiplier) + // + ; + + // + // Senario .... + // - a vale Under X3MA Slow when X3MA Bullish Ordered ... + + // + bool isX3MASenarioBBullish = + // + decisionXConditions.isX3MaBullishOrdered && + decisionXConditions.valesBuffer[1] < decisionXConditions.x3maSlowBuffer[1] && + decisionXConditions.valesBuffer[2] >= decisionXConditions.x3maSlowBuffer[2] + // + ; + if (isX3MASenarioBBullish) + { + } + + // + bool isX3MASenarioBBearish = + // + decisionXConditions.isX3MaBearishOrdered && + decisionXConditions.peaksBuffer[1] > decisionXConditions.x3maSlowBuffer[1] && + decisionXConditions.peaksBuffer[2] <= decisionXConditions.x3maSlowBuffer[2] + // + ; + if (isX3MASenarioBBearish) + { + } + + // + return result; +} + +// +bool HasSupplyZones() +{ + return HasChild(supplyZones); +} + +// +int CountSupplyZones() +{ + return ArraySize(supplyZones); +} + +// +bool HasDemandZones() +{ + return HasChild(demandZones); +} + +// +int CountDemandZones() +{ + return ArraySize(demandZones); +} + +// +bool HasSupportZones() +{ + return HasChild(supportZones); +} + +// +int CountSupportZones() +{ + return ArraySize(supportZones); +} + +// +bool HasResistanceZones() +{ + return HasChild(resistanceZones); +} + +// +int CountResistanceZones() +{ + return ArraySize(resistanceZones); +} + +// +bool HasConsolidationZones() +{ + return HasChild(consolidationZones); +} + +// +int CountConsolidationZones() +{ + return ArraySize(consolidationZones); +} + +// +bool HasWaitingBoxes() +{ + return HasChild(waitingBoxes); +} + +// +int CountWaitingBoxes() +{ + return ArraySize(waitingBoxes); +} + +// +bool HasInsideBoxes() +{ + return HasChild(insideBoxes); +} + +// +int CountInsideBoxes() +{ + return ArraySize(insideBoxes); +} + +// +bool HasBreakedBoxes() +{ + return HasChild(breakedBoxes); +} + +// +int CountBreakedBoxes() +{ + return ArraySize(breakedBoxes); +} + +// +bool HasBreakedInsideBoxes() +{ + return HasChild(breakedInsideBoxes); +} + +// +int CountBreakedInsideBoxes() +{ + return ArraySize(breakedInsideBoxes); +} + /////////////////////////////////////////////////////////////////////////////////// +// +has = ttfState.HasConsolidationZones(); +if (has) +{ // - void Update( - int barIndex, - XPOIState &htfState, - XPOIState &mtfState, - XPOIState &stfState, - XPOIState &ttfState // - ) + Copy( + ttfState.consolidationZones, + consolidationZones // + ); + CleanupArray( + consolidationZones, + 50 // + ); +} + +// +has = HasSupplyZones(); +if (has) +{ + // + count = CountSupplyZones(); + for (int i = 0; i < count; i++) + { + supplyZones[i].To(value); + } +} + +// +has = HasDemandZones(); +if (has) +{ + // + count = CountDemandZones(); + for (int i = 0; i < count; i++) + { + demandZones[i].To(value); + } +} + +// +has = HasSupportZones(); +if (has) +{ + // + count = CountSupportZones(); + for (int i = 0; i < count; i++) + { + supportZones[i].To(value); + } +} + +// +has = HasResistanceZones(); +if (has) +{ + // + count = CountResistanceZones(); + for (int i = 0; i < count; i++) + { + resistanceZones[i].To(value); + } +} + +// +// +// + +// +has = HasWaitingBoxes(); +if (has) +{ + // + count = ArraySize(waitingBoxes); + for (int i = 0; i < count; i++) + { + waitingBoxes[i].to = value; + } +} + +// +has = HasInsideBoxes(); +if (has) +{ + // + count = CountInsideBoxes(); + for (int i = 0; i < count; i++) + { + insideBoxes[i].to = value; + } +} + +// +has = HasBreakedBoxes(); +if (has) +{ +} + +// +has = HasBreakedInsideBoxes(); +if (has) +{ + // + count = CountBreakedInsideBoxes(); + for (int i = 0; i < count; i++) + { + breakedInsideBoxes[i].to = value; + } +} + +/////////////////////////////////////////////////////////////////////////////////// + +// +XBoxZone waitingBoxes[]; +has = workingZone.HasWaitingBoxes(); +if (has) +{ + // + Copy( + workingZone.waitingBoxes, + waitingBoxes // + ); + + // + while (HasChild(waitingBoxes)) { // - int idx = -1; - int count = 0; - bool has = false; - - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - has = - // - IsValid() && - // - htfState.IsValid() && - mtfState.IsValid() && - stfState.IsValid() && - // - htfState.HasChild() && - mtfState.HasChild() && - stfState.HasChild() - // - ; + XBoxZone iBox; + idx = GetYoungest(waitingBoxes); + has = IsValidIndex(idx); if (!has) { - return; + // + iBox.Clean(); + continue; } // - XOHCL zBar; - has = zBar.Init( - symbol, - period, - barIndex // + iBox = waitingBoxes[idx]; + ArrayRemove( + waitingBoxes, + idx, + 1 // ); - if (!has) + + // + bool hasInside = workingZone.HasInsideBox(iBox); + if (!hasInside) { - // - zBar.Clean(); - return; + continue; } // - XOHCL cBar; - has = zBar.GetPreviousBar(cBar); - if (!has) - { - // - zBar.Clean(); - cBar.Clean(); - - // - return; - } + double iTarget = + IsBullish(signalBoxDir) + ? iBox.lower + : iBox.upper; // - // Cleanup Resource ... + Add( + iTarget, + targets // + ); + // + iBox.Clean(); + } +} + +/////////////////////////////////////////////////////////////////////////////////// + +// +void Update( + int barIndex, + XPOIState &htfState, + XPOIState &mtfState, + XPOIState &stfState, + XPOIState &ttfState // +) +{ + // + int idx = -1; + int count = 0; + bool has = false; + + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + has = + // + IsValid() && + // + htfState.IsValid() && + mtfState.IsValid() && + stfState.IsValid() && + // + htfState.HasChild() && + mtfState.HasChild() && + stfState.HasChild() + // + ; + if (!has) + { + return; + } + + // + XOHCL zBar; + has = zBar.Init( + symbol, + period, + barIndex // + ); + if (!has) + { + // + zBar.Clean(); + return; + } + + // + XOHCL cBar; + has = zBar.GetPreviousBar(cBar); + if (!has) + { // zBar.Clean(); cBar.Clean(); + + // + return; } + // + // Cleanup Resource ... + + // + zBar.Clean(); + cBar.Clean(); +} + /////////////////////////////////////////////////////////////////////////////////// // @@ -10530,31 +10505,370 @@ int ExtractOBFVGs( /////////////////////////////////////////////////////////////////////////////////// +// // +// XCBaseObject *obObject; +// bool isCreated = drawer.CreateOrderBlock( +// obFVG.ob, +// obObject // +// ); + +// // +// count = obFVG.CountFVGs(); +// for (int i = 0; i < count; i++) +// { +// // +// XCBaseObject *fvgObject; +// isCreated = drawer.CreateFairValueGap( +// obFVG.fvgs[i], +// fvgObject // +// ); +// } /////////////////////////////////////////////////////////////////////////////////// +// +// Detect OB FVG ... +// result = +// hasNewOrderBlock && +// hasNewFairValueGap && +// ob.GetDirection() == fvg.GetDirection(); +// if (result) +// { +// // +// obFVG.ob = ob; +// obFVG.AddFVG(fvg); + +// // +// has = obFVG.IsValid(); +// if (has) +// { +// // +// has = IsExists(obFVG); +// if (!has) +// { +// // +// // New Waiting Zone ... +// AddRef( +// obFVG, +// waitingZones // +// ); +// } +// else +// { +// // +// // Check Item Is not Exists ... +// idx = FindIndex( +// obFVG, +// waitingZones // +// ); +// has = !IsValidIndex(idx); +// if (!has) +// { +// // +// // Update Exists Waiting Zone ... +// waitingZones[idx].AddFVG(fvg); +// } +// } +// } +// } + +// // +// XCFVG *decisionFVG; +// bool hasNewDecisionFVG = +// Contains( +// X_BULLISH_FVG_DETECTED, +// provider +// .decisionPoiEvents // +// ) || +// Contains( +// X_BEARISH_FVG_DETECTED, +// provider +// .decisionPoiEvents // +// ); +// if (hasNewDecisionFVG) +// { +// // +// idx = GetYoungest(provider +// .decisionState +// .fairValueGaps // +// ); +// has = IsValidIndex(idx); +// if (has) +// { +// // +// decisionFVG = provider +// .decisionState +// .fairValueGaps[idx]; + +// // +// XCBaseObject *iObj; +// bool isCreated = drawer.CreateFairValueGap( +// decisionFVG, +// iObj // +// ); + +// // +// if (isCreated) +// { +// Print("New Fair Value Gap ..."); +// } +// } +// } + +// +// Detect SupDem FVG ... +// if (!result) +// { +// // +// result = hasNewFairValueGap && +// (hasNewSupply || +// hasNewDemand); +// if (result) +// { +// // +// // Converts Supply or Demand Zone to OrderBlock ... +// XOHCL bar; +// ob = new XCOrderBlock(); +// if (hasNewSupply) +// { +// // +// has = supply.FillBar(bar); +// if (has) +// { +// // +// has = ob.Init( +// bar, +// X_DIRECTION_BEARISH // +// ); +// if (has) +// { +// // +// ob.Upper(supply.Upper()); +// ob.Lower(supply.Lower()); +// } +// } +// } +// else if (hasNewDemand) +// { +// // +// has = demand.FillBar(bar); +// if (has) +// { +// // +// has = ob.Init( +// bar, +// X_DIRECTION_BULLISH // +// ); +// if (has) +// { +// // +// ob.Upper(demand.Upper()); +// ob.Lower(demand.Lower()); +// } +// } +// } + +// // +// obFVG.ob = ob; +// obFVG.AddFVG(fvg); + +// // +// has = obFVG.IsValid(); +// if (has) +// { +// // +// // Check Item Is not Exists ... +// idx = FindIndex( +// obFVG, +// waitingZones // +// ); +// has = !IsValidIndex(idx); +// if (has) +// { +// // +// // New Waiting Zone ... +// AddRef( +// obFVG, +// waitingZones // +// ); +// } +// else +// { +// // +// // Update Exists Waiting Zone ... +// waitingZones[idx].AddFVG(fvg); +// } +// } + +// // +// bar.Clean(); +// } +// } /////////////////////////////////////////////////////////////////////////////////// +// +bool IsValidZone( + XOHCL &invalidBar, + int barIndex = 0 // +) +{ + // + bool result = false; + + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + invalidBar.Clean(); + + // + result = IsValid(); + if (!result) + { + return result; + } + + // + XCFVG *fvg; + result = GetMainFVG(fvg); + if (!result) + { + // + ZeroMemory(fvg); + return result; + } + + // + XOHCL startedBar; + bool isBodyOut = false; + result = fvg.IsStarted( + fvg.GetDirection(), + startedBar, + isBodyOut // + ); + if (!result) + { + // + ZeroMemory(fvg); + startedBar.Clean(); + + // + return result; + } + + // + XOHCL bar; + bool isBullish = fvg.IsBullish(); + + // + int fromIndex = iBarShift( + fvg.GetSymbol(), + fvg.GetPeriod(), + startedBar.NextAt() // + ); + result = IsValidIndex(fromIndex); + if (!result) + { + // + bar.Clean(); + ZeroMemory(fvg); + startedBar.Clean(); + + // + return result; + } + + // + bool isInited = false; + for (int i = barIndex; i < fromIndex; i++) + { + // + isInited = bar.Init( + fvg.GetSymbol(), + fvg.GetPeriod(), + i // + ); + if (!isInited) + { + // + bar.Clean(); + continue; + } + + // + bool isBarAbove = + bar.low > fvg.Upper(); + bool isBarBelow = + bar.high < fvg.Lower(); + + // + result = + isBullish + ? isBarAbove + : isBarBelow; + if (!result) + { + // + invalidBar = bar; + bar.Clean(); + + // + break; + } + + // + bar.Clean(); + } + + // + bar.Clean(); + ZeroMemory(fvg); + startedBar.Clean(); + + // + return result; +} /////////////////////////////////////////////////////////////////////////////////// +// +// XBoxZone iBox; +// result = iOBFVG.ToZone(iBox); +// if (!result) +// { +// // +// iBox.Clean(); +// iOBFVG.Clean(); + +// // +// continue; +// } + +// +// XCFVG *fvg; +// result = iOBFVG.GetMainFVG(fvg); +// if (!result) +// { +// // +// iOBFVG.Clean(); +// ZeroMemory(fvg); + +// // +// continue; +// } /////////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////////////////// - - -/////////////////////////////////////////////////////////////////////////////////// - - -/////////////////////////////////////////////////////////////////////////////////// - - diff --git a/Documents/BKP/Test.mq5 b/Documents/BKP/Test.mq5 index bc4ba882..02e4a712 100644 --- a/Documents/BKP/Test.mq5 +++ b/Documents/BKP/Test.mq5 @@ -30,7 +30,7 @@ int OnInit() _Symbol, _Period // ); - // mPOIDetector.Init(); + mPOIDetector.Init(); //--- mPOIDrawer = new XCPOIDrawer(); @@ -79,130 +79,165 @@ void OnTick() mPOIDetector.GetState(mPOIState); // - bool has = mPOIState.HasFairValueGaps(); + bool has = Contains( + X_BULLISH_FVG_DETECTED, + mPOIEvents // + ) || + Contains( + X_BEARISH_FVG_DETECTED, + mPOIEvents // + ); if (has) { // - int count = mPOIState.CountFairValueGaps(); - for (int i = 0; i < count; i++) + XCFVG *fvg; + int idx = GetYoungest(mPOIState.fairValueGaps); + has = IsValidIndex(idx); + if (has) { // - mPOIState.fairValueGaps[i].To(TimeCurrent()); + fvg = mPOIState.fairValueGaps[idx]; // XCBaseObject *iObj; - bool isCreated = mPOIDrawer.CreateFairValueGap( - mPOIState.fairValueGaps[i], + has = mPOIDrawer.CreateFairValueGap( + fvg, iObj // ); - } - // - Print("Salam"); + // + if (has) + { + // + Print("New Fair Value Gap ..."); + } + } } + // // + // bool has = mPOIState.HasFairValueGaps(); + // if (has) + // { + // // + // int count = mPOIState.CountFairValueGaps(); + // for (int i = 0; i < count; i++) + // { + // // + // mPOIState.fairValueGaps[i].To(TimeCurrent()); + + // // + // XCBaseObject *iObj; + // bool isCreated = mPOIDrawer.CreateFairValueGap( + // mPOIState.fairValueGaps[i], + // iObj // + // ); + // } + + // + // Print("Salam"); + // return; - // - XOHCL bar; - bool isInited = bar.Init( - _Symbol, - _Period, - 0 // - ); - if (!isInited) - { - return; - } + // // + // XOHCL bar; + // bool isInited = bar.Init( + // _Symbol, + // _Period, + // 0 // + // ); + // if (!isInited) + // { + // return; + // } - // - int index = 0; - ENUM_X_DIRECTION sameBarDir; - bool hasSameBars = mBarAnalyser.HasSameBars( - bar, - sameBarDir, - index, - 3 // - ); - if (hasSameBars) - { - } + // // + // int index = 0; + // ENUM_X_DIRECTION sameBarDir; + // bool hasSameBars = mBarAnalyser.HasSameBars( + // bar, + // sameBarDir, + // index, + // 3 // + // ); + // if (hasSameBars) + // { + // } - // - // Detect Fair Value Gap ... - XOHCL fvgEndBar; - XOHCL fvgStartBar; - ENUM_X_DIRECTION fvgDir; - bool hasFVG = mBarAnalyser.HasFairValueGap( - bar, - fvgStartBar, - fvgEndBar, - fvgDir, - 3 // - ); - if (hasFVG) - { - // - XCFVG *fvg; - fvg = new XCFVG(); - bool isInit = fvg.Init( - fvgStartBar, - fvgEndBar, - fvgDir // - ); - // if (isInit) - // { - // // - // XCBaseObject *iObj; - // bool isCreated = mPOIDrawer.CreateFairValueGap( - // fvg, - // iObj // - // ); - // - // // - // if (isCreated) - // { - // } - // } - } + // // + // // Detect Fair Value Gap ... + // XOHCL fvgEndBar; + // XOHCL fvgStartBar; + // ENUM_X_DIRECTION fvgDir; + // bool hasFVG = mBarAnalyser.HasFairValueGap( + // bar, + // fvgStartBar, + // fvgEndBar, + // fvgDir, + // 3 // + // ); + // if (hasFVG) + // { + // // + // XCFVG *fvg; + // fvg = new XCFVG(); + // bool isInit = fvg.Init( + // fvgStartBar, + // fvgEndBar, + // fvgDir // + // ); + // // if (isInit) + // // { + // // // + // // XCBaseObject *iObj; + // // bool isCreated = mPOIDrawer.CreateFairValueGap( + // // fvg, + // // iObj // + // // ); + // // + // // // + // // if (isCreated) + // // { + // // } + // // } + // } - // - XOHCL obBar; - ENUM_X_DIRECTION obDir; - bool hasOB = mBarAnalyser.HasOrderBlock( - bar, - obBar, - obDir, - 3 // - ); - if (hasOB) - { - // - XCOrderBlock *ob; - ob = new XCOrderBlock(); - bool isInit = ob.Init( - obBar, - obDir // - ); - if (isInit) - { - // // - // XCBaseObject *iObj; - // bool isCreated = mPOIDrawer.CreateOrderBlock( - // ob, - // iObj // - // ); + // // + // XOHCL obBar; + // ENUM_X_DIRECTION obDir; + // bool hasOB = mBarAnalyser.HasOrderBlock( + // bar, + // obBar, + // obDir, + // 3 // + // ); + // if (hasOB) + // { + // // + // XCOrderBlock *ob; + // ob = new XCOrderBlock(); + // bool isInit = ob.Init( + // obBar, + // obDir // + // ); + // if (isInit) + // { + // // // + // // XCBaseObject *iObj; + // // bool isCreated = mPOIDrawer.CreateOrderBlock( + // // ob, + // // iObj // + // // ); - // // - // if (isCreated) - // { - // Print("Order Block ..."); - // } - // } - } + // // // + // // if (isCreated) + // // { + // // Print("Order Block ..."); + // // } + // // } + // } - // - } + // // + // } } //+------------------------------------------------------------------+ diff --git a/Libraries/x-saherelm.x-poi.state.lib.mq5 b/Libraries/x-saherelm.x-poi.state.lib.mq5 index b65b165b..d633525b 100644 --- a/Libraries/x-saherelm.x-poi.state.lib.mq5 +++ b/Libraries/x-saherelm.x-poi.state.lib.mq5 @@ -388,7 +388,6 @@ struct XOBFVG // bool IsValidZone( - XOHCL &invalidBar, int barIndex = 0 // ) { @@ -401,9 +400,6 @@ struct XOBFVG barIndex = 0; } - // - invalidBar.Clean(); - // result = IsValid(); if (!result) @@ -412,101 +408,132 @@ struct XOBFVG } // - XCFVG *fvg; - result = GetMainFVG(fvg); - if (!result) - { - // - ZeroMemory(fvg); - return result; - } - - // - XOHCL startedBar; - bool isBodyOut = false; - result = fvg.IsStarted( - fvg.GetDirection(), - startedBar, - isBodyOut // + XCFVG *tmpFVGs[]; + Copy( + fvgs, + tmpFVGs // ); - if (!result) + int count = CountFVGs(); + for (int i = 0; i < count; i++) { // - ZeroMemory(fvg); - startedBar.Clean(); + XCFVG *iFVG = tmpFVGs[i]; // - return result; - } - - // - XOHCL bar; - bool isBullish = fvg.IsBullish(); - - // - int fromIndex = iBarShift( - fvg.GetSymbol(), - fvg.GetPeriod(), - startedBar.NextAt() // - ); - result = IsValidIndex(fromIndex); - if (!result) - { - // - bar.Clean(); - ZeroMemory(fvg); - startedBar.Clean(); - - // - return result; - } - - // - bool isInited = false; - for (int i = barIndex; i < fromIndex; i++) - { - // - isInited = bar.Init( - fvg.GetSymbol(), - fvg.GetPeriod(), - i // + XOHCL startedBar; + bool isBodyOut = false; + result = iFVG.IsStarted( + iFVG.GetDirection(), + startedBar, + isBodyOut // ); - if (!isInited) + if (!result) { // - bar.Clean(); + ZeroMemory(iFVG); + startedBar.Clean(); + ArrayRemove( + fvgs, + i, + 1 // + ); + + // continue; } // - bool isBarAbove = - bar.low > fvg.Upper(); - bool isBarBelow = - bar.high < fvg.Lower(); + XOHCL bar; + bool isBullish = iFVG.IsBullish(); + datetime fromTime = startedBar.NextAt(); // - result = - isBullish - ? isBarAbove - : isBarBelow; + int fromIndex = iBarShift( + iFVG.GetSymbol(), + iFVG.GetPeriod(), + fromTime // + ); + result = IsValidIndex(fromIndex); if (!result) { // - invalidBar = bar; bar.Clean(); + ZeroMemory(iFVG); + startedBar.Clean(); + ArrayRemove( + fvgs, + i, + 1 // + ); // - break; + continue; + } + + // + bool isInited = false; + bool isValidFVG = false; + for (int j = barIndex; j < fromIndex; j++) + { + // + isInited = bar.Init( + iFVG.GetSymbol(), + iFVG.GetPeriod(), + j // + ); + if (!isInited) + { + // + bar.Clean(); + continue; + } + + // + bool isBarAbove = + bar.low > iFVG.Upper(); + bool isBarBelow = + bar.high < iFVG.Lower(); + + // + isValidFVG = + isBullish + ? isBarAbove + : isBarBelow; + if (!isValidFVG) + { + // + bar.Clean(); + + // + break; + } + + // + bar.Clean(); + } + + // + if (!isValidFVG) + { + // + ArrayRemove( + fvgs, + i, + 1 // + ); } // bar.Clean(); + ZeroMemory(iFVG); + startedBar.Clean(); } // - bar.Clean(); - ZeroMemory(fvg); - startedBar.Clean(); + Clean(tmpFVGs); + + // + result = HasFVGs(); // return result; diff --git a/X121SMCEA/Signals/x-121.smc.xwz.signal.class.mq5 b/X121SMCEA/Signals/x-121.smc.xwz.signal.class.mq5 index 73bad417..322d4928 100644 --- a/X121SMCEA/Signals/x-121.smc.xwz.signal.class.mq5 +++ b/X121SMCEA/Signals/x-121.smc.xwz.signal.class.mq5 @@ -164,7 +164,8 @@ class XCX121SMCXWZSignalDetector : public XCBase double targets[]; double reward = 0; XBoxZone signalBox; - XOBFVG activatedZone; + int activatedFVGIDX = 0; + int activatedZoneIDX = 0; double amountPercent = 0; bool hasPriority = false; bool hasSignalBox = false; @@ -214,16 +215,8 @@ class XCX121SMCXWZSignalDetector : public XCBase // hasWaitingZones = workingZone.DetectZone( - drawer, provider // ); - if (hasWaitingZones) - { - // - // Validate Waiting Zones ... - workingZone.ValidateWaitingZones(zIndex); - hasWaitingZones = HasChild(workingZone.waitingZones); - } // // Checking Working Zone Destory or not ... @@ -239,7 +232,6 @@ class XCX121SMCXWZSignalDetector : public XCBase // result = false; workingZone.Clean(); - activatedZone.Clean(); hasWorkingZone = false; // @@ -255,13 +247,41 @@ class XCX121SMCXWZSignalDetector : public XCBase } } + // + // Start Draw ... + // + + // + UpdateTo(cTime); + + // + // Draw Working Zone ... + if (hasWorkingZone) + { + // + workingZone.Draw( + drawer, + // + true, // Draw Supply Zone ... + true, // Draw Demand Zone ... + true, // Draw Waiting Zones ... + true // Draw Waiting Zones Box Area ... + // + ); + } + + // + // End Draw ... + // + // // Detect Signal Box ... hasSignalBox = hasWorkingZone && hasWaitingZones && workingZone.IsZoneActivated( - activatedZone, + activatedZoneIDX, + activatedFVGIDX, provider, zIndex // ); @@ -269,7 +289,14 @@ class XCX121SMCXWZSignalDetector : public XCBase { // signalBox.Clean(); - hasSignalBox = activatedZone.ToZone(signalBox); + + // + XOBFVG iOBFVG = workingZone.waitingZones[activatedZoneIDX]; + XCFVG *activatedFVG = iOBFVG.fvgs[activatedFVGIDX]; + hasSignalBox = ToBox( + signalBox, + activatedFVG // + ); if (hasSignalBox) { // @@ -278,27 +305,42 @@ class XCX121SMCXWZSignalDetector : public XCBase signalProvider = X121SMC_XWZ_PROVIDER_ACTIVATED_ZONE; // - int idx = FindIndex( - activatedZone, - workingZone.waitingZones // + ArrayRemove( + workingZone.waitingZones[activatedZoneIDX].fvgs, + activatedFVGIDX, + 1 // ); - bool has = IsValidIndex(idx); - if (has) + bool isValid = workingZone.waitingZones[activatedZoneIDX].IsValid(); + if (!isValid) { // - ArrayRemove( - workingZone.waitingZones, - idx, - 1 // + AddRef( + workingZone.waitingZones[activatedZoneIDX], + workingZone.unavailableZones // ); // - AddRef( - activatedZone, - workingZone.unavailableZones // + ArrayRemove( + workingZone.waitingZones, + activatedZoneIDX, + 1 // ); } } + + // + iOBFVG.Clean(); + ZeroMemory(activatedFVG); + } + + // + // Remove Invalidate Zones ... + if (hasWaitingZones) + { + // + // Validate Waiting Zones ... + workingZone.ValidateWaitingZones(zIndex); + hasWaitingZones = workingZone.HasWaitingZones(); } // @@ -314,10 +356,6 @@ class XCX121SMCXWZSignalDetector : public XCBase signalBoxDir = X_DIRECTION_NONE; } - // - // - // - // // Check Priority Exists ... hasPriority = workingZone @@ -732,37 +770,11 @@ class XCX121SMCXWZSignalDetector : public XCBase mConditions.setupTime = cTime; mConditions.dir = signalBoxDir; mConditions.priority = priority; - mConditions.provider = signalProvider; mConditions.signalBox = signalBox; + mConditions.provider = signalProvider; mConditions.amountPercent = amountPercent; } - // - UpdateTo(cTime); - - // - // Draw Working Zone ... - if (hasWorkingZone) - { - // - workingZone.Draw( - drawer, - // - true, // Draw Supply Zone ... - true, // Draw Demand Zone ... - true, // Draw Waiting Zones ... - true // Draw Waiting Zones Box Area ... - // - ); - - // - if (hasSignalBox) - { - // - Print("Has Signal Box ..."); - } - } - // // // @@ -779,7 +791,6 @@ class XCX121SMCXWZSignalDetector : public XCBase // signalBox.Clean(); - activatedZone.Clean(); consolidationZBar.Clean(); // diff --git a/X121SMCEA/Signals/x-121.smc.xwz.signal.lib.mq5 b/X121SMCEA/Signals/x-121.smc.xwz.signal.lib.mq5 index 0b65f1c0..f4470969 100644 --- a/X121SMCEA/Signals/x-121.smc.xwz.signal.lib.mq5 +++ b/X121SMCEA/Signals/x-121.smc.xwz.signal.lib.mq5 @@ -273,7 +273,6 @@ struct X121SMCStrategyXWZWorkingZone // bool DetectZone( - XCPOIDrawer *drawer, X121SMCStrategySignalProviderData &provider // ) { @@ -290,6 +289,7 @@ struct X121SMCStrategyXWZWorkingZone // int idx = -1; + int count = 0; bool has = false; datetime cTime = TimeCurrent(); @@ -461,15 +461,102 @@ struct X121SMCStrategyXWZWorkingZone // // Detect OB FVG ... - result = - hasNewOrderBlock && - hasNewFairValueGap && - ob.GetDirection() == fvg.GetDirection(); - if (result) + if (hasNewOrderBlock) { // - obFVG.ob = ob; - obFVG.AddFVG(fvg); + XOHCL obStartedBar; + bool isOBStartedBodyOut = false; + bool isOBStarted = ob.IsStarted( + ob.GetDirection(), + obStartedBar, + isOBStartedBodyOut // + ); + + // + has = isOBStarted && + isOBStartedBodyOut; + if (has) + { + // + obFVG.ob = ob; + + // + // Select FVGs ... + count = provider + .analyseState + .CountFairValueGaps(); + has = IsValidSize(count); + if (!has) + { + obFVG.Clean(); + } + else + { + // + // Select FVG ... + for (int i = 0; i < count; i++) + { + // + XCFVG *iFVG = provider + .analyseState + .fairValueGaps[i]; + bool isBullish = iFVG.IsBullish(); + + // + XOHCL iStartedBar; + bool isBodyOut = false; + bool isStarted = iFVG.IsStarted( + iFVG.GetDirection(), + iStartedBar, + isBodyOut // + ); + iStartedBar.Clean(); + + // + bool isKindPassed = isStarted && + isBodyOut; + bool isSameDir = iFVG.GetDirection() == ob.GetDirection(); + bool isFromPassed = iFVG.From() >= obStartedBar.time; + bool isPlacePassed = + // + IsInsideOrDiff( + iFVG, + ob // + ) + // + || + // + (isBullish + ? IsAboveDiff( + iFVG, + ob, + true // Ignore Inside ... + ) + : IsBelowDiff( + iFVG, + ob, + true // Ignore Inside ... + ) + // + ) + // + ; + + // + has = isSameDir && + isKindPassed && + isFromPassed && + isPlacePassed; + if (has) + { + obFVG.AddFVG(iFVG); + } + + // + ZeroMemory(iFVG); + } + } + } // has = obFVG.IsValid(); @@ -503,98 +590,12 @@ struct X121SMCStrategyXWZWorkingZone } } } + + // + obFVG.Clean(); + obStartedBar.Clean(); } - // - // Detect SupDem FVG ... - // if (!result) - // { - // // - // result = hasNewFairValueGap && - // (hasNewSupply || - // hasNewDemand); - // if (result) - // { - // // - // // Converts Supply or Demand Zone to OrderBlock ... - // XOHCL bar; - // ob = new XCOrderBlock(); - // if (hasNewSupply) - // { - // // - // has = supply.FillBar(bar); - // if (has) - // { - // // - // has = ob.Init( - // bar, - // X_DIRECTION_BEARISH // - // ); - // if (has) - // { - // // - // ob.Upper(supply.Upper()); - // ob.Lower(supply.Lower()); - // } - // } - // } - // else if (hasNewDemand) - // { - // // - // has = demand.FillBar(bar); - // if (has) - // { - // // - // has = ob.Init( - // bar, - // X_DIRECTION_BULLISH // - // ); - // if (has) - // { - // // - // ob.Upper(demand.Upper()); - // ob.Lower(demand.Lower()); - // } - // } - // } - - // // - // obFVG.ob = ob; - // obFVG.AddFVG(fvg); - - // // - // has = obFVG.IsValid(); - // if (has) - // { - // // - // // Check Item Is not Exists ... - // idx = FindIndex( - // obFVG, - // waitingZones // - // ); - // has = !IsValidIndex(idx); - // if (has) - // { - // // - // // New Waiting Zone ... - // AddRef( - // obFVG, - // waitingZones // - // ); - // } - // else - // { - // // - // // Update Exists Waiting Zone ... - // waitingZones[idx].AddFVG(fvg); - // } - // } - - // // - // bar.Clean(); - // } - // } - // result = HasWaitingZones(); @@ -635,6 +636,12 @@ struct X121SMCStrategyXWZWorkingZone barIndex = 0; } + // + if (barIndex == 0) + { + barIndex = 1; + } + // has = IsValid() && HasWaitingZones(); @@ -649,12 +656,7 @@ struct X121SMCStrategyXWZWorkingZone for (int i = 0; i < result; i++) { // - XOBFVG iOBFVG = waitingZones[i]; - - // - XOHCL iInvalidBar; - has = iOBFVG.IsValidZone( - iInvalidBar, + has = waitingZones[i].IsValidZone( barIndex // ); if (!has) @@ -667,13 +669,10 @@ struct X121SMCStrategyXWZWorkingZone // AddRef( - iOBFVG, + waitingZones[i], unavailableZones // ); } - - // - iInvalidBar.Clean(); } // @@ -697,7 +696,8 @@ struct X121SMCStrategyXWZWorkingZone // bool IsZoneActivated( - XOBFVG &zone, + int &zoneIDX, + int &fvgIDX, X121SMCStrategySignalProviderData &provider, int barIndex = 0 // ) @@ -706,8 +706,10 @@ struct X121SMCStrategyXWZWorkingZone bool result = false; // - // Cleanup Result ... - zone.Clean(); + zoneIDX = -1; + + // + fvgIDX = -1; // // Normalize Bar Index ... @@ -742,7 +744,6 @@ struct X121SMCStrategyXWZWorkingZone { // bar.Clean(); - zone.Clean(); // return result; @@ -752,6 +753,64 @@ struct X121SMCStrategyXWZWorkingZone double peak = provider.decisionXConditions.peaksBuffer[1]; double vale = provider.decisionXConditions.valesBuffer[1]; + // + double analysePeak = provider.analyseXConditions.peaksBuffer[1]; + double analyseVale = provider.analyseXConditions.valesBuffer[1]; + + // + double consolidationPeak = provider.consolidationXConditions.peaksBuffer[1]; + double consolidationVale = provider.consolidationXConditions.valesBuffer[1]; + + // + double visionPeak = provider.visionXConditions.peaksBuffer[1]; + double visionVale = provider.visionXConditions.valesBuffer[1]; + + // + bool isPeaksSame = + peak == analysePeak && + analysePeak == consolidationPeak; + + // + bool isValesSame = + vale == analyseVale && + analyseVale == consolidationVale; + + // + // + // + + // + bool isDecisionScoreBullish = + provider.decisionBullishScore > provider.decisionBearishScore; + + // + bool isDecisionScoreBearish = + provider.decisionBearishScore > provider.decisionBullishScore; + + // + bool isAnalyseScoreBullish = + provider.analyseBullishScore > provider.analyseBearishScore; + + // + bool isAnalyseScoreBearish = + provider.analyseBearishScore > provider.analyseBullishScore; + + // + bool isConsolidationScoreBullish = + provider.consolidationBullishScore > provider.consolidationBearishScore; + + // + bool isConsolidationScoreBearish = + provider.consolidationBearishScore > provider.consolidationBullishScore; + + // + bool isVisionScoreBullish = + provider.visionBullishScore > provider.visionBearishScore; + + // + bool isVisionScoreBearish = + provider.visionBearishScore > provider.visionBullishScore; + // int count = CountWaitingZones(); for (int i = 0; i < count; i++) @@ -764,56 +823,112 @@ struct X121SMCStrategyXWZWorkingZone bool isBullish = iOBFVG.IsBullish(); // - XBoxZone iBox; - result = iOBFVG.ToZone(iBox); - if (!result) + int fvgsCount = iOBFVG.CountFVGs(); + bool has = IsValidSize(fvgsCount); + if (has) { // - iBox.Clean(); - iOBFVG.Clean(); + for (int j = 0; j < fvgsCount; j++) + { + // + XCFVG *jFVG = iOBFVG.fvgs[j]; - // - continue; + // + XBoxZone iBox; + has = ToBox( + iBox, + jFVG // + ); + if (has) + { + // + double iRange = iBox.lower + ((iBox.upper - iBox.lower) / 2); + + // + // Activate Zone Using PV ... + bool isPVPassed = + isBullish + ? vale < iBox.upper && + vale > iBox.lower + : peak < iBox.upper && + peak > iBox.lower; + bool isPV50Passed = + isBullish + ? vale < iBox.upper && + vale < iRange && + vale > iBox.lower + : peak < iBox.upper && + peak < iRange && + peak > iBox.lower; + + // + // Activate Zone using Rejection ... + bool isRejected = + isBullish + ? bar.low <= iBox.upper && + bar.GetDown() > iBox.upper + : bar.high >= iBox.lower && + bar.GetUp() < iBox.lower; + + // + // Combine Result ... + result = isPV50Passed; + // || isPV50Passed + // || isRejected; + if (result) + { + // + fvgIDX = j; + iBox.Clean(); + zoneIDX = i; + + // + break; + } + } + + // + if (result) + { + // + iBox.Clean(); + ZeroMemory(jFVG); + + // + break; + } + + // + iBox.Clean(); + } } // - // XCFVG *fvg; - // result = iOBFVG.GetMainFVG(fvg); - // if (!result) - // { - // // - // iOBFVG.Clean(); - // ZeroMemory(fvg); - - // // - // continue; - // } - - // - result = - isBullish - ? vale < iBox.upper && - vale > iBox.lower - : peak < iBox.upper && - peak > iBox.lower; if (result) { // - zone = iOBFVG; + iOBFVG.Clean(); break; } // - iBox.Clean(); iOBFVG.Clean(); } // - result = zone.IsValid(); + result = + IsValidIndex(fvgIDX) && + IsValidIndex(zoneIDX); // bar.Clean(); + // + if (result) + { + bar.Clean(); + } + // return result; } @@ -1466,6 +1581,7 @@ struct X121SMCStrategyXWZWorkingZone iObjects, true, // Draw Order Block ... true, // Draw Fair Value Gaps ... + true, // Draw All Fair Value Gaps ... // true, // Draw OB StartedBar ... true, // Draw OB ActivatedBar ...