Skip to content

Trade server return code

10017 TRADE_RETCODE_TRADE_DISABLED

Trade is disabled for the symbol or the account

What it means

The server does not allow trading in the request's context: the symbol is not tradable right now, or the account cannot trade. It is a state on the broker's side, not a mistake in the request, so resending it does not help.

Common causes

  • The symbol's trade mode is SYMBOL_TRADE_MODE_DISABLED ("Trade is disabled for the symbol"), for example a contract around expiry or rollover.
  • The terminal is signed in with the investor (read-only) password, so ACCOUNT_TRADE_ALLOWED is false.
  • The broker has switched trading off for the account.
  • A quotes-only symbol: some brokers show a reference symbol next to the tradable one with a suffix.

A real scenario

A trader watches a funded account from a second terminal signed in with the investor password and attaches the same EA there. The EA's signals fire, every order fails, and the journal fills up. A check of ACCOUNT_TRADE_ALLOWED in OnInit() now stops the EA with a clear message on the read-only terminal.

How to fix it

  1. Check ACCOUNT_TRADE_ALLOWED and the symbol's SYMBOL_TRADE_MODE before trading, and say which one blocks it.
  2. Handle the restricted modes too: long only, short only and close only have their own codes (10042, 10043, 10044).
  3. Stop retrying until the state changes; check again on the next bar or in OnTimer().

Fixed MQL5 code

MQL5
bool TradingAllowedFor(const string symbol)
{
   if(!AccountInfoInteger(ACCOUNT_TRADE_ALLOWED))
   {
      Print("This account cannot trade (for example, signed in with the investor password)");
      return false;
   }
   ENUM_SYMBOL_TRADE_MODE mode = (ENUM_SYMBOL_TRADE_MODE)SymbolInfoInteger(symbol, SYMBOL_TRADE_MODE);
   if(mode == SYMBOL_TRADE_MODE_DISABLED)
   {
      PrintFormat("%s: trading is disabled for this symbol", symbol);
      return false;
   }
   if(mode == SYMBOL_TRADE_MODE_CLOSEONLY)
      PrintFormat("%s: only closing is allowed right now", symbol);
   return mode != SYMBOL_TRADE_MODE_CLOSEONLY;
}

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

  • LowAlgo trading permission not checkedThe EA sends orders without checking that algo trading is allowed in the terminal, for the EA and on the account, so every order fails when one is off.

Sources

Get your EA fixed

Still failing with 10017? 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.