Download MetaTrader 5
To add comments, please log in or register
Publish your article and get a reward!
franky
54
franky 2014.05.20 06:19 
Hello,
I don't know all the new functions after updating.
Is there a function to switch windows? (eg USDCAD is in the foreground and the function must change to EURUSD)
thank you
Drazen Penic
2404
Drazen Penic 2014.05.20 08:23  

You can do it with ChartSetSymbolPeriod() function

ChartSetSymbolPeriod(0, "EURUSD", PERIOD_H1); 

Besides symbol, you can also change chart timeframe.

Drazen Penic
2404
Drazen Penic 2014.05.20 09:18  

If you want to switch existing charts, check these topics:


franky
54
franky 2014.05.20 22:21  
hi,
thank you,
the first function does not work it blocks everything (in 646), plus she overwrites the existent window with another window and it does not allow navigation between existing windows.
I'll try the script.
franky
54
franky 2014.05.20 23:04  
I found a solution:

I create a function from the script that I can incorporate into my EA's

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

#define WM_MDIACTIVATE 0x222


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

int WindowActivate(int hwnd) {
   int p = GetParent(hwnd);
   SendMessageA(GetParent(p), WM_MDIACTIVATE, p, 0);
return(0);}


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


void selectwind(string paire){
   int hwnd;
   hwnd = WindowGetHandle(paire);
   WindowActivate(hwnd);}


//----------------------------------------------------


... trade_function (..........){
 --------
 -------
 if(  signal_detected  || ...... || .......  ){
    -------
    selectwind(Symbol());
    --------           }

Thank you for the links

whroeder1
13607
whroeder1 2014.05.22 12:01  
franky: I don't know all the new functions after updating.
Alphabetic Index of MQL4 Functions (600+) - MQL4 forum
franky
54
franky 2014.05.22 14:38  
WHRoeder:
franky: I don't know all the new functions after updating.
Alphabetic Index of MQL4 Functions (600+) - MQL4 forum

it is very convenient, thank you !
/
To add comments, please log in or register