Quick Answer
Trade return code 10027 (TRADE_RETCODE_CLIENT_DISABLES_AT) means that the client terminal blocks automated trading, so the order never reaches the broker. The EA runs and its logic works, but one of the switches that allow an EA to trade is off. There are four places to look: the AutoTrading / Algo Trading button of the terminal, the permission in the EA properties (the Common tab), the account (some accounts do not allow trading at all), and the account setting for expert advisors (some accounts allow manual trading only).
A similar code, 10026 (TRADE_RETCODE_SERVER_DISABLES_AT), says that the server of the broker disabled automated trading for the account. You cannot fix 10026 in the terminal: ask the broker. The helper below reads all four switches and says which one is off, so the EA can print the reason instead of failing quietly.
From the author: I build and convert Expert Advisors, and "the EA does nothing" is the question I get most often. Very often the logic is fine and a switch is off, for example after a terminal restart, a new profile or a new account. This guide shows how to read each switch from code, so you do not have to guess.
Key Facts
| What you see | Usual cause | Fix |
|---|---|---|
| 10027, the toolbar button is red or grey | The terminal button is off | Turn it on (the name is AutoTrading or Algo Trading, depending on the build) |
| 10027, the button is on | The EA itself is not allowed to trade | Open the EA properties and allow algo trading |
| 10027 on one account only | The account setting for EAs is off | Ask the broker, or check the account type |
| 10026 | The server disabled automated trading | Contact the broker, there is nothing to change in the EA |
| The EA runs but no order is ever sent | An EA that does not check the result | Print the return code and the reason |
| It worked yesterday | A restart, a new profile or a changed option reset a switch | Check the four switches again |
What the Error Looks Like
With CTrade, a rejected order makes Buy or Sell return false, and the details are in the result:
if(!trade.Buy(lots, _Symbol, 0.0, sl, tp, "bot"))
{
PrintFormat("Order failed. Retcode %u: %s",
trade.ResultRetcode(), trade.ResultRetcodeDescription());
}
The full list of return codes is in MQL5 trade return codes. Other order rejections with a clear fix are invalid stops, 10016 and unsupported filling mode.
The Four Switches
1. The terminal button
The toolbar of MetaTrader 5 has a button for automated trading. When it is off, no EA can send orders, on any chart. In code you read it with:
bool terminalAllows = (bool)TerminalInfoInteger(TERMINAL_TRADE_ALLOWED);
Check the options of the terminal as well (Tools, Options, the Expert Advisors tab): there is a general permission for algorithmic trading there, and there are options that switch it off by themselves in some situations, for example when the account or the profile changes. The exact wording depends on the build, so read the tab once.
2. The EA properties
When you attach an EA, its properties have a Common tab with a permission for algorithmic trading. If it is off, only this EA is blocked, even when the button is on:
bool eaAllows = (bool)MQLInfoInteger(MQL_TRADE_ALLOWED);
If the value is false, open the properties of the EA (F7 on the chart, or the EA's context menu), allow algo trading and press OK.
3. Trading on the account
An account can be read-only. This happens with an investor password login, which gives you a view without trading rights, and with accounts that the broker blocked:
bool accountAllows = (bool)AccountInfoInteger(ACCOUNT_TRADE_ALLOWED);
If you logged in with the investor password, log in again with the master password. The trade permission is a different thing from the permission of the terminal.
4. Automated trading on the account
Some accounts allow manual trading but not Expert Advisors. The server tells the terminal:
bool accountExpertsAllow = (bool)AccountInfoInteger(ACCOUNT_TRADE_EXPERT);
If this is false, the broker did not allow it for the account. Ask the broker, because a change in the terminal does not help.
10026 or 10027?
- 10027 comes from the client terminal. Fix it in the terminal, the EA or the account login.
- 10026 comes from the server. The broker disabled automated trading for this account, so contact them.
Both codes mean that the order was not sent for a reason that has nothing to do with price, volume or stops. Do not change the lot size or the stops to fix them.
A Helper That Names the Switch
This function returns an empty string when everything is on, and the reason when something is off:
string TradeBlockReason()
{
if(!TerminalInfoInteger(TERMINAL_CONNECTED))
return "the terminal is not connected to the server";
if(!TerminalInfoInteger(TERMINAL_TRADE_ALLOWED))
return "the AutoTrading button of the terminal is off";
if(!MQLInfoInteger(MQL_TRADE_ALLOWED))
return "this EA is not allowed to trade (check the EA properties)";
if(!AccountInfoInteger(ACCOUNT_TRADE_ALLOWED))
return "trading is not allowed for this account (investor login?)";
if(!AccountInfoInteger(ACCOUNT_TRADE_EXPERT))
return "automated trading is not allowed for this account";
return "";
}
Use it before every order, and print the reason once per minute at most, so that the log stays readable:
string reason = TradeBlockReason();
if(reason != "")
{
Print("Not trading: ", reason);
return;
}
When an order is rejected, you can still react to the two codes by name:
uint rc = trade.ResultRetcode();
if(rc == TRADE_RETCODE_CLIENT_DISABLES_AT || rc == TRADE_RETCODE_SERVER_DISABLES_AT)
Print("Automated trading is disabled. ", TradeBlockReason());
A Full EA That Prints the State
This EA does not place trades. It prints the four switches at start and every 30 seconds, so you can switch the button or the permission and watch the log change:
#property strict
int OnInit()
{
EventSetTimer(30);
PrintState();
return INIT_SUCCEEDED;
}
void OnDeinit(const int reason)
{
EventKillTimer();
}
void OnTimer()
{
PrintState();
}
void PrintState()
{
PrintFormat("connected=%d terminal_trade=%d ea_trade=%d account_trade=%d account_expert=%d",
(int)TerminalInfoInteger(TERMINAL_CONNECTED),
(int)TerminalInfoInteger(TERMINAL_TRADE_ALLOWED),
(int)MQLInfoInteger(MQL_TRADE_ALLOWED),
(int)AccountInfoInteger(ACCOUNT_TRADE_ALLOWED),
(int)AccountInfoInteger(ACCOUNT_TRADE_EXPERT));
string reason = TradeBlockReason();
if(reason == "")
Print("Automated trading is allowed.");
else
Print("Not trading: ", reason);
}
string TradeBlockReason()
{
if(!TerminalInfoInteger(TERMINAL_CONNECTED))
return "the terminal is not connected to the server";
if(!TerminalInfoInteger(TERMINAL_TRADE_ALLOWED))
return "the AutoTrading button of the terminal is off";
if(!MQLInfoInteger(MQL_TRADE_ALLOWED))
return "this EA is not allowed to trade (check the EA properties)";
if(!AccountInfoInteger(ACCOUNT_TRADE_ALLOWED))
return "trading is not allowed for this account (investor login?)";
if(!AccountInfoInteger(ACCOUNT_TRADE_EXPERT))
return "automated trading is not allowed for this account";
return "";
}
Attach it to a chart on a demo account, switch the terminal button off and on, and read the Experts tab. Each switch should change one number in the line.
Checklist: What to Check When You See 10027
- Look at the toolbar button of the terminal. Is it on?
- Open the EA properties (F7). Is algo trading allowed in the Common tab?
- Check the login. Did you use the investor password?
- Run the printing EA above and read which of the four values is 0.
- Check the options of the terminal for settings that switch trading off when the account or profile changes.
- If the code is 10026, write to the broker.
- Add the helper to your EA, and print the return code of every order.
- Test on a demo account before the EA trades with real money.
Common Mistakes
- Changing the lot size or the stops to fix a code that is about permission.
- Turning the button on and forgetting the permission in the EA properties.
- Logging in with the investor password and wondering why nothing trades.
- Not printing the return code, so the EA seems to do nothing.
- Mixing up 10026 and 10027, and trying to fix a server decision in the terminal.
- Not rechecking after a restart, a VPS move or a new profile.
FAQ
Related Guides
- MQL5 trade return codes: what each return code means and how to react.
- MQL5 invalid stops error 10016: the matching error for stop loss and take profit.
- MQL5 unsupported filling mode error: another order rejection with a clear fix.
- MQL5 daily loss limit: stop trading when the day goes wrong.
- MQL5 filter positions by magic number: keep each EA to its own trades.
- MT5 hedging vs netting: the account type changes how orders behave.
- What to check in a trading bot before going live: a pre-live checklist for stops, lot size, spread and trade results.
- MQL5 invalid request error 10013: a request with a missing or wrong field.
- MQL5 invalid volume error 10014: a lot size that does not match the symbol rules.
- MQL5 invalid price error 10015: a price that is stale, on the wrong side or not rounded to the tick size.
- MQL5 market closed error 10018: an order sent outside the trading session.
- MQL5 not enough money error 10019: not enough free margin for the order.
- MQL5 request rejected error 10006: the server refused the request without naming a reason.
- MQL5 too frequent requests error 10024: slow down, queue requests and back off.
- MQL5 no quotes (10021) and no connection (10031): check the link and the tick before you send.
- MQL5 error 4014: system function is not allowed to call: trading functions in an indicator.
Fix Compile Errors Without Guessing
If an Expert Advisor does not compile, or you want a second look at its order and risk logic, paste the code into the CodeFlowOS Error Fixer. It suggests a minimal fix, explains each error and shows what changed. A fix uses 1 credit, with up to 3 attempts included, and the compiler check is optional. Outputs are not guaranteed, and code that compiles can still have wrong trading logic, so always review the result. The Code Review is free during the early-bird period and checks an EA for common mistakes such as a fixed lot size or a missing stop loss. CodeFlowOS also converts strategies between Pine Script, MQL5 and cTrader C#: try the converter page.
This article is educational. It does not describe trading performance and is not financial advice. Always compile and test code in MetaEditor and the Strategy Tester before using it on a live account.