Getting Symbol info in Services

 

Hi,

I am new to MQL5 and wanted to build a Service to monitor/send data of multiple charts to some other app/file. 

But as documentations states that we cannot use Symbol() function in Services, if tried following codes

chartID = ChartID();
Sym = ChartSymbol(chartID);

and 

Sym = ChartGetString(chartID,CHART_SCRIPT_NAME);

but ChartID() is returning me an ID which I am using to get info of Symbol, but it is returning me empty string. 


Please guide me how can I get Symbol info in Services.


Thanks.

 

Hi please try to see if this code works:

//--- 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
     }
What Script are you trying to read exactly ? 
 
Marco vd Heijden:

Hi please try to see if this code works:

It is working, thanks for the help.
Marco vd Heijden:
What Script are you trying to read exactly ? 

I am have opened 2 charts one for EPM21, and second for ENQM21.

What I am trying to do is write all L1 and L2 data to file for open charts. This is just for learning purpose and my first code in MQL and I was stuck in start of it.

 

Okay I'm glad you got it to work.

There are many examples in the documentation.

 
bhattikashif:
It is working, thanks for the help.

I am have opened 2 charts one for EPM21, and second for ENQM21.

What I am trying to do is write all L1 and L2 data to file for open charts. This is just for learning purpose and my first code in MQL and I was stuck in start of it.

Have you succeeded in achieving this? If so, please add comments so that others can benefit from it. I am also trying to do the similar thing.