If you are getting the Metatrader error: Ordersend Error 130, it could mean a few different things are going wrong. First, it might mean your stop loss is too close to the market price. Second, it might mean your take profit is too close to the market price. And Third, if you are placing a pending order, you might be trying to place it too close to the market price. What should you do?
Because there are many different forex brokers with different account types out there, you have to check the current account’s market info within your expert advisor to find out the minimum stop level distance you have. Some accounts are 3 pips, while others might be 15 pips.
The function you will use is called MarketInfo. It requires two parameters, SYMBOL & TYPE. SYMBOL is the currency pair or security you want to access and TYPE is the request identifier to specify the account info you wish to return. Since we are looking for the minimum stop level, we will use the type, MODE_STOPLEVEL.
double MarketInfo (string symbol, int type)
int MinStopDist = MarketInfo(“EURUSD”,MODE_STOPLEVEL);
Once you have this data, you want to make sure you do not try to place stop losses or take profits closer than this minimum distance from the market price. Additionally, you do not want to try to place pending orders closer than this distance from the current market price. If you are using an expert advisor that you do not have the source code for, you will want to look in the input value settings and see if there is a stop loss or minimum stop loss setting that you can change.