Common MQL5 Trading Mistakes: Fix Them Before They Cost You

Quick Summary

Most failed mql5 automated trading robots break because of avoidable errors, not bad strategies. The most common mistakes are vague trading rules, broker stop and lot-size rejections, overfit backtests, oversized positions, duplicate orders after restarts, and changing inputs while the EA runs.

  • Write entry, exit, and filter rules as exact, measurable conditions before coding.
  • Read the broker’s minimum stop level and normalize lot size before every order.
  • Test on real tick data and check out-of-sample results, not just the in-sample period.
  • Size each trade from a fixed percentage of equity and enforce a maximum drawdown limit.
  • Tag orders with a magic number and rebuild state from open positions after restarts.
Ready-made MT5 systems?EZMT5 gives unlimited access to 11 MT5 systems and TradingView indicators, with no contract.

Start Trading Today

Table of Contents

What are the most common mistakes in MQL5 automated trading?

Last Updated: November 26, 2026

Trader reviewing MQL5 automated trading charts on a dual-monitor setup with a printed debugging checklist.
Trader reviewing MQL5 automated trading charts on a dual-monitor setup with a printed debugging checklist.

Most failed Expert Advisors do not fail because the strategy is bad. They fail because of avoidable errors in the code, the settings, or the testing process. The same handful of mistakes come up again and again among serious traders using MetaTrader 5. The good news is that each one has a clear fix.

Common mistakes in MQL5 automated trading usually fall into four groups: unclear trading rules, broker-level order errors, weak backtesting, and poor risk control. Each group can quietly drain an account long before a trader notices.

  • Vague or unwritten trading rules
  • Orders rejected because of broker constraints
  • Backtests that look better than live results
  • Position sizes that ignore account risk
  • Duplicate orders from unhandled state
  • Inputs changed while the EA is running

Below, we walk through each mistake, show what goes wrong, and explain the fix. The checklist at the end gives you a clear process to follow before any robot trades real money.

Mistake 1 to 3: Turning Discretionary Rules into Explicit, Measurable Logic

The first three mistakes all come from one root problem: the trader has not written the strategy down as exact logic. A discretionary idea like “buy when price looks strong” cannot be coded. The EA then guesses, and the guess rarely matches what the trader intended.

Mistake 1: No written trading plan. The EA runs on rules that exist only in the trader’s head. Turn the plan into a short list of entry, exit, and filter conditions before writing a single line of MQL5. A written plan also makes it easier to separate rule failures from execution noise, including paper trading limitations that can hide how live conditions affect an EA.

Mistake 2: Vague entry conditions. Words like “strong trend” or “good momentum” need numbers. Define the exact indicator, period, and threshold.

Mistake 3: Missing spread and cost filters. A strategy that looks profitable on paper can lose money once spread is counted. Add a maximum spread check before every trade.

Watch out: an EA with no spread filter can open trades during news spikes, when spreads widen sharply and fills move far from the signal price.

Fixing the MQL5 Invalid Stops Error and Broker Constraints

The “Invalid stops” error is one of the most common reasons an order fails in MetaTrader 5. It appears when your stop loss or take profit sits too close to the current price, or on the wrong side of it, based on the broker’s minimum distance rules.

Each broker sets a minimum stop level for each symbol. Your code must respect it. Check the value before sending the order, not after it fails.

Wrong approach:

// Hardcoded stop that ignores broker limits
request.sl = price - 5 * _Point;
Right approach:

```mql5
// Read the broker's minimum stop distance first
long stopLevel = SymbolInfoInteger(_Symbol, SYMBOL_TRADE_STOPS_LEVEL);
double minDist = stopLevel * _Point;
double sl = price - MathMax(5 * _Point, minDist);
Lot size causes similar trouble. Volume must match the broker's step and limits, so normalize it before sending:

```mql5
double NormalizeVolume(double lots)
{
   double step = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_STEP);
   double minV = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MIN);
   double maxV = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MAX);
   lots = MathFloor(lots / step) * step;
   return MathMax(minV, MathMin(maxV, lots));
}
Always log the return code of `OrderSend`. A silent failure is harder to fix than a logged one.

