MT5 Python error -8: Auto-trading disabled (RES_E_AUTO_TRADING_DISABLED)

Algo Trading is off in the terminal, so order_send won't trade. Turn it on in the toolbar; nothing was sent.

-8RES_E_AUTO_TRADING_DISABLED
After a fixSafe to retry?
NoCould it have executed?

What it means

You see this code in mt5.last_error() in Python, after a package call returns None or False.

The terminal refuses trades from code while its Algo Trading button is off. The package reports this as -8.

Depending on the build, the same state can also show as a result with retcode 10027. Both mean the same thing.

Common causes

  • The Algo Trading button in the terminal toolbar is off.
  • The terminal switched it off, for example after a login to another account.
  • Terminal options that don't allow algorithmic trading.

How to fix it

  • Turn Algo Trading on in the terminal.
  • Check mt5.terminal_info().trade_allowed before sending and stop with a clear message if it is false.

Example in Python:

import MetaTrader5 as mt5

info = mt5.terminal_info()
if info is None or not info.trade_allowed:
    raise SystemExit("Turn on Algo Trading in the terminal first")

r = mt5.order_send(request)
if r is None:
    print(mt5.last_error())          # (-8, ...) when trading is off
elif r.retcode == mt5.TRADE_RETCODE_CLIENT_DISABLES_AT:
    print("10027: trading is off in the terminal")

Is it safe to retry?

Yes, once Algo Trading is on.

Could the order have executed?

No. The terminal blocked the trade.

How Tickwire handles it

Health shows trading_enabled false when the account can't trade, so you can catch it before an order fails. A trade sent while trading is off comes back as 10027 with nothing sent. See health.

Related MT5 Python functions

All MetaTrader error codes

All MetaTrader5 Python functions

One API for MT4 and MT5

Clear trade outcomes, idempotent orders and an audit log. Read the error reference or the quickstart.