Download MetaTrader 5
To add comments, please log in or register
Write articles, help other developers and make money
Steven Van Ingelgem
835
Steven Van Ingelgem 2014.11.27 04:44 

I know that the function "WindowHandle" exists. But what if I have multiple same Currency-Period charts? It will return one of these, but I would like to get the one were my EA is running from.

How could I achieve that?

 

Thanks! 

Carl Schreiber
5952
Carl Schreiber 2014.11.27 06:33  

I would suggest your EA writes (Comment() or test-lable) the no. of its chart (not ChartID) on the screen and sets a global-variable with a informative name and sets the value to the no. of its chart

(Not tested!)

int findChart(){
   long myChart = ChartID(),
        nxChart = ChartFirst();
   if (nxChart == myChart) return(1);
   int ret = 2;
   while(nxChart!=-1) {//beyond last chart
      nxChart = ChartNext(nxChart);
      if (myChart == nxChart) return(ret);
      ret++;
   }
   return(-1); // not found
}


Don't set the value to the Chart-ID! Its a long value which will be converted to a double and if you re-convert it back to a long value again this value will differ from the original ChartID!!

Steven Van Ingelgem
835
Steven Van Ingelgem 2014.11.27 08:25  

This will not work 100%, but it gave me the idea: Use CHART_WINDOW_HANDLE combined with looping of the charts!

Thanks! 

Alain Verleyen
Moderator
28606
Alain Verleyen 2014.11.27 08:29  
svaningelgem:

I know that the function "WindowHandle" exists. But what if I have multiple same Currency-Period charts? It will return one of these, but I would like to get the one were my EA is running from.

How could I achieve that?

 

Thanks! 

ChartGetInteger(0,CHART_WINDOW_HANDLE);
/
To add comments, please log in or register