Download MetaTrader 5

Get Current Window Handle

To add comments, please log in or register
Steven Van Ingelgem
836
Steven Van Ingelgem  

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
6688
Carl Schreiber  

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
836
Steven Van Ingelgem  

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
31180
Alain Verleyen  
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