New candle by Volume!

 

Dear experts.

I'm a newcomer and I was thinking about that Is it possible to find Birth of a new candle By real volume When is it equal to zero?

But seems some thing is wrong !

Can you please help me to find out why it won't work?

thanks.


void OnTick()
  {
MqlRates symbolRates[] ;
      ArraySetAsSeries(symbolRates,true)                  ;
      CopyRates(_Symbol,_Period,0,5,symbolRates)    ;
      long volume_Re = symbolRates[0].real_volume   ;
 //
   if(volume_Re==0)
   {
   Print("new candle")  ;
   }

  }

Files:
NEW_bar.mq5  2 kb
 
sitehaye ozv: I'm a newcomer and I was thinking about that Is it possible to find Birth of a new candle By real volume When is it equal to zero?

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 programming forum.) Always use time.
          New candle - MQL4 programming forum #3 2014.04.04

I disagree with making a new bar function, because it can only be called once per tick. A variable can be tested multiple times.
          Running EA once at the start of each bar - MQL4 programming forum 2011.05.06

Reason: