Quick Answer
4756 is the number you get from GetLastError() after OrderSend fails. The MQL5 reference lists it as a failure to send a trade request. It tells you that the send failed, not why. The reason is in the return code of the trade server, in MqlTradeResult.retcode (or trade.ResultRetcode() with CTrade), and it can be 10013 (invalid request), 10016 (invalid stops), 10015 (invalid price), 10004 (requote) and others.
Forum threads on 4756 show the same few causes again and again: a sell order that uses the Ask price ("you buy at the Ask and sell at the Bid"), a price, stop loss or take profit that is not a multiple of the tick size, and stops that sit inside the spread. The fix has two steps: print the retcode (and its comment) every time the call fails, and build the request so that the price follows the direction and every level is rounded to the tick size.
From the author: I build and convert Expert Advisors. An EA that prints only "OrderSend failed, error 4756" is hard to debug, because the useful part is missing. The retcode tells you which guide to open next.
Key Facts
| What you see | Usual cause | Fix |
|---|---|---|
| 4756 with retcode 10013 | The request has a wrong or missing field | Check the request fields, see invalid request |
| 4756 with retcode 10016 | A stop or take profit is too close or on the wrong side | See invalid stops |
| 4756 with retcode 10015 | The price is not valid for the request | See invalid price |
| 4756 and 10004 | The price changed, the server asks for a new quote | Refresh the price and send again |
| Sell orders fail, buy orders work | The sell uses the Ask price | Sell at the Bid, buy at the Ask |
| Works on one symbol, fails on another | The price is not on the tick size of that symbol | Round to the tick size |
| Fails near the end of the day | The spread is wider, stops are inside it | Check the spread before you send |
What the Error Looks Like
A typical log line from a real thread: OrderSend failed with error: 4756. Other threads show it together with a retcode, for example 4756 10004 or 4756 (10013 - invalid request). The thread titles also show "Error 4756, Invalid Stops". So the same number appears for different reasons, which is why the next line of your code must print the retcode:
MqlTradeRequest request;
MqlTradeResult result;
ZeroMemory(request);
ZeroMemory(result);
// ... fill the request ...
if(!OrderSend(request, result))
{
PrintFormat("OrderSend failed. GetLastError=%d retcode=%u comment=%s",
GetLastError(), result.retcode, result.comment);
}
With CTrade, use trade.ResultRetcode() and trade.ResultRetcodeDescription(). The list of all codes is in MQL5 trade return codes.
Cause 1: The Wrong Price for the Direction
A thread with the title "Can't send a sell order. 4756 10004" had a request where the price was set once, from the Ask, before the code split into buy and sell. The sell order went out at the Ask. The answer from a moderator was short: "You buy at the Ask and sell at the Bid." After the author set the price by direction, the problem was solved.
MqlTick tick;
if(!SymbolInfoTick(_Symbol, tick))
return;
double price = (type == ORDER_TYPE_BUY) ? tick.ask : tick.bid;
The same rule applies to stops: a buy position closes at the Bid, a sell position closes at the Ask. A stop loss that is calculated from the wrong side is off by the spread.
Cause 2: Prices Not on the Tick Size
The same moderator said, in another thread, that "prices (open, SL, and TP) must be a multiple of ticksize". Many EAs use _Point to build distances, and _Point is not always the tick size (some symbols have a tick size that is a multiple of the point). Round every level to the tick size of the symbol:
double NormalizePrice(const string symbol, double price)
{
double tick = SymbolInfoDouble(symbol, SYMBOL_TRADE_TICK_SIZE);
int digits = (int)SymbolInfoInteger(symbol, SYMBOL_DIGITS);
if(tick <= 0.0)
return NormalizeDouble(price, digits);
return NormalizeDouble(MathRound(price / tick) * tick, digits);
}
Use it for the open price, the stop loss and the take profit. A price that is a bit off the tick size is the kind of problem that gives 10015 (see invalid price).
Cause 3: The Spread Is Larger Than the Code Assumes
The charts show the Bid line by default. The real spread is the distance to the Ask line, and with some brokers it widens a lot around the end of the trading day. A stop that is placed a fixed distance from the price can end up inside the spread or inside the minimum stop distance of the symbol, and the request is refused (see invalid stops error 10016). Read the spread before you send, and skip the trade when it is wider than your rule allows:
long spreadPoints = SymbolInfoInteger(_Symbol, SYMBOL_SPREAD);
if(spreadPoints > maxSpreadPoints)
return; // wait for a better moment
Cause 4: A Request Field Is Wrong or Missing
Retcode 10013 behind 4756 means that the request has a problem in its fields: the action, the type, the volume, the filling mode or a missing symbol. See MQL5 invalid request error 10013 for the field by field check. Zero the structures (ZeroMemory) before you fill them, so that a field that you did not set is empty and not random.
A Full Script That Prints the Rules
This script does not send an order. It prints the entry price and the rounded stop and take profit for a buy and a sell, using fixed example numbers (Ask 1.10520, Bid 1.10500, tick size 0.00005, 5 digits, stop 10 pips = 0.00100, target 20 pips = 0.00200):
#property strict
double RoundToTick(double price, double tick, int digits)
{
return NormalizeDouble(MathRound(price / tick) * tick, digits);
}
void OnStart()
{
const double ask = 1.10520, bid = 1.10500, tick = 0.00005;
const int digits = 5;
const double slDist = 0.00100, tpDist = 0.00200;
double buyEntry = ask;
double buySl = RoundToTick(bid - slDist, tick, digits); // a buy closes at the Bid
double buyTp = RoundToTick(bid + tpDist, tick, digits);
double sellEntry = bid;
double sellSl = RoundToTick(ask + slDist, tick, digits); // a sell closes at the Ask
double sellTp = RoundToTick(ask - tpDist, tick, digits);
PrintFormat("BUY entry=%.5f sl=%.5f tp=%.5f", buyEntry, buySl, buyTp);
PrintFormat("SELL entry=%.5f sl=%.5f tp=%.5f", sellEntry, sellSl, sellTp);
}
The output should be: BUY entry=1.10520 sl=1.10400 tp=1.10700 and SELL entry=1.10500 sl=1.10620 tp=1.10320. Check the numbers by hand: the buy stop is the Bid minus 0.00100, and the sell stop is the Ask plus 0.00100.
A Safer Send With CTrade
#include <Trade\Trade.mqh>
CTrade trade;
bool SendBuy(double lots, double sl, double tp)
{
if(!trade.Buy(lots, _Symbol, 0.0, sl, tp, "bot"))
{
PrintFormat("Buy failed. retcode=%u (%s) GetLastError=%d",
trade.ResultRetcode(),
trade.ResultRetcodeDescription(),
GetLastError());
return false;
}
return true;
}
With a price of 0.0, CTrade takes the current price for the direction. The request is then right for the price side, and the remaining checks are on the stops and the volume. A thread on this error also suggested CTrade instead of a hand built MqlTradeRequest.
Retry or Not
Only a few retcodes are worth a retry: a requote (10004) after you refresh the price, or a temporary connection problem. A retcode that says that the request is wrong (10013, 10016, 10015) will fail again with the same numbers, and a loop of retries will bring a different error: too frequent requests (10024). Fix the request, do not repeat it.
Similar Return Codes
| Code | Name | What it means |
|---|---|---|
| 4756 | ERR_TRADE_SEND_FAILED | The trade request could not be sent (the reason is in the retcode) |
| 10013 | TRADE_RETCODE_INVALID | The request is invalid |
| 10015 | TRADE_RETCODE_INVALID_PRICE | The price is not valid |
| 10016 | TRADE_RETCODE_INVALID_STOPS | The stops are not valid |
| 10006 | TRADE_RETCODE_REJECT | The request was refused, no reason named |
Checklist: What to Check When You See 4756
- Print the retcode and the comment next to
GetLastError(). - Open the guide for that retcode.
- Use the Ask for a buy and the Bid for a sell as the entry price.
- Calculate stops from the closing side of each direction.
- Round every price to the tick size of the symbol.
- Check the spread and the minimum stop distance before you send.
- Zero the request and fill every field.
- Do not retry a request that is wrong, only one that can pass.
- Test on a demo account before the EA trades with real money.
Common Mistakes
- Logging only
GetLastError(). - Setting the price once for buys and sells.
- Using
_Pointas if it were the tick size. - Placing stops inside the spread.
- Retrying in a loop after a request error.
- Leaving a field of the request unset.
FAQ
Related Guides
- MQL5 trade return codes: what each return code means and how to react.
- 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 invalid price error 10015: a price that is stale, on the wrong side or not rounded to the tick size.
- MQL5 request rejected error 10006: the server refused the request without a reason.
- MQL5 no changes error 10025: a modify that changes nothing.
- MQL5 trailing stop EA: move a stop without breaking the minimum distance.
- 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.
- cTrader volume is in units, not lots:
QuantityToVolumeInUnits, the symbol minimum, maximum and step, andBadVolume. - MQL5 return value of OrderSend should be checked: store the result and read
result.retcode. - 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.