Download MetaTrader 5
To add comments, please log in or register
Do you have questions on how to turn your idea into reality? Ask them on the Forum!
Hknight
175
Hknight 2012.11.13 13:11 
Is there a way to automatically close and open all charts using MQL4?
whroeder1
13644
whroeder1 2012.11.13 14:46  
Search for Post Message
Hknight
175
Hknight 2012.11.13 14:58  
Sorry, that does not help.  I cannot find anything searching for "Post Message" that would tell me how to open or close charts.
phi nuts
2185
phi nuts 2012.11.13 16:00  
hknight:
Sorry, that does not help.  I cannot find anything searching for "Post Message" that would tell me how to open or close charts.

This is what WHRoeder meant https://www.mql5.com/en/forum/124688, specifically message 

#define MT4_WMCMD_57602           57602 /* close the current chart */

But I couldn't find to open a chart :(

tao zemin.
402
tao zemin. 2014.02.20 00:12  
hknight:
Is there a way to automatically close and open all charts using MQL4?

I have the same problem, too. I try to use ChartClose()/ChartNext(), etc. to do so, but there are some problem .... What's wrong with it?

void CloseAllCharts()
{
  long curChart,prevChart=ChartFirst();
  int i=0,limit=100;//limit is the maximum numbrt that might open in the terminal.
  //Print("ChartFirst =",ChartSymbol(prevChart),"ChartPeriod=",ChartPeriod(prevChart)," ID =",prevChart);
  while(i<limit){
    curChart=ChartNext(prevChart); // Get the new chart ID by using the previous chart ID
    if(curChart==-1)break;
    //Print("ChartCurrent =",ChartSymbol(curChart),"ChartPeriod=",ChartPeriod(curChart)," ID =",curChart);
    bool ret=ChartClose(prevChart);
    if(!ret){
      Alert("chart close failed, #",GetLastError());
      Print(i,ChartSymbol(curChart)," ID =",curChart);
    }
    else prevChart=curChart;// let's save the current chart ID for the ChartNext()
    i++;// Do not forget to increase the counter
  }
}
Alain Verleyen
Moderator
28672
Alain Verleyen 2014.02.20 18:02  
tzm:

I have the same problem, too. I try to use ChartClose()/ChartNext(), etc. to do so, but there are some problem .... What's wrong with it?



It seems to work, what's your problem ?
/
To add comments, please log in or register