Advance Risk Manager Equity and Trade Protection
- Utilità
- Roshani Moghaddam Parham
- Versione: 1.0
- Attivazioni: 5
Risk Manager EA monitors all your open positions and account equity automatically, closing trades when your defined risk thresholds are hit. It runs two independent modules simultaneously: a Per-Trade PnL Manager that watches each individual trade, and an Account Equity Manager that guards your total account balance.
The EA does not open trades. It works alongside any signal EA, manual trading, or copy-trading service as a protective layer that enforces your risk rules automatically.
Key Features
- Two independent risk modules in one EA — no need to run separate EAs on multiple charts
- Per-trade protection: close trades at fixed $ profit/loss or % move from entry price
- Account-level protection: 4 baseline modes — Defined, Auto, Daily, Trailing
- Smart Close logic: profitable positions close first; all close only if none are profitable
- Priority execution: PnL Manager fires before Equity Manager each cycle
- Timer-based polling via OnTimer() — works even on low-activity symbols and during news gaps
- External SL detection in Trailing mode — resets trailing high on broker-side stop outs
- Automatic baseline reset in Auto mode when account goes flat
- Compatible with all brokers — auto-detects FOK, IOC, or RETURN order filling
How It Works
Every Check Interval seconds the EA runs in this order:
- PnL Manager scans all open positions and closes any hitting their per-trade TP or SL
- Equity Manager re-reads account equity after PnL closures and checks account-level thresholds
If both thresholds are hit at the same time, PnL Manager closes trades first. The Equity Manager then re-evaluates — if equity is no longer in breach, it does nothing.
Per-Trade PnL Manager
Fixed mode: closes a trade when floating P&L reaches +TP or -SL in account currency.
Percentage mode: closes a trade when price moves +TP% or -SL% from the entry price.
- Buy: (Current Bid - Entry) / Entry x 100
- Sell: (Entry - Current Ask) / Entry x 100
Account Equity Manager — 4 Baseline Modes
Defined — baseline is a fixed value you set manually. Never changes. Ideal for prop firm challenges where you know the exact drawdown limit.
Auto — baseline starts at current balance. Resets automatically when all positions close. Each trading cycle starts a fresh risk window.
Daily — baseline refreshes at midnight (server time) every day. Perfect for day traders who want limits that reset each morning.
Trailing — baseline trails the running equity high. SL is measured from the peak, TP from the current balance. The floor rises as the account grows. Includes external SL detection.
Smart Close Logic
When the equity threshold is triggered:
- Profitable positions exist: close winners only, leave losing trades open to recover
- No profitable positions: close all positions to stop further damage
Input Parameters
General Settings:
- Check Interval (seconds) — default 10. Recommended 5–15 for active trading.
Per-Trade PnL Manager:
- PnL Mode — Disabled / Fixed Amount / Percentage
- Per-Trade TP — take profit per trade ($ or %)
- Per-Trade SL — stop loss per trade ($ or %)
Account Equity Manager:
- Baseline Mode — Disabled / Defined / Auto / Daily / Trailing
- TP / SL Type — Fixed Amount or Percentage
- Define Baseline — used in Defined mode only
- TP — account-level take profit
- SL — account-level stop loss
Recommended Configurations
Prop firm challenge:
Baseline: Defined, TP/SL Type: Fixed. Set Define Baseline to your starting balance, TP to your daily profit target, SL to your maximum drawdown limit.
Day trading:
Baseline: Daily. Set TP and SL as your daily goal and maximum loss. Enable PnL Mode for additional per-trade control.
Growing account protection:
Baseline: Trailing, TP/SL Type: Percentage. TP 3–5%, SL 1–2%.
Installation
- Copy Risk_Manager.ex5 to your MQL5/Experts/ folder
- Attach to any chart — the EA monitors all account positions regardless of symbol
- Enable Allow Algo Trading in MetaTrader settings
- Set your inputs and click OK
Important Notes
- Trades are closed at market price — slippage may occur during fast markets or news events
- The EA must remain running to provide protection — it does not act while MetaTrader is offline
- Both modules can run simultaneously for maximum protection
- Set either module to Disabled to suspend it without removing the EA from the chart
Trading involves significant risk of loss. This EA is a risk management tool, not a guarantee against losses. Always test on a demo account before deploying on a live account.
