MQL5 code reference

MQL5 Error Codes List by Diagnostic Layer

There is no single undifferentiated MQL5 error code list. MetaEditor compilation codes, terminal runtime codes from GetLastError, and trade server return codes from MqlTradeResult.retcode are separate namespaces. Record the source field with the number before looking it up.

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

Label runtime and trade codes.mq5
ResetLastError();
bool sent=OrderSend(request,result);
int runtime_error=GetLastError();

PrintFormat("OrderSend=%s GetLastError=%d TradeRetcode=%u %s",
            sent ? "true" : "false",runtime_error,
            result.retcode,result.comment);
  • Compiler: MetaEditor output
  • Runtime: GetLastError
  • Trade: MqlTradeResult.retcode
  • Precheck: MqlTradeCheckResult

Also searched as: mql5 error codes list.

Representative codes and their sources

These examples show why the source field matters. Open the focused page for the full checks and official link.

CodeNamespaceOfficial meaning
199CompilationWrong number of parameters in the function
256CompilationUndeclared identifier
4003RuntimeWrong parameter calling system function
4756RuntimeTrade request sending failed
4806RuntimeRequested indicator data not found
10019Trade serverInsufficient funds for request
10030Trade serverInvalid order filling type

How to look up an error safely

Copy the constant name and description when available. A forum title or log label may use informal wording, as with the search phrase internal error 112 even though the official compiler definition is omitted double quote.

  • Prefer the official table for the diagnostic namespace.
  • Preserve the function return and any comment alongside the code.
  • Check current symbol and account properties for broker-sensitive trade errors.
  • Verify source repairs by compiling and runtime repairs by reproducing the call.

What error 0 does and does not say

Runtime code 0 means success in the GetLastError namespace. It does not prove a trade executed, an indicator copied all requested values, or a strategy produced the intended behavior. Check the direct API result and domain-specific output.

Use a focused diagnostic

The labels prevent a terminal runtime number from being confused with a trade server retcode. Use MetaEditor output separately for compiler codes.

A clean compile or a cleared error code does not prove strategy logic, broker compatibility, backtest quality, or live-trading safety. Reproduce the result in the target MetaTrader 5 terminal and account environment.

Label runtime and trade codes.mq5
ResetLastError();
bool sent=OrderSend(request,result);
int runtime_error=GetLastError();

PrintFormat("OrderSend=%s GetLastError=%d TradeRetcode=%u %s",
            sent ? "true" : "false",runtime_error,
            result.retcode,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

    Identify the producer

    Locate whether the number came from MetaEditor, GetLastError, OrderCheck, or MqlTradeResult.retcode.

  2. 2

    Open the matching table

    Use the official compilation, runtime, or trade server reference linked below.

  3. 3

    Preserve context

    Keep the direct return, inputs, symbol, server comment, and source location with the code.

  4. 4

    Repair and verify

    Change the violated contract or state, then reproduce the original operation.

Frequently asked questions

Are MQL5 runtime and trade error codes the same?

No. Runtime errors are read through GetLastError. Trade server return codes are read from MqlTradeResult.retcode after a request.

What is MQL5 error 0?

In the runtime table, 0 is ERR_SUCCESS. It means no runtime error is recorded, but other returns and retcodes still need to be checked.

Which MQL5 code should I log after OrderSend?

Log the boolean return, GetLastError, result.retcode, and result.comment, plus the relevant request fields.

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