Skip to content

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_FOK or ORDER_FILLING_IOC hard-coded from the broker the EA was written on.
  • ORDER_FILLING_RETURN used 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

  1. Read SYMBOL_FILLING_MODE for the symbol of the order and choose a mode it allows.
  2. With CTrade, call trade.SetTypeFillingBySymbol(symbol) before trading that symbol.
  3. Do not expose the filling mode as a user setting; derive it from the symbol.

Fixed MQL5 code

MQL5
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.

EA Doctor rules that catch it

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.