Time[0] != Time[1] not working for me (I think)

 

Hi, this is a print out which shows the time over to the right (ignore that number 6).

I thought I told it to only print when the time if unequal to the previous time. (part of the code is below)

But as you can see the time is being printed the same time multiple times. Over to the left you can also see the time is the same on multiple prints.

What did I do wrong? And how can I fix it? (I'm assuming there are multiple ticks within a second and that's why it's happening, but I don't know how to count ticks either. I tried count++ but as you can see by the 6's, it keeps printing without adding up the count variable)

thanks

 if (Time[0]!= Time[1])
  {
  count++;
  Print(Time[0],"  ",count); 
  }
return(0)



print out

 
moneycode: I thought I told it to only print when the time if unequal to the previous time.

Time[1] is the start of the previous bar. Time[0] is the time of the current bar. The difference is usually 60 * Period(). They will never be equal. Neither will change until the next bar forms (1 minute on the M1, 1 day on the D1)

If you searched for once per bar you'd find many variations like

static datetime time0;
if (time0 != Time[0])
  {
  time0 = Time[0];
  count++;
  Print(Time[0],"  ",count); 
  }
return(0)
 
WHRoeder:

Time[1] is the start of the previous bar. Time[0] is the time of the current bar. The difference is usually 60 * Period(). They will never be equal. Neither will change until the next bar forms (1 minute on the M1, 1 day on the D1)

If you searched for once per bar you'd find many variations like


Oh okay, I was leaving the door wide open for a potentially whole minute, and then as soon as it would have closed the next bar started the time all over again. so the door was basically open all the time.

Thanks