Trade server return code
10030 TRADE_ RETCODE_ INVALID_ FILL
Invalid filling type: FOK, IOC or Return not allowed for the symbol
What it means
The filling policy in the request (type_filling) is not one the symbol allows. Each symbol publishes its allowed modes as flags in SYMBOL_FILLING_MODE ("Flags of allowed order filling modes"): Fill or Kill, Immediate or Cancel, and Return, which is "not allowed in the Market Execution mode".
Common causes
ORDER_FILLING_FOKorORDER_FILLING_IOChard-coded from the broker the EA was written on.ORDER_FILLING_RETURNused on a symbol with Market execution.- One filling mode used for every symbol of a multi-symbol EA, while the broker sets it per symbol.
A real scenario
An EA written on one broker sets type_filling = ORDER_FILLING_FOK. A client runs it on a broker whose symbols allow only Immediate or Cancel, and every order fails with 10030. Choosing the mode from the symbol's flags made it work on both brokers without a setting.
How to fix it
- Read
SYMBOL_FILLING_MODEfor the symbol of the order and choose a mode it allows. - With
CTrade, calltrade.SetTypeFillingBySymbol(symbol)before trading that symbol. - Do not expose the filling mode as a user setting; derive it from the symbol.
Fixed MQL5 code
ENUM_ORDER_TYPE_FILLING FillingFor(const string symbol)
{
long modes = SymbolInfoInteger(symbol, SYMBOL_FILLING_MODE);
if((modes & SYMBOL_FILLING_FOK) == SYMBOL_FILLING_FOK)
return ORDER_FILLING_FOK;
if((modes & SYMBOL_FILLING_IOC) == SYMBOL_FILLING_IOC)
return ORDER_FILLING_IOC;
return ORDER_FILLING_RETURN; // not allowed with Market execution: such symbols set FOK or IOC
}
// usage: req.type_filling = FillingFor(req.symbol);
// with CTrade: trade.SetTypeFillingBySymbol(_Symbol);
A focused example for MetaTrader 5: adapt names, magic number and limits to your EA, and test it on a demo account first.
Related codes
- 4756Trade Request Sending FailedERR_TRADE_SEND_FAILEDTrade request sending failed: read the retcode, not 4756
- 10013Invalid RequestTRADE_RETCODE_INVALIDInvalid request: a field of the trade request is wrong or missing
EA Doctor rules that catch it
- MediumTrade request not cleared before useA local MqlTradeRequest is declared without an initializer and never cleared, so the fields the code does not set hold leftover values.
- MediumFilling mode not taken from the symbolRaw trade requests go out with a fixed filling type, or the default Fill or Kill, instead of one the symbol allows, which brokers refuse with 10030.
Sources
Get your EA fixed
Still failing with 10030? Send us the EA and the journal lines: we find the cause in the code and fix it. Or check it yourself first with the EA Doctor.