- Strategy
- Does not open trades. Closes all matching positions and deletes pending orders when the account loses the daily limit, falls the maximum drawdown from its peak or reaches the equity target, then keeps closing new positions while locked.
- Risk model
- Opens no trades; caps daily loss and total drawdown by flattening the account and blocking re-entry
What it does
Equity Protector EA is a safety net for the whole account. It watches equity every second and, when one of your limits is reached, closes positions, deletes pending orders and locks trading. While the lock is active, any new position that appears, whether from you or another EA, is closed again. A status block on the chart shows the numbers it is watching.
How it works
Three limits can be used, alone or together:
- Daily loss: the day-start balance is the current balance minus today's closed trade results (profit, swap, commission and fees since server midnight). Daily loss % = (day-start balance − equity) ÷ day-start balance × 100. Because equity is used, open losses count.
- Maximum drawdown: the EA records the highest equity it has seen (the high-water mark). Drawdown % = (peak − equity) ÷ peak × 100.
- Equity target: equity at or above the amount you set.
When a limit triggers, the EA loops through positions from last to first, closes each matching one by ticket, and deletes matching pending orders. A daily-loss lock ends at the next server midnight. Drawdown and target locks stay until you restart the EA with "Reset lock" set to true. The lock and peak are stored in terminal global variables, so they survive a restart.
Example (illustrative): with a 10,000 day-start balance and a 3% limit, the lock triggers once equity falls to 9,700 or below.
How to use it
Attach it to one chart only and leave the terminal running. Keep "All symbols" and "All positions" so the protection covers the whole account; narrow the filters only if you want to protect one strategy. Watch the status block to see the day-start balance, daily result, peak, drawdown and lock state.
Settings
| Input | Default | What it changes |
|---|---|---|
| Daily loss limit (%) | 3.0 | Daily stop (0 = off) |
| Max drawdown (%) | 10.0 | Peak-to-equity stop (0 = off) |
| Equity target | 0 | Close-all target (0 = off) |
| Delete pending orders | true | Also removes pending orders |
| Block after trigger | true | Re-closes new positions while locked |
| Reset lock / Reset peak | false / false | Clears saved state on start |
| Symbols / Positions | All / All | Scope of closing |
| Max slippage (points) | 20 | For closing orders |
Limitations
The EA reacts to prices it sees; in a fast market or a weekend gap the final loss can exceed the limit. Closing many positions takes time and each can slip. The day starts at the broker's server midnight, not your local time. It cannot protect the account when the terminal is off, and it does not stop trades opened from another device until it sees and closes them.
Before you run it live
Test the limits on a demo account by opening small trades and setting a tight limit. Decide in advance what you will do after a lock. Read about drawdown and equity, and keep the EA on a reliable, always-on terminal. Trading carries a substantial risk of loss.

