How to obtain the HWND of the chart window in strategy tester?

 

Hi there,

anyone an idea? For whatever reason, the corresponding - ChartGetInteger(m_chart_id,CHART_WINDOW_HANDLE) - returns zero.

 
I'm afraid you can't do it directly (without a DLL). The tester is a separate process in MT5, it does not support many API features available in the terminal.
 

I know. The question is how, which functions of winuser32.dll lead to the result?

 
That's my question too. 
 

Include:

#include <WinAPI/WinUser.mqh>

Then use appropriate WinAPI functions from the header, such as FindWindowExW, GetWindowTextW, GetClassNameW, etc to interate through window hierarchy of the tester. Of course, you need to investigate this hierarchy beforehand by tools like Microsoft Spy, so that you know class names and titles of all related windows.

NB. Only visual mode of the tester will produce visible windows.
 
You can use FindWindow from the WinAPI to search for the window by the class name. Looking at the AHK Windows Spy, we can see that the window the cursor is at (the chart window) has the class name AfxFrameOrView140su1. Pass it to FindWindow and get the handle (this was not tested). Sometimes there're more than one metatester64.exe process (it happens when a test ends, but for some reason the process is not terminated). You may have to implement some logic with EnumWindows to select the correct running process in which the backtest is happening.