Who can help me convert this code from mql5 to mql5?

 

Hi there,

I'm a newbie and I want to create a new indicator mql5, but I want to use  IndicatorCounted() function like this mql4 code:

   int limit;

   int counted_bars = IndicatorCounted();

   if (counted_bars < 0) return (-1);

   if (counted_bars > 0) counted_bars--;

   limit= Bars - counted_bars;

   for (int i = 0; i <= limit; i++) {

      //// ....

   }


But I got a error : "'IndicatorCounted' - undeclared identifier". I don't know which function instead this in mql5?

Please help me! Many thanks!



 
SilSama:

Hi there,

I'm a newbie and I want to create a new indicator mql5, but I want to use  IndicatorCounted() function like this mql4 code:


But I got a error : "'IndicatorCounted' - undeclared identifier". I don't know which function instead this in mql5?

Please help me! Many thanks!



Hello, 
So as far as I know the closest thing to IndicatorCalculated on mql5 is BarsCalculated() 
So I think try counter_bars=Bars(_symbol) -BarsCalculated(*indicator handle here*).
This will only work if you are working with a buffer (which you most likely are) but if you're not using a buffer, then you could try using Bars-1 ,which would simply iterate through all the bars on the chart.
 
busta bruno #:
Hello, 
So as far as I know the closest thing to IndicatorCalculated on mql5 is BarsCalculated() 
So I think try counter_bars=Bars(_symbol) -BarsCalculated(*indicator handle here*).
This will only work if you are working with a buffer (which you most likely are) but if you're not using a buffer, then you could try using Bars-1 ,which would simply iterate through all the bars on the chart.
Thank you so much! 
Reason: