DayOfWeek()

 

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

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

 
ggekko: because my EA works based on timer, not tick.
Don't do that, wait for a tick. No tick means nothing has changed.
 
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. :)
 
if (MarketInfo(Symbol(),MODE_TRADEALLOWED)==1) Print("Trade is allowed for symbol ", Symbol());
else                                           Print("Trade is not allowed for symbol ", Symbol());
 
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.
 
sxTed:

I've tried it already and didn't work.
 
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.

 
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)".
 
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."
Reason: