MQL5 trade retcode reference

MQL5 Trade Error Codes List

MQL5 trade error codes should usually be read from MqlTradeResult.retcode, not inferred from GetLastError. The server reports specific outcomes such as 10014 invalid volume, 10016 invalid stops, 10018 market closed, 10019 no money, and 10030 invalid filling type. Log the complete request and result, then repair the rejected field or state.

Open the Coding Agent and choose MQL5 from the language menu.

Trade result diagnostic.mq5
ResetLastError();
bool sent=OrderSend(request,result);

PrintFormat("sent=%s runtime=%d retcode=%u deal=%I64u order=%I64u comment=%s",
            sent ? "true" : "false",GetLastError(),result.retcode,
            result.deal,result.order,result.comment);
  • Source: MqlTradeResult.retcode
  • Precheck: OrderCheck
  • Boolean true: not execution proof
  • Constraints: broker and symbol specific

Also searched as: mql5 buy error; mql5 error constants err_no_money err_market_closed.

High-priority trade server retcodes

The meanings below come from the official MQL5 trade server return code table. Each link opens a focused diagnostic.

CodeConstantMeaning
10014TRADE_RETCODE_INVALID_VOLUMEInvalid volume
10015TRADE_RETCODE_INVALID_PRICEInvalid price
10016TRADE_RETCODE_INVALID_STOPSInvalid stops
10017TRADE_RETCODE_TRADE_DISABLEDTrade disabled
10018TRADE_RETCODE_MARKET_CLOSEDMarket closed
10019TRADE_RETCODE_NO_MONEYInsufficient funds
10024TRADE_RETCODE_TOO_MANY_REQUESTSToo many requests
10027TRADE_RETCODE_CLIENT_DISABLES_ATClient disables autotrading
10030TRADE_RETCODE_INVALID_FILLInvalid filling type
10031TRADE_RETCODE_CONNECTIONNo trade server connection

Use OrderCheck without overpromising

OrderCheck validates request fields and projected account values before sending. Its official reference explicitly says a successful check does not guarantee execution. Quotes, sessions, permissions, funds, and server state can still change.

ERR_NO_MONEY and ERR_MARKET_CLOSED names

Searches often use ERR_NO_MONEY or ERR_MARKET_CLOSED. In current MQL5 trade code, the official constants are TRADE_RETCODE_NO_MONEY for 10019 and TRADE_RETCODE_MARKET_CLOSED for 10018. Use the numeric result and official constant when writing diagnostics.

Use a focused diagnostic

A complete result record exposes the terminal runtime layer and the server outcome. The accepted success retcodes depend on whether the request places, changes, cancels, or partially fills an order.

A valid request can still be rejected or filled differently by the trade server. Check the returned retcode, test with the broker symbol and account, and review risk before any live order.

Trade result diagnostic.mq5
ResetLastError();
bool sent=OrderSend(request,result);

PrintFormat("sent=%s runtime=%d retcode=%u deal=%I64u order=%I64u comment=%s",
            sent ? "true" : "false",GetLastError(),result.retcode,
            result.deal,result.order,result.comment);
Where Pineify fits

Repair editable MQL5 source with compiler feedback

Pineify can generate or revise MQL5 source and use MQL5 compilation diagnostics during the coding workflow. Keep the exact error, source location, program type, and intended behavior in the request so the change remains reviewable.

Open MQL5 Coding Agent

Pineify does not run your broker terminal, Strategy Tester, market data, or live orders. Validate the final program in your own MetaTrader 5 environment.

Review MQL5 AI Coding Agent capabilities
Pineify MQL5 AI Coding Agent with an editable MetaTrader 5 code artifact

A practical verification workflow

  1. 1

    Build a complete request

    Set action, symbol, order type, volume, price when required, stops, filling, and time policy.

  2. 2

    Run OrderCheck

    Log the precheck retcode, comment, margin, and projected free margin.

  3. 3

    Send and read result

    Keep the OrderSend boolean, GetLastError, result.retcode, result.comment, order, and deal.

  4. 4

    Repair the specific cause

    Change the rejected field or wait for valid state, then retest on the same broker symbol and account mode.

Frequently asked questions

Where do I read MQL5 trade error codes?

Read the server outcome from MqlTradeResult.retcode. Keep GetLastError as a separate terminal runtime diagnostic.

What are ERR_NO_MONEY and ERR_MARKET_CLOSED in MQL5?

The current official trade retcodes are 10019 TRADE_RETCODE_NO_MONEY and 10018 TRADE_RETCODE_MARKET_CLOSED.

Does OrderCheck guarantee that OrderSend will work?

No. It checks the request and projected account state at that moment. The server outcome can still change before or during processing.

Last verified against the linked official references on . Compile and test the final source in the MetaTrader 5 build, broker, symbol, and account environment you plan to use.

Continue with reviewable MQL5 source

Provide the exact diagnostic and intended behavior, inspect the generated change, compile it, and verify it in your MT5 test environment.

Open MQL5 Coding Agent