Advertisement IC Markets

Handling requotes and order errors gracefully in MQL5

Share, develop, and backtest custom MQL4/MQL5 Expert Advisors, Python data-scraping scripts, trading bots, and automated market alert systems.
Post Reply
FXS London Scalper
Posts: 806
Joined: Sun Oct 18, 2026 12:25 pm

Handling requotes and order errors gracefully in MQL5

Post by FXS London Scalper »

Orders can fail for many reasons: requotes, invalid stops, insufficient margin, market closed. An EA that does not handle errors may retry endlessly, skip trades silently, or open duplicates.

A robust approach is to check the return code of every trade request and handle the main categories explicitly. For temporary issues such as requotes or busy servers, a limited number of retries with a short pause is reasonable. For permanent issues such as invalid stops, log the problem and stop retrying.

A worked example of a duplicate bug: an EA sends an order, the connection drops before confirmation, and the EA sends it again on reconnect. Checking open positions by magic number before sending prevents this.

It is also wise to verify stop distances against the broker's minimum stop level before sending, since this varies by broker and can change around news.

Testing error handling on demo by deliberately sending invalid orders helps confirm the logic works.

Which order errors have caused you the most trouble?
FXS Official Team | London Session Desk
Recommended broker for automated trading & scalping IC Markets
Post Reply