Fce. IndicatorCounted() always return zero...

 

Hi,

I am using: https://www.mql5.com/en/code/7673 for create graph no-standard time frame on MT4. I created graph 2min, inserted my test easy code, see below. Why fce. IndicatorCounted() always return zero?!! When I insert the same indicator in graph with standard timeframe MT4 (1min, 5min,...) return no-zero value - that´s ok.

#property copyright "Copyright 2012, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#property indicator_chart_window
int cnt=0;
int init()
  {
   return(0);
  }
int deinit()
  {
   return(0);
  }
int start()
  {
   int    counted_bars=IndicatorCounted();
   cnt++;
   if(cnt==10) {Alert (Symbol()," ",Period(),"---", counted_bars); cnt=0; }
   return(0);
  }

 


 
endy5:

Hi,

I am using: https://www.mql5.com/en/code/7673 for create graph no-standard time frame on MT4. I created graph 2min, inserted my test easy code, see below. Why fce. IndicatorCounted() always return zero?!! When I insert the same indicator in graph with standard timeframe MT4 (1min, 5min,...) return no-zero value - that´s ok.

You aren't the first to report that IndicatorCouned() returns 0

https://www.mql5.com/en/forum/135405

This might help:  https://www.mql5.com/en/forum/138616 

 
Or don't use IndicatorCounted
datetime  historyAnalyzed;
int start(){
// int counted = IndicatorCounted();
// for(int iBar = Bars - 1 - counted; iBar >= 0; iBar--){ ..
   int iBar = iBarShift(NULL, 0, historyAnalyzed); historyAnalyzed = Time[0];
   for(; iBar >= 0; iBar--){ ..
 

Thank you for links. I have one question:

How can I detect programatically that is chart offline? Is it possible? Does it exist any predefined constant into MT / MQL?

 
Why do you care? You're going to have to adjust anyway
 
endy5:

Thank you for links. I have one question:

How can I detect programatically that is chart offline? Is it possible? Does it exist any predefined constant into MT / MQL?

I do it by changing the symbol name of my offline chart,  then all I need do is check for the change.  For example,  on-line chart "EURUSD",  offline chart "EURUSDx"  I look for the   x
 
Ok, thank you for help. I use solution WHRoeder - don't use IndicatorCounted in my code.
 

the most bad thing  for offline chart:

on last loop ,  if set a indicator buff:    buff[0]  = 1

after  one new bar added,  buff[0]  still = 1,   it can't became to  buff[1] = 1 

Reason: