ChartSymbol() returns incorrect information

 

Hi everyone,

I created an expert advisor that loops among all open charts using MQL5's ChartFirst() and ChartNext() functions. The code is organized as follows:

GraphId=ChartFirst();
while (GraphId > 0) {
GraphSymbol=ChartSymbol(GraphId);
// (process graph)
GraphId=ChartNext(GraphId);
}

However, for unknown reasons, sometimes the ChartSymbol function returns an empty string, causing the subsequent processing of the graph to be skipped (the rest of the code, not shown for brevity, scans objects in the graphs of forex symbols).

Once the problems occurs, generally it persists for a while, i.e., the next graph, fetched via ChartNext(), has the same problem, and so on, until the end of the loop. The next loop, at the end of the next candle, is generally fine. The times this problem occurs seem to be quite random, that is, they do not generally coincide with the opening or closing of the different exchanges).

Did anyone experience this problem before? What can be the cause and how can I fix it?

Thanks
Stefano