diff --git a/Experts/x-saherelm.xcaea.ea.mq5 b/Experts/x-saherelm.xcaea.ea.mq5 index d83c3749..63c7bd3b 100644 --- a/Experts/x-saherelm.xcaea.ea.mq5 +++ b/Experts/x-saherelm.xcaea.ea.mq5 @@ -173,7 +173,7 @@ void OnTick() eaConditions.Clean(); // - double r2r = 5; + double r2r = 2; string provider = "XCAEA"; ENUM_POSITION_TYPE type = POSITION_TYPE_BUY; ENUM_X_ORDER_MODES mode = X_ORDER_MODE_MARKET; diff --git a/XCAEA/Libraries/xcaea.signaller.lib.mq5 b/XCAEA/Libraries/xcaea.signaller.lib.mq5 index e42b1285..e91b8b94 100644 --- a/XCAEA/Libraries/xcaea.signaller.lib.mq5 +++ b/XCAEA/Libraries/xcaea.signaller.lib.mq5 @@ -771,23 +771,23 @@ bool DetectXCAEAConditions( // bool isX3MaBullishState = - z3MAFast > c3MAFast && - isCBarValidForBullish && + // + z3MAFast > z3MAMedium && c3MAFast > c3MAMedium && - isCBarBullishRejected && - c3MAMedium > c3MASlow && - cBar.low < x3maBullishGapLower && - cBar.GetDown() > x3maBullishGapLower; + z3MAMedium > z3MASlow && + c3MAMedium > c3MASlow + // + ; // bool isX3MaBearishState = - z3MAFast < c3MAFast && - isCBarValidForBearish && + // + z3MAFast < z3MAMedium && c3MAFast < c3MAMedium && - isCBarBearishRejected && - c3MAMedium < c3MASlow && - cBar.high > x3maBearishGapLower && - cBar.GetUp() < x3maBearishGapLower; + z3MAMedium < z3MASlow && + c3MAMedium < c3MASlow + // + ; // bool isX3MaValidForBullishRejection = @@ -819,6 +819,7 @@ bool DetectXCAEAConditions( XBoxZone rejectedPivot; XBoxZone insidePivots[]; int insidePivotsCount = 0; + bool isRejectedOnMid = false; bool hasInsidePivots = false; bool hasPivots = HasChild(pivots); if (hasPivots) @@ -860,11 +861,13 @@ bool DetectXCAEAConditions( has = SelectRejectedBox( allowedPivots, rejectedPivot, + isRejectedOnMid, pivots, zBar, cBar, pBar, p2Bar, + true, // Ignore Mid Rejection ... true, true // ); @@ -888,8 +891,8 @@ bool DetectXCAEAConditions( bool isCond1Bullish = // rejectedPivot.IsValid() && - rejectedPivot.IsBullish() // && - // isX3MaValidForBullishRejection + rejectedPivot.IsBullish() && + isX3MaValidForBullishRejection // ; @@ -897,8 +900,8 @@ bool DetectXCAEAConditions( bool isCond1Bearish = // rejectedPivot.IsValid() && - rejectedPivot.IsBearish() // && - // isX3MaValidForBearishRejection + rejectedPivot.IsBearish() && + isX3MaValidForBearishRejection // ; @@ -907,6 +910,9 @@ bool DetectXCAEAConditions( isCond1Bearish; if (isCond1) { + // + pivotBox = rejectedPivot; + // drawer.DrawBox( rejectedPivot, @@ -920,14 +926,22 @@ bool DetectXCAEAConditions( // bool isCond2Bullish = // - false + false && + isX3MaBearishState && + isCBarBullishRejected // && + // cBar.GetDown() > pVale && + // conditions.isValeUnderLast // ; // bool isCond2Bearish = // - false + false && + isX3MaBullishState && + isCBarBearishRejected // && + // cBar.GetUp() < pPeak && + // conditions.isPeakOverLast // ; @@ -936,6 +950,8 @@ bool DetectXCAEAConditions( isCond2Bearish; if (isCond2) { + // + // Print("Cond2"); } // @@ -1000,11 +1016,13 @@ bool DetectXCAEAConditions( dir // ); + // + double sls[]; + // if (isCond1) { // - double sls[]; if (isCond1Bullish) { // @@ -1014,16 +1032,16 @@ bool DetectXCAEAConditions( sls // ); - // - // X3MA Medium ... - if (c3MAMedium < entry) - { - // - Add( - c3MAMedium, - sls // - ); - } + // // + // // X3MA Medium ... + // if (c3MAMedium < entry) + // { + // // + // Add( + // c3MAMedium, + // sls // + // ); + // } } else { @@ -1034,16 +1052,16 @@ bool DetectXCAEAConditions( sls // ); - // - // X3MA Medium ... - if (c3MAMedium > entry) - { - // - Add( - c3MAMedium, - sls // - ); - } + // // + // // X3MA Medium ... + // if (c3MAMedium > entry) + // { + // // + // Add( + // c3MAMedium, + // sls // + // ); + // } } // @@ -1051,72 +1069,13 @@ bool DetectXCAEAConditions( isCond1Bullish ? GetMax(sls) : GetMin(sls); - // - double supportRisk = MathAbs(entry - cSupport); - double supportRiskPoint = supportRisk / points; - - // - double resistanceRisk = MathAbs(entry - cSupport); - double resistanceRiskPoint = resistanceRisk / points; - - // - double rejectedPivotMid = rejectedPivot.lower + - ((rejectedPivot.upper - rejectedPivot.lower) / 2); - double rejectedPivotMidRisk = MathAbs(entry - rejectedPivotMid); - double rejectedPivotMidRiskInPoint = rejectedPivotMid / points; - - // - Clean(sls); - - // - // Preparing Targets ... - if (isBullish) - { - // - if (cPeak > entry) - { - // - Add( - cPeak, - targets // - ); - } - } - else - { - // - if (cVale < entry) - { - // - Add( - cVale, - targets // - ); - } - } } // double risk = MathAbs(providedSL - entry); double riskPoint = risk / points; - // - double minAllowedSLRiskPoint = 25.0; - double minAllowedSLRisk = minAllowedSLRiskPoint * points; - double minAllowedSL = - isBullish - ? entry - minAllowedSLRisk - : entry + minAllowedSLRisk; - - // - double maxAllowedSLRiskPoint = 40.0; - double maxAllowedSLRisk = maxAllowedSLRiskPoint * points; - double maxAllowedSL = - isBullish - ? entry + maxAllowedSLRisk - : entry - maxAllowedSLRisk; - // double sl = providedSL > 0 @@ -1148,6 +1107,9 @@ bool DetectXCAEAConditions( // box.type = "XCASignal"; + + // + Clean(sls); } // @@ -1292,11 +1254,13 @@ int SelectInsideBoxes( bool SelectRejectedBox( ENUM_XCA_PIVOTS &allowedTypes[], XBoxZone &box, + bool &rejectOnMid, XBoxZone &boxes[], XOHCL &zBar, XOHCL &cBar, XOHCL &pBar, XOHCL &p2Bar, + bool ignoreMidRejection = true, bool forceBarType = false, bool forcePressure = false // ) @@ -1306,6 +1270,7 @@ bool SelectRejectedBox( // box.Clean(); + rejectOnMid = false; // // Validate ... @@ -1385,6 +1350,14 @@ bool SelectRejectedBox( forcePressure // ); + // + if (ignoreMidRejection) + { + // + isMidBullishRejected = false; + isMidBearishRejected = false; + } + // bool isBullishRejected = isBullish && @@ -1405,6 +1378,9 @@ bool SelectRejectedBox( { // box = iBox; + rejectOnMid = isBullishRejected + ? isMidBullishRejected + : isMidBearishRejected; break; } diff --git a/XCAEA/Signals/xcaea.signaller.class.mq5 b/XCAEA/Signals/xcaea.signaller.class.mq5 index 09cbc9a2..6ac30d12 100644 --- a/XCAEA/Signals/xcaea.signaller.class.mq5 +++ b/XCAEA/Signals/xcaea.signaller.class.mq5 @@ -40,6 +40,7 @@ class XCXCAEASignaller : XCBase // // Props ... bool useGuards; + bool useTargets; int poiLoopback; XCAEAInputs inputs; XBarTracker barTraker; @@ -407,19 +408,44 @@ class XCXCAEASignaller : XCBase // // Targets Preparing ... - Copy( - targets, - mConditions.targets // - ); - - // - // Select RF Rewards ... - if (continuesRFTillTarget) + if (useTargets) { // - double rfReward = 1; - while (rfReward < tpReward) + Copy( + targets, + mConditions.targets // + ); + + // + // Select RF Rewards ... + if (continuesRFTillTarget) { + // + double rfReward = 1; + while (rfReward < tpReward) + { + // + double rewardRF = risk * rfReward; + double rfTP = + isBullish + ? entry + rewardRF + : entry - rewardRF; + + // + Add( + rfTP, + mConditions.targets // + ); + + // + rfReward++; + } + } + else + { + // + double rfReward = 2; + // double rewardRF = risk * rfReward; double rfTP = @@ -432,116 +458,95 @@ class XCXCAEASignaller : XCBase rfTP, mConditions.targets // ); - - // - rfReward++; } - } - else - { - // - double rfReward = 2; // - double rewardRF = risk * rfReward; - double rfTP = - isBullish - ? entry + rewardRF - : entry - rewardRF; - - // - Add( - rfTP, - mConditions.targets // - ); - } - - // - // Detect Rf on Invalid Pivots ... - if (rfOnInvalidPivots) - { - // - has = detector.HasInvalidPivots(); - if (has) + // Detect Rf on Invalid Pivots ... + if (rfOnInvalidPivots) { // - XBoxZone targetBox; - double targetBoxPrice = 0; - count = detector.CountInvalidPivots(); - for (int i = 0; i < count; i++) + has = detector.HasInvalidPivots(); + if (has) { // - XBoxZone iPivot = detector.invalidPivots[i]; - - // - bool isValidPivot = - Contains( - "XCA_PEAKSWHRES", - iPivot.type // - ) || - Contains( - "XCA_VALESWLSUP", - iPivot.type // - ) || - Contains( - "XCA_FVG", - iPivot.type // - ); - if (!isValidPivot) + XBoxZone targetBox; + double targetBoxPrice = 0; + count = detector.CountInvalidPivots(); + for (int i = 0; i < count; i++) { + // + XBoxZone iPivot = detector.invalidPivots[i]; + + // + bool isValidPivot = + Contains( + "XCA_PEAKSWHRES", + iPivot.type // + ) || + Contains( + "XCA_VALESWLSUP", + iPivot.type // + ) || + Contains( + "XCA_FVG", + iPivot.type // + ); + if (!isValidPivot) + { + // + iPivot.Clean(); + continue; + } + + // + double selectedPrice = + isBullish + ? iPivot.lower - (5 * points) + : iPivot.upper + (5 * points); + + // + double targetBoxSelectedPrice = + isBullish + ? targetBox.lower - (5 * points) + : targetBox.upper + (5 * points); + + // + bool isDirPassed = iPivot.dir = signalBoxDir; + bool isPricePassed = + isBullish + ? entry < selectedPrice + : entry > selectedPrice; + bool canSetTarget = + !targetBox.IsValid() + ? true + : isBullish + ? targetBoxSelectedPrice > selectedPrice + : targetBoxSelectedPrice < selectedPrice; + if (canSetTarget) + { + // + targetBox = iPivot; + targetBoxPrice = targetBoxSelectedPrice; + } + // iPivot.Clean(); - continue; } // - double selectedPrice = - isBullish - ? iPivot.lower - (5 * points) - : iPivot.upper + (5 * points); - - // - double targetBoxSelectedPrice = - isBullish - ? targetBox.lower - (5 * points) - : targetBox.upper + (5 * points); - - // - bool isDirPassed = iPivot.dir = signalBoxDir; - bool isPricePassed = - isBullish - ? entry < selectedPrice - : entry > selectedPrice; - bool canSetTarget = - !targetBox.IsValid() - ? true - : isBullish - ? targetBoxSelectedPrice > selectedPrice - : targetBoxSelectedPrice < selectedPrice; - if (canSetTarget) + if (targetBox.IsValid() && + targetBoxPrice > 0) { // - targetBox = iPivot; - targetBoxPrice = targetBoxSelectedPrice; + Add( + targetBoxPrice, + mConditions.targets // + ); } // - iPivot.Clean(); + targetBox.Clean(); } - - // - if (targetBox.IsValid() && - targetBoxPrice > 0) - { - // - Add( - targetBoxPrice, - mConditions.targets // - ); - } - - // - targetBox.Clean(); } } } @@ -766,6 +771,7 @@ class XCXCAEASignaller : XCBase { // useGuards = false; + useTargets = false; rfOnInvalidPivots = false; continuesRFTillTarget = false;