MT4 error 130: Invalid stops (ERR_INVALID_STOPS)

The stop loss, take profit or pending price is too close to the market or on the wrong side. Nothing was executed; widen it.

130ERR_INVALID_STOPS
After a fixSafe to retry?
NoCould it have executed?

What it means

You see this code in GetLastError() in MQL4, after a trade function fails on the server side.

MT4 refuses stops that are closer to the market than the broker's stop level, or on the wrong side of the price. It also refuses a pending order placed too close to the market.

For a buy, the stop loss must be below the Bid and the take profit above it. For a sell, the stop loss must be above the Ask and the take profit below it.

Common causes

  • A stop distance below MarketInfo(sym, MODE_STOPLEVEL) points.
  • Stops built in pips on a 5 digit broker, so they end up ten times too close.
  • Stop loss and take profit swapped between buy and sell code.
  • Prices not normalized to Digits.
  • An ECN account that refuses stops on the opening order.

How to fix it

  • Read the stop level and keep every stop at least that far from the price, plus a small margin.
  • Convert pips with care: on 5 and 3 digit symbols, one pip is 10 points.
  • If the broker refuses stops on the opening order, open first and then add them with OrderModify().

Example in MQL4:

RefreshRates();
double stopLevel = MarketInfo(Symbol(), MODE_STOPLEVEL) * Point;
double pip       = (Digits == 5 || Digits == 3) ? 10 * Point : Point;
double gap       = MathMax(20 * pip, stopLevel + 2 * Point);

double sl = NormalizeDouble(Bid - gap, Digits);      // buy: stops from the Bid
double tp = NormalizeDouble(Bid + 2 * gap, Digits);
int ticket = OrderSend(Symbol(), OP_BUY, 0.10, Ask, 3, sl, tp, "", 4711);
if(ticket < 0) Print("error ", GetLastError());

Is it safe to retry?

After you move the stops or the pending price.

Could the order have executed?

No. The whole order was refused, not just its stops.

How Tickwire handles it

Tickwire treats it like MT5 10016, and the MT4 code stays in the message. See trade results.

All MetaTrader error codes

One API for MT4 and MT5

Clear trade outcomes, idempotent orders and an audit log. Read the error reference or the quickstart.