Unable to get chart id of second chart in EA

 

Hi all,

I developing an EA and I am using multiple currencies in it and I want to show arrow object on each chart for which I need chart id. The problem I am facing is I am unable to get chart if of the chart other then first chart while back testing.

I am using following script to chartid of the specified symbol.

long getChartID(string symbol)
  {
   long prevChartID = ChartFirst();
   string chartSymbol="";
   do
     {
      string chartSymbol= ChartSymbol(prevChartID);

      if(chartSymbol == symbol)
         break;

      prevChartID = ChartNext(prevChartID);
     }
   while(prevChartID!=-1);

   return prevChartID;
  }

however the above script terminated after fetching first chart id. the while loop only executes once.

please help.

Documentation on MQL5: Constants, Enumerations and Structures / Objects Constants / Object Types
Documentation on MQL5: Constants, Enumerations and Structures / Objects Constants / Object Types
  • www.mql5.com
Object Types - Objects Constants - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
salirazataqvi:

Hi all,

I developing an EA and I am using multiple currencies in it and I want to show arrow object on each chart for which I need chart id. The problem I am facing is I am unable to get chart if of the chart other then first chart while back testing.

I am using following script to chartid of the specified symbol.

however the above script terminated after fetching first chart id. the while loop only executes once.

please help.

Not possible currently, it's a MT5 Strategy Tester limitation.
 
Alain Verleyen #: Not possible currently, it's a MT5 Strategy Tester limitation.

Hey. Any update to this? Still not possible to draw on multiple charts while backtesting?

 
salirazataqvi:

Hi all,

I developing an EA and I am using multiple currencies in it and I want to show arrow object on each chart for which I need chart id. The problem I am facing is I am unable to get chart if of the chart other then first chart while back testing.

I am using following script to chartid of the specified symbol.

however the above script terminated after fetching first chart id. the while loop only executes once.

please help.

long getChartId(string sym){
   
   long chartId=ChartFirst();
   
   while(chartId != -1){      
         Print("sym...",ChartSymbol(chartId)," ID =",chartId);
         if ( ChartSymbol(chartId)==sym) {       
         return chartId;
     }
      
      chartId=ChartNext(chartId);
   }
    return -1;
}