Popup window with already opened chart

 

Hi folks, 


Is there any function to maximize or "bring to front" or "pop up" a chart window inside of MT5? 

I don't want to open a new chart (ChartOpen function), I just want to show a specific chart in case it already opened at my MT5.

 
Guilherme Mendonca: Is there any function to maximize or "bring to front" or "pop up" a chart window inside of MT5? I don't want to open a new chart (ChartOpen function), I just want to show a specific chart in case it already opened at my MT5.

That is a good question that I have never thought of before!

As far as I can remember, there does not seem to be any MQL function for that, but I may be wrong. If that is the case, you may need to use Win32 API functions to identify the window and bring focus to it. It has been a long time since I manipulated MetaTrader via Win32 API so I no longer remember how to do that but you can probably use the WindowHandle function to get the handle for the chart in question and then the Windows API to give it focus. Try doing a search with that in mind and may just find a few clues on how to handle the windows via the Windows API.

There may be a simpler solution, so just wait a while to see if anyone else has a better idea.

Documentation on MQL5: Standard Library / Price Charts / WindowHandle
Documentation on MQL5: Standard Library / Price Charts / WindowHandle
  • www.mql5.com
WindowHandle - Price Charts - Standard Library - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Guilherme Mendonca:

Hi folks, 


Is there any function to maximize or "bring to front" or "pop up" a chart window inside of MT5? 

I don't want to open a new chart (ChartOpen function), I just want to show a specific chart in case it already opened at my MT5.

Are you talking about

  • CHART_BRING_TO_TOP shows the chart on top of all others.

//+----------------------------------------------------------------------+
//| Sends command to the terminal to display the chart above all others  |
//+----------------------------------------------------------------------+
bool ChartBringToTop(const long chart_ID=0)
  {
//--- reset the error value
   ResetLastError();
//--- show the chart on top of all others
   if(!ChartSetInteger(chart_ID,CHART_BRING_TO_TOP,0,true))
     {
      //--- display the error message in Experts journal
      Print(__FUNCTION__+", Error Code = ",GetLastError());
      return(false);
     }
//--- successful execution
   return(true);
  }

 Of course you will need additional code to identify the  relevant chart ID, but that's not difficult.

 
Keith Watford:

Are you talking about

 Of course you will need additional code to identify the  relevant chart ID, but that's not difficult.

 Thank you very much! 
 
Keith Watford: Are you talking about "CHART_BRING_TO_TOP". Of course you will need additional code to identify the  relevant chart ID, but that's not difficult.
I did not know about that one. Thanks Keith! That is good to know for future reference!
 
Fernando Carreiro:
I did not know about that one. Thanks Keith! That is good to know for future reference!

Thanks for your answer Fernando.

 

Fernando Carreiro:

 If that is the case, you may need to use Win32 API functions to identify the window and bring focus to it. It has been a long time since I manipulated MetaTrader via Win32 API so I no longer remember how to do that but you can probably use the WindowHandle function to get the handle for the chart in question and then the Windows API to give it focus. Try doing a search with that in mind and may just find a few clues on how to handle the windows via the Windows API.

I vaguely remember having some problems with bringing a minimised chart to the top.

Something like this, but I am not sure now.

#include <WinUser32.mqh>
#define SW_SHOWMAXIMIZED 3
                     int hWnd = WindowHandle(Symbol(), Period());
                     int parent = GetParent(hWnd);
                     ShowWindow(parent, SW_SHOWMAXIMIZED);
 
Keith Watford: I vaguely remember having some problems with bringing a minimised chart to the top. Something like this, but I am not sure now.
I have been staying away from using DLL calls in MQL for so long now that I no longer remember how. Thanks Keith, for reminding me of the "good old days"! ;)
 
Keith Watford:

I vaguely remember having some problems with bringing a minimised chart to the top.

Something like this, but I am not sure now.

Except there is no WindowHandle on mql5.

Need to use :

ChartGetInteger(0,CHART_WINDOW_HANDLE)
And I doubt the rest of the code will work on MT5, but I didn't try.
 
Alain Verleyen: Except there is no WindowHandle on mql5. Need to use :And I doubt the rest of the code will work on MT5, but I didn't try.
According to the current MQL5 documentation, WindowHandle is still a valid MQL5 function - Documentation on MQL5: Standard Library / Price Charts / WindowHandle
Documentation on MQL5: Standard Library / Price Charts / WindowHandle
Documentation on MQL5: Standard Library / Price Charts / WindowHandle
  • www.mql5.com
WindowHandle - Price Charts - Standard Library - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Fernando Carreiro:
According to the current MQL5 documentation, WindowHandle is still a valid MQL5 function - Documentation on MQL5: Standard Library / Price Charts / WindowHandle
It's a method of a CChart object, not an mql function.
Reason: