diff --git a/Classes/x-saherelm.x-bar.analyser.class.mq5 b/Classes/x-saherelm.x-bar.analyser.class.mq5 index b8e5f8ae..5c72181d 100644 --- a/Classes/x-saherelm.x-bar.analyser.class.mq5 +++ b/Classes/x-saherelm.x-bar.analyser.class.mq5 @@ -2735,6 +2735,100 @@ class XCBarAnalyser : public XCBase return result; } + // + // Implement Some Custom Senarios ... + + /** + * Calculate Specified Bars Range Volume ... + * + * @param bar: XOHCL instance reference ... + * @param bullishVolume: double + * @param bearishVolume: double + * @param loopback: int + * + * @return ( bool ) + */ + bool CalculateRangeVolume( + XOHCL &bar, + double &bullishVolume, + double &bearishVolume, + int loopback = 5 // + ) + { + // + bool result = false; + + // + // Normalize Args ... + bullishVolume = 0; + bearishVolume = 0; + loopback = NormalizeInt(loopback, 3); + + // + // Validate ... + result = bar.IsValid(); + if (!result) + { + return result; + } + + // + XOHCL iBar; + bool has = false; + int start = bar.Index(); + int end = start + loopback; + for (int i = start; i <= end; i++) + { + // + iBar.Clean(); + has = iBar.Init( + bar.symbol, + bar.period, + i // + ); + if (!has) + { + // + iBar.Clean(); + + // + break; + } + + // + bool isBullish = iBar.IsBullish(); + bool isBearish = iBar.IsBearish(); + + // + if (isBullish) + { + bullishVolume += iBar.volume; + } + else if (isBearish) + { + bearishVolume += iBar.volume; + } + else + { + // + bullishVolume += iBar.volume; + bearishVolume += iBar.volume; + } + + // + iBar.Clean(); + } + + // + result = iBar.IsValid(); + + // + iBar.Clean(); + + // + return result; + } + // protected: // diff --git a/XCAEA/Libraries/xcaea.signaller.lib.mq5 b/XCAEA/Libraries/xcaea.signaller.lib.mq5 index a3ee8d8e..d90d6cce 100644 --- a/XCAEA/Libraries/xcaea.signaller.lib.mq5 +++ b/XCAEA/Libraries/xcaea.signaller.lib.mq5 @@ -665,9 +665,40 @@ bool DetectXCAEAConditions( conditions .GenerateSummary(); + // + // Calculating Range Volumes ... + + // + double bullishVolume = 0; + double bearishVolume = 0; + int volumeRangeLoopback = 5; + helper.barAnalyser.CalculateRangeVolume( + cBar, + bullishVolume, + bearishVolume, + volumeRangeLoopback // + ); + + // + double rangeVolume = bullishVolume = bearishVolume; + double rangeVolumeAvg = rangeVolume / volumeRangeLoopback; + + // + bool isVolumeBullish = bullishVolume > bearishVolume; + bool isVolumeBearish = bullishVolume < bearishVolume; + bool isVolumeOverLast = cBar.volume > pBar.volume; + bool isVolumeOverAvg = cBar.volume > rangeVolumeAvg; + // // Conditions ... + // + // SAR ... + double zSar = conditions.sarBuffer[zIDX]; + double cSar = conditions.sarBuffer[cIDX]; + double pSar = conditions.sarBuffer[pIDX]; + double p2Sar = conditions.sarBuffer[p2IDX]; + // // PEAK ... double zPeak = conditions.peakBuffer[zIDX]; @@ -797,7 +828,8 @@ bool DetectXCAEAConditions( z3MAMediumState > 0 && c3MAMediumState > 0 && z3MAMedium > z3MASlow && - c3MAMedium > c3MASlow + c3MAMedium > c3MASlow && + conditions.isVidyaBullish // ; @@ -809,7 +841,8 @@ bool DetectXCAEAConditions( z3MAMediumState < 0 && c3MAMediumState < 0 && z3MAMedium < z3MASlow && - c3MAMedium < c3MASlow + c3MAMedium < c3MASlow && + conditions.isVidyaBearish // ; @@ -832,7 +865,18 @@ bool DetectXCAEAConditions( // // Select Inside Boxes ... + + // + ENUM_XCA_PIVOTS allowedInsidePivots[] = { + XCA_FVG_BULL, + XCA_FVG_BEAR, + XCA_PEAKSWHRES, + XCA_VALESWLSUP, + XCA_TREND_BULL, + XCA_TREND_BEAR, + }; insidePivotsCount = SelectInsideBoxes( + allowedInsidePivots, insidePivots, pivots, zBar, @@ -840,17 +884,19 @@ bool DetectXCAEAConditions( pBar, p2Bar // ); - - // hasInsidePivots = IsValidSize(insidePivotsCount); if (hasInsidePivots) { - // drawer.DrawBoxes(insidePivots, TimeCurrent()); + // + // drawer.DrawBoxes( + // insidePivots, + // zBar.time // + // ); } // // Detect Rejected Pivot ... - ENUM_XCA_PIVOTS allowedPivots[] = { + ENUM_XCA_PIVOTS allowedRejectedPivots[] = { XCA_FVG_BULL, XCA_FVG_BEAR, // XCA_PEAKSWHRES, @@ -859,7 +905,7 @@ bool DetectXCAEAConditions( // XCA_TREND_BEAR, }; has = SelectRejectedBox( - allowedPivots, + allowedRejectedPivots, rejectedPivot, isRejectedOnMid, pivots, @@ -871,14 +917,6 @@ bool DetectXCAEAConditions( true, true // ); - // if (has) - // { - // // - // drawer.DrawBox( - // rejectedPivot, - // TimeCurrent() // - // ); - // } } // @@ -890,6 +928,10 @@ bool DetectXCAEAConditions( // bool isCond1Bullish = // + // false && // TODO: Remove this ... + isVolumeOverAvg && + isVolumeOverLast && + conditions.isSarBullish && rejectedPivot.IsValid() && rejectedPivot.IsBullish() && isX3MaValidForBullishRejection @@ -899,6 +941,10 @@ bool DetectXCAEAConditions( // bool isCond1Bearish = // + // false && // TODO: Remove this ... + isVolumeOverAvg && + isVolumeOverLast && + conditions.isSarBearish && rejectedPivot.IsValid() && rejectedPivot.IsBearish() && isX3MaValidForBearishRejection @@ -918,6 +964,9 @@ bool DetectXCAEAConditions( rejectedPivot, TimeCurrent() // ); + + // + Print("Cond1"); } // @@ -926,9 +975,19 @@ bool DetectXCAEAConditions( // bool isCond2Bullish = // - false && - isX3MaBearishState && - isCBarBullishRejected // && + // false && + // + c3MASlowState > 0 && + c3MAMediumState > 0 && + cBar.GetUp() > pSar && + conditions.isFastOverSlow && + conditions.isVidyaBullish && + conditions.isFastOverMedium && + conditions.isSarSwitchedToBullish + // + // + // isX3MaBearishState && + // isCBarBullishRejected // && // cBar.GetDown() > pVale && // conditions.isValeUnderLast // @@ -937,9 +996,9 @@ bool DetectXCAEAConditions( // bool isCond2Bearish = // - false && - isX3MaBullishState && - isCBarBearishRejected // && + false // && + // isX3MaBullishState && + // isCBarBearishRejected // && // cBar.GetUp() < pPeak && // conditions.isPeakOverLast // @@ -951,7 +1010,7 @@ bool DetectXCAEAConditions( if (isCond2) { // - // Print("Cond2"); + Print("Cond2"); } // @@ -1166,6 +1225,7 @@ bool DetectXCAEAConditions( // // Select Inside Boxes ... int SelectInsideBoxes( + ENUM_XCA_PIVOTS &allowedTypes[], XBoxZone &insideBoxes[], XBoxZone &boxes[], XOHCL &zBar, @@ -1200,14 +1260,15 @@ int SelectInsideBoxes( XBoxZone iBox = boxes[i]; // - // Check Box Type ... - bool isTypePassed = - // - iBox.type == GetBoxType(XCA_TREND_BULL) || - iBox.type == GetBoxType(XCA_TREND_BEAR) - // - ; - if (!isTypePassed) + ENUM_XCA_PIVOTS iType = GetPivotType(iBox); + bool isAllowedType = IsValid(iType) && + !HasChild(allowedTypes) + ? true + : Contains( + iType, + allowedTypes // + ); + if (!isAllowedType) { // iBox.Clean(); @@ -1314,12 +1375,18 @@ bool SelectRejectedBox( // ENUM_XCA_PIVOTS iType = GetPivotType(iBox); bool isAllowedType = IsValid(iType) && - Contains( - iType, - allowedTypes // - ); + !HasChild(allowedTypes) + ? true + : Contains( + iType, + allowedTypes // + ); if (!isAllowedType) { + // + iBox.Clean(); + + // continue; } diff --git a/XCAEA/Signals/xcaea.signaller.class.mq5 b/XCAEA/Signals/xcaea.signaller.class.mq5 index 9e247546..88d3bb25 100644 --- a/XCAEA/Signals/xcaea.signaller.class.mq5 +++ b/XCAEA/Signals/xcaea.signaller.class.mq5 @@ -210,10 +210,14 @@ class XCXCAEASignaller : XCBase // // Draw Founded Pivots ... // drawer.Draw(cTime); - drawer.DrawPeakResSWHPivots(cTime); - drawer.DrawValeSupSWLPivots(cTime); - drawer.DrawFVGBullishPivots(cTime); - drawer.DrawFVGBearishPivots(cTime); + + // + // drawer.DrawPeakResSWHPivots(cTime); + // drawer.DrawValeSupSWLPivots(cTime); + // drawer.DrawFVGBullishPivots(cTime); + // drawer.DrawFVGBearishPivots(cTime); + // drawer.DrawRSICrossedOverOSPivots(cTime); + // drawer.DrawRSICrossedUnderOBPivots(cTime); // // Retrieve Valid Pviots ... @@ -817,10 +821,10 @@ class XCXCAEASignaller : XCBase // inputs.caInputs.showKI = false; inputs.caInputs.showTKI = false; - inputs.caInputs.showSar = false; - inputs.caInputs.showVidya = false; - inputs.caInputs.showTrend = false; - inputs.caInputs.showSwings = false; + inputs.caInputs.showSar = true; + inputs.caInputs.showVidya = true; + inputs.caInputs.showTrend = true; + inputs.caInputs.showSwings = true; inputs.caInputs.showLongCycle = false; inputs.caInputs.showHindCycle = false; inputs.caInputs.showFiboLevel1 = false; @@ -914,10 +918,10 @@ class XCXCAEASignaller : XCBase drawer.drawPeakResSWHPivots = true; drawer.drawTrendBullishPivots = false; drawer.drawTrendBearishPivots = false; - drawer.drawRSICrossedOverOSPivots = false; - drawer.drawRSICrossedUnderOBPivots = false; drawer.drawCCICrossedOverOSPivots = false; drawer.drawCCICrossedUnderOBPivots = false; + drawer.drawRSICrossedOverOSPivots = true; + drawer.drawRSICrossedUnderOBPivots = true; // // Configure Widths ...