How to protect an MT5 Expert Advisor: the complete guide
To protect an MT5 Expert Advisor, set hard loss limits on the account and on the bot, validate the EA on a backtest you can trust, then watch it live against that backtest. Add a kill switch that stops it automatically when a limit is close or its behaviour drifts. Prop firm traders must also follow every challenge rule.
This guide covers the five layers of protection, one by one. Each section gives the essentials and links to a detailed article. At the end you will find a checklist, a summary table and a short note on where Crash Guard fits.
Why an Expert Advisor needs protection
An Expert Advisor is a program that places trades in MetaTrader 5 according to fixed rules. Those rules were built and tuned on past market conditions. When conditions change, the EA keeps applying the same rules. It can lose more often, hold positions longer or increase its exposure.
These changes are often small at first. They are easy to miss, especially when you follow several accounts. An EA also runs when you are asleep, travelling or busy. A bug, a broker change or a news spike can push it far from its normal behaviour within hours.
At a prop firm the stakes are sharper. A single breach of the daily loss limit or of the maximum drawdown ends the challenge or the funded account. One bad session can erase weeks of work.
Protection does not make an EA profitable. It limits the damage when something goes wrong, and it tells you early that something is going wrong.
1. Drawdown and loss limits
Loss limits are the first layer. They define how much the account may lose before trading stops. Two limits matter most.
The daily loss limit caps the loss allowed in one trading day. It is usually measured from the day's starting balance or equity. It protects you against a single bad session.
The maximum drawdown caps the largest fall from a peak of the account value to a later low. It protects the account over its whole life.
Maximum drawdown comes in two forms:
- A static drawdown is measured from the initial balance. The floor never moves.
- A trailing drawdown follows the highest value reached. Each new peak raises the floor, so a winning streak followed by a pullback can breach it.
The way your platform or prop firm measures these limits changes everything. Some count floating losses on open positions. Some reset the daily limit at a fixed server time. Read the exact definition before you set your own limits.
A good practice is to stop trading before the official limit. A safety margin leaves room for slippage, spread spikes and positions that close a little late.
Detailed articles:
2. Prop firm rules
A prop firm challenge adds its own rules on top of the loss limits. The most common ones are:
- a daily loss limit;
- a maximum drawdown, static or trailing;
- a profit target to reach;
- sometimes a consistency rule, which caps the share of total profit made in a single day;
- sometimes limits on trading hours, news trading or position size.
Each firm sets its own values and its own way of measuring them. The values also change over time. Always check the current rules in your firm's own documents.
An EA does not know these rules. It was usually designed to maximise return on a backtest, with no idea of a daily cap or a consistency rule. A strategy that makes most of its profit in a few big days can reach the profit target and still fail the consistency rule. A strategy with a deep but short drawdown can look fine on a backtest and break a trailing limit live.
So the rules must be enforced from outside the EA. Translate each rule into a limit on the account, add a safety margin, and stop trading automatically before the firm's own threshold.
Detailed pages:
3. Validating an EA before going live
Before an EA trades real money, you need a backtest you can trust. A flattering backtest guarantees nothing. The main risk is overfitting: the EA was tuned so closely to past data that it learned noise instead of a real edge.
Signs to look for:
- Too little data. A short test, few trades or poor-quality price data cannot support a conclusion.
- A curve carried by a few big wins. A smooth, regular equity curve is more trustworthy. Check its linearity.
- Ratios that look too good. A very high profit factor or Calmar ratio on a short test is a warning sign.
- No out-of-sample check. Walk-forward validation optimises on one period and checks on the next, unseen one. A strategy that only works on the period it was tuned on is likely overfitted.
- Rules it would break. Check the daily drawdown, the VaR and the worst day against the limits you plan to use.
The backtest also gives you a reference. You will later compare live behaviour against it: win rate, average loss, holding time, drawdown. Keep the report.
You can run a free audit of an MT5 backtest report. Export the strategy tester report as an .xlsx file and drop it on the page. The file is analysed in your browser. The audit looks at the Calmar ratio, curve linearity, data quality, prop firm compliance and avoidable drawdown. When the test is too short or too thin, it says so instead of showing a misleading score.
Detailed pages:
4. Watching it live: drift, kill switch, quarantine
A good backtest is a starting point. Markets change, and an EA that passed every test can still behave differently live.
Drift
Drift is a lasting gap between how a bot behaves live and what its backtest promised. Examples: the win rate falls, losses get larger, positions stay open longer, exposure grows. One losing day is noise. A gap that persists over many trades is drift.
To detect drift, compare the same metrics on both sides: the backtest and the live account. Do it continuously. A monthly review comes too late. By the time a drift is obvious on the equity curve, a large part of the damage is done.
Kill switch
A kill switch stops trading automatically when a condition is met. It can act at several levels:
- suspend one bot;
- close the bot's open positions;
- block new orders on the account.
The kill switch must work without you. It should trigger on loss limits, on exposure, on a run of consecutive losses and, ideally, on drift. It should also alert you at once by e-mail, messaging app or push notification.
Quarantine
After a stop, the worst move is an automatic restart. Quarantine is a paused state: the bot stays stopped until you restore it yourself. This gives you time to understand what happened. Was it a market event, a broker issue, a bug or a real loss of edge?
Detailed articles:
5. Running several EAs as a portfolio
Once you run several EAs, new risks appear. Two bots can take the same position and double your exposure. Two bots can hedge each other and cancel out. A bot with a good month can hide another that is slowly drifting.
The multi-manager model used by large funds gives a useful frame. Treat each bot as a separate manager, or pod, with:
- its own capital allocation;
- its own limits on drawdown, exposure and positions;
- its own promise, for example a maximum drawdown and a minimum win rate, checked continuously.
A new bot starts small, on a trial basis. It moves up to full capital only after it has kept its promise live. A bot that breaks its promise goes back to quarantine. Rules between bots prevent overlapping exposure.
Detailed page:
Checklist: protecting an Expert Advisor
Before launch
- Run a long backtest with quality data and enough trades.
- Check for overfitting with an out-of-sample or walk-forward test.
- Write down the reference metrics: win rate, average loss, holding time, maximum drawdown, worst day.
- Set a daily loss limit and a maximum drawdown for the account.
- If you trade at a prop firm, read the current rules and copy them into your limits, with a safety margin.
- Set limits per bot when several bots share an account.
- Configure alerts on a channel you actually read.
- Test the kill switch on a demo account before going live.
Every day
- Check that the terminal and the EA are running and synchronized.
- Look at the day's loss against the daily limit.
- Look at the drawdown against the maximum, static or trailing.
- Compare live metrics with the backtest reference.
- Check total exposure across all bots.
When something goes wrong
- Let the kill switch act. Do not override it in the heat of the moment.
- Keep the bot in quarantine until you understand the cause.
- Check the market context: news, spread, liquidity.
- Check the technical side: broker, VPS, connection, EA settings.
- Compare the losing trades with the backtest. Is this behaviour new?
- Restart only with a clear reason, and consider a smaller size first.
Risks and matching protections
| Risk | What happens | Matching protection |
|---|---|---|
| Bad trading day | One session wipes out a large share of the account | Daily loss limit with a safety margin |
| Deep drawdown | The account falls far from its peak over several days | Maximum drawdown, static or trailing |
| Prop firm breach | One rule broken ends the challenge or funded account | Firm rules copied into limits, triggered before the official threshold |
| Profit concentrated in one day | Consistency rule fails despite reaching the target | Consistency rule tracked on the account |
| Overfitted EA | Live results never match the backtest | Robustness audit and walk-forward test before launch |
| Drift | The bot slowly departs from its backtest behaviour | Continuous live vs backtest comparison |
| Runaway bot | Exposure or losses grow while you are away | Kill switch: suspend, close positions, block orders |
| Restart too soon | The same problem repeats after an automatic restart | Quarantine until manual restore |
| Overlapping bots | Several bots stack the same exposure | Per-bot capital, exposure caps and rules between bots |
Where Crash Guard fits
Crash Guard is a tool that enforces these protections on MetaTrader 5 accounts. You install a small program, the Bridge, in your MT5 terminal and paste a personal key. Your MetaTrader password is never requested. The Bridge reports account activity about once a minute and applies the rules you have approved.
Crash Guard can enforce a maximum daily loss, a static or trailing maximum drawdown, profit targets, position limits, exposure, consecutive losses and the consistency rule, with a safety margin before the prop firm's own limit. When a limit is reached, it can suspend a bot, close its positions, block new orders or put the bot in quarantine. It alerts you by e-mail, Telegram or MT5 push notification. On Crash Guard Pro, a drift detector compares each bot with its backtest.
Some limits of the approach:
- The Bridge acts from your terminal, so the terminal must stay open, like your EA. If an account stops synchronizing, you are notified by e-mail.
- It works with MetaTrader 5 only.
- A protection reduces the risk of a blow-up. It does not remove it, and it does not make a strategy profitable.
- Crash Guard does not tell you what to trade. It enforces the limits you choose.
Crash Guard Watch is free in read-only mode on one account. Shadow Protect shows the losses protection would have avoided, without acting on the account. For several bots managed as a portfolio, Pod Shop adds per-bot capital, promises and a quarantine-to-production pipeline.
Glossary
The key terms of this guide, defined in the glossary:
- Expert Advisor
- Daily loss limit
- Drawdown, static and trailing
- Safety margin
- Consistency rule
- Overfitting and walk-forward validation
- Drift, kill switch and quarantine
- Multi-manager
In short
- Set a daily loss limit and a maximum drawdown, and stop before the official threshold.
- At a prop firm, copy every rule into your limits, including the consistency rule.
- Validate the EA on a long, clean backtest and check it for overfitting.
- Watch it live against its backtest, with a kill switch and a quarantine that waits for you.
- With several EAs, give each one its own capital, limits and promise.