Download MetaTrader 5

How to programmatically maximize a chart window

To add comments, please log in or register
Shawn
189
Shawn  

Hi all, in an effort to debug my EA, I would like for it to programatically take a screenshot of the current state of the chart whenever a trade is placed. I did some searching and found pretty much what I needed at https://www.mql5.com/en/articles/1534. I just have one remaining little issue - my EA is running on about 10 different charts at the same time and therefore I need to be able to programatically maximize the chart window where a trade has just taken place, before I take the screenshot. Would anyone have any idea how to do this... if it's possible?


Thanks!

Shawn

qjol
3243
qjol  

here is a script i find I hope it will be useful for u

#property show_inputs
#import "user32.dll"
int GetParent(int hWnd);
int SendMessageA(int hWnd, int Msg, int wParam, int lParam);
#import

#define WM_MDIACTIVATE 0x222
#define WM_MDIMAXIMIZE 0x0225

extern string symbol = "EURUSD"; 

int periods[9] = {PERIOD_MN1, PERIOD_W1, PERIOD_D1, PERIOD_H4, PERIOD_H1, PERIOD_M30, PERIOD_M15, PERIOD_M5, PERIOD_M1};

int Window.activate(int hwnd) {
   int p = GetParent(hwnd);
   SendMessageA(GetParent(p), WM_MDIACTIVATE, p, 0);
}
int Window.maximize(int hwnd) {
   int p = GetParent(hwnd);
   SendMessageA(GetParent(p), WM_MDIMAXIMIZE, p, 0);
}

int Window.getHandle(string symbol) {
   int i, hwnd;
   for (i=0; i<ArraySize(periods); i++) {
      hwnd = WindowHandle(symbol, periods[i]);
      if (hwnd != 0) break;
   }
   return (hwnd);
}

void start() {
   int hwnd = Window.getHandle(symbol);
   Window.activate(hwnd);
   Window.maximize(hwnd);
   
}
Arbubu
198
Arbubu  

I get this message "2011.02.15 15:50:26 Forex 4H HiLo GBPJPYSB,H4: dll calls are not allowed; 'user32.dll'-'GetParent'."

How do I enable dll calls?

qjol
3243
qjol  

when drag & drop the Expert

Or Tools ---> Options ---> Expert Adviser

Arbubu
198
Arbubu  
Thanks!
Arbubu
198
Arbubu  

Is it possible to select the time scale programatically? I appreciate that this could be done by having one chart open at each time scale but I don't want to do that it would be too cumbersome. I'd like to have just one chart open for a market and have my EA set the timescale on that as appropriate. Can it be done?

Thanks.

qjol
3243
qjol  

yes

33137 - М1
33138 - М5
33139 - М15
33140 - М30
33135 - Н1
33136 - Н4
33134 - D1
33141 - W1
33334 - MN

Arbubu
198
Arbubu  
qjol:

yes

33137 - М1
33138 - М5
33139 - М15
33140 - М30
33135 - Н1
33136 - Н4
33134 - D1
33141 - W1
33334 - MN

How do I use those figures? Are they the lParam?
qjol
3243
qjol  
no, wParam
whroeder1
16306
whroeder1  
Arbu:
Is it possible to select the time scale programatically?

From http://https://forum.mql4.com/30667

#define MT4_WMCMD_PERIOD_D1       33134
                                        /* 33135       unknown */
#define MT4_WMCMD_PERIOD_H4       33136
#define MT4_WMCMD_PERIOD_M1       33137
#define MT4_WMCMD_PERIOD_M5       33138
#define MT4_WMCMD_PERIOD_M15      33139
#define MT4_WMCMD_PERIOD_M30      33140
#define MT4_WMCMD_PERIOD_W1       33141
qjol
3243
qjol  
/* 33135       unknown */ #define MT4_WMCMD_PERIOD_H1 33135 //  33135 = H1
12
To add comments, please log in or register