How to find out if the market is closed? (mql4) - page 4

 

And we do this:

MqlTick Tick;
bool IsNewTick(string symbol)
  {
   MqlTick t;
   SymbolInfoTick(symbol,t);
   if(t.time>Tick.time)
     {
      SymbolInfoTick(symbol,Tick);
      return(true);
     }
   return(false);
  }

The function outputs whether there is a new tick on the instrument.

Great for OnTime. Only for eachsymbol, there must beadifferentTick

 
Vasyl Nosal:

Wow, that's a lot of text.

MarketInfo(Symbol(),MODE_TRADEALLOWED)

In this way, you will only get the permission status of the instrument to trade. If the instrument is traded, you will get true for it any day of the week.
 
Ihor Herasko:
This will only give you the trading authorisation status of the instrument. If the instrument is tradable, you will get true on it any day of the week.
Not true.
 
Before sending an order, carry out a check, http://docs.mql4.com/check/istradeallowed
 
Ramiz Mavludov:
Before sending an order, perform a check, http://docs.mql4.com/check/istradeallowed
And this refers to the auto-trade button.
 
Vasyl Nosal:
And this refers to the auto-trade button.
I don't get it. Without auto-trading on, your EA shouldn't do anything at all.
 
Ramiz Mavludov:
I don't get it. Without auto-trading on, your EA shouldn't do anything at all.
No. It can and, in fact, more often than not, it should do nothing. When the AutoTrade button is disabled, it cannot work with the trading functions only. The rest of the calculations are fine.
 
Ramiz Mavludov:
I don't get it. If you don't enable auto-trading, your EA should not do anything at all.
What is written on the link has no relevance at all to the issue of closing the market.
 
Vasyl Nosal:
Not true.

Perhaps it should be checked again. The last time I worked on this question was before the update of MQL4. At that time such a way indicated the possibility to trade on the symbol in general, not at a specific time. Besides, the help is now formulated in such a way that it does not give a clear answer. Let's wait until the weekend and check. Or may be someone has some American stocks in the list of symbols for which the market is now closed. Then we can check it now.

As for IsTradeAllowed indicated by Ramiz Mavludov, it is indeed correct. This function allows you to check the situation of a closed market. And you can know about it now in advance, instead of waiting for the weekend:

   datetime curDay = D'2015.12.14 05:00';
   Print("Trade allowed for 2015.12.14 05:00: ", IsTradeAllowed(_Symbol, curDay));
   
   datetime sunday = D'2015.12.20 03:00';
   Print("Trade allowed for Sunday: ", IsTradeAllowed(_Symbol, sunday));

Result:

2015.12.16 13:37:23.662 TestData EURUSD,Daily: Trade allowed for Sunday: false
2015.12.16 13:37:23.662 TestData EURUSD,Daily: Trade allowed for 2015.12.14 05:00: true
 
Ihor Herasko:

Perhaps it should be checked again. The last time I worked on this issue was before the update of MQL4. At that time such a way indicated the possibility to trade on the symbol in general, not at a specific time. Besides, the help is now formulated in such a way that it does not give a clear answer. Let's wait until the weekend and check. Or may be someone has some American stocks in the list of symbols for which the market is now closed. Then we can check it now.

As for IsTradeAllowed indicated by Ramiz Mavludov, it is indeed correct. This function allows you to check the situation of a closed market. And you can know about it now in advance, instead of waiting for the weekend:

Result:

Yes, it is.

I thought he meantboolIsTradeAllowed();.