Download MetaTrader 5

DayOfWeek()

To add comments, please log in or register
Have you found a good programmer? Make a targeted order!
Gordon Gekko
623
Gordon Gekko 2015.05.24 14:08 

Hi guys,

Today is sunday. I run this code

Comment(DayOfWeek());


and got 5 (it means friday). I guess it came from the last known server time.

So, the server time has stopped on friday.

My question is, how can I check whether today is saturday (6) or sunday (0)?

Or:

How can I check whether the market is open or closed?

(Solution with pending/deleted order is not good for me.)

Thx

whroeder1
14480
whroeder1 2015.05.25 15:54  
ggekko: and got 5 (it means friday). I guess it came from the last known server time.

So, the server time has stopped on friday.

My question is, how can I check whether today is saturday (6) or sunday (0)?

The market is closed Sat/Sun untill 6pm ET. You will get no ticks, there is nothing to check for. The market is open when you get a tick and DOW will return Sunday (if broker uses UTC server time,) or Monday if it uses ET+6 (GMT+2/3) No short day.
Gordon Gekko
623
Gordon Gekko 2015.05.25 16:47  
WHRoeder:
The market is closed Sat/Sun untill 6pm ET. You will get no ticks, there is nothing to check for. The market is open when you get a tick and DOW will return Sunday (if broker uses UTC server time,) or Monday if it uses ET+6 (GMT+2/3) No short day.

Thank you.

I need to check the status of the market, because my EA works based on timer, not tick.

whroeder1
14480
whroeder1 2015.05.25 16:55  
ggekko: because my EA works based on timer, not tick.
Don't do that, wait for a tick. No tick means nothing has changed.
Gordon Gekko
623
Gordon Gekko 2015.05.25 18:12  
WHRoeder:
Don't do that, wait for a tick. No tick means nothing has changed.
It is a multicurrency EA (20+ pairs), so I need to refresh it frequently. :)
Edward Hirsch
714
Edward Hirsch 2015.05.26 08:24  
if (MarketInfo(Symbol(),MODE_TRADEALLOWED)==1) Print("Trade is allowed for symbol ", Symbol());
else                                           Print("Trade is not allowed for symbol ", Symbol());
whroeder1
14480
whroeder1 2015.05.26 14:09  
ggekko: It is a multicurrency EA (20+ pairs), so I need to refresh it frequently. :)
  1. Do not trade multiple currencies, you can't use any predefined variables, can't use the tester, must poll, and usually other problems.
  2. Code it to trade the chart pair only. Look at the other's if you must.
  3. Then put it on other charts to trade the other pairs. Done.
Gordon Gekko
623
Gordon Gekko 2015.05.26 14:32  
sxTed:

I've tried it already and didn't work.
Gordon Gekko
623
Gordon Gekko 2015.05.26 14:37  
WHRoeder:
  1. Do not trade multiple currencies, you can't use any predefined variables, can't use the tester, must poll, and usually other problems.
  2. Code it to trade the chart pair only. Look at the other's if you must.
  3. Then put it on other charts to trade the other pairs. Done.

This EA works perfectly in this method. One can use Timeseries and Indicators Access instead of predefined variables. You are right about tester.

My only need is the knowing of status of the market (open or closed).

I had an idea, but that is wrong too: comparing the change of TimeCurrent() and TimeLocal(). It works fine until there is no pause in the data feed. Unfortunately, there are some pause sometimes.

Edward Hirsch
714
Edward Hirsch 2015.05.26 16:28  
if (MarketInfo(Symbol(),MODE_TRADEALLOWED)==1) Print("Trade is allowed for symbol ", Symbol());
else                                           Print("Trade is not allowed for symbol ", Symbol());
answers your "My only need is the knowing of status of the market (open or closed)".
Gordon Gekko
623
Gordon Gekko 2015.05.26 17:20  
sxTed:
answers your "My only need is the knowing of status of the market (open or closed)".
I answered: "I've tried it already and didn't work."
12
To add comments, please log in or register