MT5 error 10018: Market is closed (TRADE_RETCODE_MARKET_CLOSED)
The symbol is outside its trading session, such as a weekend or a holiday. Nothing was executed; wait for the session to open.
What it means
You see this code in the retcode of a trade result, from OrderSend() in MQL5 or order_send() in Python.
Each symbol has trading sessions set by the broker, in the broker's server time. Outside them the server refuses trades with 10018, even if a last price is still on screen.
Quote sessions and trade sessions can differ, so seeing a price doesn't always mean you can trade it.
Common causes
- Weekends, and the daily break many symbols have.
- Public holidays, when brokers shorten or cancel sessions.
- A schedule written in UTC when the broker's server runs on another time zone.
- A symbol that only trades in certain hours, such as a stock CFD.
How to fix it
- Check the session in the symbol specification before sending, in server time.
- Look at the age of the last tick. No movement for a long time usually means the market is shut.
- Queue the decision for the next session instead of retrying in a loop.
Example in MQL5:
// Is the symbol inside a trade session right now (server time)?
bool InTradeSession(const string sym)
{
MqlDateTime now; TimeToStruct(TimeTradeServer(), now);
datetime from, to;
const datetime secs = now.hour * 3600 + now.min * 60 + now.sec;
for(uint i = 0; SymbolInfoSessionTrade(sym, (ENUM_DAY_OF_WEEK)now.day_of_week, i, from, to); i++)
if(secs >= from && secs < to) return true;
return false;
} Is it safe to retry?
Yes, once the session is open. Retrying now gets the same answer.
Could the order have executed?
No. A closed market fills nothing.
How Tickwire handles it
When no Market Watch price has moved for 30 s, health turns degraded and a new market order is refused with quote_stale before it is sent. Set allowStaleQuote: true to send it anyway. See when prices stop moving.
Server time is measured per server, never assumed to be UTC. See time zones.
MT4 error 132 comes back as 10018.
Related codes
- MT5 error 10021: No quotes to process the request (TRADE_RETCODE_PRICE_OFF)
- MT5 error 10017: Trade is disabled (TRADE_RETCODE_TRADE_DISABLED)
- MT4 error 132: Market is closed (ERR_MARKET_CLOSED)
Related MT5 Python functions
One API for MT4 and MT5
Clear trade outcomes, idempotent orders and an audit log. Read the error reference or the quickstart.