Programmatically open multiple charts

 

There is this code to programmatically a chart

https://forum.mql4.com/24948#194891

But a call like this:

 ChartWindow("EURUSD");
 ChartWindow("GBPJPY");
 ChartWindow("AUDUSD");

only works for the first symbol, the second and third window don't open,

why is this so ?

I modified the code to take variable window handles still doesn't work:

int hWndcount = 0;
int ChartWindow(string SymbolName)
{
   int hFile, SymbolsTotal, hTerminal;
   int hWnd[30];

   hFile = FileOpenHistory("symbols.sel", FILE_BIN|FILE_READ);
   if(hFile < 0) return(-1);

   SymbolsTotal = (FileSize(hFile) - 4) / 128;
   FileSeek(hFile, 4, SEEK_SET);

   hTerminal = GetAncestor(WindowHandle(Symbol(), Period()), 2);

   hWnd[hWndcount] = GetDlgItem(hTerminal, 0xE81C);
   hWnd[hWndcount] = GetDlgItem(hWnd[hWndcount], 0x50);
   hWnd[hWndcount] = GetDlgItem(hWnd[hWndcount], 0x8A71);

   PostMessageA(hWnd[hWndcount], WM_KEYDOWN, VK_HOME, 0);

   for(int i = 0; i < SymbolsTotal; i++)
   {
      if(FileReadString(hFile, 12) == SymbolName)
      {
         PostMessageA(hTerminal, WM_COMMAND, 33160, 0);
         return(0);
      }
      PostMessageA(hWnd[hWndcount], WM_KEYDOWN, VK_DOWN, 0);
      FileSeek(hFile, 116, SEEK_CUR);
   }
   hWndcount++;
   FileClose(hFile);

   return(-1);
}
 
You don't need all this hack any more, use ChartOpen()
 
Awesome, thank you.
 
angevoyageur: You don't need all this hack any more, use ChartOpen()
Alphabetic Index of MQL4 Functions (600+) - MQL4 forum
Reason: