MT5 error 4752: Automated trading is not allowed for the program (ERR_TRADE_DISABLED)

The terminal or this program isn't allowed to trade, so OrderSend refused before sending. Check Algo Trading and the program's settings.

4752ERR_TRADE_DISABLED
After a fixSafe to retry?
NoCould it have executed?

What it means

You see this code in GetLastError() in MQL5, after a function fails.

MQL5 programs need permission to trade, both in the terminal as a whole and for each program. Without it, trade functions fail with 4752.

The request was stopped inside the terminal. The broker never saw it.

Common causes

  • The Algo Trading button in the toolbar is off.
  • The program was attached without "Allow Algo Trading" in its settings.
  • The terminal options don't allow algorithmic trading.
  • A program type that can't trade, such as an indicator.

How to fix it

  • Turn on Algo Trading in the toolbar.
  • Open the program's settings and allow algorithmic trading.
  • Check TerminalInfoInteger(TERMINAL_TRADE_ALLOWED) and MQLInfoInteger(MQL_TRADE_ALLOWED) at start up.

Example in MQL5:

int OnInit()
{
   if(!TerminalInfoInteger(TERMINAL_TRADE_ALLOWED))
      Print("Algo Trading is off in the terminal");
   if(!MQLInfoInteger(MQL_TRADE_ALLOWED))
      Print("This program was attached without permission to trade");
   return INIT_SUCCEEDED;
}

Is it safe to retry?

Yes, once trading is allowed. Nothing was sent.

Could the order have executed?

No. The terminal blocked it.

How Tickwire handles it

Tickwire checks that trading is switched on in the terminal before sending. If it is off, the order comes back as 10027 with nothing sent, and health shows trading_enabled false. See health.

All MetaTrader error codes

One API for MT4 and MT5

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