Boolean combination. - page 2

 
Erik1:

. . .

This one pops up just fine. So i though it might be gotta do with the NewBar() one.

I had been staring at this one for so long and yet no clue.

First, you probably shouldn't use iBarShift() in the way you have. iBarShift(NULL,0,0) returns the shift to the last bar on the chart because you are giving it a date of 0. You aren't interested in the last bar; instead, you want to know if the current bar is actually a new bar. Second, the better way to determine whether a bar is a new bar is to test the bar's time with the last recorded bar time. If the bar's time is equal to the last recorded bar time, then it is not a new bar. See some explanation here and here. Based on those explanations, here is some example code.

Example of a variable in start():

int start() {
   static datetime time0;
   bool newBar = time0 != Time[0]; time0 = Time[0];
        
   if (newBar)
      Print ("New Bar Found!");
        
   return (0);
}
 
NewBar() has a side-effect. The first time you call it it is true, the second time it is false. Do instead...
bool a = NewBar(); 
if(a){            //boolean a
Alert("a ");
}
if(r){                   //boolean b
Alert("b");
}
if(Rcount>=29){          //boolean c
Alert("c");
}
if(a && r && Rcount>=29){
Alert("a b c");
}

 

i think the new bar is already changing when you call it the first time int count HAS CHANGE ITS VALUE

then when you call it twice it not detect a new bar

Reason: