MT4 Version: EA AccountTrailingStop MT4
MT5 Version: EA AccountTrailingStop MT5
Complete User Documentation — MT4 & MT5
1. OVERVIEW
The EA AccountTrailingStop is a portfolio-level risk manager that tracks your total floating profit (or profit from a specific magic number) and automatically closes all trades when that profit drops by a set amount from its highest point. Instead of setting individual trailing stops on every position, it watches the combined P&L and locks in gains across your entire strategy or account. This solves the classic problem of watching a winning portfolio turn into a loser because you didn't have a systematic way to trail overall profit — the EA does it tick by tick.
Who Should Use It: Traders running multiple EAs or manual trades simultaneously who want to protect aggregate profits without setting individual trailing stops on every position. It's especially useful for grid, martingale, or multi-symbol strategies where individual trade management doesn't capture the big picture.
Main Benefit: One setting protects your entire account's profit by trailing a single number — the total floating P&L — and closing everything when the market gives back too much.
2. INPUT PARAMETERS & SETTINGS
This product shares a common set of general input settings with all Expert Advisor products in this series. The following sections are covered in the common guide: General Settings (lot size, SL/TP modes, magic number, trade direction), Breakeven Settings, Trailing Stop Settings, News Filter Settings and News Action Settings, Martingale Settings, Grid Settings, Hedge Settings, Risk Settings, Position Sizing, Alert Settings, Display Settings, Trade Time Settings, Trade Days Settings, Safeguard Settings, and Trend Filter Settings (MA Filter, ADX Filter, RSI Filter, MACD Filter, Parabolic SAR Filter — each with their own strategy options). All of these are fully documented in the Common General Input Settings for Expert Advisors. The sections below cover only the product-specific inputs unique to this product.
Accountstop Settings
These four settings form the core of the trailing-stop mechanism — they control when the EA starts watching profit, how much drawdown it tolerates, and how it tightens the trail as profits grow.
| Setting Name | Type | Default Value | Description | Example |
|---|---|---|---|---|
| Use Trailing Stop | bool | true | Master switch for the account-level trailing stop. When enabled, the EA tracks peak profit and closes all trades if profit falls by the distance you set. Disable it if you want manual control or are using a different trailing method on individual trades. | Set to true when running multiple EAs on one account and you want automatic profit protection. Set to false if you trail each trade individually with your own logic. |
| Activate | double | 30 | The minimum profit in account currency that must be reached before the trailing stop activates. Until profit hits this threshold, no trailing occurs. Set higher to avoid premature activation during small fluctuations that don't represent real gains. | Set to 50 if your average trade profit is around $40 and you want to avoid triggering on noise. For a $10,000 account, 30 is a reasonable starting point. |
| Trail price by | double | 20 | The drawdown amount from peak profit that triggers a close of all trades. Once profit peaks, if it drops by this amount, the EA exits everything. Smaller values lock in gains tighter but risk premature exits during normal retracements. | Set to 15 for a conservative approach where you want to protect gains tightly. Set to 40 if you're willing to give back more profit to let winners run longer in a trending market. |
| Increment by | double | 10 | The step size by which the activation threshold increases after each close event. After a trailing stop triggers and closes trades, the next activation point is raised by this amount, preventing immediate re-entry and re-triggering in a volatile market. | Set to 10 so after a close at $30 profit, the next activation becomes $40. Use 0 if you want the same threshold every time, but that can cause repeated triggers in choppy conditions. |
Risk Settings
These settings let you fine-tune how the EA calculates position sizing when the risk-to-lot feature is enabled — useful if you want consistent dollar risk per trade across different symbols.
| Setting Name | Type | Default Value | Description | Example |
|---|---|---|---|---|
| Risk Per MicroLot | double | 10 | Defines the dollar risk per microlot (0.01 lot) when the risk-to-lot calculation is active. This lets you standardize risk across different instruments — a microlot of EURUSD and a microlot of Gold will both risk the same dollar amount. | Set to 10 if you want each microlot to risk $10. For a $5,000 account with 2% risk per trade, you'd set this to 10 and let the EA calculate the lot size automatically. |
3. HOW IT WORKS
Core Calculation & Logic
This EA doesn't open trades itself — it's a portfolio-level risk manager that watches your account's floating profit (or a specific magic number's profit) and trails a stop-loss threshold behind it. Think of it as a moving profit-lock: once your total profit hits the Activate level, the EA starts tracking the highest profit peak. If profit then drops by the Trail price by distance from that peak, it closes all relevant trades. The Increment by setting lets you tighten the trail as profit grows further — so you don't give back too much after a big run.
Mathematically, it's a simple peak-detection loop running on every tick. The EA stores the highest profit seen since activation, then compares current profit against (peak - trail distance). If current profit falls below that line, it's exit time. No indicators, no price action — just pure equity curve management. This is especially useful in high-volatility markets where a single trade could swing your whole account.
Entry Strategies Explained
This EA has no entry logic — it's a trailing-stop manager that works on existing positions. But it does have two distinct modes based on how you filter trades.
Account-Wide Mode (Magic Number Disabled)
BUY Signal: Not applicable — this EA never opens trades.
SELL Signal: Not applicable — this EA never opens trades.
Best For: Traders running multiple EAs or manual trades who want a global profit lock. I use this when I have several grid or martingale systems running — it prevents a single bad day from wiping out a month of gains.
Magic Number Mode (Enabled)
BUY Signal: Not applicable — this EA never opens trades.
SELL Signal: Not applicable — this EA never opens trades.
Best For: Running multiple strategies on one account. You can set different magic numbers for each strategy and give each its own trailing-stop instance. I've seen traders run three copies of this EA — one for each strategy — all on the same chart.
Step-by-Step Workflow
Step 1: Attach to chart Drag the EA onto any chart (it doesn't matter which symbol — it scans all open trades). Set Enable Magic Number to true and enter your strategy's magic number if you want to trail only those trades. Leave it false for account-wide trailing.
Step 2: Set activation threshold In the Activate field, enter the minimum profit in account currency that must be reached before trailing begins. For a $10,000 account, 30 is a reasonable starting point — adjust higher if you trade smaller lots.
Step 3: Set trail distance In the Trail price by field, enter how much profit drop from the peak triggers a close. A value of 20 means if profit peaks at $100 and drops to $80, all trades close. Tighter values protect gains but may exit prematurely.
Step 4: Set increment In the Increment by field, enter the amount to raise the activation threshold after each close. A value of 10 means after a close at $30 profit, the next activation becomes $40. Use 0 for the same threshold every time, but that can cause repeated triggers.
Step 5: Enable the trailing stop Set Use Trailing Stop to true. The EA will now monitor your account's floating profit on every tick and close trades when the drawdown condition is met.
Step 6: Verify in tester Run a backtest with Visual Mode enabled to see the profit trail in real-time. Watch how the EA closes all trades when profit drops from its peak — you'll see the equity curve flatten.
Step 7: Go live Once you're satisfied with the settings, attach the EA to a live chart. Ensure there are no open positions before starting — the EA will begin monitoring immediately.
4. RISK MANAGEMENT FEATURES
Beyond the core trailing stop, this EA includes several built-in safeguards to protect your account from unexpected market behavior.
| Feature | Description |
|---|---|
| Magic Number Filter | When enabled, the EA only tracks and closes trades with the specified magic number. This lets you run multiple trailing-stop instances for different strategies on the same account without interference. |
| Incremental Activation | After each close event, the activation threshold rises by the increment amount. This prevents the EA from repeatedly triggering on small profit swings and forces it to wait for larger gains before trailing again. |
| Peak Detection | The EA continuously tracks the highest floating profit since activation. This ensures the trail distance is always measured from the true peak, not from a random point — critical for accurate drawdown protection. |
| No Trade Opening | This EA never opens new positions. It only closes existing trades when the trailing condition is met. This eliminates the risk of unintended entries and keeps it purely as a risk manager. |
| Logging Control | The Capture Logs option lets you enable or disable detailed logging. When troubleshooting, turn it on to see peak profit values and close triggers in the Experts tab. Turn it off to reduce journal clutter during normal operation. |
Quick Start Guide
Follow these steps to get started in under 5 minutes:
- Download and install: Purchase the EA from the MQL5 Market and install it via the MetaTrader Navigator. Drag it onto any chart — it doesn't matter which symbol.
- Configure magic number: If you want to trail only trades from a specific strategy, set Enable Magic Number to true and enter that strategy's magic number. Leave it false for account-wide trailing.
- Set activation threshold: In the Activate field, enter the minimum profit in account currency (e.g., 30 for a $10,000 account). This prevents premature trailing during small fluctuations.
- Set trail distance: In the Trail price by field, enter how much profit drop from the peak triggers a close. Start with 20 for a balanced approach.
- Set increment: In the Increment by field, enter 10 to raise the activation threshold after each close. This prevents repeated triggers.
- Enable the trailing stop: Set Use Trailing Stop to true. The EA will now monitor your account's floating profit on every tick.
- Test and go live: Run a backtest with Visual Mode to verify the behavior. Once satisfied, attach to a live chart with no open positions. The EA will start protecting your profits immediately.
Installation Guide for MQL Products | Updating Purchased MQL Products on MT4/MT5 | General Troubleshooting Guide | Backtest and Set Files
Check all my products: https://www.mql5.com/en/users/biswait50/seller
Contact me for support: https://www.mql5.com/en/users/biswait50


