EA operating Time

 

Hi all,

I have a function that checks the time of day in my EA.  It looks like this:

void CheckTime()
{

   static int reset;   

   if(Hour()==NewDay && reset==1)
   {
      TradeTime=True;
      reset=0;   
   }

   if(Hour()==CloseDay && reset==0)
   {
      TradeTime=False;
      reset=1;
   }
}

NewDay/CloseDay are external int variables, 0 and 2 respectively.

TradeTime is an external bool variable that allows trading to occur / not occur.

It functions correctly on every day of the week...except for Mondays. 

Would anyone be able to explain why this is? 

And anything I can do to overcome this and allow trading 5 days a week.

Any advice would be greatly appreciated!

 

Well you can also use

TimeDayOfWeek();
 
Marco vd Heijden:

Well you can also use

Thanks I'll have a pop at it
 
RainyDay: It functions correctly on every day of the week...except for Mondays. Would anyone be able to explain why this is?
static int reset;
It shouldn't work at all because reset has a random value initially. Simplify your code:
bool isTradingTime = NewDay <= Hour() && Hour() < CloseDay;
 
whroeder1:
It shouldn't work at all because reset has a random value initially. Simplify your code:
As always...thank you!
Reason: