WithdrawalTracker
WithdrawalTracker is a utility EA that monitors account balance changes to detect external withdrawals. When a withdrawal is identified, it automatically updates the stored initial deposit global variable to reflect the new account balance for use by other EAs.
Open the interactive view (equity curve, symbol switch)Key facts
Backtest results (H1, about 1 year)
Not backtested yet — this EA could not be converted automatically.
Strategy analysis
This EA is not a trading strategy but an account monitoring utility. It uses a 5-second timer to continuously track account balance changes, with the core logic comparing the current balance against the expected balance to detect withdrawals. Entry and exit conditions are not applicable since it does not execute any trades. Position sizing is irrelevant as the EA never opens or closes positions. For money management, it stores the initial deposit value using MT5 global variables and automatically resets it to the current balance when a withdrawal is detected, enabling other EAs that depend on this global variable to correctly calculate profit. The detection logic relies on comparing the actual balance against the expected balance (last balance + trading profit), where a negative difference is interpreted as a withdrawal event.
Strengths
- Automatically detects account withdrawals and updates the initial deposit value, reducing manual maintenance
- Uses MT5 global variables for data persistence across EA restarts
- Reasonably distinguishes normal trading P&L from external withdrawals by comparing trading profit against balance changes
Weaknesses
- The conditional statement has a logic bug: if(!NormalizeDouble(...) != NormalizeDouble(...)) has operator precedence error — the ! applies to the first value, not the entire comparison
- Only detects withdrawals (negative changes) but ignores deposits (positive changes), making the functionality incomplete
- The 5-second polling interval may miss intermediate state changes in high-frequency trading environments and wastes resources when nothing changes
Possible improvements
- Fix the operator precedence bug — the condition should be if(NormalizeDouble(currentBalance,2) != NormalizeDouble(LastBalanceChecked,2))
- Add detection and handling logic for deposits (positive non-trading balance changes)
- Replace timer polling with OnTradeTransaction event-driven detection for better responsiveness and reduced resource consumption
Risk assessment
Overall risk: Safe
- Operator precedence bug may cause balance change detection to malfunction — the ! operator binds to the NormalizeDouble return value instead of the entire comparison expression
- Global variable naming based on account login ID doesn't account for naming conflicts when multiple EA instances run on the same account
Evaluation scores
Parameters
| Parameter | Default | Description |
|---|---|---|
EventSetTimer interval | 5 | Timer interval (seconds), controls balance check frequency |
MyInitialDeposit | 动态生成 | Global variable name, format: myDeposit_+account login ID |
LastBalanceChecked | 0 | Account balance at last check |
lastDealId | 0 | ID of the last deal at previous check |
Similar Utility EAs
Backtests are historical simulations and do not guarantee future results. Not financial advice.