Advertisement IC Markets

Handling OrderSend errors in MT4: 130, 134, 136 and what to do with each

Share, develop, and backtest custom MQL4/MQL5 Expert Advisors, Python data-scraping scripts, trading bots, and automated market alert systems.
Post Reply
Fairman
Posts: 3303
Joined: Tue Jul 21, 2026 7:11 am
Location: Abuja

Handling OrderSend errors in MT4: 130, 134, 136 and what to do with each

Post by Fairman »

Handling OrderSend errors in MT4: 130, 134, 136 and what to do with each

Every EA eventually hits order errors, and a lot of EA problems come from handling them badly. The common response is to retry immediately, which can make things worse. Here are three I see often and how I think about them.

Error 130, invalid stops. Your stop loss or take profit is too close to the current price or on the wrong side of it. This often happens when the broker has a minimum stop level and the EA ignores it, or when price moves between calculating the stop and sending the order. The fix is to check the stop level from the symbol info before sending, and recalculate stops using a fresh price right before the order.

Error 134, not enough money. The account doesn't have the margin for the size. Retrying won't help. The EA should reduce size or skip, and log it so you notice.

Error 136, off quotes. The broker couldn't provide a price, often during fast markets or news. A short wait and a limited number of retries with a fresh price can make sense, but with a cap so the EA doesn't loop forever.

The general rule: separate errors that might clear on their own from errors that mean something is wrong with the order. Retry the first type a limited number of times. Stop and log the second type.

What does your EA do when an order fails?
It’s Fairman :geek:
Recommended broker for automated trading & scalping IC Markets
Fairman
Posts: 3303
Joined: Tue Jul 21, 2026 7:11 am
Location: Abuja

Re: Handling OrderSend errors in MT4: 130, 134, 136 and what to do with each

Post by Fairman »

The error you get can depend on the execution mode. On instant execution accounts, a price change between your request and the server's check can return a requote. On market execution accounts you're more likely to get filled with slippage instead, and stops might have to be set after the trade opens rather than with the order. An EA written for one mode can behave badly on the other, so I'd check the execution mode of the account before trusting how it handles errors. If you ever move an EA between brokers, run it on a demo of the new one first and watch the journal for a day.
It’s Fairman :geek:
Fairman
Posts: 3303
Joined: Tue Jul 21, 2026 7:11 am
Location: Abuja

Re: Handling OrderSend errors in MT4: 130, 134, 136 and what to do with each

Post by Fairman »

I'd also log the full context with each error: the price the EA used, the current bid and ask, the stop level, the spread, and the time. A bare error number in the journal tells you something failed but not why. With the context you can see whether, for example, error 130 was caused by a stop that was too tight or by a spread spike right at that moment. That makes the difference between fixing the code and blaming the broker for something that was actually your own logic.
It’s Fairman :geek:
Post Reply