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).

 
Mansour Fahad M Almogaiteeb #:

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

As someone else has noticed in another post about this kind of situation, this solution isn't quite perfect because it won't work in indicators, not to mention it's a workaround, even if it works well in some scenarios.

 
Fernando Carreiro #:

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.

Hi Fernando,

Would you be willing to say more about this "Quote Session" and "Trade Session"? I have been searching for those terms and can't find any reference.
The issue is exactly those minutes that you describe at start of day, usually midnight. How would I be able to find out if code executing right after midnight is able to manage a position/trade, even if tick data is coming but trading is somehow disabled on the broker side? Is this broker-specific and I should simply ask my broker?
 
@Captain Of #: Would you be willing to say more about this "Quote Session" and "Trade Session"? I have been searching for those terms and can't find any reference.
The issue is exactly those minutes that you describe at start of day, usually midnight. How would I be able to find out if code executing right after midnight is able to manage a position/trade, even if tick data is coming but trading is somehow disabled on the broker side? Is this broker-specific and I should simply ask my broker?

SymbolInfoSessionQuote

Allows receiving time of beginning and end of the specified quoting sessions for a specified symbol and day of week.

SymbolInfoSessionTrade

Allows receiving time of beginning and end of the specified trading sessions for a specified symbol and day of week.

Example contract specifications ...