Errors, bugs, questions - page 2522

 

I'm asking for help on WinAPI. Need to be able to do these two actions in MT5.

Call the menu shown and select to save the report.


Call the menu shown and select to load a set file.


In MT4 this kind of thing is very easy. In MT5 it is not.

I.e. you just need to open menu and select an appropriate option. But it cannot do that.


Sounds like it should be.

 

If you record a Message log to call the context menu for task 2, you can get the following result:


Try to call this menu programmatically viaSendMessage WinApi.

 
Sergey Dzyublik:

If you write a Message log to call the context menu for task 2, you can get the following result:

Try to call this menu programmatically viaSendMessage WinApi.

Not successful.

#include <WinAPI\winuser.mqh>

#define  GA_ROOT           0x00000002

#define  GET_HANDLE                                                                       \
  long Handle = user32::GetAncestor(::ChartGetInteger(0, CHART_WINDOW_HANDLE), GA_ROOT); \
                                                                                         \
  for (int i = 0; i < sizeof(ControlID) / sizeof(int); i++)                              \
    Handle = user32::GetDlgItem(Handle, ControlID[i]);

void OnStart()
{
  static const int ControlID[] = {}; // Пробовал углубляться по дереву окон - не помогает.
  GET_HANDLE
  
  user32::SendMessageW(Handle, 0x10C1, 0, 0);
}
 
fxsaber:

It didn't work out

You're probably using the wrong handle.
The charts are implemented within the MDIClient object, you need to go up to the root terminal.exe window and then go down through the windows to the highlighted "SysListView32" and use its handle.
There may be an easier way, try it out...


 
Sergey Dzyublik:

Most likely you're using the wrong handle.
The charts are implemented within the MDIClient object, you need to go up to the root terminal.exe window and then go down through the windows to the highlighted "SysListView32" and use its handle.
There may be an easier way, try it out...

Got to the Handle, didn't help.

#include <WinAPI\winuser.mqh>

#define  GA_ROOT           0x00000002

#define  GET_HANDLE                                                                       \
  long Handle = user32::GetAncestor(::ChartGetInteger(0, CHART_WINDOW_HANDLE), GA_ROOT); \
                                                                                         \
  for (int i = 0; i < sizeof(ControlID) / sizeof(int); i++)                              \
    Handle = user32::GetDlgItem(Handle, ControlID[i]);

void OnStart()
{
  static const int ControlID[] = {0xE81E, 0x804E, 0x28EF, 0x28FE};
  GET_HANDLE
  
  Print(Handle); // Распечатал хендл.
  
  user32::SendMessageW(Handle, 0x10C1, 0, 0);
}


Probably a different Message.

 

A question that has long plagued me is how to motivate the thought process correctly

if (value[0] > value[1]

or vice versa

first zero and then the next?

 

Hi, Can you tell me why my terminal behaves like this onVMware x64?

Forum on trading, automated trading systems and trading strategies testing

Bugs, bugs, questions

Gudgeon, 2019.07.31 12:16

2019.07.31 08:20:46.595 Terminal MetaTrader 5 x64 build 2085 started (MetaQuotes Software Corp.)
2019.07.31 08:20:46.596 Terminal Windows 10 (build 14393) on VMware x64, IE 11, UAC, Intel Core i5-3450 @ 3.10GHz, Memory: 2728 / 4095 Mb, Disk: 69 / 99 Gb, GMT+3
2019.07.31 08:20:46.596 Terminal C:\PROGI\MT-5


It feels like it happens more often when the terminal is loaded with chart objects.

e.g.: trades, calendar events

Indicator after a malfunction

After some time the indicator stops working properly:

- M1 chart;

- any indicator (in the figure standard Moving Average);

- tested on three machines.

If you change the schedule period, everything falls into place.

For me this is critical as I use signals from chart indicators in my EA.

 
Gudgeon:

Hello, could you please tell me why the terminal behaves this way?


After some time the indicator stops working correctly:

- M1 chart;

- Any indicator (the standard Moving Average is shown in the picture);

- I checked it on three machines.

If you change the period of the graph, everything falls into place.

For me, it is critical, because I use signals from the chart indicators in my Expert Advisor.

Specify the data:

copy three lines from "Log" tab (select three lines -> right mouse click -> Copy)


and paste it into your message. It should look like this:

2019.07.31 11:53:10.681 MetaTrader 5 x64 build 2093 started (MetaQuotes Software Corp.)
2019.07.31 11:53:10.685 Windows 10 (build 18362) x64, IE 11, UAC, Intel Core i3-3120 M  @ 2.50 GHz, Memory: 3188 / 8077 Mb, Disk: 99 / 415 Gb, GMT+2
2019.07.31 11:53:10.685 C:\Users\barab\AppData\Roaming\MetaQuotes\Terminal\D0E8209F77C8CF37AD8BF550E51FF075
 

2019.07.31 08:20:46.595 Terminal MetaTrader 5 x64 build 2085 started (MetaQuotes Software Corp.)
2019.07.31 08:20:46.596 Terminal Windows 10 (build 14393) on VMware x64, IE 11, UAC, Intel Core i5-3450 @ 3.10GHz, Memory: 2728 / 4095 Mb, Disk: 69 / 99 Gb, GMT+3
2019.07.31 08:20:46.596 Terminal C:\PROGI\MT-5


It seems to happen more often when the terminal is loaded with graphical objects.

for example: trades, calendar events and small timeframes
 
fxsaber:

Got to the Handle, didn't help.
Probably a different Message.

Got it with WM_CONTEXTMENU.
Slightly tweaked the code, it's easier to debug and can be reused:

#include <WinAPI\winuser.mqh>

#define  GA_ROOT            0x00000002
#define  WM_CONTEXTMENU     0x007B


#define  PRINT(x) ; Print(#x, ":", string(x))
#define  PRINT64(x) ; printf("%s%s%#.08x", #x, ":", x)


long GetHandle(long handle, int &controls[]){
   long next_handle = handle;                                                                        
   for (int i = 0; i < ArraySize(controls); i++){
      next_handle = user32::GetDlgItem(next_handle, controls[i]);
      PRINT64(next_handle);
   }           
   return next_handle;                
}
  

void OnStart(){
  long RootHandle = user32::GetAncestor(::ChartGetInteger(0, CHART_WINDOW_HANDLE), GA_ROOT);
  PRINT64(RootHandle);  
  
  int controls[] = {0xE81E, 0x804E, 0x28EF, 0x28FE}; 
  long handle = GetHandle(RootHandle, controls);
  PRINT64(handle);
  
  
  //PRINT(user32::SendMessageW(handle, WM_CONTEXTMENU, 0, -1));
  PRINT(user32::PostMessageW(handle, WM_CONTEXTMENU, 0, -1));
  PRINT("Sleep");

  Sleep(10 * 1000);
}