Download MetaTrader 5
To add comments, please log in or register
Have you developed a profitable strategy? Share it with millions of traders via Signals!
Fa Cao
1140
Fa Cao 2013.11.26 05:59 

According to my understanding, "IndicatorCounted()" will return "-1" when it was loaded at the first time and will return the mount of "effective bars" from the second loaded or executed.

But when I run below codes, I see that the parameter, "counted_bars", always is -1 and constant repeatly.

I don't know why and how shall get the effective bars by "IndicatorCounted() "?

 int start()
  {
   int counted_bars=IndicatorCounted();
   Print("counted_bars:",counted_bars);
   return(0);
  }
Ubzen
5394
Ubzen 2013.11.26 06:30  

You're running it like an expert_advisor. Identify it as indicator, place it within the correct folders, do-some reading about indicators instead of trial and error.

example:


#property indicator_separate_window
#property indicator_buffers 1

void start(){
    int counted_bars=IndicatorCounted();
    Comment("counted_bars=",counted_bars);
}
Fa Cao
1140
Fa Cao 2013.11.26 12:29  
ubzen:

You're running it like an expert_advisor. Identify it as indicator, place it within the correct folders, do-some reading about indicators instead of trial and error.

example:


yes, it is.

thanks,

whroeder1
14236
whroeder1 2013.11.26 13:27  

vx0532: According to my understanding, "IndicatorCounted()" will return "-1" when it was loaded at the first time a

But when I run below codes, I see that the parameter, "counted_bars", always is -1 and constant repeatly.

  1. False IndicatorCounted() function returns the count of bars minus one. If IndicatorCounted is "always is -1" something is wrong like using indicator functions in a EA or script.
  2. No decrement Contradictory information on IndicatorCounted() - MQL4 forum
  3. //b4plusdi=iADX(NULL,0,ADXbars,PRICE_CLOSE,MODE_PLUSDI,shift+1);
      int lookback =       ADXbars                              +1;
    
    int shift,counted_bars=IndicatorCounted();
    if(counted_bars < lookback) counted_bars = lookback;
    for (shift = Bars - 1 - CountBars; shift>=0; shift--)
/
To add comments, please log in or register