I use this to change the chart on my EA if it's not on the right one (M15 in this case)
//+------------------------------------------------------------------+ //| CTF.mq4 | //| Copyright ©2013 PaulB | //+------------------------------------------------------------------+ #property copyright "" #property link "" #import "user32.dll" int PostMessageA(int hWnd,int Msg,int wParam,int lParam); int GetParent(int hWnd); #import //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init(){ if(Period()!=PERIOD_M15) { int intParent = GetParent( WindowHandle( Symbol(), Period() ) ), intCmd; switch( PERIOD_M15 ) { case PERIOD_M1: intCmd = 33137; break; case PERIOD_M5: intCmd = 33138; break; case PERIOD_M15: intCmd = 33139; break; case PERIOD_M30: intCmd = 33140; break; case PERIOD_H1: intCmd = 35400; break; case PERIOD_H4: intCmd = 33136; break; case PERIOD_D1: intCmd = 33134; break; case PERIOD_W1: intCmd = 33141; break; case PERIOD_MN1: intCmd = 33334; break; } PostMessageA( intParent, 0x0111, intCmd, 0 ); } return(0);} //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit(){ return(0);} //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start(){ return(0);} //+------------------------------------------------------------------+
Paul_B: I use this to change the chart on my EA if it's not on the right one (M15 in this case)
case PERIOD_H1: intCmd = 35400; break;
That agrees with https://www.mql5.com/en/forum/124688 #define's for known commands that can be used for PostMessageA() - MQL4 forum
But https://www.mql5.com/en/forum/128744 How to programmatically maximize a chart window - MQL4 forum and https://www.mql5.com/ru/forum/121297 Конвертер периодов. Вопрос к getch, Zhunko, YuraZ - MQL4 форум both specify:
MT4_WMCMD_PERIOD_H1 33135
Since February 3, 2014 (Build 600) we can now use ChartSetSymbolPeriod - Chart Operations - MQL4 Reference
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi is there a way for change Timeframe only on select chart?
I found this script but it changes Timeframe on all charts.
I try to modify the script but does't work... it appears a Popup: "Do you really want to stop the script?" Does anybody kwow the reason?