DEV Community

Arnold Holm
Arnold Holm

Posted on Originally published at stratcorealpha.com

MT4 OrderModify error 1: skip a stop update that changes nothing

Your trailing stop can skip an unchanged update: my native MT4 test returned error 1 for the same stop, then error 0 after a real change. If you see error 1 on every tick, check stored and requested values before you change code.

Native MT4 tester: same stop returns error 1, changed stop returns error 0 and stored stop matches. Zero account orders.

What the error means

A trader asked: "Why does OrderModify keep reporting error 1 when I change the stop value?" A follow-up asked if an unchanged stop would also block a take-profit change. Those are different requests.

An unchanged intended request can be skipped before the call.

I compare the complete intended change before calling OrderModify.

The official MQL4 reference calls error 1 ERR_NO_RESULT. Passing unchanged values can produce it. It does not say every field must change. A new take profit can still matter while the stop stays put. Open price and expiration can change only for pending orders.

I ran the unchanged-stop case in the native MT4 Strategy Tester on EURUSD H4. It opened one simulated BUY 0.10 at 1.2054 with stop 1.1934. It called OrderModify with the same open price, stop and target. It returned false with immediate error 1. It then moved the requested stop to 1.1944. That call returned true with immediate error 0, and a fresh selection read back 1.1944. The position closed inside the tester at 1.2034 with zero account orders.

A trailing rule can print the same valid target on many ticks. The candle low can stay flat, or rounding to the symbol increment can erase a tiny move. Logging error 1 each time hides what matters: stored value, requested value, and whether they differ.

Three checks before you edit

Stored target already matches

Read the order again and compare stored and intended values at symbol precision. Do not trust a rounded chart label.

Stop-only test hides a target change

Compare take profit too. An unchanged stop does not mean the whole request is unchanged. My native run covered only the stop path. Test a target-only change separately.

Stale error looks current

Check the return value. Clear the error before the call and read GetLastError right after a fail, before another call replaces it. Keep request and result together.

Compare both fields, then validate the rest

The helper below expects valid prices on the symbol increment. Zero can mean no stop or target. A false result means do not call. It never means remove protection.

Use the order symbol increment, select the right ticket, and keep the market open price. Then run your own distance, freeze, direction and account checks. A different price is not automatically an allowed price. The helper does not choose a stop, round a price, select an order or send a request.

bool StopPairChanged(double currentSL,double currentTP,
                     double targetSL,double targetTP,double tickSize)
{
   if(!MathIsValidNumber(tickSize) || tickSize<=0) return false;
   if(!MathIsValidNumber(currentSL) || !MathIsValidNumber(currentTP) ||
      !MathIsValidNumber(targetSL) || !MathIsValidNumber(targetTP)) return false;
   return MathAbs(currentSL-targetSL)>tickSize*0.5 ||
          MathAbs(currentTP-targetTP)>tickSize*0.5;
}
Enter fullscreen mode Exit fullscreen mode

The picture shows the real tester run. Its single-price check uses Point for this supplied EURUSD dataset. The two-field helper is for review only. It did not run in that test case. Do not read the picture as a test of every helper branch.

How you know it is fixed

Unchanged call must return false with immediate error 1, then skip. Changed call must return true with immediate error 0, and a fresh selection must show 1.1944.

Your five-minute source check

Find OrderModify in your trailing branch. Print the selected ticket, current stop and target, intended stop and target, symbol increment and immediate result. Check that a target-only update is not lost behind a stop-only equality test.

Common questions

Does error 1 mean the trailing stop is broken?

It can mean that this call requested no change. Inspect the current and intended values before changing your trading logic.

Must both stop loss and take profit change?

No. One genuine parameter change can make the request meaningful. The unchanged-value condition concerns the request as a whole.

Does a true comparison guarantee a successful modification?

No. Stop distances, freeze rules, order state and server conditions still matter. Check the actual function result and stored order values.

Sources

Original OrderModify error 1 question with stop and target follow-up

Original article and free EA check

Native MT4 offline/default tester test case on supplied EURUSD H4 history, fixed 20-point spread, zero account orders sent. No broker acceptance, live execution or strategy performance is established.

Top comments (0)