I'm using other method to determine a new bar. I want to know at the open price, at the first second of a new bar that this is a new bar and I'm doing it in this way:
1) define variable newBars before init() function
2) check if the Bars variable (with is included in mql4 language) is bigger than my newBar
3) if it is bigger then it means that this is a new bar so I throw an alert and fill newBar with Bars variable.
The Bars variable as we know is the number of Bars in current chart, if we save the value of the previous tick of the number of the bars (in the newBar variable) and compare it with actual value of Bars we can get to know that the new bar was shown on the screen.
I'm attaching an mq4 script example :)
Kalenzo