Account Protector Pro
- Utilità
- projektfarm GmbH
- Versione: 1.0
Account Protector Pro is a free, lightweight Expert Advisor that monitors open positions and closes them when they exceed your configured profit or loss thresholds. It includes a daily loss limit that halts trading when triggered.
Features Overview
- Weekend Gap Detection — Detects when markets reopen after a weekend gap and scans positions based on your configured thresholds.
- Per-Trade Thresholds — Set a maximum profit or loss amount for individual trades. Positions that reach the limit are closed automatically.
- Daily Loss Limit — Define a maximum daily drawdown. When equity drops below the threshold, all positions are closed.
- Max Account Drawdown — Total drawdown limit from a reference balance that works across trading days. Useful for accounts with strict drawdown rules.
- Equity Trailing Stop — Tracks your equity high-water mark and closes all positions if equity drops by a set amount from the peak.
- Runs Alongside Other EAs — Monitors positions opened by other EAs without interfering with their logic.
Closing Conditions
- Per-trade profit and loss close — close any position that exceeds a configured profit or loss amount
- Lot-scaled loss limit — set a loss limit per 0.01 lot that scales with position size
- Daily account loss limit — close all positions when daily drawdown is hit, then halt trading for the day
- Max account drawdown — total drawdown limit from a reference balance, works across trading days and survives EA restarts
- Equity trailing stop — tracks equity high-water mark, closes all when equity drops by a set amount, then resets and resumes trailing
Filters and Options
- Symbol filter — monitor one specific instrument or all open positions
- Lot size filter — only act on positions above a minimum lot size
- Magic number filter — target trades from a specific EA, or monitor all trades
- Weekend-only mode — activate only after weekend gaps (timezone-agnostic detection)
- Configurable delay — wait N seconds after market open before scanning
- Retry logic — automatic retries with configurable slippage
- Multi-channel alerts — popup, push notification, and email alerts on every action
- Built-in test mode — opens trades in the Strategy Tester so you can verify closing logic
Input Parameters
Symbol and Trade Filter
- Symbol — leave empty to monitor all instruments, or enter a specific symbol (e.g. EURUSD)
- Min Lots — minimum lot size to trigger (0 = any size)
- Magic Number — filter by magic number (-1 = any EA)
Per-Trade Thresholds
- Profit Close — close if trade profit reaches this amount (0 = disabled)
- Loss Close — close if trade loss reaches this amount, entered as a positive number (0 = disabled)
- Loss Per 0.01 Lot — loss limit per 0.01 lot. Scales with position size (e.g., 2 per 0.01 lot = a 1.0 lot trade closes at 200 loss). (0 = disabled)
Account-Level Limits
- Daily Loss Limit — maximum daily account loss. When equity drops below (day-start balance minus limit), all positions are closed (0 = disabled)
- Max Drawdown — maximum total drawdown from the reference balance. Closes all positions and halts the EA when hit (0 = disabled)
- Reference Balance — the balance to measure drawdown from. Set this to your account starting balance so the limit survives EA restarts (0 = use balance at EA startup)
- Equity Trailing Stop — close all positions if equity drops this amount from its peak (high-water mark). After closing, the peak resets and trailing resumes. (0 = disabled)
Timing
- Weekend Only — only activate after weekend gaps
- Delay Seconds — seconds to wait after market open before acting
Close Order Settings
- Slippage — max slippage in points (default 50)
- Max Retries — number of retry attempts on failed close orders
Notifications
- Alert Popup — show alert popup on close
- Push Notification — send push notification to mobile
- Email Notification — send email alert
Usage Examples
Example 1: Weekend Gap Scanning on EURUSD
- Symbol: EURUSD
- Min Lots: 1.0
- Profit Close: 5000
- Loss Close: 2000
- Weekend Only: true
- Delay: 30 seconds
Monitors EURUSD positions of 1+ lots. After the Monday open, waits 30 seconds, then closes any position above 5000 profit or 2000 loss.
Example 2: Daily Loss Limit
- Symbol: (empty, monitors all)
- Daily Loss Limit: 5000
- Weekend Only: false
Monitors all positions on every tick. If total daily drawdown reaches 5000, all open positions are closed and the EA halts for the rest of the day.
Example 3: Drawdown Rule Compliance
- Symbol: (empty, monitors all)
- Loss Close: 500 per trade
- Daily Loss Limit: 2500
- Max Drawdown: 5000
- Reference Balance: 100000
- Weekend Only: false
Useful for accounts with drawdown rules. Individual trades close at 500 loss, daily loss is limited to 2500, and total drawdown from the 100000 reference balance is limited to 5000. If equity drops below 95000, all positions are closed and the EA halts.
Example 4: Lot-Scaled Loss Limit
- Symbol: (empty, monitors all)
- Loss Per 0.01 Lot: 3.00
- Weekend Only: false
Loss limits scale with position size: a 0.10 lot trade closes at 30 loss, a 0.50 lot trade at 150, and a 1.0 lot trade at 300. Useful for accounts running multiple position sizes.
Example 5: Equity Trailing Stop
- Equity Trailing Stop: 1000
- Weekend Only: false
The EA tracks your equity high-water mark. If equity reached 52000 at its peak and drops to 51000, all positions are closed. After closing, the peak resets to the new equity level and trailing resumes.
How It Works
- On every tick, the EA checks if a new trading day has started and resets daily tracking.
- If Weekend Only is enabled, it detects weekend gaps by measuring the time since the last tick (more than 48 hours = weekend gap). This method is timezone-agnostic and works with any broker.
- If a delay is configured, the EA waits the specified number of seconds after market open before scanning.
- It checks the max account drawdown (reference balance minus current equity). If reached, it closes all positions and halts.
- It checks the daily account loss limit (day-start balance minus current equity). If reached, it closes all positions and halts for the rest of the day.
- It checks the equity trailing stop (peak equity minus current equity). If the drop exceeds the limit, all positions are closed, the peak resets, and trailing resumes.
- It scans all open positions matching the configured filters and closes any that exceed the profit or loss thresholds.
Built-In Test Mode
Since this EA only closes trades (it does not open them), testing in the Strategy Tester would normally show nothing. The built-in Test Mode solves this by automatically opening trades so you can verify each closing scenario.
Test Mode only works in the Strategy Tester. If you accidentally leave it enabled on a live chart, it will show a warning and refuse to open any trades. Test trades use a dedicated magic number and comment tag for identification.
At the end of every backtest, a summary is printed to the Experts log showing trades opened, trades closed, daily limits triggered, and more.
Important Notes
- The EA must be running and connected when the market opens.
- Loss values are entered as positive numbers (e.g., enter 2000 to close at 2000 loss).
- The daily loss limit compares starting balance vs current equity (includes floating P/L).
- The daily loss limit resets at the start of each new trading day.
- The max drawdown limit does not reset. Once triggered, the EA halts until restarted. Set the Reference Balance to your account starting balance so the limit survives EA restarts.
- Slippage is set to 50 points by default.
- Weekend detection uses time-gap measurement, not day-of-week, so it works correctly regardless of broker server timezone.
- All monetary thresholds (profit, loss, daily limit) use your account deposit currency.
- All actions are logged to the Experts tab in MetaTrader 5.
Support
If you have questions, feature requests, or encounter any issues, please leave a comment or send a message.
