Download MetaTrader 5

Function to change currency windows

To add comments, please log in or register
franky
54
franky  
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
2699
Drazen Penic  

You can do it with ChartSetSymbolPeriod() function

ChartSetSymbolPeriod(0, "EURUSD", PERIOD_H1); 

Besides symbol, you can also change chart timeframe.

Drazen Penic
2699
Drazen Penic  

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


franky
54
franky  
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  
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
15736
whroeder1  
franky: I don't know all the new functions after updating.
Alphabetic Index of MQL4 Functions (600+) - MQL4 forum
franky
54
franky  
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