Does "Volume[0]>1" means this is not a new bar?

 

Hi,


I see from an EA followings:

...
//--- go trading only for first tiks of new bar
   if(Volume[0]>1) return;
...

It seems only when the Volume[0] = 1. it is a new bar, right?

 
thomas2004:

Hi,


I see from an EA followings:

It seems only when the Volume[0] = 1. it is a new bar, right?

That's a very old way to do it.

You'd better check the time:

   static datetime tmeBar0;
   bool newBar = false;
   ...
   if ( tmeBar0 != Time[0] ) {
      tmeBar0 = Time[0];
      newBar = true;
   }
(not tested)
 
For a new bar test, Bars is unreliable (a refresh/reconnect can change number of bars on chart,) volume is unreliable (miss ticks,) Price is unreliable (duplicate prices and The == operand. - MQL4 forum.) Always use time. New candle - MQL4 forum
I disagree with making a new bar function, because it can only be called once per tick. A variable can be tested multiple times.