Detecting the start of a new bar

 

Can someone please remind me how an EA can recognise the start of a new bar. Is it that

if (Volume[0] == 0) // means start of a new bar

 

Time[0] will have changed.


CB

 
BigAl:

Can someone please remind me how an EA can recognise the start of a new bar. Is it that

if (Volume[0] == 0) // means start of a new bar

// This function return the value true if the current bar/candle was just formed
bool NewBar()
{
if(PreviousBar<Time[0])
{
PreviousBar = Time[0];
return(true);
}
else
{
return(false);
}
return(false); // in case if - else statement is not executed
}




void start()
{

..........

if(NewBar() == true)

{

........

}

}

Reason: