Download MetaTrader 5

DayOfWeek()

To add comments, please log in or register
Gordon Gekko
623
Gordon Gekko  

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
15910
whroeder1  
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  
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
15910
whroeder1  
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  
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
699
Edward Hirsch  
if (MarketInfo(Symbol(),MODE_TRADEALLOWED)==1) Print("Trade is allowed for symbol ", Symbol());
else                                           Print("Trade is not allowed for symbol ", Symbol());
whroeder1
15910
whroeder1  
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  
sxTed:

I've tried it already and didn't work.
Gordon Gekko
623
Gordon Gekko  
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
699
Edward Hirsch  
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  
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