
MT5 Market Closed Error (10018): Sessions, Breaks and Time Zones
The MT5 "market closed" error is return code 10018, TRADE_RETCODE_MARKET_CLOSED, which MetaQuotes describes simply as "Market is closed." The broker's server refused the request because the symbol was outside its trading session at that moment, so there is nothing wrong with the order itself, and the same request would usually succeed once the session opens again.
The difficulty is that "open" is defined by your broker, symbol by symbol and in the broker's own server time, which means an automated strategy firing on TradingView's chart can easily send orders into a gap it did not know existed. This guide shows how to read the sessions and keep your alerts inside them.
How to check a symbol's trading sessions in MT5#
Right-click the symbol in Market Watch and open Specification. The Sessions section lists, for each weekday, when the broker streams quotes and when it accepts trades, and since the two are not always the same, a symbol can show moving prices while still refusing orders.
The times are given in the broker's server time, which is the clock shown in Market Watch rather than your local time. Many brokers run their servers a few hours ahead of UTC and shift with daylight saving, so a session that opens at 01:00 server time can open at a different local hour in summer and in winter.
Why MT5 says the market is closed#
Weekends#
Forex, metals and index CFDs close from Friday evening to Sunday evening. A strategy running on a 24/7 TradingView feed, such as a crypto exchange's chart, keeps firing alerts through the weekend, and every one of them will fail on a broker symbol that is closed.
Daily breaks#
Many CFDs pause every day, often around the broker's daily rollover, and indices, metals and energies commonly have a break of up to an hour that follows the underlying futures market. An alert that lands in that window fails even though the market was open a few minutes earlier.
Holidays#
Exchange and bank holidays close or shorten the sessions of the instruments they affect. Brokers usually announce their holiday schedules by email or on their website a few days ahead, and those schedules can differ from the calendar of the TradingView chart you trade from.
Shares and ETFs#
Stock CFDs trade only during the exchange's regular hours, so pre-market and after-hours moves on the TradingView chart do not mean the broker will accept an order at that time.
The chart and the broker keep different hours#
TradingView alerts follow the data feed of the chart they were created on, and a futures feed, an exchange's spot feed or another broker's CFD can all keep different hours from your MT5 symbol. Where possible, build alerts on a feed whose session matches the instrument you actually trade.
Error 10018 and related return codes#
| Return code | Meaning | Typical cause |
|---|---|---|
| 10018 | Market is closed | The symbol is outside its trading session |
| 10021 | There are no quotes to process the request | The session just opened, the feed paused, or the symbol has no current price |
| 10044 | Only position closing is allowed | The symbol is set to close only |
| 10017 | Trade is disabled | Trading is switched off for the symbol or account |
From MetaQuotes' trade server return codes.
Closing positions while the market is closed#
A closed market refuses closing orders as well as new ones, so a close alert that arrives during a break or over the weekend fails and the position stays open until the session resumes, at which point it may open at a very different price. Stop losses and take profits are held by the broker and trigger once trading restarts, which is one more reason to give every automated position a stop rather than relying on a later close alert.
How to stop market closed errors#
The aim is to stop sending orders at times the broker cannot accept them, and you can combine several approaches:
- Restrict the strategy to the hours the symbol trades, either in the strategy's code or in the alert's conditions.
- Use a TradingView feed that keeps the same hours as your broker's symbol.
- Leave a margin around daily breaks and the weekly open, when spreads are also at their widest.
Avoid resending a failed entry automatically when the session opens, though. The price at the open can be far from the price the alert was based on, and the trade may no longer make sense.
How PineHook handles market hours for you#
PineHook lets you enforce trading hours on the receiving side, so a strategy that fires at the wrong time never reaches the broker in the first place. Active Hours sets UTC windows for new entries and blocks any entry outside them, while closes, cancels and trade management still run outside the window so you can always manage an open position. Each blocked entry is recorded on its Signal Logs row with the reason written out, so you can see that it was your own schedule that held the trade back rather than an error you need to chase.
When the broker does refuse an order because the market is closed, the row records it as a failed execution with the broker's description beside the code. PineHook deliberately does not hold the entry and fire it at the open, for the reasons above, and if you want an order to wait for a specific time, delay= schedules it on purpose. The trade errors reference covers the related messages, the Active Hours settings explain the window, and you can create a PineHook account without payment details to set it up on a demo account.
FAQ#
Why does Market Watch show prices when the MT5 market is closed?
Quote and trade sessions are listed separately in the symbol's specification, and some symbols stream quotes before trading opens or during a break in trading.
Can I place a pending order while the market is closed?
That depends on the broker and the symbol, and many brokers refuse new pending orders and modifications outside trading hours, so do not assume a pending order can be placed or adjusted during a break.
Related guides#
- MT5 EA not trading
- What happens to alerts when the MT5 EA disconnects
- Active Hours and other EA settings
- Trade errors
MetaTrader and TradingView are trademarks of their owners, and PineHook is an independent product that is not affiliated with, endorsed by, or sponsored by MetaQuotes or TradingView. Leveraged trading carries a high risk of loss, so test any automated setup on a demo account before you trade it live.
