diff --git a/Classes/x-saherelm.x121.xtrade.handler.class.mq5 b/Classes/x-saherelm.x121.xtrade.handler.class.mq5 index c9b94cb3..81047537 100644 --- a/Classes/x-saherelm.x121.xtrade.handler.class.mq5 +++ b/Classes/x-saherelm.x121.xtrade.handler.class.mq5 @@ -1194,6 +1194,71 @@ class X121SCTradeHandler : public XSCBaseAlert // // In Drawdown Positions Protecting ... + // + // Protect ... + + // + bool AllowProtect() + { + return mAllowProtect; + } + + // + void AllowProtect(bool value) + { + mAllowProtect = value; + } + + // + double ProtectionStartDistance() + { + return mProtectionStartDistance; + } + + // + void ProtectionStartDistance(double value) + { + // + if (value < 0) + { + value = 0; + } + + // + mProtectionStartDistance = value; + } + + // + double ProtectionVolumeMultiplier() + { + return mProtectionVolumeMultiplier; + } + + // + void ProtectionVolumeMultiplier(double value) + { + // + if (value < 0) + { + value = 0; + } + + // + mProtectionVolumeMultiplier = value; + } + + // + bool ProtectOnConditions() + { + return mProtectOnConditions; + } + + // + void ProtectOnConditions(bool value) + { + mProtectOnConditions = value; + } + // // // // Freeze ... // bool AllowFreeze() @@ -1369,7 +1434,8 @@ class X121SCTradeHandler : public XSCBaseAlert // Partial Close (In Drawdown) ... // - double PartialCloseInDrawdownDistance() + double + PartialCloseInDrawdownDistance() { return mPartialCloseInDrawdownDistance; } @@ -2648,6 +2714,20 @@ class X121SCTradeHandler : public XSCBaseAlert // // Reading Requirement for Freezing Positions ... + // + // Protect ... + bool allowProtect = AllowProtect(); + bool protectOnConditions = ProtectOnConditions(); + double protectDistance = ProtectionStartDistance(); + double protectVolumeMultiplier = ProtectionVolumeMultiplier(); + bool canProtect = + !isInProfit && + allowProtect && + supportsCount == 0 && + protectDistance > 0 && + protectVolumeMultiplier > 0 && + MathAbs(profitInPoint) >= Mathbs(protectDistance); + // // bool allowFreeze = AllowFreeze(); // double freezeDistance = FreezeDistance(); @@ -2692,6 +2772,7 @@ class X121SCTradeHandler : public XSCBaseAlert result = canTrail || canFreeze || + canProtect || canSupport || canPartialClose; if (!result) @@ -3189,11 +3270,30 @@ class X121SCTradeHandler : public XSCBaseAlert // } // } + // + // Protect ... + bool isProtected = false; + if (canProtected) + { + // + bool hasLongProtectConditions = isTicksBullishForLong && + hasBullishConditions; + bool hasShortProtectConditions = isTicksBearishForShort && + hasBearishConditions; + bool hasProtectConditions = hasLongProtectConditions || + hasShortProtectConditions; + if (hasSupportConditions) { + // + + } + } + // result = isTrailed || isFreezed || isSupported || + isProtected || isPartialClosed; // @@ -3248,6 +3348,13 @@ class X121SCTradeHandler : public XSCBaseAlert // // In Drawdown Positions Protecting ... + // + // Protect ... + bool mAllowProtect; // Allow Proptecting + double mProtectionStartDistance; // Protection Start Drawdown in Profit + double mProtectionVolumeMultiplier; // Protection Volume Multiplier + bool mProtectOnConditions; // Do Protection only when Conditions happens + // // Freeze ... // bool mAllowFreeze; // Allow Freezing