EA Upgrade & VPS Setup
Software you already own, fixed or extended — and deployed on a VPS so it keeps running when your own machine is o…
Read moreAn EA that worked perfectly on one broker places nothing on another, and the log says retcode 10030. This is almost always one line of missing code.
You move a working EA to a new broker, or your broker changes something server-side. Suddenly no trades open. The Experts log shows:
OrderSend failed. Retcode: 10030 // TRADE_RETCODE_INVALID_FILL
Nothing is wrong with your strategy. The EA is asking the server to fill the order in a way that this particular broker, on this particular symbol, does not accept.
| Mode | Meaning | If it cannot be fully filled |
|---|---|---|
ORDER_FILLING_FOK | Fill or Kill | The whole order is cancelled |
ORDER_FILLING_IOC | Immediate or Cancel | Fills what it can, cancels the rest |
ORDER_FILLING_RETURN | Return | Fills what it can, the remainder stays as a pending order |
Each broker decides which modes it supports, per symbol. It is not an account-level setting and it is not something you can assume.
Most EAs that break this way have the mode hard-coded, usually because it worked during development:
request.type_filling = ORDER_FILLING_FOK; // works here, fails there
That line is the whole bug. It is correct on one broker and wrong on the next.
The terminal already knows which modes the symbol allows. Read it instead of guessing:
ENUM_ORDER_TYPE_FILLING PickFilling(const string symbol)
{
int allowed = (int)SymbolInfoInteger(symbol, SYMBOL_FILLING_MODE);
if((allowed & SYMBOL_FILLING_FOK) != 0) return ORDER_FILLING_FOK;
if((allowed & SYMBOL_FILLING_IOC) != 0) return ORDER_FILLING_IOC;
// Neither flag set: the symbol uses RETURN (market execution)
return ORDER_FILLING_RETURN;
}
Two details that catch people out. SYMBOL_FILLING_MODE is a
bit mask, so test it with &, never with ==. And
ORDER_FILLING_RETURN has no flag of its own — when neither FOK nor IOC is set, RETURN
is what the symbol uses.
Pending orders (limit and stop) generally use ORDER_FILLING_RETURN regardless of
what the symbol reports for market orders. If your EA places pending orders, handle them
separately rather than reusing the market-order mode.
Resolve the filling mode once in OnInit() and refuse to start if nothing
workable is available. Finding out at 2am, on the first signal of the week, is the expensive
version.
int OnInit()
{
if(!SymbolSelect(_Symbol, true))
{
Print("Symbol not available: ", _Symbol);
return INIT_FAILED;
}
g_filling = PickFilling(_Symbol);
Print("Filling mode resolved to: ", EnumToString(g_filling));
return INIT_SUCCEEDED;
}
| Retcode | Constant | Usual cause |
|---|---|---|
| 10030 | TRADE_RETCODE_INVALID_FILL | Filling mode not supported |
| 10016 | TRADE_RETCODE_INVALID_STOPS | Stop closer than the broker's minimum |
| 10014 | TRADE_RETCODE_INVALID_VOLUME | Lot below minimum, above maximum, or off the step |
| 10019 | TRADE_RETCODE_NO_MONEY | Insufficient free margin |
| 10027 | TRADE_RETCODE_CLIENT_DISABLES_AT | Algo Trading button is off |
Always print the retcode and the comment from the result structure. "OrderSend failed" on its own tells nobody anything; the retcode tells you exactly which of these it was.
Software you already own, fixed or extended — and deployed on a VPS so it keeps running when your own machine is o…
Read moreYou write the rules. We implement them in MQL5 as a working Expert Advisor that runs on your own MetaTrader 5 terminal, …
Read moreSend your rules, your script or your existing file on WhatsApp and we will reply with a written scope, price and timeline.