Strategy testing and trading software · Germanycontact@stratcorealpha.com · DE
All trading software errors

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. 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. 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. 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.

Check my EA locally

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 behaviour

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

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.

Trading risk disclosure

Futures and forex trading contains substantial risk and is not for every investor. An investor could potentially lose all or more than the initial investment. Risk capital is money that can be lost without jeopardizing one's financial security or lifestyle. Only risk capital should be used for trading, and only those with sufficient risk capital should consider trading. Past performance is not necessarily indicative of future results.

Hypothetical performance disclosure

Hypothetical performance results have many inherent limitations. No representation is being made that any account will or is likely to achieve profits or losses similar to those shown. There are frequently sharp differences between hypothetical performance results and the actual results subsequently achieved by any particular trading program. Hypothetical results are generally prepared with the benefit of hindsight, do not involve financial risk, and cannot completely account for the impact of financial risk in actual trading. Market conditions, the ability to withstand losses, and adherence to a trading program can all materially affect actual results.

NinjaTrader trademark disclosure

NinjaTrader® is a registered trademark of NinjaTrader Group, LLC. No NinjaTrader company has any affiliation with the owner, developer, or provider of the products or services described herein, or any interest, ownership or otherwise, in any such product or service, or endorses, recommends or approves any such product or service.

Testimonials, when shown, may not represent the experience of other clients and are not a guarantee of future performance or success. Virtual-currency trading carries additional risks. See the CFTC customer advisories. Read the full financial risk disclaimer.