From a5e1f601d3c91d52eebcd8cefe54a3430903e24f Mon Sep 17 00:00:00 2001 From: Hadi Khazaee Asl Date: Sat, 23 Nov 2024 17:33:51 +0330 Subject: [PATCH] Last ... --- X121SMCEA/Experts/x-121.smc.expert.class.mq5 | 9 + .../x-121.smc.test.strategy.class.mq5 | 159 +++++++++--------- 2 files changed, 85 insertions(+), 83 deletions(-) diff --git a/X121SMCEA/Experts/x-121.smc.expert.class.mq5 b/X121SMCEA/Experts/x-121.smc.expert.class.mq5 index f48dd521..e7f86f99 100644 --- a/X121SMCEA/Experts/x-121.smc.expert.class.mq5 +++ b/X121SMCEA/Experts/x-121.smc.expert.class.mq5 @@ -454,6 +454,15 @@ class XC121SMCExpert : public XCBaseExpert return result; } + // + // Configure Alerts ... + SetAlertPrefix(GetTag()); + SetAlertEnableAlerts(GetAlertEnableAlerts()); + SetAlertLogAlerts(GetAlertLogAlerts()); + SetAlertMailAlerts(GetAlertMailAlerts()); + SetAlertPushAlerts(GetAlertPushAlerts()); + SetAlertTerminalAlerts(GetAlertTerminalAlerts()); + // // Create Trader Instance and Configure it ... mTrader = new XCTrade( diff --git a/X121SMCEA/Strategy/x-121.smc.test.strategy.class.mq5 b/X121SMCEA/Strategy/x-121.smc.test.strategy.class.mq5 index e7088782..3af2a678 100644 --- a/X121SMCEA/Strategy/x-121.smc.test.strategy.class.mq5 +++ b/X121SMCEA/Strategy/x-121.smc.test.strategy.class.mq5 @@ -100,6 +100,7 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy double entry = 0; double reward = 0; double r2r = R2R(); + string provider = ""; double volume = Volume(); ENUM_POSITION_TYPE type = POSITION_TYPE_BUY; ENUM_X_ORDER_MODES mode = X_ORDER_MODE_MARKET; @@ -245,6 +246,15 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy // bool isOrderFlowBullish = IsBullish(mOrderFlowDir); + // + // Check Parabolic Sar is in Order of Order Flow ... + bool isPSarInDirectionOfOrderFlow = + isOrderFlowBullish + ? conditions.xchsarConditions.cSars[0] < cBar.low && + conditions.xchsarConditions.cSars[1] >= pBar.low + : conditions.xchsarConditions.cSars[0] > cBar.high && + conditions.xchsarConditions.cSars[1] <= pBar.high; + // // Check BOS or CHOCH Happens ... bool hasBOS = @@ -282,35 +292,23 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy if (hasBOS || hasCHOCH) { // - RedrawOrderFlow(); - - // - string mTitle = - hasBOS ? "BOS" - : "CHOCH"; - - // - Print(mTitle); - - // - // Here We Have to Decide How to Act Based On - // Conditions for Updating Order Flow ... + // Do on CHOCH ... if (hasCHOCH) { - // + hasLong = // !isOrderFlowBullish && cBar.IsBullish() && (isCBullishMomentumBar || - isCBullishRejectionBar) && + isCBullishRejectionBar) && conditions.xchsarConditions.cSars[0] < cBar.low // ; - if (hasLong) { + if (hasLong) + { // - // selectedSL = conditions.xpvConditions.peaks[1]; - // selectedSL = conditions.xchsarConditions.cSars[1]; + provider = "CHOCH-Long"; selectedSL = cBar.low; } @@ -320,80 +318,60 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy isOrderFlowBullish && cBar.IsBearish() && (isCBearishMomentumBar || - isCBearishRejectionBar) && + isCBearishRejectionBar) && conditions.xchsarConditions.cSars[0] > cBar.high // ; - if (hasShort) { + if (hasShort) + { // - // selectedSL = conditions.xpvConditions.vales[1]; - // selectedSL = conditions.xchsarConditions.cSars[1]; + provider = "CHOCH-Short"; + selectedSL = cBar.high; + } + } + + // + // Do on BOS ... + if (hasBOS) + { + // + hasLong = + // + isOrderFlowBullish && + cBar.IsBullish() && + (isCBullishMomentumBar || + isCBullishRejectionBar) && + conditions.xchsarConditions.cSars[0] < cBar.low + // + ; + + // + if (hasLong) + { + // + provider = "BOS-Long"; + selectedSL = cBar.low; + } + + // + hasShort = + // + !isOrderFlowBullish && + cBar.IsBearish() && + (isCBearishMomentumBar || + isCBearishRejectionBar) && + conditions.xchsarConditions.cSars[0] > cBar.high + // + ; + if (hasShort) + { + // + provider = "BOS-Short"; selectedSL = cBar.high; } } } - // - // Check Parabolic Sar is in Order of Order Flow ... - bool isPSarInDirectionOfOrderFlow = - isOrderFlowBullish - ? conditions.xchsarConditions.cSars[0] < cBar.low && - conditions.xchsarConditions.cSars[1] >= pBar.low - : conditions.xchsarConditions.cSars[0] > cBar.high && - conditions.xchsarConditions.cSars[1] <= pBar.high; - - // - if (isPSarInDirectionOfOrderFlow) - { - RedrawOrderFlow(); - Print(""); - } - else - { - ClearDraws(); - } - - // - bool long1 = - // - false - // - ; - if (long1) - { - // - CustomStateDrawing(mTriggerPOIState); - selectedSL = conditions.xpvConditions.vales[cIndex]; - } - - // - // Works by WVAP and PSar ... - bool short1 = - // - false - // - ; - if (short1) - { - // - CustomStateDrawing(mTriggerPOIState); - selectedSL = conditions.xpvConditions.peaks[cIndex]; - } - - // // - // hasLong = - // // - // long1 - // // - // ; - - // // - // hasShort = - // // - // short1 - // // - // ; - // result = hasLong || hasShort; @@ -449,6 +427,7 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy : entry - reward; // + Print("PRV: ", provider); ClearDraws(); // @@ -466,6 +445,10 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy // result = PrepareSignal(signal); + if (result) + { + ResetOrderFlow(); + } // hasLong = false; @@ -1156,6 +1139,16 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy } } + /** + * When a BOS Happens ... + * we have to Update Order Flow ... + */ + void UpdateOrderFlowOnBOS() + { + // + Print("UpdateOrderFlowOnBOS"); + } + /** * Fill Pivot Tick Zone ... *