Array out of range. Please help. Please help.

 

How to solve the problem "Array out of range"?

Below is the error happening during running stage.

Please help. I'm not a programmer. 

------------------------------------------------------ 

datetime time;

bool IsNewBar()

{

   bool retVAR = false;

   if(time != Time[0])

   {

      time = Time[0];

      retVAR = true;

   }

   return (retVAR;

------------------------------------------------------  

 
There can be perfectly a situation when you have no bars in history, so Time[0] is out of bounds. You should check available bar number via Bars.
 

So what can i do in order to overcome this error?

Can show me the way? =( 

 
Jason:

So what can i do in order to overcome this error?

Can show me the way? =( 

You just got the answer, please do some efforts to understand it or pay someone to code it for you.
 
Siew Fei Wong:

So what can i do in order to overcome this error?

Can show me the way? =( 

To check if you have any bars on chart use this snippet:

datetime time;

bool IsNewBar()
{

   bool retVAR = false;
   if(Bars>0)
   {
      if(time != Time[0])
      {
         time = Time[0];
         retVAR = true;
      }
   }
   return (retVAR);

} 
Reason: