3 Technical MT5 Bugs That Silently Trigger Drawdown Violations (CET/EST DST, Open Commissions, Balance Payouts)
Most accounts that fail strict evaluation or risk-limit rules do not blow up because a strategy stopped working overnight. They get clipped by silent accounting mismatches between how traders expect MetaTrader 5 to compute daily P&L and what MQL5 terminal functions actually return on each tick.
When auditing drawdown monitors in MQL5, three recurring bugs cause false triggers—or worse, delayed reactions that let losses run past hard equity limits. Below is how each bug arises inside MT5 and the exact pure-MQL5 patterns required to fix it cleanly without external DLLs.
1. Bug #1: Broker Midnight Is Rarely Rule Reset Midnight (Plus EU vs US DST Drift)
Almost every free equity indicator marks daily starting balance using iTime(_Symbol, PERIOD_D1, 0) or TimeCurrent() midnight. That fails whenever your broker clock differs from the account's actual evaluation reset clock.
- Broker servers often run fixed UTC+2 / UTC+3 (or EET), while rules reset strictly at 00:00 Europe/Prague (CET/CEST) or 17:00 / 00:00 America/New_York (EST/EDT).
- Europe switches DST clocks on the last Sunday of March and October (01:00 UTC), while the US switches on the second Sunday of March and first Sunday of November, creating 1-3 week annual 1-hour drift windows.
- Strategy Tester simulations return simulated server time from TimeGMT() , requiring explicit tester offset correction.
Clean MQL5 Fix:
Compute EU and US DST state directly from UTC calendar arithmetic rather than Windows registry calls or external libraries:
bool IsEuDstUtc(const datetime utcTime)
{
MqlDateTime dt;
TimeToStruct(utcTime, dt);
MqlDateTime mStart; ZeroMemory(mStart);
mStart.year = dt.year; mStart.mon = 3; mStart.day = 31; mStart.hour = 1;
datetime mar31 = StructToTime(mStart); TimeToStruct(mar31, mStart);
datetime dstStart = mar31 - (datetime)mStart.day_of_week * 86400;
MqlDateTime mEnd; ZeroMemory(mEnd);
mEnd.year = dt.year; mEnd.mon = 10; mEnd.day = 31; mEnd.hour = 1;
datetime oct31 = StructToTime(mEnd); TimeToStruct(oct31, mEnd);
datetime dstEnd = oct31 - (datetime)mEnd.day_of_week * 86400;
return (utcTime >= dstStart && utcTime < dstEnd);
} 2. Bug #2: Live POSITION_PROFIT Omits Open Entry Commissions
MetaTrader 5 provides POSITION_PROFIT and POSITION_SWAP , but there is no POSITION_COMMISSION property for live open positions on raw-spread commission accounts. Entry commissions deducted on DEAL_ENTRY_IN remain hidden until close unless queried from HistorySelectByPosition(POSITION_IDENTIFIER) :
double GetEntryCommissionForPosition(const long posId)
{
if(posId <= 0 || !HistorySelectByPosition((ulong)posId))
return 0.0;
double comm = 0.0;
int total = HistoryDealsTotal();
for(int i = 0; i < total; i++)
{
ulong ticket = HistoryDealGetTicket(i);
if(ticket == 0) continue;
ENUM_DEAL_ENTRY entryType = (ENUM_DEAL_ENTRY)HistoryDealGetInteger(ticket, DEAL_ENTRY);
if(entryType == DEAL_ENTRY_IN || entryType == DEAL_ENTRY_INOUT)
{
comm += HistoryDealGetDouble(ticket, DEAL_COMMISSION);
comm += HistoryDealGetDouble(ticket, DEAL_FEE);
}
}
return comm;
} When summing closed deals today after rollover, filter out DEAL_COMMISSION / DEAL_FEE belonging to still-open position IDs so entry commission is never double-counted.
3. Bug #3: Withdrawals and Payouts Trigger False Daily Drawdown Locks
When a payout withdrawal executes, the broker records a negative DEAL_TYPE_BALANCE transaction. Comparing ACCOUNT_EQUITY directly against dayStartBalance misinterprets a payout as a sudden trading loss and triggers false emergency closes. Always separate DEAL_TYPE_BUY / DEAL_TYPE_SELL from DEAL_TYPE_BALANCE , DEAL_TYPE_CREDIT , DEAL_TYPE_CHARGE , and DEAL_TYPE_CORRECTION when calculating adjusted daily equity:
adjustedEquity = AccountInfoDouble(ACCOUNT_EQUITY) - todayBalanceOps;
Ready-to-Use Implementation on MQL5 Market
Both utilities in this pure-MQL5 suite implement this exact ledger architecture with zero external DLLs:
- Prop Rule Live Monitor MT5 (Free Read-Only Telemetry): https://www.mql5.com/en/market/product/210548
- Prop Rule Shield and Risk Panel MT5 (Automated Account Guardian & Visual Trade Planner): https://www.mql5.com/en/market/product/210550
In Part 2, we examine how End-of-Day (EOD) Trailing Drawdown updates high-water marks at rollover and clamps floors at starting balance in MQL5.


