Prop Firm DrawDown Guard MT5
- ユーティリティ
- Branko Balog
- バージョン: 1.0
- アクティベーション: 5
Prop Firm Drawdown Guard EA – Documentation (MT5 Version)
Version: 1.00
Platform: MetaTrader 5 (MT5)
Author: Branko Balog
Website: https://www.mql5.com
🛡️ Purpose
This Expert Advisor (EA) helps prop firm traders adhere to drawdown rules by monitoring daily and total account equity loss and enforcing restrictions when thresholds are breached.
It performs the following actions:
- Monitors account equity in real-time
- Closes all open positions when drawdown limits are hit
- Blocks opening of new trades for the day if required
- Sends alerts and/or notifications upon drawdown breaches
⚙️ Inputs
Parameter | Type | Description
------------------------------|---------|---------------------------------------------------------------
MaxDailyDrawdownPercent | double | Maximum allowed daily drawdown in percentage of daily start equity.
MaxTotalDrawdownPercent | double | Maximum allowed total drawdown in percentage of initial balance.
BlockTradingAfterDrawdown | bool | Blocks new trades for the day if drawdown limits are breached.
EnableAlerts | bool | Enables terminal alerts when drawdown is exceeded.
EnableEmail | bool | Sends email notification (requires setup in terminal options).
EnablePush | bool | Sends mobile push notification (requires setup in terminal options).
EnableLog | bool | Logs drawdown events to the Experts tab.
⏱️ How It Works
- At EA initialization, it records the current equity and balance.
- Each new day, it resets the "day start equity" to monitor daily drawdown.
- Continuously compares the current equity to:
- Daily start equity → for daily drawdown check
- Initial balance → for total drawdown check
- If either threshold is breached:
- All positions are closed immediately
- New trade entries are blocked (if enabled)
- Optional alerts are triggered (alert/email/push/log)
🧠 Special Logic
- Uses `TimeDay(TimeCurrent())` to detect start of new day.
- Uses `CTrade` class for order operations (MT5 standard library).
- Trades are blocked after a drawdown breach for the rest of the day if the option is enabled.
- All types of open positions are force-closed; new positions are not allowed until the next day.
✅ Compatible With
- MetaTrader 5 platforms (builds supporting standard MQL5 trade library)
- All prop firm challenge accounts (e.g., FTMO, MyForexFunds, etc.)
- All symbols and timeframes