MT4 Version: Ea CloseManager MT4
MT5 Version: Ea CloseManager MT5
Complete User Documentation — MT4 & MT5
1. OVERVIEW
The Ea CloseManager is a utility that automatically closes trades when your account hits a predefined profit, loss, drawdown, or time limit. It monitors your entire portfolio or just the current chart, and it can work with both manual and EA-placed positions using a magic number filter. The core idea is simple: set your exit rules once, and let the EA enforce them without you staring at the screen. This solves the common problem of letting a winning trade turn into a loser, or failing to cut losses quickly enough during fast markets.
Who Should Use It: Retail forex traders who run multiple positions, trade news events, or want to enforce strict risk limits without manual intervention.
Main Benefit: Automate your trade exits so you never miss a profit target or blow past your max loss — even when you're away from the desk.
2. INPUT PARAMETERS & SETTINGS
This product shares a common set of general input settings with all Utility products in this series. The following sections are covered in the common guide: Position Sizing, Alert Settings (popup, push notification, email), Trade Time Settings (session-based time filters), Trade Days Settings (per-day enable/disable with broker start and end times, covering Monday through Sunday), and Day-wise Time Filter Settings (close trades if outside valid trading time). For full details refer to the Common General Input Settings Guide. The sections below cover only the product-specific inputs unique to this product.
General Settings
These settings define the core behavior of the Close Manager — what it monitors, how it calculates drawdown, and whether it includes swap costs in its profit/loss calculations.
| Setting Name | Type | Default Value | Description | Example |
|---|---|---|---|---|
| Chart lines for virtual SL/TP (never drawn during optimization) | bool | false | When enabled, the EA draws horizontal lines on the chart showing where your virtual stop loss and take profit levels sit. This is purely visual — it helps you see your exit zones without placing actual orders. Disable it during optimization to speed things up. | true — Enable when you're manually monitoring a few charts and want a clear visual of your risk levels. Leave false for backtests. |
| Monitor scope | ENUM | CHART_SYMBOL | See options explained below. | See options explained below. |
| Drawdown calculation mode | ENUM | DD_TRADE_HISTORY | See options explained below. | See options explained below. |
| Include Swap charges in Profit | bool | true | Controls whether overnight swap fees (positive or negative) are counted when the EA checks your profit/loss limits. Set to true for a realistic view of your actual P&L; set to false if you only care about price movement. | true — Keep this on if you hold positions overnight and want swap costs to count toward your loss limit. Turn it off for day trading only. |
| Enable history for backtests or optimization | bool | false | When enabled, the EA loads historical trade data so it can calculate drawdown from closed deals. This is essential for realistic backtesting of drawdown-based exit rules. Leave it off for live trading to save memory. | true — Enable this only during optimization runs where you're testing drawdown limits. Keep it false in live trading. |
Monitor scope — Options Explained
This setting tells the EA which positions to watch. You can either limit it to the current chart's symbol or let it scan your entire account.
CHART_SYMBOL: The EA only monitors trades on the symbol of the chart it's attached to. This is the safest choice if you run multiple EAs on different charts and don't want them interfering with each other. Use this when you have a dedicated chart for each strategy.
ACCOUNT_WIDE: The EA checks all open positions across your entire account, regardless of which chart it's on. This is useful if you want a single Close Manager instance to enforce global profit/loss limits for all your trades. Be careful — it will close positions from other EAs if they hit your limits.
Drawdown calculation mode — Options Explained
This setting changes how the EA measures drawdown from your account's peak. The two methods give different results, especially after partial closes or multiple trades.
DD_TRADE_HISTORY: The EA reconstructs your equity curve by combining closed trade profits with current open P&L. This gives a more accurate picture of your actual drawdown from the start of the trading session. It's the standard method for most retail traders.
DD_PEAK_EQUITY: The EA tracks the highest equity your account has reached and measures drawdown from that peak. This is the method used by prop firms — it resets only when you hit a new equity high. Use this if you're practicing for a funded account challenge.
Safeguard Settings
These settings let you set early warnings before the EA takes action, giving you a chance to intervene manually if you want.
| Setting Name | Type | Default Value | Description | Example |
|---|---|---|---|---|
| Alert at this % of limit before trigger [0: disable] | double | 80 | Sets a warning threshold as a percentage of your profit or loss limit. When the current P&L reaches this level, the EA fires an alert (popup, email, or push) but does not close trades. This gives you a heads-up before the automatic exit kicks in. | 80 — Get an alert when you're at 80% of your daily loss limit. Set to 0 to disable warnings entirely. |
Actions Settings
These settings control what the EA
3. HOW IT WORKS
Core Calculation & Logic
The Close Manager EA doesn't predict price direction — it watches your open positions and calculates the combined profit or loss across all of them (or only those matching a specific magic number). It compares the running total against your configured thresholds: a hard currency amount, a percentage of account equity, or a pip count. The math is straightforward — it sums floating P&L, checks drawdown as a percentage of peak equity, and counts candles since a trade was opened. There's no indicator or price pattern involved; it's pure position accounting.
What it identifies is simple but critical: when your aggregate risk or reward has crossed a line you set. Most traders overlook the fact that a basket of trades can hit a target even if no single trade does. This EA catches that scenario and closes everything at once, which is something you can't do manually without staring at the screen all day.
How It Operates
On every tick (or once per bar, depending on your Conditions check mode setting), the EA loops through all open positions on the chart's symbol. It tallies the current floating profit/loss, compares it to your Profit Amount, Loss Amount, Profit Percent, and Loss Percent thresholds, and also checks the number of candles since each trade opened. If any threshold is exceeded, it closes every trade that matches the magic number filter (or all trades if the filter is disabled).
The filtering logic is straightforward: you can restrict the EA to only manage trades placed with a specific magic number, leaving manual trades untouched. This is essential if you run multiple EAs on the same symbol and don't want one closing another's positions. The EA also respects time-based filters from the common settings — it won't close trades outside your defined trading hours or days, which prevents unwanted exits during news events or low liquidity periods.
Key Features in Detail
What sets this EA apart from a simple trailing stop or take-profit order is its ability to manage a basket of trades as a single unit. You can set a combined profit target for five micro-lots that no single trade would hit alone. It also supports virtual stop-loss and take-profit levels drawn as chart lines (hidden from the broker), so you can set exits without the broker seeing your strategy. The log capture feature writes every close action to the Experts tab, which is invaluable for backtesting — you can see exactly why each trade was closed and tweak your thresholds accordingly.
Step-by-Step Workflow
Step 1: Attach to chart Drag the EA onto the chart of the symbol you want to manage. Make sure auto-trading is enabled in the platform toolbar.
Step 2: Set your profit/loss thresholds In the General Settings section, enter your target profit and maximum loss in either currency amount or percentage. Start with small values during testing — say $5 profit and $3 loss — to see how the EA behaves.
Step 3: Configure magic number filtering If you use other EAs, enable Enable Magic Number and enter the magic number assigned to those trades. For manual trades, leave it disabled so the EA manages everything.
Step 4: Set time-based filters (optional) In the common settings section, configure trading hours and days if you want to prevent closes during specific sessions. This is useful if you only want exits during the London open, for example.
Step 5: Enable log capture Set Capture Logs to true so you can review the EA's decisions in the Experts tab. This is especially helpful during the first week of live use.
Step 6: Run a backtest first Before going live, run a backtest on at least three months of data with your chosen settings. Check the log output to confirm the EA closed trades at the right thresholds.
Step 7: Go live with small size Start with micro lots (0.01) on a demo account for at least 20 trades. Only then move to a live account with the same settings.
4. KEY FEATURES & CAPABILITIES
The Close Manager EA packs several practical features that go beyond a simple take-profit order, giving you fine-grained control over how and when your trades are closed.
| Feature | Description |
|---|---|
| Basket Profit/Loss Targets | Closes all trades when the combined floating P&L hits a specified amount or percentage. This is the core feature — it lets you manage multiple positions as a single portfolio rather than one by one. |
| Virtual Stop-Loss & Take-Profit | Draws hidden SL/TP lines on the chart that the broker never sees. You can set these in pips, currency amount, or percentage, and they work even if the broker doesn't support hard stops on your account type. |
| Magic Number Filtering | Restricts the EA to only manage trades placed with a specific magic number. This is essential when running multiple EAs on the same symbol — it prevents one EA from interfering with another's positions. |
| Time-Based Exit | Closes trades after a set number of candles have passed since opening. Useful for time-sensitive strategies where you don't want to hold a position beyond a certain bar count, regardless of profit or loss. |
| Log Capture for Audit | Writes every close action and the reason for it to the Experts tab. This makes backtesting and live review straightforward — you can see exactly which threshold triggered the exit and adjust your settings accordingly. |
Quick Start Guide
Follow these steps to get started in under 5 minutes:
- Download the EA: Get the Close Manager EA from the MQL5 marketplace. Both MT4 and MT5 versions are available from the same seller page.
- Install the EA: Place the .ex4 or .ex5 file in your platform's MQL4/Experts or MQL5/Experts folder. Restart the platform or refresh the Navigator panel.
- Attach to chart: Open a chart for the symbol you want to manage (e.g., EURUSD). Drag the EA from the Navigator onto the chart. A settings dialog will appear.
- Set your profit target: In the General Settings section, enter a small profit amount like 10 (in account currency) to test. Leave loss amount at 0 for now.
- Disable magic number: Set Enable Magic Number to false so the EA manages all trades on the chart. You'll refine this later.
- Enable auto-trading: Click the AutoTrading button in the platform toolbar (it should turn green). The EA will start monitoring immediately.
- Place a test trade: Manually open a small buy or sell trade on the same chart. Watch the Experts tab — when the floating profit hits your target, the EA will close it automatically.
- Review the logs: Check the Experts tab to see the close reason. If it didn't fire as expected, double-check your threshold values and that auto-trading is enabled.
Installation Guide for MQL Products | Updating Purchased MQL Products on MT4/MT5 | General Troubleshooting Guide | Indicator Settings / Guide
Check all my products: https://www.mql5.com/en/users/biswait50/seller
Contact me for support: https://www.mql5.com/en/users/biswait50


