diff --git a/Experts/x-test-strategies.ea.mq5 b/Experts/x-test-strategies.ea.mq5 index accbfcd9..5891ac89 100644 --- a/Experts/x-test-strategies.ea.mq5 +++ b/Experts/x-test-strategies.ea.mq5 @@ -359,7 +359,7 @@ bool InitialEA() eurusdSymbol, PERIOD_M5, eaVolume, - eaR2R, // R2R ... + 1, // eaR2R, // R2R ... eaSlippage, magicNumber, true, // Ignore Signal Execution @@ -371,8 +371,8 @@ bool InitialEA() eaIgnoreSL, eaAllowLong, eaAllowShort, - 1, // eaMaxAllowedLongs, // Max Longs - 1 // eaMaxAllowedShorts // Max Shorts + eaMaxAllowedLongs, // Max Longs + eaMaxAllowedShorts // Max Shorts ); eurusdXCHKMStrategy.SetAlertLogAlerts(true); eurusdXCHKMStrategy.SetAlertEnableAlerts(true); diff --git a/Strategies/x-saherelm.xchkm.strategy.mq5 b/Strategies/x-saherelm.xchkm.strategy.mq5 index 7b308292..d2e110e5 100644 --- a/Strategies/x-saherelm.xchkm.strategy.mq5 +++ b/Strategies/x-saherelm.xchkm.strategy.mq5 @@ -147,8 +147,8 @@ public: bool hasShort = false; // - bool forceCloseLongs = false; - bool forceCloseShorts = false; + // Draw Support/Resistance/OB(s)/FVG(s) ... + bool drawImportantAreas = false; // // Retrieve Conditions ... @@ -289,10 +289,14 @@ public: if (hasSupport) { // - DrawSupport( - support, - ChartID() // - ); + if (drawImportantAreas) + { + // + DrawSupport( + support, + ChartID() // + ); + } // supportTime = cBar.time; @@ -315,10 +319,14 @@ public: if (hasResistance) { // - DrawResistance( - resistance, - ChartID() // - ); + if (drawImportantAreas) + { + // + DrawResistance( + resistance, + ChartID() // + ); + } // resistanceTime = cBar.time; @@ -343,10 +351,14 @@ public: if (hasBullishOB) { // - DrawBullishOrderBlock( - bullishOB, - ChartID() // - ); + if (drawImportantAreas) + { + // + DrawBullishOrderBlock( + bullishOB, + ChartID() // + ); + } // bullishOBTime = cBar.time; @@ -368,10 +380,14 @@ public: if (hasBearishOB) { // - DrawBearishOrderBlock( - bearishOB, - ChartID() // - ); + if (drawImportantAreas) + { + // + DrawBearishOrderBlock( + bearishOB, + ChartID() // + ); + } // bearishOBTime = cBar.time; @@ -397,12 +413,18 @@ public: { // bullishFVG = cBar; - DrawBullishFVG( - bullishFVG, - bullishFVGUpper, - bullishFVGLower, - ChartID() // - ); + + // + if (drawImportantAreas) + { + // + DrawBullishFVG( + bullishFVG, + bullishFVGUpper, + bullishFVGLower, + ChartID() // + ); + } // bullishFVGTime = cBar.time; @@ -425,12 +447,18 @@ public: { // bearishFVG = cBar; - DrawBearishFVG( - bearishFVG, - bearishFVGUpper, - bearishFVGLower, - ChartID() // - ); + + // + if (drawImportantAreas) + { + // + DrawBearishFVG( + bearishFVG, + bearishFVGUpper, + bearishFVGLower, + ChartID() // + ); + } // bearishFVGTime = cBar.time; @@ -1406,171 +1434,102 @@ public: // ; + // + // Other Conditions ... + + // + bool isPriceOveralBullish = + // + cBar.low > chhkConditions.hBars[cIndex].high + // + ; + + // + bool isPriceOveralBullishPrev = + // + pBar.low > chhkConditions.hBars[pIndex].high + // + ; + + // + bool isPriceOveralSwitchedToBullish = + // + isPriceOveralBullish && + !isPriceOveralBullishPrev + // + ; + + // + bool isPriceOveralBearish = + // + cBar.high < chhkConditions.hBars[cIndex].low + // + ; + + // + bool isPriceOveralBearishPrev = + // + pBar.high < chhkConditions.hBars[pIndex].low + // + ; + + // + bool isPriceOveralSwitchedToBearish = + // + isPriceOveralBearish && + !isPriceOveralBearishPrev + // + ; + // // Signalling ... // Looking for Signals Based on Conditions ... - // - // Preparing Signals for Execution ... - bool allowCHMSignals = false; - bool allowCHHKSignals = false; - bool allowCHSTRSignals = false; - - // - // Check Signals based on: - // XCHMA ... - if (allowCHMSignals) - { - // - double pressureDistance = 200; - - // - if (isCHMBullish) - { - // - hasLong = - // - isCHMBullish && - hasBullishPattern && - chmDistanceDiffInPoint <= pressureDistance - // - ; - - // - if (hasLong) - { - // - type = POSITION_TYPE_SELL; - sl = chmMin; - } - } - - // - if (isCHMBearish) - { - // - hasShort = - // - isCHMBearish && - hasBearishPattern && - chmDistanceDiffInPoint <= pressureDistance - // - ; - - // - if (hasShort) - { - // - type = POSITION_TYPE_SELL; - sl = chmMin; - } - } - } - - // - // Check Signals based on: - // XCHHK ... - if (allowCHHKSignals) - { - // - double pressureDistance = 200; - - // - if (isCHHKSwitchedBullish) - { - // - hasLong = - // - false - // - // isCHMBullish && - // isCHHKBullish && - // isCHSTRBullish && - // hasBullishPower && - // hasBullishPressure && - // hasBullishPattern && - // chhkDistanceDiffInPoint <= pressureDistance - // - ; - - // - if (hasLong) - { - // - type = POSITION_TYPE_BUY; - sl = chhkLowMin; - } - } - - // - if (isCHHKSwitchedToBearish) - { - // - hasShort = - // - false - // - // isCHMBearish && - // isCHHKBearish && - // isCHSTRBearish && - // hasBearishPower && - // hasBearishPressure && - // hasBearishPattern && - // chhkDistanceDiffInPoint <= pressureDistance - // - ; - - // - if (hasShort) - { - // - type = POSITION_TYPE_SELL; - sl = chhkHighMax; - } - } - } - - // - // Check Signals based on: - // XCHSTR ... - if (allowCHSTRSignals) - { - } - // // Checking Long Conditions ... - - // - // forceCloseLongs = isCHHKBullishBreaked; - // forceCloseShorts = isCHHKBearishBreaked; - - // - // Check Exist Conditions ... - if (forceCloseLongs || forceCloseShorts) + if (isPriceOveralSwitchedToBullish) { // - string comment = "Exit Condition ..."; + hasLong = + // + hasBullishPower && + hasBullishPressure && + chstrConditions.isHBullish && + cheConditions.isStrongBullish && + cBar.low > pvConditions.fib2s[cIndex] + // + ; // - ENUM_X_POSITION_TYPES mType = - forceCloseLongs - ? X_POSITION_TYPE_LONG - : X_POSITION_TYPE_SHORT; - - // - int count = trader.Close( - comment, - mSymbol, - GetTag(), - mPeriod, - mType, - false // Filter By Magic ... - ); - if (IsValidSize(count)) + if (hasLong) { // - string msg = "Close (" + ToString(count) + ") " + (forceCloseLongs ? "Long" : "Short") + " Positions due Exit Conditions ..."; - Alert(msg); + type = POSITION_TYPE_BUY; + sl = pvConditions.fib3s[cIndex]; + } + } + + // + // Checking Short Conditions ... + if (isPriceOveralSwitchedToBearish) + { + // + hasShort = + // + hasBearishPower && + hasBearishPressure && + chstrConditions.isHBearish && + cheConditions.isStrongBearish && + cBar.high < pvConditions.fib4s[cIndex] + // + ; + + // + if (hasShort) + { + // + type = POSITION_TYPE_SELL; + sl = pvConditions.fib3s[cIndex]; } } @@ -1661,13 +1620,17 @@ public: // // Calculate TP and SL ... // based on Strategy ... - CalculateTPSLByPrice( - sl, - tp, - type, - entry, - r2r // - ); + // only when on of TP or SL Provides, using provided R2R ... + if ((tp <= 0 && sl > 0) || (tp > 0 && sl <= 0)) + { + CalculateTPSLByPrice( + sl, + tp, + type, + entry, + r2r // + ); + } // // Preparing Signal ...