I cannot duplicate the error you're getting. The code you provided above is likely not the same code you're running as the above code does-not have #property indicator. There are also some actions when using mt4 which would reset indicatorCounted to zero. Example here.
Rosh:"If history changes IndicatorCounted() returns 0 (zero). For example, you attached an indicator to a chart and pressed key "Home" several times."
To find more instances of what could cause it to zero, i recommend searching the forum with key-word IndicatorCounted().
I remember reading a forum post about an issue with IndicatorCounted() returning zero at intervals when the chart history is maxed out maybe there is some connection with this ?
I created an indicator whose only function is to display what IndicatorCounted() returns. I think it interesting that Bars is updated one tick before IndicatorCounted(), meaning it returns Bars - 2 one time each time a new Bar is created.
Version 4.00, Build 451 (21 Dec 2012)

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Testing code like this:
int start()
{
//----
Print("IndicatorCounted=", IndicatorCounted());
//----
return(0);
}
Sometimes, the printed message is:
15:42:50 DayIndic EURUSD,Daily: loaded successfully
15:42:50 DayIndic EURUSD,Daily: initialized
15:42:50 DayIndic EURUSD,Daily: IndicatorCounted=0
15:42:54 DayIndic EURUSD,Daily: IndicatorCounted=3256
15:42:58 DayIndic EURUSD,Daily: IndicatorCounted=3256
15:42:58 DayIndic EURUSD,Daily: IndicatorCounted=3256
15:42:58 DayIndic EURUSD,Daily: IndicatorCounted=3256
15:42:59 DayIndic EURUSD,Daily: IndicatorCounted=0
15:42:59 DayIndic EURUSD,Daily: IndicatorCounted=3256
...
See, 0 appears twice. 0 never appears three times.
But sometimes, 0 only appears once, which is thought to be the normal result.
How does this happen?