## Backtesting Assumptions and MQL5 EA Backtesting Best Practices

A backtest is only as good as the assumptions behind it. Many traders see a smooth equity curve, go live, and find the results fall apart. The gap usually comes from how the test was run.

[Use real tick data](/backtest-mt5-robots-real-tick-data/) where possible, and set the modeling mode in the Strategy Tester accordingly. Test across several market conditions, not one favorable year. Keep spread and commission realistic for your broker.

Watch for overfitting. If you tune a dozen inputs until the curve looks perfect, the EA has learned the past, not the market. Split your data into an in-sample period for building and an out-of-sample period for checking. Strong results on the out-of-sample period matter far more than a perfect in-sample run.

Forward testing on a demo account, running for several weeks before real capital, can surface differences that backtests miss, such as server time differences and execution delays.

## Automated Trading Risk Management: Position Sizing, Drawdown and Account Protection

Risk management decides whether an EA survives its bad periods. A strategy with a solid edge can still wipe out an account if each trade risks too much.

Size every position from a fixed percentage of account equity, a common practice being a small fraction of equity per trade. Calculate lots from the stop distance and the tick value, so a wide stop automatically means a smaller position.

Set a maximum drawdown limit at the account level. When the limit is hit, the EA should stop opening new trades and alert you. Prop firm accounts often impose drawdown rules, and breaching them can end a challenge. Check your firm's specific rules.

Do not average into losing positions. Adding size to a loser turns a small problem into a large one, and it is one of the fastest ways to lose an account.

## Concurrency, Duplicate Orders and Changing Inputs While Running

When an EA runs for long periods, state problems appear. The EA may restart, lose track of an open trade, and open a second one. This is a duplicate order, and it doubles your exposure without any new signal.

Use a magic number to tag every order the EA places, and check for existing positions with that number before opening a new one. After a restart, the EA should rebuild its state from open positions rather than assume it starts fresh.

Changing inputs while the EA is running is another quiet risk. Some traders tweak settings mid-trade, which can make the EA close positions or ignore its own rules. Stop the EA, change the input, and restart it when you need to adjust, and record each change so you can trace results later.

The article's main failure points during live operation can be summarised as follows.

| Problem | Cause | Fix |
| --- | --- | --- |
| Duplicate orders | EA restarts and loses track of open trades | Tag orders with a magic number and check for existing positions |
| Unintended exposure | Restart treats the EA as starting fresh | Rebuild state from open positions after restart |
| Mid-trade rule breaks | Inputs changed while the EA is running | Stop the EA, change the input, restart, and log the change |

## MQL5 EA Debugging Checklist and Prevention Steps Before Going Live

Work through this list before any robot trades real capital:

- [ ] Trading rules are written as exact, measurable conditions
- [ ] Spread and cost filters are active
- [ ] Stop loss and take profit respect the broker's minimum stop level
- [ ] Lot sizes are normalized to the symbol's volume step and limits
- [ ] Every `OrderSend` result and error code is logged
- [ ] Backtest uses real tick data and realistic spread and commission
- [ ] Out-of-sample results hold up, not just the in-sample period
- [ ] Forward test ran on a demo account for several weeks
- [ ] Risk per trade and maximum drawdown limits are enforced in code
- [ ] Magic number is set and duplicate-order checks are in place
- [ ] EA rebuilds its state correctly after a restart
- [ ] Input changes are made only with the EA stopped, and recorded

Run the checklist each time you change the code, not just once. For guidance on [monitoring running robots to catch problems early](/monitoring-mt5-trading-robots-best-practices/), see our best practices. A small edit can break a rule that used to work.

## Your Next Step: Test Your Current Setup Before Trading Real Capital

Pick one EA you already run or plan to run, and walk through the checklist above against its code and its test results. Note every item you cannot confidently tick off. Those gaps are where the next loss would most likely come from.

