Market Closed in MT5: Fix Error 10018 & 132 (Even on Weekdays)
Contents
- What the codes mean (10018 vs 132)
- ① TRADE_RETCODE_MARKET_CLOSED = 10018 (MT5, `OrderSend()` return code)
- ② ERR_MARKET_CLOSED = 132 (MT4 / MQL4, from `GetLastError()`)
- 30-second triage
- Causes & fixes (6 patterns)
- ① Weekend or holiday — the whole market is closed
- ② Outside the symbol's own session (daily breaks)
- ③ Server time vs your local time
- ④ Symbol set to disabled or close-only (SYMBOL_TRADE_MODE)
- ⑤ The first minutes after Monday open or a session break
- ⑥ News and event halts
- MQL5 code to prevent it (for EA developers)
- Check whether the trading session is open
- Check the trade mode
- Put them together as a pre-trade gate
- Handling a 10018 that slips through anyway
- Priority checklist
- Summary
- FAQ
- Q: Why do I get "Market closed" on a weekday afternoon?
- Q: What's the difference between 10018 and 132?
- Q: My EA spams this error all weekend. Is that a problem?
- Q: I got "Market closed" on BTCUSD. Isn't crypto 24/7?
Market Closed in MT5 (10018 / 132)
When your EA logs Market closed, the "it's the weekend, obviously" explanation only covers half the cases. The ones that actually cost people hours are the others: the error fires on a weekday afternoon, or only on one symbol while EURUSD trades fine.
That's because "market closed" doesn't just mean Saturday. It also means per-symbol trading sessions (gold and index CFDs pause every day), broker server time that doesn't match your clock, and symbols set to close-only or disabled. This article covers all of it for both MT5 users running EAs and MQL5 developers writing them — what the codes mean, the 6 root causes, a 30-second triage, and the pre-trade code that prevents the error permanently. For the full list of error codes, see the complete MT5 error-code guide.
This article targets MT5 (build 4xxx) as of July 2026. Session times and panel names vary by broker and build.
What the codes mean (10018 vs 132)
"Market is closed" has a different code on MT5 and MT4 (MQL4). Read it according to the platform and where you got the value.
① TRADE_RETCODE_MARKET_CLOSED = 10018 (MT5, OrderSend() return code)
In MQL5, the outcome of OrderSend() lands in MqlTradeResult.retcode. When the trade server decides the symbol is outside its trading session and rejects the request, the code is 10018. This isn't an internal terminal error — it's a rejection from the broker's server.
Meaning: Market is closed
Constant: TRADE_RETCODE_MARKET_CLOSED
Value : 10018
// typical log line
2026.07.06 23:05:11.204 EA_NAME XAUUSD,M5: OrderSend error 10018 [Market closed]
② ERR_MARKET_CLOSED = 132 (MT4 / MQL4, from GetLastError())
On MT4, a failed OrderSend() followed by GetLastError() returns 132, with the same meaning. If you run both platforms, the same underlying cause shows up as 10018 on MT5 and 132 on MT4.
Meaning: Market is closed
Constant: ERR_MARKET_CLOSED (MQL4)
Value : 132
Side by side:
| Platform | Source | Value |
|---|---|---|
| MT5 (MQL5) | MqlTradeResult.retcode / CTrade.ResultRetcode() | 10018 |
| MT4 (MQL4) | GetLastError() after a failed OrderSend() | 132 |
The root cause is shared: an order was sent outside the server's trading session for that symbol (or the symbol's trading is restricted). So are the fixes — the rest of this article applies to both.
30-second triage
Before restarting anything, four checks narrow it down:
- Read the symbol's trading sessions — Market Watch → right-click the symbol → Specification → "Trading sessions". This lists the tradable hours per weekday, in server time. If "now" falls outside them, that's your answer.
- Check server time — the clock at the top of the Market Watch window is the broker's server time. Sessions are judged against that clock, not your PC's. It's normal for it to be hours off your local time.
- Check the trade mode — in the same Specification window, the "Trade" field. Anything other than
Full access(Disabled,Close only, …) means new orders get rejected even mid-session. - Try another symbol — if the same EA or a manual order goes through on EURUSD, the problem isn't your account or the EA. It's that symbol's sessions or restrictions.
Causes & fixes (6 patterns)
① Weekend or holiday — the whole market is closed
Symptom: errors on Saturday/Sunday, or around Christmas / New Year. All symbols affected.
Cause: FX is closed roughly from Friday close to Monday open in server time, and holidays bring full or shortened closures even midweek. If your EA still tries to send orders (bar-close bookkeeping, pending logic), 10018/132 pile up in the log.
Fix:
- The error itself is harmless — it resolves when the market reopens
- To keep the log clean, add a weekday/session check so the EA never sends the order in the first place (code below)
- Holiday calendars differ per broker — check your broker's trading-schedule announcements
② Outside the symbol's own session (daily breaks)
Symptom: errors on a weekday, but only on specific symbols — gold, silver, index CFDs, energies — and at roughly the same time every day.
Cause: FX pairs trade almost 24 hours on weekdays, but metals and index CFDs have a daily trading pause (from tens of minutes to a few hours), tied to the underlying exchange's maintenance and rollover. The exact window differs by broker and symbol. An order sent during that pause returns 10018.
Fix:
- Open Specification → Trading sessions and read the exact pause window for your broker's symbol. That table is the only source of truth — don't trust session times from someone else's blog post, because brokers differ
- Use the EA's time filter (
TradeStartHour/TradeEndHouretc.) to step around the pause - Developers: check
SymbolInfoSessionTrade()in code (below)
Note on crypto: many brokers quote BTCUSD and friends through the weekend, but not all. Don't assume "crypto = 24/7" — that too is broker-dependent, and the Specification window tells you what your broker actually does.
③ Server time vs your local time
Symptom: "the spec says the session should be open" — yet the error fires. Common with offshore brokers.
Cause: every session time in the Specification window, and every clock inside MT5, is broker server time. Many brokers run GMT+2/+3 (so New York close lands on midnight), which can be many hours away from your local clock. "Still Friday evening" locally can already be Saturday in server time.
Fix:
- Make the Market Watch clock (= server time) your reference, always
- EA time-filter inputs are conventionally interpreted in server time — re-check any values you set thinking in local time
- In code, judge sessions with
TimeTradeServer(), neverTimeLocal()
④ Symbol set to disabled or close-only (SYMBOL_TRADE_MODE)
Symptom: weekday, mid-session, yet every new order on one symbol is rejected — while closing positions may still work.
Cause: brokers can restrict trading per symbol:
| SYMBOL_TRADE_MODE | Meaning |
|---|---|
SYMBOL_TRADE_MODE_FULL | no restrictions (normal) |
SYMBOL_TRADE_MODE_CLOSEONLY | close operations only — no new entries. Typical for expiring CFD contracts or delistings |
SYMBOL_TRADE_MODE_DISABLED | trading disabled entirely |
SYMBOL_TRADE_MODE_LONGONLY / SHORTONLY | only buys / only sells allowed |
Settings can also differ between demo and live accounts, or between account types.
Fix:
- Check the "Trade" field in the Specification window
Close only: no new entries will go through — manage down the position. If you need the instrument long-term, look for the replacement symbol (a newer contract or a differently-suffixed variant) in Market WatchDisabled: ask your broker whether the symbol is tradable on your account type at all
⑤ The first minutes after Monday open or a session break
Symptom: rejections only in the first minutes after Monday open, or right after a daily break ends.
Cause: "session opened" and "orders reliably fill" are not the same moment. Right at open, liquidity is thin and spreads blow out, and some brokers won't accept orders until quotes are actually streaming — rejecting them as market-closed until then. EAs that signal at the very first Monday bar, and gold EAs that trade the break reopen, hit this routinely.
Fix:
- Add a skip window after open (
AvoidMondayOpenand similar). This is exactly why the EAs we distribute skip roughly the first hours of Monday (server time) by default - Always pair it with a spread filter (
MaxSpread) — a fill at an open-spike spread hurts more than the error does - On a 10018, don't retry immediately — wait for the next bar
⑥ News and event halts
Symptom: temporary rejections around major news releases or during extreme moves on a particular instrument.
Cause: some brokers/instruments suspend or restrict trading around major events, and index CFDs can halt in step with circuit breakers on the underlying market. Orders during the halt come back as market-closed-style rejections.
Fix:
- It's temporary — it clears on its own
- A news filter (
UseEconomicFilterin our EAs) that pauses new entries around releases kills two birds: no error spam, and no fills into the spike itself
MQL5 code to prevent it (for EA developers)
The right design isn't "handle the error after it happens" — it's check the session and trade mode before ordering, and don't send when the market is shut. That keeps logs clean and prevents retry storms against a closed server.
Check whether the trading session is open
SymbolInfoSessionTrade() returns the start/end of session i for a given weekday, as seconds from 00:00 server time. Symbols with daily breaks have multiple sessions per day, so loop through all of them.
// Is the current server time inside one of this symbol's trading sessions?
bool IsTradeSessionOpen(const string symbol)
{
MqlDateTime dt;
TimeToStruct(TimeTradeServer(), dt); // always judge in SERVER time
int now = dt.hour*3600 + dt.min*60 + dt.sec; // seconds since midnight
datetime from, to;
for(uint i = 0; SymbolInfoSessionTrade(symbol, (ENUM_DAY_OF_WEEK)dt.day_of_week, i, from, to); i++)
{
int f = (int)from; // seconds from 00:00
int t = (int)to; // a session ending at 24:00 yields 86400
if(now >= f && now < t)
return true;
}
return false; // no session this weekday (weekend), or between sessions
}
Check the trade mode
// Does the symbol's trade mode allow a NEW entry in this direction?
bool IsNewEntryAllowed(const string symbol, ENUM_ORDER_TYPE type)
{
long mode = SymbolInfoInteger(symbol, SYMBOL_TRADE_MODE);
if(mode == SYMBOL_TRADE_MODE_DISABLED) return false; // trading disabled
if(mode == SYMBOL_TRADE_MODE_CLOSEONLY) return false; // close-only = no new entries
if(mode == SYMBOL_TRADE_MODE_LONGONLY && type != ORDER_TYPE_BUY) return false;
if(mode == SYMBOL_TRADE_MODE_SHORTONLY && type != ORDER_TYPE_SELL) return false;
return true; // SYMBOL_TRADE_MODE_FULL etc.
}
Put them together as a pre-trade gate
// In OnTick: even with a valid signal, don't send while the market is shut
if(!IsTradeSessionOpen(_Symbol) || !IsNewEntryAllowed(_Symbol, ORDER_TYPE_BUY))
{
// 10018 prevented before it happens — log once and wait for the next bar
return;
}
Handling a 10018 that slips through anyway
Session data refreshes, right-at-open rejections, and halts mean the gate can't be perfect. So still read the retcode — and on 10018, never retry in a tight loop. Hammering a closed market improves nothing and floods the log; wait for the next bar (or the next session).
MqlTradeRequest req; MqlTradeResult res;
ZeroMemory(req); ZeroMemory(res);
// ... build req ...
if(!OrderSend(req, res) || res.retcode != TRADE_RETCODE_DONE)
{
if(res.retcode == TRADE_RETCODE_MARKET_CLOSED) // 10018
Print("Market closed. Skip and wait for the next session.");
else
PrintFormat("OrderSend failed: retcode=%d, lastError=%d", res.retcode, GetLastError());
}
Honestly: any EA that fires at Monday open or around daily breaks — gold and index EAs especially — meets this error as a matter of routine. Schedule-aware EAs, meaning ones with a session check, an open-skip window, and a before-weekend close, don't just avoid pointless errors; they also avoid the thin-liquidity fills those moments produce. The EAs FXEA365 distributes ship with Monday-open avoidance (AvoidMondayOpen), time filters, and weekend close (CloseAllBeforeWeekend) as standard.
Priority checklist
| Priority | Check | Fix |
|---|---|---|
| 🚨 first | is it the weekend / a holiday (in server time)? | just wait — the error is harmless |
| 🚨 first | inside the "Trading sessions" window in Specification? | route around the symbol's daily break with a time filter |
| ⚠️ next | confusing server time with local time? | reset your reference to the Market Watch clock |
| ⚠️ next | trade mode = Full access? | Close only / Disabled → check the broker's symbol setup |
| ✅ check | first minutes after open / break reopen? | skip window + spread filter |
| 🛠 dev | session & mode checked before OrderSend? | implement the SymbolInfoSessionTrade gate above |
Summary
- "Market closed" is 10018 (TRADE_RETCODE_MARKET_CLOSED) on MT5 and 132 (ERR_MARKET_CLOSED) on MT4 — same meaning, same fixes: an order sent outside the symbol's trading session or against a trading restriction.
- It's not only weekends. Per-symbol daily breaks (gold, indices), server-time confusion, SYMBOL_TRADE_MODE restrictions, and right-at-open rejections all trigger it. Weekday error → open Specification → Trading sessions first.
- Session times differ by broker and symbol. The table in your terminal's Specification window is the only correct source.
- Developers: gate entries with
SymbolInfoSessionTrade()+SYMBOL_TRADE_MODE+TimeTradeServer(), and on a 10018, wait for the next bar instead of retrying.
For all error codes, see the complete MT5 error-code guide; for free EAs that ship with session awareness and time filters built in, see the EA list.
FAQ
Q: Why do I get "Market closed" on a weekday afternoon?
Either the symbol has its own daily trading pause, or its trade mode is restricted. Gold, silver, and index CFDs have windows every weekday when they can't be traded. Right-click the symbol in Market Watch → Specification, and read both "Trading sessions" and the "Trade" field.
Q: What's the difference between 10018 and 132?
Only the platform. 10018 (TRADE_RETCODE_MARKET_CLOSED) is the MT5 OrderSend() return code; 132 (ERR_MARKET_CLOSED) is what MQL4's GetLastError() returns on MT4. Causes and fixes are identical.
Q: My EA spams this error all weekend. Is that a problem?
No real harm — it stops by itself when the market reopens. If the log noise or push notifications bother you, the proper fix is a weekday/session check in the EA so the order is never sent (see the code above).
Q: I got "Market closed" on BTCUSD. Isn't crypto 24/7?
Whether crypto CFDs trade through the weekend is up to your broker. Some suspend weekend trading or insert short maintenance breaks. Check Specification → Trading sessions for the actual tradable hours at your broker, exactly as you would for an FX pair.
Related
2026-07-07
AutoTrading Disabled in MT5: Fix Retcodes 10027 & 10026 (EA Not Trading)
2026-07-07
Invalid Stops in MT5: Fix Retcode 10016 & MT4 Error 130
2026-07-07
Off Quotes & Requote in MT5: Fix Errors 10021 / 10004 (and MT4's 136 / 138)
2026-07-07
Unsupported Filling Mode (MT5 Error 10030): The Fix When Your EA Stops Working on a New Broker
5-Day Email Course (Free)
Get one email a day covering the essentials of FX automated trading, how to read backtests correctly, and tips for choosing a broker.
* Privacy strictly protected. You can unsubscribe at any time.