From f21e2c13dcef704812b69b0c86cd6add3ac46b18 Mon Sep 17 00:00:00 2001 From: Hadi Khazaee Asl Date: Fri, 23 Aug 2024 23:40:02 +0330 Subject: [PATCH] apply long and short 1 conditions on xch che strategy ... --- Libraries/x-saherelm.common.lib.mq5 | 47 ++++++++ Strategies/x-saherelm.xch.che.strategy.mq5 | 122 ++++++++++++++++++++- 2 files changed, 164 insertions(+), 5 deletions(-) diff --git a/Libraries/x-saherelm.common.lib.mq5 b/Libraries/x-saherelm.common.lib.mq5 index 6f12f3a6..14222a6e 100644 --- a/Libraries/x-saherelm.common.lib.mq5 +++ b/Libraries/x-saherelm.common.lib.mq5 @@ -1928,6 +1928,53 @@ struct XOHCL return result; } + // + // Decisions ... + + // + bool IsBullishDecision( + double percent = 70 // Percent of Body + ) + { + // + bool result = false; + + // + result = + // + IsValid() && + Index() > 0 && + IsBullish() && + (GetRange() * percent) / 100 <= GetBody() + // + ; + + // + return result; + } + + // + bool IsBearishDecision( + double percent = 70 // Percent of Body + ) + { + // + bool result = false; + + // + result = + // + IsValid() && + Index() > 0 && + IsBearish() && + (GetRange() * percent) / 100 <= GetBody() + // + ; + + // + return result; + } + // // Touches ... diff --git a/Strategies/x-saherelm.xch.che.strategy.mq5 b/Strategies/x-saherelm.xch.che.strategy.mq5 index e09a6d83..eaed25db 100644 --- a/Strategies/x-saherelm.xch.che.strategy.mq5 +++ b/Strategies/x-saherelm.xch.che.strategy.mq5 @@ -348,16 +348,128 @@ public: !chvwapConditions.hasBullishPower); // - // Detecting Signals ... - - // - bool isCHHKFullSwitchedToBullish = + bool isCHHKFullSwitchedToBullish = chhkHelper.IsSwitchedToBullish(cIndex); // - bool isCHHKFullSwitchedToBearish = + bool isCHHKFullSwitchedToBearish = chhkHelper.IsSwitchedToBearish(cIndex); + // + bool isBearishPowerDecreasing = + // + conditions.chhkConditions.isBearishPowerDecreasing && + conditions.chcheConditions.isBearishPowerDecreasing + // + ; + + // + bool isBullishPowerDecreasing = + // + conditions.chhkConditions.isBullishPowerDecreasing && + conditions.chcheConditions.isBullishPowerDecreasing + // + ; + + // + bool hasBearishDecision = + // + cBar.IsBearishDecision() + // + || + // + pBar.IsBearishDecision() + // + ; + + // + bool hasBullishDecision = + // + cBar.IsBullishDecision() + // + || + // + pBar.IsBullishDecision() + // + ; + + // + double long1SL = + (cBar.IsBullishDecision() + ? cBar.low + : pBar.low) - + (10 * points); + + // + double short1SL = + (cBar.IsBearishDecision() + ? cBar.high + : pBar.high) - + (10 * points); + + // + // Detecting Signals ... + + // + bool hasLong1 = + // + hasBullishDecision && + notHaveBearishPower && + isBearishPowerDecreasing && + isCHHKFullSwitchedToBullish + // + ; + if (hasLong1) + { + // + pushers++; + Add( + "XCHHKE", + signallers // + ); + + // + sl = long1SL; + type = POSITION_TYPE_BUY; + } + + // + bool hasShort1 = + // + hasBearishDecision && + notHaveBullishPower && + isBullishPowerDecreasing && + isCHHKFullSwitchedToBearish + // + ; + if (hasShort1) + { + // + pushers++; + Add( + "XCHHKE", + signallers // + ); + + // + sl = short1SL; + type = POSITION_TYPE_SELL; + } + + // + hasLong = + // + hasLong1 + // + ; + + // + hasShort = + // + hasShort1 + // + ; + // result = hasLong || hasShort; if (!result)