Hour() Minute()

 

What is wrong with this IF statement. It doesn't seem to work properly.


if ( (Hour()== 7) && (Minute() >= 58) )

{


}

 
Nothing wrong. It's working from 7:58 to 8:00 only.
 
Roger:
Nothing wrong. It's working from 7:58 to 8:00 only.

I have this code in an EA on a 1 Hour chart. It appears that the one hour chart does not recognize the minute() function. Is this a correct assumption??

When I remove minute() the IF statement is executed. The IF statement does not execute with the minute() function.

 
SquareRoot wrote >>

I have this code in an EA on a 1 Hour chart. It appears that the one hour chart does not recognize the minute() function. Is this a correct assumption??

When I remove minute() the IF statement is executed. The IF statement does not execute with the minute() function.

No, not correct. Doesn't matter what charts you put your EA. Something's wrong in your code.

 

if ( (Hour()== 7) && (Minute() >= 58) )

Should be


if (Hour()== 7 && Minute() >= 58)


It will trade from 07:58:00 to 07:59:59


Does not matter what time frame you are on

 
gazza101:

if ( (Hour()== 7) && (Minute() >= 58) )

Should be


if (Hour()== 7 && Minute() >= 58)


It will trade from 07:58:00 to 07:59:59


Does not matter what time frame you are on



gazza101, that change to the parentheses is not necessary and won't actually make a difference in this case.

 

I do a similar thing using TimeMinute(TimeCurrent());

So try;

datetime CTime=CurrentTime();

if(TimeHour(CTime)==7 && TimeMinute(CTime)>=58)

{

}

Keep in mind, if this is running in Start() and there is NO TICK during this time window, nothing will happen since there is no tick to kick it off.... this is where you'd want (possibly) a Script running an endless (While) loop with a Sleep() command that is waiting for your IF logic of 7:58-7:59 to occur...

 
7979:

I do a similar thing using TimeMinute(TimeCurrent());

So try;

datetime CTime=CurrentTime();

if(TimeHour(CTime)==7 && TimeMinute(CTime)>=58)

{

}

Keep in mind, if this is running in Start() and there is NO TICK during this time window, nothing will happen since there is no tick to kick it off.... this is where you'd want (possibly) a Script running an endless (While) loop with a Sleep() command that is waiting for your IF logic of 7:58-7:59 to occur...

Exactly, which leads me to ask of the original poster - we never really did hear any details of the implementation and the symptoms of the problem. Can you fill us in?

 
cloudbreaker:

Exactly, which leads me to ask of the original poster - we never really did hear any details of the implementation and the symptoms of the problem. Can you fill us in?

Parenthetically speaking,

the number of parenthesis does not matter.

 
hkjonus:

Parenthetically speaking,

the number of parenthesis does not matter.

Yes, we established that earlier in the thread. What message are you trying to get across? Am I missing something?

Reason: