Trade server return codes
Diagnose the server outcome stored in MqlTradeResult.retcode after a trade request.
MQL5 error directory
MQL5 errors come from distinct layers: MetaEditor compilation, terminal runtime, request precheck, and trade server response. Identify where the number was produced before applying a fix. This directory covers 38 focused MQL5 error and symptom guides, each linked to the relevant official MQL5 reference and a reproducible diagnostic pattern.
Open the Coding Agent and choose MQL5 from the language menu.
ResetLastError();
bool sent=OrderSend(request,result);
int runtime_error=GetLastError();
PrintFormat("sent=%s runtime=%d retcode=%u comment=%s",
sent ? "true" : "false",
runtime_error,result.retcode,result.comment);Also searched as: common errors in mql5; common errors in mql5 programming; mql5 error.
Select the layer that produced the message, then open the focused guide for its official meaning and repair path.
Diagnose the server outcome stored in MqlTradeResult.retcode after a trade request.
Repair source and function contracts that prevent MetaEditor from producing an EX5 file.
Isolate terminal runtime failures with direct returns, ResetLastError, and GetLastError.
Trace a visible symptom through initialization, data, signal, permission, and execution layers.
The same numeric value can be meaningless without its source. Copy the full MetaEditor message, the GetLastError call site, or the MqlTradeResult field that produced it.
| Layer | Where to read it | What it controls |
|---|---|---|
| Compilation | MetaEditor build output | Whether EX5 can be created |
| Terminal runtime | GetLastError | Client API operation |
| Trade precheck | MqlTradeCheckResult.retcode | Request and projected account state |
| Trade server | MqlTradeResult.retcode | Server processing outcome |
Save enough context to reproduce the failure without exposing account credentials. For code errors, keep file, line, column, function, and build. For runtime and trade failures, keep symbol, timeframe, request fields, return values, retcodes, comments, and server time.
A compiler repair can make an EA runnable without making its signals correct. A cleared trade retcode can make an order valid without making the strategy safe. Keep source validation, Strategy Tester behavior, broker constraints, and live risk as separate gates.
This diagnostic keeps the function return, terminal runtime code, and trade server retcode separate. Compiler diagnostics remain in MetaEditor and should be resolved before this code can run.
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.
ResetLastError();
bool sent=OrderSend(request,result);
int runtime_error=GetLastError();
PrintFormat("sent=%s runtime=%d retcode=%u comment=%s",
sent ? "true" : "false",
runtime_error,result.retcode,result.comment);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 AgentPineify 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
Record the code, description, call or compiler location, and the program state that produced it.
Decide whether the source is MetaEditor, GetLastError, OrderCheck, or MqlTradeResult.retcode.
Use the directory below to check the official meaning, required inputs, and smallest repair.
Compile, run a controlled test, and keep the new diagnostic record with the result.
Use the official compilation, runtime, and trade server code tables according to the source of the number. This directory links those references and focused repair pages.
No. Keep the OrderSend boolean, GetLastError, and MqlTradeResult.retcode plus comment. They describe different stages of the operation.
Pineify can generate and revise MQL5 source and use compilation diagnostics in its coding workflow. Broker state, terminal permissions, historical data, Strategy Tester configuration, and live behavior still require checks in your MT5 environment.
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.
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