From 2a85f97ad38960a7397ba766e2f9f24bda3685ea Mon Sep 17 00:00:00 2001 From: Hadi Khazaee Asl Date: Sat, 27 Jul 2024 17:38:32 +0330 Subject: [PATCH] last ... --- Experts/x-test-strategies.ea.mq5 | 42 ++--- Helpers/x-saherelm.xchstr.helper.mq5 | 204 ++++++++++++++++++++- Strategies/x-saherelm.xchkm.strategy.mq5 | 223 ++++++++++++++++------- 3 files changed, 377 insertions(+), 92 deletions(-) diff --git a/Experts/x-test-strategies.ea.mq5 b/Experts/x-test-strategies.ea.mq5 index 0a60a901..ffae68dc 100644 --- a/Experts/x-test-strategies.ea.mq5 +++ b/Experts/x-test-strategies.ea.mq5 @@ -47,15 +47,15 @@ int eaMaxAllowedLongs = 1; // Max Allowed Long Positions int eaMaxAllowedShorts = 1; // Max Allowed Short Positions // -input double eaTPPoint = 100; // Static TP Point -input double eaSLPoint = 100; // Static SL Point +double eaTPPoint = 100; // Static TP Point +double eaSLPoint = 100; // Static SL Point // bool eaIgnoreTP = false; // Ignore TP bool eaIgnoreSL = false; // Ignore SL // -int eaMaxAllowedSLsInDay = 2; +// int eaMaxAllowedSLsInDay = 0; // double eaR2R = 1.5; // Risk to Reward Ratio @@ -64,7 +64,7 @@ double eaR2R = 1.5; // Risk to Reward Ratio // Variables ... // -int mNumberOfSLs = 0; +// int mNumberOfSLs = 0; // // Bar Style nad Time Instances ... @@ -80,7 +80,7 @@ XSCBaseStrategy *strategies[]; XSCTrade *eaTrader; // -XTimeTracker eaTimeTracker; +// XTimeTracker eaTimeTracker; // // Alert Class ... @@ -179,11 +179,11 @@ void OnTimer() // HandleTradeState(); - // - if (eaTimeTracker.IsNewDay()) - { - mNumberOfSLs = 0; - } + // // + // if (eaTimeTracker.IsNewDay()) + // { + // mNumberOfSLs = 0; + // } } // @@ -521,12 +521,12 @@ void OnSignalRecieved(XSignal &signal) return; } - // - if (eaMaxAllowedSLsInDay > 0 && - mNumberOfSLs >= eaMaxAllowedSLsInDay) - { - return; - } + // // + // if (eaMaxAllowedSLsInDay > 0 && + // mNumberOfSLs >= eaMaxAllowedSLsInDay) + // { + // return; + // } // ENUM_X_SIGNAL_EXECUTION_RESULT state; @@ -593,11 +593,11 @@ void OnStopLossTriggered(const XDeal &deal) // Finish ... eaTradeHandler.Finish(deal); - // - if (deal.profit < 0) - { - mNumberOfSLs++; - } + // // + // if (deal.profit < 0) + // { + // mNumberOfSLs++; + // } } // diff --git a/Helpers/x-saherelm.xchstr.helper.mq5 b/Helpers/x-saherelm.xchstr.helper.mq5 index 4ca1e329..6ccda110 100644 --- a/Helpers/x-saherelm.xchstr.helper.mq5 +++ b/Helpers/x-saherelm.xchstr.helper.mq5 @@ -1582,6 +1582,198 @@ public: return result; } + // + double GetMax( + int barIndex // Bar Index + ) + { + // + double result = 0; + + // + ENUM_X_MARKET_CYCLES cycles[]; + int cyclesCount = GetAllMarketCycles(cycles); + if (!IsValidSize(cyclesCount)) + { + return result; + } + + // + result = GetCyclesMax( + barIndex, + cycles // + ); + + // + return result; + } + + // + double GetMin( + int barIndex // Bar Index + ) + { + // + double result = 0; + + // + ENUM_X_MARKET_CYCLES cycles[]; + int cyclesCount = GetAllMarketCycles(cycles); + if (!IsValidSize(cyclesCount)) + { + return result; + } + + // + result = GetCyclesMin( + barIndex, + cycles // + ); + + // + return result; + } + + // + double GetMaxBullish( + int barIndex // Bar Index + ) + { + // + double result = 0; + + // + ENUM_X_MARKET_CYCLES cycles[]; + int cyclesCount = GetAllMarketCycles(cycles); + if (!IsValidSize(cyclesCount)) + { + return result; + } + + // + double values[]; + int valuesCount = GetBullishTrends( + values, + barIndex, + cycles // + ); + if (!IsValidSize(valuesCount)) + { + return result; + } + + // + result = GetSpecifiedMax(values); + + // + return result; + } + + // + double GetMinBullish( + int barIndex // Bar Index + ) + { + // + double result = 0; + + // + ENUM_X_MARKET_CYCLES cycles[]; + int cyclesCount = GetAllMarketCycles(cycles); + if (!IsValidSize(cyclesCount)) + { + return result; + } + + // + double values[]; + int valuesCount = GetBullishTrends( + values, + barIndex, + cycles // + ); + if (!IsValidSize(valuesCount)) + { + return result; + } + + // + result = GetSpecifiedMin(values); + + // + return result; + } + + // + double GetMaxBearish( + int barIndex // Bar Index + ) + { + // + double result = 0; + + // + ENUM_X_MARKET_CYCLES cycles[]; + int cyclesCount = GetAllMarketCycles(cycles); + if (!IsValidSize(cyclesCount)) + { + return result; + } + + // + double values[]; + int valuesCount = GetBearishTrends( + values, + barIndex, + cycles // + ); + if (!IsValidSize(valuesCount)) + { + return result; + } + + // + result = GetSpecifiedMax(values); + + // + return result; + } + + // + double GetMinBearish( + int barIndex // Bar Index + ) + { + // + double result = 0; + + // + ENUM_X_MARKET_CYCLES cycles[]; + int cyclesCount = GetAllMarketCycles(cycles); + if (!IsValidSize(cyclesCount)) + { + return result; + } + + // + double values[]; + int valuesCount = GetBearishTrends( + values, + barIndex, + cycles // + ); + if (!IsValidSize(valuesCount)) + { + return result; + } + + // + result = GetSpecifiedMin(values); + + // + return result; + } + // double GetCyclesMax( int barIndex, // Bar Index @@ -1604,7 +1796,7 @@ public: } // - result = GetMax(trends); + result = GetSpecifiedMax(trends); // return result; @@ -1632,7 +1824,7 @@ public: } // - result = GetMin(trends); + result = GetSpecifiedMin(trends); // return result; @@ -1660,7 +1852,7 @@ public: } // - result = GetMax(trends); + result = GetSpecifiedMax(trends); // return result; @@ -1688,7 +1880,7 @@ public: } // - result = GetMin(trends); + result = GetSpecifiedMin(trends); // return result; @@ -1716,7 +1908,7 @@ public: } // - result = GetMax(trends); + result = GetSpecifiedMax(trends); // return result; @@ -1744,7 +1936,7 @@ public: } // - result = GetMin(trends); + result = GetSpecifiedMin(trends); // return result; diff --git a/Strategies/x-saherelm.xchkm.strategy.mq5 b/Strategies/x-saherelm.xchkm.strategy.mq5 index 831bf0e4..715d8cb6 100644 --- a/Strategies/x-saherelm.xchkm.strategy.mq5 +++ b/Strategies/x-saherelm.xchkm.strategy.mq5 @@ -571,31 +571,56 @@ public: double chhkMaxBullishLow = chhkHelper.GetMaxBullishLow(cIndex); double chhkMinBullishLow = chhkHelper.GetMinBullishLow(cIndex); + // + double chmBullishPower = chmHelper.GetBullishPower(cIndex); + double chmBearishPower = chmHelper.GetBearishPower(cIndex); + + // + double chmMaxBullishFast = chmHelper.GetMaxBullishFast(cIndex); + double chmMinBullishFast = chmHelper.GetMinBullishFast(cIndex); + double chmMaxBullishSlow = chmHelper.GetMaxBullishSlow(cIndex); + double chmMinBullishSlow = chmHelper.GetMinBullishSlow(cIndex); + double chmMaxBearishFast = chmHelper.GetMaxBearishFast(cIndex); + double chmMinBearishFast = chmHelper.GetMinBearishFast(cIndex); + double chmMaxBearishSlow = chmHelper.GetMaxBearishSlow(cIndex); + double chmMinBearishSlow = chmHelper.GetMinBearishSlow(cIndex); + + // + double chstrBullishPower = chstrHelper.GetBullishPower(cIndex); + double chstrBearishPower = chstrHelper.GetBearishPower(cIndex); + + // + double chstrMinBullish = chstrHelper.GetMinBullish(cIndex); + double chstrMaxBullish = chstrHelper.GetMaxBullish(cIndex); + double chstrMinBearish = chstrHelper.GetMinBearish(cIndex); + double chstrMaxBearish = chstrHelper.GetMaxBearish(cIndex); + // // XCHHK ... + int pushers = 0; // if (chhkConditions.isBullishPowerUp) { // - hasLong = + bool chhkHasLong = // hasBullishPower && cBar.IsBullish() && - // hasBullishPattern && + hasBullishPattern && hasBullishPressure && cheConditions.isStrongBullish && cBar.low > chhkMinBullishHigh && - chhkConditions.isBullishPowerUp // && - // chhkConditions.isBullishPowerIncreasing && - // chhkConditions.isBearishPowerDecreasing + chhkConditions.isBullishPowerUp // ; // + hasLong = chhkHasLong; if (hasLong) { // + pushers++; sl = chhkMaxBullishLow; type = POSITION_TYPE_BUY; } @@ -605,24 +630,24 @@ public: if (chhkConditions.isBearishPowerUp) { // - hasShort = + bool chhkHasShort = // hasBearishPower && cBar.IsBearish() && - // hasBearishPattern && + hasBearishPattern && hasBearishPressure && cheConditions.isStrongBearish && cBar.high < chhkMaxBearishLow && - chhkConditions.isBearishPowerUp // && - // chhkConditions.isBearishPowerIncreasing && - // chhkConditions.isBullishPowerDecreasing + chhkConditions.isBearishPowerUp // ; // + hasShort = chhkHasShort; if (hasShort) { // + pushers++; sl = chhkMinBearishHigh; type = POSITION_TYPE_SELL; } @@ -632,56 +657,116 @@ public: // XCHM ... // - // if (chmConditions.isBullishPowerUp) - // { - // // - // hasLong = - // // - // false && - // hasBullishPower && - // cBar.IsBullish() && - // hasBullishPattern && - // cheConditions.isStrongBullish && - // chmConditions.isBullishPowerUp - // // - // ; + if (chmConditions.isBullishPowerUp) + { + // + bool chmHasLong = + // + hasBullishPower && + cBar.IsBullish() && + hasBullishPattern && + hasBullishPressure && + cBar.low > chmMinBullishFast && + cheConditions.isStrongBullish && + chmConditions.isBullishPowerUp + // + ; - // // - // if (hasLong) - // { - // // - // sl = 0; - // type = POSITION_TYPE_BUY; - // } - // } + // + hasLong = chmHasLong; + if (hasLong) + { + // + pushers++; + sl = chmMaxBullishFast; + type = POSITION_TYPE_BUY; + } + } - // // - // if (chmConditions.isBearishPowerUp) - // { - // // - // hasShort = - // // - // false && - // hasBearishPower && - // cBar.IsBearish() && - // hasBearishPattern && - // cheConditions.isStrongBearish && - // chmConditions.isBearishPowerUp - // // - // ; + // + if (chmConditions.isBearishPowerUp) + { + // + bool chmHasShort = + // + hasBearishPower && + cBar.IsBearish() && + hasBearishPattern && + hasBearishPressure && + cBar.high < chmMaxBearishFast && + cheConditions.isStrongBearish && + chmConditions.isBearishPowerUp + // + ; - // // - // if (hasShort) - // { - // // - // sl = 0; - // type = POSITION_TYPE_SELL; - // } - // } + // + hasShort = chmHasShort; + if (hasShort) + { + // + pushers++; + sl = chmMinBearishFast; + type = POSITION_TYPE_SELL; + } + } // // XCHSTR ... + // + if (chstrConditions.isBullishPowerUp) + { + // + bool chstrHasLong = + // + hasBullishPower && + cBar.IsBullish() && + hasBullishPattern && + hasBullishPressure && + cBar.low > chstrMinBullish && + cheConditions.isStrongBullish && + chstrConditions.isBullishPowerUp + // + ; + + // + hasLong = chstrHasLong; + if (hasLong) + { + // + pushers++; + sl = chstrMinBullish; + type = POSITION_TYPE_BUY; + } + } + + // + if (chstrConditions.isBearishPowerUp) + { + // + bool chstrHasShort = + // + hasBearishPower && + cBar.IsBearish() && + hasBearishPattern && + hasBearishPressure && + cBar.high < chstrMaxBearish && + cheConditions.isStrongBearish && + chstrConditions.isBearishPowerUp + // + ; + + // + hasShort = chstrHasShort; + if (hasShort) + { + // + pushers++; + sl = chstrMaxBearish; + type = POSITION_TYPE_SELL; + } + } + // result = hasLong || hasShort; if (!result) @@ -795,6 +880,12 @@ public: tp // ); + // + if (pushers > 1) + { + Print("Pusher: ", pushers); + } + // return result; } @@ -911,9 +1002,9 @@ private: pvInputs.showLevels = false; pvInputs.showConsolidations = false; pvInputs.showFibo1Levels = false; - pvInputs.showFibo2Levels = true; - pvInputs.showFibo3Levels = true; - pvInputs.showFibo4Levels = true; + pvInputs.showFibo2Levels = false; + pvInputs.showFibo3Levels = false; + pvInputs.showFibo4Levels = false; pvInputs.showFibo5Levels = false; // @@ -931,10 +1022,10 @@ private: cheInputs.Default(); // - cheInputs.showLongExit1Line = true; - cheInputs.showShortExit1Line = true; - cheInputs.showLongExit2Line = true; - cheInputs.showShortExit2Line = true; + cheInputs.showLongExit1Line = false; + cheInputs.showShortExit1Line = false; + cheInputs.showLongExit2Line = false; + cheInputs.showShortExit2Line = false; // cheHelper = new XSCXCHEHelper(); @@ -1000,11 +1091,13 @@ private: // chhkInputs.ignoreShadows = true; - chhkInputs.showCurrent = true; - chhkInputs.showShort = true; - chhkInputs.showMedium = true; - chhkInputs.showLong = true; - chhkInputs.showHind = true; + + // + chhkInputs.showCurrent = false; + chhkInputs.showShort = false; + chhkInputs.showMedium = false; + chhkInputs.showLong = false; + chhkInputs.showHind = false; // chhkHelper = new XSCXCHHKHelper();