diff --git a/Classes/x-saherelm.x121.setup.xea.mq5 b/Classes/x-saherelm.x121.setup.xea.mq5 index 1cf1a8dd..35342f91 100644 --- a/Classes/x-saherelm.x121.setup.xea.mq5 +++ b/Classes/x-saherelm.x121.setup.xea.mq5 @@ -4877,10 +4877,11 @@ protected: // bool isMarginPassed = IsMarginPassed(); - if (!isMarginPassed) + bool isDrawdownPassed = IsDrawdownPassed(); + if (!isDrawdownPassed) { // - string message = "No Margin For Execute Signals ..."; + string message = "Desn't Have Good State For Execute Signals ..."; // Alert(message); @@ -4999,6 +5000,24 @@ protected: return result; } + // + bool IsDrawdownPassed() { + // + bool result = false; + + // + double maxAllowedDrawdownPercent = 5; // MaxAllowedDrawdownPercent(); + double drawdownPercent = GetDrawdownPercent(); + + // + result = maxAllowedDrawdownPercent <=0 + ? true + : drawdownPercent <= maxAllowedDrawdownPercent; + + // + return result; + } + // // EQM Functions ... @@ -5125,16 +5144,15 @@ protected: } // - bool isForce = mSetups[setupIDX].ForceState(); - if (!isForce) + // bool isForce = mSetups[setupIDX].ForceState(); + if (!mForce) { return; } // - // Check Delay Between Two Signals ... - bool isMarginPassed = IsMarginPassed(); - bool isDelayPassed = IsSignalDelayPassed(signal); + // TODO: Implement this later ... + return; // XSignal signals[]; @@ -5225,6 +5243,29 @@ protected: { return; } + + // + // Exit From Force State ... + + // + // One: Based On Positions Count ... + XPosition positions[]; + int positionsCount = mTrader.GetPositions(positions); + if (!IsValidSize(positionsCount)) { + // + mForce = false; + return; + } + + // + // Two: Based On Free Margin ... + bool isMarginPassed = IsMarginPassed(); + bool isDrawdownPassed = IsDrawdownPassed(); + if (isDrawdownPassed) { + // + mForce = false; + return; + } // // Additional Works on Force States ... diff --git a/MQL5.code-workspace b/MQL5.code-workspace index 8f4073c0..1c16752b 100644 --- a/MQL5.code-workspace +++ b/MQL5.code-workspace @@ -7,6 +7,7 @@ "settings": { "C_Cpp.default.includePath": [ "c:\\Users\\saherelm\\AppData\\Roaming\\MetaQuotes\\Terminal\\FAE4959D5A0334AE230243FCFFFD4053\\MQL5\\Include" - ] + ], + "C_Cpp.clang_format_style": "file:c:\\Users\\SaherElm\\.vscode\\extensions\\l-i-v.mql-tools-2.1.0\\files\\.clang-format" } } \ No newline at end of file