If you want to skip part of the build-and-test cycle, EZMT5 gives you instant access to 11 fully built and optimized MT5 Trading Systems and TradingView indicators, plus future systems. Subscriptions have no contracts, and you can cancel anytime. [Signup Now](https://ezmt5.com) to start trading with systems that are ready to use right after download.

---


<section style="margin:3rem 0 2rem 0;" itemscope itemtype="https://schema.org/FAQPage"><h2 style="font-weight:700; margin:0 0 4px 0;">Frequently Asked Questions</h2><div style="padding:20px 0; border-bottom:1px solid #e5e7eb;" itemscope itemprop="mainEntity" itemtype="https://schema.org/Question"><h3 style="font-weight:600; margin:0 0 8px 0;" itemprop="name">What is the 3-5-7 rule in trading?</h3><div style="line-height:1.7;" itemscope itemprop="acceptedAnswer" itemtype="https://schema.org/Answer"><p itemprop="text" style="margin:0;">The 3-5-7 rule is a risk framework often used to cap exposure: no more than 3% of account equity risked on a single trade, 5% across open trades, and 7% total exposure at any time. Traders apply it as a guideline rather than a guarantee. In an MQL5 Expert Advisor, the same limits are enforced in code by checking account equity and open positions before each OrderSend call. Verify any percentage you adopt against your own account size and your prop firm or broker rules before relying on it.</p></div></div><div style="padding:20px 0; border-bottom:1px solid #e5e7eb;" itemscope itemprop="mainEntity" itemtype="https://schema.org/Question"><h3 style="font-weight:600; margin:0 0 8px 0;" itemprop="name">How do you test an MQL5 Expert Advisor before using it live?</h3><div style="line-height:1.7;" itemscope itemprop="acceptedAnswer" itemtype="https://schema.org/Answer"><p itemprop="text" style="margin:0;">Start with a backtest on clean historical data using the same broker spread and commission settings you will trade with. Then run forward testing on a demo account for several weeks, watching for differences in fills, slippage and trade timing. Log every order request and its result, and compare the EA&#039;s trade list against your expectations. Only move to a live account after the demo results match the backtest within reasonable tolerance and the debugging checklist shows no open issues.</p></div></div><div style="padding:20px 0; border-bottom:1px solid #e5e7eb;" itemscope itemprop="mainEntity" itemtype="https://schema.org/Question"><h3 style="font-weight:600; margin:0 0 8px 0;" itemprop="name">Why does an MQL5 Expert Advisor place invalid orders?</h3><div style="line-height:1.7;" itemscope itemprop="acceptedAnswer" itemtype="https://schema.org/Answer"><p itemprop="text" style="margin:0;">The most frequent cause is a stop loss or take profit placed too close to the current price, which the broker rejects with an invalid stops error. Other causes include lot sizes that fall outside the symbol&#039;s volume minimum, maximum or volume step, and prices that are not normalized to the symbol&#039;s tick size. Read the symbol specification with SymbolInfoInteger and SymbolInfoDouble, compute distances in points, and validate every order request before sending it.</p></div></div><div style="padding:20px 0; border-bottom:1px solid #e5e7eb;" itemscope itemprop="mainEntity" itemtype="https://schema.org/Question"><h3 style="font-weight:600; margin:0 0 8px 0;" itemprop="name">What should you check when an MQL5 EA stops trading?</h3><div style="line-height:1.7;" itemscope itemprop="acceptedAnswer" itemtype="https://schema.org/Answer"><p itemprop="text" style="margin:0;">First check the Experts and Journal tabs in MetaTrader 5 for runtime or compile errors, and confirm that AutoTrading is enabled. Next confirm the EA still has permission to trade, that the symbol is open for trading at the broker&#039;s server time, and that spread filters are not blocking every signal. Finally verify that no open position or pending order is blocking a new entry, since a stale magic number can prevent the EA from managing its own trades.</p></div></div></section>