Quick Answer
The MetaEditor message "return value of 'OrderSend' should be checked" is a warning: the code compiles. It means that your EA calls OrderSend() and throws away the bool that the function returns. The fix is to store the value and test it. But the forum threads on this warning agree on a second point that matters more: a true return does not mean that the trade was executed. According to the MQL5 documentation, as quoted in the threads, true only means that the request passed a basic structure check. The outcome is in result.retcode.
A short if(OrderSend(request, result)) { ... } removes the warning, and a forum answer says exactly that, but it does not check the result. A proper check has three parts: test the returned bool, read result.retcode, and treat only the codes that mean "done" or "placed" as success. This post shows the broken call, the one-line silencer, a full check with a helper you can test, and a mistake from one thread: a stop loss given in points instead of as a price.
From the author: I review EAs that were converted from MQL4 and Pine Script. A call to
OrderSendwith no check is the most common reason an EA "does nothing": the order is refused, the code goes on, and nothing is logged. The warning is a gift. It points at the line where the log should be.
Key Facts
| What you wrote | What it does | Better |
|---|---|---|
| OrderSend(request, result); | Warning, the result is thrown away | Store and test the return value |
| if(OrderSend(request, result)) { ... } | The warning goes away, but true is not "executed" | Also check result.retcode |
| bool ticket = OrderSend(...) | A misleading name: the function returns a flag, not a ticket | bool sent = OrderSend(...) |
| request.sl = 100 (points) | A forum answer: SL must be a price, 0 means none | Calculate the price from the entry |
| An else branch with no log | A failure goes unseen | Print the retcode and the comment |
The Broken Call
void SendBuy(double lots, double sl, double tp)
{
MqlTradeRequest request;
MqlTradeResult result;
ZeroMemory(request);
ZeroMemory(result);
request.action = TRADE_ACTION_DEAL;
request.symbol = _Symbol;
request.volume = lots;
request.type = ORDER_TYPE_BUY;
request.price = SymbolInfoDouble(_Symbol, SYMBOL_ASK);
request.sl = sl;
request.tp = tp;
OrderSend(request, result); // warning: return value of 'OrderSend' should be checked
}
What the Documentation Says (as Quoted in the Threads)
A moderator replied to a beginner who followed a tutorial: the message is a warning, not an error, and the return value of OrderSend() was not checked. A second reply quoted the documentation: the function returning true is not a sign of successful execution of a trade operation, it only means that the request passed a basic check of the structure. To learn the result you must analyze the fields of the result structure, mainly result.retcode.
The One-Line Silencer, and Why It Is Not Enough
if(OrderSend(request, result))
{
// ... something
}
A forum answer suggested exactly this and said that the warning disappears. Another answer agreed that it removes the warning and pointed out that it does not check the result. The compiler is satisfied, and the EA still cannot tell a placed order from a refused one.
The Check That Works
Read the return value, then the retcode, and log both when the trade is not accepted:
bool IsAccepted(uint retcode)
{
return(retcode == TRADE_RETCODE_DONE ||
retcode == TRADE_RETCODE_PLACED ||
retcode == TRADE_RETCODE_DONE_PARTIAL);
}
bool SendBuy(double lots, double sl, double tp)
{
MqlTradeRequest request;
MqlTradeResult result;
ZeroMemory(request);
ZeroMemory(result);
request.action = TRADE_ACTION_DEAL;
request.symbol = _Symbol;
request.volume = lots;
request.type = ORDER_TYPE_BUY;
request.price = SymbolInfoDouble(_Symbol, SYMBOL_ASK);
request.sl = sl;
request.tp = tp;
bool sent = OrderSend(request, result);
if(!sent || !IsAccepted(result.retcode))
{
PrintFormat("Buy not accepted. sent=%d retcode=%u comment=%s GetLastError=%d",
sent, result.retcode, result.comment, GetLastError());
return false;
}
return true;
}
TRADE_RETCODE_DONE (10009) means the request was completed, TRADE_RETCODE_PLACED (10008) means a pending order was placed, and TRADE_RETCODE_DONE_PARTIAL (10010) means that only a part of the volume was filled. The full list is in MQL5 trade return codes. Decide for your EA whether a partial fill counts as success, and say it in a comment.
A Mistake Inside the Same Request: SL in Points
In the thread about this warning, a poster set request.sl = 100. An answer said that the stop loss must be a price, not a number of points, and that 0 is the only value that means "no stop loss" (the same is true for the take profit). A request with a stop that is a price far from the market is refused, and the error is in the retcode, not in the compiler. Build the price from the entry:
double point = SymbolInfoDouble(_Symbol, SYMBOL_POINT);
double ask = SymbolInfoDouble(_Symbol, SYMBOL_ASK);
double sl = ask - 100 * point; // a price, 100 points below the Ask
For the rounding rules of the stop, see MQL5 OrderSend failed with error 4756 and invalid stops error 10016.
OrderCheck Before OrderSend
The thread also had code that called OrderCheck() first and OrderSend() only if the check passed. That is a valid pattern, because OrderCheck() tests the request without sending it. It does not remove the need to check the result of OrderSend(): a request that passes the check can still be refused by the server (for example request rejected 10006 or too many requests 10024).
A Script That Tests the Helper
This script does not trade. It runs IsAccepted on fixed return codes and prints the result:
#property strict
bool IsAccepted(uint retcode)
{
return(retcode == TRADE_RETCODE_DONE ||
retcode == TRADE_RETCODE_PLACED ||
retcode == TRADE_RETCODE_DONE_PARTIAL);
}
void OnStart()
{
uint codes[] = { 10009, 10008, 10010, 10006, 10013, 10016, 10024 };
for(int i = 0; i < ArraySize(codes); i++)
PrintFormat("%u -> %s", codes[i], IsAccepted(codes[i]) ? "accepted" : "not accepted");
}
The log should show 10009, 10008 and 10010 as accepted, and 10006, 10013, 10016 and 10024 as not accepted. If a line differs, check the constants in the helper.
What to Do When the Check Fails
| Retcode | What it usually means | Guide | |---|---|---| | 10006 | The request was refused | 10006 | | 10013 | The request is invalid | 10013 | | 10015 | The price is not valid | 10015 | | 10016 | The stops are not valid | 10016 | | 10024 | Too many requests | 10024 |
Only retry a failure that can pass the next time (a requote after a new price). A request that is wrong fails again, and a loop of retries brings the "too many requests" code.
Checklist: What to Check When You See This Warning
- Find the
OrderSendcall the compiler points at. - Store the return value in a
bool. - Read
result.retcodeand compare it with the success codes. - Log the retcode and the comment when the trade is not accepted.
- Make the stop loss and take profit prices, or
0. - Decide what a partial fill means for your EA.
- Do not retry a request that is wrong.
- Test on a demo account before the EA trades with real money.
Common Mistakes
- Ignoring the warning because the EA compiles.
- Using
if(OrderSend(...))as the whole check. - Naming the returned flag
ticket. - Giving the stop loss in points.
- Logging only
GetLastError(). - Retrying a request that is wrong.
FAQ
Related Guides
- MQL5 OrderSend failed with error 4756: the wrapper error, and how to read the retcode behind it.
- MQL5 trade return codes: what each return code means and how to react.
- MQL5 request rejected error 10006: the server refused the request without a reason.
- MQL5 invalid request error 10013: a request with a missing or wrong field.
- MQL5 invalid stops error 10016: a stop that is too close or on the wrong side.
- MQL5 too many requests error 10024: why a retry loop makes it worse.
- MQL5 lot size calculation: the volume side of a valid request.
- What to check in a trading bot before going live: a pre-live checklist for stops, lot size, spread and trade results.
- MQL5 unexpected end of program, unbalanced parentheses: find the missing brace.
- MQL5 error 4014: system function is not allowed to call: trading functions in an indicator.
Fix Compile Errors Without Guessing
If an Expert Advisor does not compile, or you want a second look at its order and risk logic, paste the code into the CodeFlowOS Error Fixer. It suggests a minimal fix, explains each error and shows what changed. A fix uses 1 credit, with up to 3 attempts included, and the compiler check is optional. Outputs are not guaranteed, and code that compiles can still have wrong trading logic, so always review the result. The Code Review is free during the early-bird period and checks an EA for common mistakes such as a fixed lot size or a missing stop loss. CodeFlowOS also converts strategies between Pine Script, MQL5 and cTrader C#: try the converter page.
This article is educational. It does not describe trading performance and is not financial advice. Always compile and test code in MetaEditor and the Strategy Tester before using it on a live account.