MT4 · code and request checks
MT4 OrderSend error 130 invalid stops
Keep the rejected price, Stop Loss and Take Profit before changing anything. Error 130 can mean a stop on the wrong side, a distance in the wrong unit, an invalid pending-entry price or a broker rule that the terminal does not expose as a fixed distance.
Arnold Holm · 2026-10-05 · Source-backed checks, no trading-result promise.
What the error means
130 is ERR_INVALID_STOPS. OrderSend returns -1 when the request fails; capture GetLastError immediately. Stop Loss and Take Profit are absolute prices in this function, not cash amounts or distances. Pending-entry prices also have distance restrictions. The error identifies a rejected request, not the exact faulty line and not the quality of a trading strategy.
Three code paths to check
1. Stop direction or unit does not match the order
A BUY closes against Bid and a SELL closes against Ask. A protective BUY stop belongs below Bid; a protective SELL stop belongs above Ask. A cash-risk number cannot be subtracted directly from a quote without the symbol's value, volume and price-unit contract. In the linked forum case, a SELL stop was calculated below a historical close. More slippage does not correct that direction. Keep cash, points, pips and absolute prices separately named.
2. The calculation uses another symbol's quote or price grid
Bid, Ask, Point and Digits are predefined values for the current chart. An EA sending an order for a different symbol must read that symbol's properties. Save the requested levels, current Bid/Ask, point size, digits and tick size. Decimal rounding alone does not establish that a price lies on an instrument's allowed tick grid. Validate the rule's intended price and distance after grid alignment; do not silently move a stop to make a request pass.
3. The server distance rule or pending-entry path is ignored
MODE_STOPLEVEL is stated in points, not pips or cash. For pending orders, check both the entry's distance from the market and its stops against the pending-entry price. A zero stop level is not proof that every distance is allowed: the official OrderSend reference says a server may apply dynamic restrictions that cannot be represented by a fixed terminal value. A quote can also move between your local check and server processing.
Own pattern: preserve the error and log the rejected request
Pass the exact values sent by the failing request, not values recalculated later. This helper sends no order, changes no stop and performs no retry. Its quote reads happen after rejection, so they are diagnostic context, not a recording of the server's exact processing quote. For a complete investigation, also preserve a quote snapshot immediately before the existing send and label both snapshots with their times.
// Call from your existing failure branch, immediately after OrderSend.
// Save the error BEFORE any other terminal call.
// int savedError = GetLastError();
// LogStopRequest(symbol, command, requestedPrice, sl, tp, savedError);
void LogStopRequest(string symbol, int command, double requestedPrice,
double sl, double tp, int savedError)
{
int digits = (int)MarketInfo(symbol, MODE_DIGITS);
Print("stop-check symbol=", symbol, " cmd=", command,
" error=", savedError,
" requested=", DoubleToString(requestedPrice, digits),
" sl=", DoubleToString(sl, digits),
" tp=", DoubleToString(tp, digits),
" bid=", DoubleToString(MarketInfo(symbol, MODE_BID), digits),
" ask=", DoubleToString(MarketInfo(symbol, MODE_ASK), digits),
" point=", DoubleToString(MarketInfo(symbol, MODE_POINT), digits),
" stopLevelPoints=", MarketInfo(symbol, MODE_STOPLEVEL),
" tickSizePoints=", MarketInfo(symbol, MODE_TICKSIZE));
}This is a source-integration pattern, not a complete EA or a recorded broker fix. Property reads can fail or be stale; a production diagnostic should record their errors and freshness. Compile with authorised source and run the agreed cases on a demo account. Do not turn repeated rejection into unbounded retries or open an unprotected position by deleting the Stop Loss. Cash-risk sizing, margin, volume and duplicate-order handling remain separate checks.
Three cases to agree before calling it fixed
Positive case: an agreed valid BUY and SELL request
Use the actual symbol's quotes and grid. Preserve the requested prices and contract settings. The agreed stop stays on the protective side with sufficient documented distance, and a demo request is accepted with the intended stop recorded on the actual order. A successful function call alone is not the final receipt.
Negative case: a SELL stop below the relevant Ask
The local validation rejects that request before sending it. The log shows the order direction, absolute stop price and quote. The EA neither removes the stop nor retries the same invalid request on every tick. The corresponding BUY wrong-side case must be rejected too.
Boundary case: zero stop level or a pending order near market
A zero terminal value does not bypass validation or promise server acceptance. Test the pending-entry path separately and record a server rejection as a rejection. An unresolved dynamic restriction ends the bounded attempt; it does not trigger an automatic change to the trader's risk rule.
Your own source
Find the next line to check
Start with the free EA-Check. Your code stays in your browser. It highlights patterns with line numbers; it does not prove the broker accepts an order.
Want one small change shown on your own case?
SOLVED-FIRST: one small fix or change to your own case, shown first as screenshots or a short screen video. 15 USD fixed (or the higher platform minimum), first five paid orders only during 4–17 October 2026. The file follows within 24 hours after funding. Close on Upwork first; marketplace cases stay on their marketplace.
Outside that sprint: R49: one authorised, reproducible MT4/MT5 defect, with three agreed cases. 49 USD fixed. Delivery within 48 hours after source review and funding. The exact case is agreed before funded work.
Send the expected and actual behaviourRelated checks
Common questions
Does MODE_STOPLEVEL equal to zero rule out error 130?
No. It can mean no minimum distance, or a dynamic server restriction that the terminal cannot express as a fixed value. Keep the rejection and ask for the actual symbol's specification instead of treating zero as permission.
Should I increase slippage or remove the stop?
Neither fixes a stop on the wrong side or a cash amount used as a price distance. First identify the failing request field. Any two-stage placement that opens before adding protection changes exposure and needs an explicit agreed rule; this pattern does not implement it.
Does this page prove my broker will accept the corrected request?
No. The checks narrow a reproducible defect. Broker acceptance and the actual recorded stop still need a demo observation for your source, symbol and account conditions. This is no performance or challenge-pass promise.
Sources and limits
- Official MQL4 OrderSend errors and floating stop-level rule
- Official MQL4 symbol-property units
- Official BUY, SELL and pending-order distance table
- Observed question: error 130 with a SELL stop and a cash-risk amount
The linked forum case belongs to its author. It is not my customer case or proof that your broker has the same cause. This article covers request behaviour only; it makes no performance or challenge-passing claim.