Why IndicatorCounted() come back to 0?

 

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?

 

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 ?
 
SDC:
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 ?
It very well could be the culprit. I remember reading something like that too. I believe there's at least 5-different things which could make the IndicatorCounted() reset to zero. If someone want to write reliable indicators in mt4, they really have to do their research and play around with indicators in-order to avoid stuff like this.....Imo.
 

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)


Files:
Reason: