diff --git a/XCAEA/Classes/xcaea.x-poi.detector.class.mq5 b/XCAEA/Classes/xcaea.x-poi.detector.class.mq5 index d9106880..1390559b 100644 --- a/XCAEA/Classes/xcaea.x-poi.detector.class.mq5 +++ b/XCAEA/Classes/xcaea.x-poi.detector.class.mq5 @@ -1478,7 +1478,6 @@ class XCXCAEAPOIDetector : public XCBase XBoxZone tmp[]; int count = FillPivots( tmp, - pivots, unavailables, allowedTypes, to // @@ -1495,20 +1494,20 @@ class XCXCAEAPOIDetector : public XCBase has = // // Validate Time .. - iBox.from > box.from + iBox.from > decision.from // && // // Validate Price ... ( // - (iBox.upper < box.upper && - iBox.upper > box.lower) + (iBox.upper < decision.upper && + iBox.upper > decision.lower) // || // - (iBox.lower > box.lower && - iBox.lower < box.upper) + (iBox.lower > decision.lower && + iBox.lower < decision.upper) // ); if (has) diff --git a/XCAEA/Libraries/xcaea.signaller.lib.mq5 b/XCAEA/Libraries/xcaea.signaller.lib.mq5 index db8119a4..7e75e2cf 100644 --- a/XCAEA/Libraries/xcaea.signaller.lib.mq5 +++ b/XCAEA/Libraries/xcaea.signaller.lib.mq5 @@ -538,6 +538,7 @@ bool DetectDecisionZone( XCXCAEAPOIDrawer *drawer, XBoxZone &box, ENUM_X_DIRECTION &dir, + XBoxZone &unavailables[], XCAEAConditions &conditions, int barIndex = 0, int loopback = 10 // @@ -1210,7 +1211,20 @@ bool DetectDecisionZone( if (result) { // - // Do Signal Preparing ... + // Check UnAvailables ... + int idx = -1; + has = FindBoxIndex( + idx, + box, + unavailables // + ); + if (has) + { + // + box.Clean(); + conditions.Clean(); + dir = X_DIRECTION_NONE; + } // // Check Box is Prepared or Not ... @@ -1235,6 +1249,7 @@ bool DetectDecisionZone( // box.Clean(); conditions.Clean(); + dir = X_DIRECTION_NONE; } // @@ -1660,46 +1675,195 @@ bool CanTriggerCond2( return result; } + // + string symbol = helper.GetSymbol(); + bool isBullish = decisionZone.IsBullish(); + bool isBearish = decisionZone.IsBearish(); + ENUM_TIMEFRAMES period = helper.GetPeriod(); + + // + int zIndex = barIndex; + int cIndex = zIndex + 1; + int pIndex = cIndex + 1; + int p2Index = pIndex + 1; + + // + // Extract Bars ... + XOHCL zBar; + XOHCL cBar; + result = zBar.Init( + symbol, + period, + cIndex // + ); + result = + result && + zBar.GetPreviousBar(cBar); + if (!result) + { + // + zBar.Clean(); + cBar.Clean(); + + // + return result; + } + // bool has = false; + XBoxZone selectedPivot; bool hasPivots = HasChild(decisionPivots); int pivotsCount = ArraySize(decisionPivots); // - // Draw Decision Pivots ... + // Select Activated Pivot ... if (hasPivots) { // for (int i = 0; i < pivotsCount; i++) { // - XCBoxObject *iObj; - - // - has = helper.poiDrawer.DrawBox( - decisionPivots[i], - iObj // - ); + // Check Rejection of Block ... + has = + isBullish + ? cBar.IsBullish() && + decisionPivots[i].IsBullish() && + cBar.low < decisionPivots[i].upper && + cBar.low > decisionPivots[i].lower && + cBar.close > decisionPivots[i].upper + : cBar.IsBearish() && + decisionPivots[i].IsBearish() && + cBar.high > decisionPivots[i].lower && + cBar.high < decisionPivots[i].upper && + cBar.close < decisionPivots[i].lower; if (has) { - drawns.Add(iObj); + selectedPivot = decisionPivots[i]; } - // - ZeroMemory(iObj); + // // + // // Draw Pivot ... + // XCBoxObject *iObj; + + // // + // has = helper.poiDrawer.DrawBox( + // decisionPivots[i], + // iObj // + // ); + // if (has) + // { + // drawns.Add(iObj); + // } + + // // + // ZeroMemory(iObj); } } + // + // Check Selected Pivot is Exists or not ... + bool hasSelectedPivot = selectedPivot.IsValid(); + + // + // Detect Liquidity For Selected Pivot ... + double ssl = 0; + double bsl = 0; + bool hasSSL = false; + bool hasBSL = false; + if (hasSelectedPivot) + { + // + // Required Info ... + // int toIDX = selectedPivot.ToIndex(); + // int fromIDX = selectedPivot.FromIndex(); + + // // + // // SSL ... + // datetime sslTo = NULL; + // datetime sslFrom = NULL; + + // // + // // BSL ... + // datetime bslTo = NULL; + // datetime bslFrom = NULL; + + // // + // // Loop ... + // XOHCL iBar; + // for (int i = fromIDX; i > toIDX; i--) + // { + // // + // hasSSL = + // ssl > 0 && + // IsValid(sslTo) && + // IsValid(sslFrom); + + // // + // hasBSL = + // bsl > 0 && + // IsValid(bslTo) && + // IsValid(bslFrom); + + // // + // iBar.Clean(); + + // // + // if (hasSSL && hasBSL) + // { + // break; + // } + // } + // iBar.Clean(); + } + + // + // Draw Selected Pivot ... + if (hasSelectedPivot) + { + // + // Draw Pivot ... + XCBoxObject *iObj; + + // + has = helper.poiDrawer.DrawBox( + selectedPivot, + iObj // + ); + if (has) + { + // + color iColor = + isBullish + ? clrAqua + : clrMagenta; + + // + iObj.BoxWidth(2); + iObj.BoxColor(iColor); + iObj.BoxStyle(STYLE_SOLID); + + // + drawns.Add(iObj); + } + + // + ZeroMemory(iObj); + } + // // Summarizing ... // bool canTriggerLong = - false; + isBullish && + hasSelectedPivot && + selectedPivot.IsBullish(); // bool canTriggerShort = - false; + isBearish && + hasSelectedPivot && + selectedPivot.IsBearish(); // result = canTriggerLong || @@ -1715,8 +1879,8 @@ bool CanTriggerCond2( // sl = canTriggerLong - ? decisionZone.lower // activatedFVG.lower - : decisionZone.upper; // activatedFVG.upper; + ? selectedPivot.lower // activatedFVG.lower + : selectedPivot.upper; // activatedFVG.upper; // // Since Here TP Must Calculated @@ -1726,6 +1890,8 @@ bool CanTriggerCond2( // // Cleanup Resources ... + zBar.Clean(); + cBar.Clean(); // return result; diff --git a/XCAEA/Signals/xcaea.signaller.class.mq5 b/XCAEA/Signals/xcaea.signaller.class.mq5 index fd3ae50c..f6a3a5ce 100644 --- a/XCAEA/Signals/xcaea.signaller.class.mq5 +++ b/XCAEA/Signals/xcaea.signaller.class.mq5 @@ -255,6 +255,7 @@ class XCXCAEASignaller : XCBase drawer, decisionZone, decisionZoneDir, + unAvailableBoxes, conditions, zIndex, loopback // @@ -288,8 +289,20 @@ class XCXCAEASignaller : XCBase // Do What we Want ... barTraker.Waits(); + // + double pivot = isBullish + ? decisionZone.lower + : decisionZone.upper; + + // + double point = isBullish + ? decisionZone.upper + : decisionZone.lower; + // // Prepare Conditions ... + mConditions.point = point; + mConditions.pivot = pivot; mConditions.symbol = symbol; mConditions.period = period; mConditions.time = zBar.time; @@ -396,40 +409,32 @@ class XCXCAEASignaller : XCBase int toIDX = conditions.decisionZone.ToIndex(); int fromIDX = conditions.decisionZone.FromIndex(); -// - - - // for (int i = fromIDX; i > toIDX; i--) - // { - // // - // // Initializing iBar; - // XOHCL iBar; - // has = iBar.Init( - // conditions.symbol, - // conditions.period, - // i // - // ); - // if (!has) - // { - // // - // iBar.Clean(); - // continue; - // } - - // // - // // Retrieve Conditions ... - // XCAEAConditions iConditions; - // has = helper.GetConditions( - // iConditions, - // i, - // 5 // - // ); - // if (!has) { - // // - // iBar.Clean(); - // iConditions.Clean(); - // } - // } + // + XBoxZone decisionOBs[]; + ENUM_XCA_PIVOTS allowedTypes[]; + if (isBullish) + { + // + Add( + XCA_OB_BULL, + allowedTypes // + ); + } + else + { + // + Add( + XCA_OB_BEAR, + allowedTypes // + ); + } + int decisionOBsCount = detector.FillPivots( + conditions.decisionZone, + decisionOBs, + unAvailableBoxes, + allowedTypes, + cTime // + ); // CArrayObj *iObjects; @@ -594,15 +599,15 @@ class XCXCAEASignaller : XCBase // // Handling RF ... - // double rfReward = risk * 1.85; - // double rfPrice = - // isBullish - // ? entry + rfReward - // : entry - rfReward; - // Add( - // rfPrice, - // conditions.targets // - // ); + double rfReward = risk * 1.95; + double rfPrice = + isBullish + ? entry + rfReward + : entry - rfReward; + Add( + rfPrice, + conditions.targets // + ); // // rfReward = risk * 2.85; @@ -853,7 +858,7 @@ class XCXCAEASignaller : XCBase inputs.caInputs.showFiboLevel5 = false; inputs.caInputs.showPeaksAndVales = true; inputs.caInputs.showPeakAndValeGolden = false; - inputs.caInputs.showSupportAndResistance = false; + inputs.caInputs.showSupportAndResistance = true; // // XOSCS ...