Fix warningPrinted scope - restructure CheckDailyDrawdown function

This commit is contained in:
2026-03-29 22:27:13 -04:00
parent 04756ef2bd
commit 16b69d251c
2 changed files with 21 additions and 8 deletions

View File

@@ -128,7 +128,8 @@ bool CheckDailyDrawdown()
{
static bool warningPrinted = false;
if(InpMaxDailyDrawdown <= 0) return true; // Protection disabled
if(InpMaxDailyDrawdown <= 0)
return true; // Protection disabled
datetime today = TimeCurrent() / 86400 * 86400;
if(today != lastEquityReset)
@@ -142,11 +143,14 @@ bool CheckDailyDrawdown()
}
double currentEquity = AccountInfoDouble(ACCOUNT_EQUITY);
if(dailyStartEquity <= 0) return true;
if(dailyStartEquity <= 0)
return true;
double drawdownPercent = (dailyStartEquity - currentEquity) / dailyStartEquity * 100;
if(drawdownPercent >= InpMaxDailyDrawdown)
bool overLimit = (drawdownPercent >= InpMaxDailyDrawdown);
if(overLimit)
{
if(!warningPrinted)
{
@@ -157,8 +161,11 @@ bool CheckDailyDrawdown()
}
return false; // Block new trades
}
else
{
warningPrinted = false; // Reset when below limit
}
warningPrinted = false; // Reset when below limit
return true;
}