What is MT4 error 130?
The MT4 error 130 is an OrderSend error code of the MetaTrader 4 platform. A trading platform shows this error code when an Expert Advisor fails to execute an order according to expectations. This error is also known as invalid stops.
An OrderSend error can be very crucial for the day traders because their timing of market entry and exits are equally important. Also, such errors may damage your profit factors and heavily affect your risk to reward ratio.
In this article, we will discuss when an MT4 error 130 happens and how to fix this issue ensuring a smoother trading experience.
Why does MT4 error 130 happen?
An MT4 error 130 may occur for the following reasons:
Market orders
While opening a buy or sell order if you set the stop-loss and take profit levels closer to the market price, the MT4 platform will not accept the order. Instead, it will show your the error code 130.
For direct buy orders, if your stop-loss limit is greater than the asking price and the take profit level is lower than the bidding price, the MT4 will still show the OrderSend error code. On the other hand, for market sell orders, an error code 130 appears when the stop-loss level is lower than the bidding price and the take-profit level is higher than the asking price.
Pending orders
An error code130 may also appear during placing a buy limit and buy stop order. It happens when the difference between the asking and the entry price or the difference between the entry and take profit price is less than the stop-loss limit.
For sell limit and sell stop orders, the OrderSend error occurs if the difference between the bidding and entry price or the difference between the entry and take profit price is less than the stop-loss level.
How to fix Invalid Stops errors
Time needed: 3 minutes.
Solutions for MT4 error 130 differ depending on whether you are using an Expert Advisor or not:
- Check with your broker the minimum Stop Loss & Take Profit Limits
If you are not using an Expert Advisor then what you can do best is to follow the rules set by the broker for setting the stop loss and take profit levels. Generally, most brokers don’t allow setting SL and TP less than 10 pips. When you place an order with less than 10 pips of SL or TP, the MT4 automatically denies executing the order. So, check with your broker about the minimum SL and TP limit, and place the order accordingly. If you still face the problem then it might be caused by slippage or high spreads due to the high volatility of the market.
- Buy Stop (with Expert Advisor)
When you are using Expert Advisors and receiving MT4 error 130 for a Buy Stop order, you need to make a few edits to the EA code.
- Sell Stop (with Expert Advisor)
To fix MT4 error 130 on an EA for a Sell Stop order, you need to make the following adjustments:
- Buy Limit (with Expert Advisor)
For an Expert Advisor that returns MT4 error 130 when you are attempting to place a Buy Limit order:
- Sell Limit (with Expert Advisor)
On an Expert Advisor that returns MT4 error 130 when you try to place a Sell Limit order:
The above codes will help you to prevent showing MT4 error code 130 while placing pending orders only. For market orders (direct buy/sell), check with your broker about their requirements, rules, and limits of setting stop-loss and take profit.
What do you mean by “stopLoss” and “stopLevel”, what is the difference between them (?)
Hi Beto, stopLoss refers to the price level defined by a client to close a trade, while stopLevel is used to define the Stop Loss price relative to the open price. Hope this helps!
stoplevel = MarketInfo(Symbol(), MODE_STOPLEVEL);