how i can get the chart id of all the opened chart

 
i'm building ad indicator in mql for mt4

in my mql indicator, i need to get the chart id of all the chart that i opened manually on my mt4
how i can get these id?
 

Use ChartFirst() and ChartNext()  functions to enumerate active charts. 

This is sample code from the documentation for the ChartNext():

//--- variables for chart ID
   long currChart,prevChart=ChartFirst();
   int i=0,limit=100;
   Print("ChartFirst =",ChartSymbol(prevChart)," ID =",prevChart);
   while(i<limit)// We have certainly not more than 100 open charts
     {
      currChart=ChartNext(prevChart); // Get the new chart ID by using the previous chart ID
      if(currChart<0) break;          // Have reached the end of the chart list
      Print(i,ChartSymbol(currChart)," ID =",currChart);
      prevChart=currChart;// let's save the current chart ID for the ChartNext()
      i++;// Do not forget to increase the counter
     }
 

Or more simply:

long chartID=ChartFirst();
while(chartID >= 0)
  {
   Print(chartID);
   chartID = ChartNext(chartID);
  }
 
it's work!, thx to all!
 
Thx also to all!!
Reason: