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

Back to topics list To post a new topic, please log in or register
andream1977 2016.07.25 12:28
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?
drazen64 2016.07.25 12:36 #

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




honest_knave 2016.07.25 18:32 #

Or more simply:

long chartID=ChartFirst();
while(chartID >= 0)
   chartID = ChartNext(chartID);
andream1977 2016.07.26 07:15 #

it's work!, thx to all!
Back to topics list  

To add comments, please log in or register