Download MetaTrader 5

How to bring to front one chart by code?

To add comments, please log in or register
Do you have a trading signal? Publish it in your blog as well!
HongDi s& t development co.,ltd.
1598
hongbin fei 2010.01.22 07:48 

if there is 3 charts, I want let expert   bring one chart(for example D1) to front by code? how to do?

thanks

HongDi s& t development co.,ltd.
1598
hongbin fei 2010.02.02 09:46  
codeidea posted  :

if there is 3 charts, I want let expert   bring one chart(for example D1) to front by code? how to do?

thanks

 

who can help me ?
Automated-Trading
Admin
99094
Automated-Trading 2010.02.03 18:14  
codeidea posted  :

if there is 3 charts, I want let expert   bring one chart(for example D1) to front by code? how to do?

thanks

 

Here is the script that brings EURUSD Daily chart to front:

//+------------------------------------------------------------------+
//|                                                  BringWindow.mq5 |
//|                        Copyright 2010, MetaQuotes Software Corp. |
//|                                              http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "2010, MetaQuotes Software Corp."
#property link      "http://www.mql5.com"
#property version   "1.00"
#import "user32.dll"
int SendMessageW(int hWnd,int Msg,int wParam,int lParam);
int GetParent(int hWnd);
#import

//#property script_show_inputs
//--- input parameters
input string          InpSymbol="EURUSD";
input ENUM_TIMEFRAMES InpPeriod=PERIOD_D1;

#define WM_MDIACTIVATE  0x222
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//---
   long chart_id=ChartFirst();
   while(chart_id>=0)
     {
      if(ChartSymbol(chart_id)==InpSymbol && ChartPeriod(chart_id)==InpPeriod)
         break;
      chart_id=ChartNext(chart_id);
     }
   if(chart_id<0)
     {
      Print("Chart not found");
      return;
     }
   int handle=(int)ChartGetInteger(chart_id,CHART_WINDOW_HANDLE);
   handle=GetParent(handle);

   int WinParent=GetParent(handle);
   SendMessageW(WinParent,WM_MDIACTIVATE,handle,0);
  }
//+------------------------------------------------------------------
To add comments, please log in or register