From 59d11b91086b0de28a7d204826cc7978f5b6e744 Mon Sep 17 00:00:00 2001 From: Hadi Khazaee Asl Date: Tue, 17 Sep 2024 14:23:09 -0700 Subject: [PATCH] last try to debug Position Protecting ... --- .../x-saherelm.x121.xtrade.handler.class.mq5 | 12 ++++++--- Experts/x-saherelm.x121.ea.mq5 | 27 ++++++++++++++----- 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/Classes/x-saherelm.x121.xtrade.handler.class.mq5 b/Classes/x-saherelm.x121.xtrade.handler.class.mq5 index ae8cb8f8..bb05fd2b 100644 --- a/Classes/x-saherelm.x121.xtrade.handler.class.mq5 +++ b/Classes/x-saherelm.x121.xtrade.handler.class.mq5 @@ -2055,14 +2055,18 @@ class X121SCTradeHandler : public XSCBaseAlert // double iSymbolPoint = GetPoints(iPosition.symbol); - double iDistance = MathAbs(iPosition.profit) / iSymbolPoint; + double iDistance = MathAbs(iPosition.profit) * iSymbolPoint; // bool isDistancePassed = iDistance >= requiredDistance; - bool isProtected = HandlePositionProtecting(iPosition); - if (isProtected) + if (isDistancePassed) { - protectedPositions++; + // + bool isProtected = HandlePositionProtecting(iPosition); + if (isProtected) + { + protectedPositions++; + } } } diff --git a/Experts/x-saherelm.x121.ea.mq5 b/Experts/x-saherelm.x121.ea.mq5 index 2f5c2321..fbe6dbc2 100644 --- a/Experts/x-saherelm.x121.ea.mq5 +++ b/Experts/x-saherelm.x121.ea.mq5 @@ -82,6 +82,20 @@ input int eaMaxAllowedLongs = 2; // Max Allowed Long Position input int eaMaxAllowedShorts = 2; // Max Allowed Short Positions input double eaMaxDrawdownPercentForOpenTrades = 3; // Max Drawdown Percent for Open Trades +// +// Protector ... +input group "Protector"; +input int eaDelayBarBetweenTwoSameSignal = 5; // Delay Bars Between Two Same Type Signal +input double eaProtectorStartDistanceInPoint = 35; // Protector Start Distance in Point + +// +// Protector > Hedging Properties ... +input bool eaAllowHedge = false; // Allow Protector to Hedge Positions +input double eaHedgeMinVolumeStep = 0.01; // Minimum Volume Step For Hedge +input int eaMinimumOpenPositionsForHEHedge = 2; // Minimum Open Positions For HE Hedge +input double eaHedgeHEMinProfitPerVolumeStep = 0.2; // Minimum Required Profit For HE Hedge Per Volume Step +input double eaHedgeBEMinProfitPerVolumeStep = 0.05; // Minimum Required Profit For BE Hedge Per Volume Step + // // Alert ... input group "Alert"; @@ -440,18 +454,17 @@ bool InitialEA() // // Configure Position Protector ... - // TODO: Configure it using Inputs ... // - eaTradeHandler.DelayBarBetweenTwoSameSignal(5); - eaTradeHandler.ProtectorStartDistanceInPoint(35); + eaTradeHandler.DelayBarBetweenTwoSameSignal(eaDelayBarBetweenTwoSameSignal); + eaTradeHandler.ProtectorStartDistanceInPoint(eaProtectorStartDistanceInPoint); // // Configure Hedging ... - eaTradeHandler.AllowHedge(true); - eaTradeHandler.HedgeMinVolumeStep(0.01); - eaTradeHandler.MinimumOpenPositionsForHEHedge(2); - eaTradeHandler.HedgeHEMinProfitPerVolumeStep(0.2); + eaTradeHandler.AllowHedge(eaAllowHedge); + eaTradeHandler.HedgeMinVolumeStep(eaHedgeMinVolumeStep); + eaTradeHandler.MinimumOpenPositionsForHEHedge(eaMinimumOpenPositionsForHEHedge); + eaTradeHandler.HedgeHEMinProfitPerVolumeStep(eaHedgeHEMinProfitPerVolumeStep); // // TODO: Implement ...