Market Open or Close - how can I find it? - page 3

 
Daniel #: I shouldn't receive tickets in a closed market, I think just like you. That's why I would like to know why I get "market closed" if I am within the onTick function. I can't find the answer, do you know it? I am doing tests in MT5.

There is a difference between the "Quote Session" and the "Trade Session". One may be within a valid quote session (there is tick data for quotes) but be outside of a valid trade session, not being able to place or manage trades.

EDIT: A good example is the last few minutes of the end of the day, or the first few minutes at the start of the day, where there is still quote data, but trading is temporarily disabled because of the rollover swaps calculations.

 

just an idea for this issue:

we can send a stop order( or limit order) to the chart that we want to know whether is open or not. if ordersend(...) command return true, the chart is working and it's market is open and vise versa. after that, the taken stop order( or limit order) should be deleted.

 
Asadollah Ramezani #:

just an idea for this issue:

we can send a stop order( or limit order) to the chart that we want to know whether is open or not. if ordersend(...) command return true, the chart is working and it's market is open and vise versa. after that, the taken stop order( or limit order) should be deleted.

Perfect solution! Just tried it on the weekend it will fail and return 132 error code (ERR_MARKET_CLOSED).

Reason: