Alain Verleyen:
will it fix the problem that I've mentioned??
- All these WinApi calls are not needed, MT4 has now built-in functions to do such things.
- MT4 is now using Unicode for strings, you have to use unicode version of WinApi functions (with suffix 'W' instead of 'A').
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
It will open a new chart with specific template when you drag it from script list and drop it on the open chart, but when using "hotkey" it will open chart which is selected in MT4 "symbol list" instead the one which is currently open.
#import "user32.dll" int GetAncestor(int hWnd, int gaFlags); int GetDlgItem(int hDlg, int nIDDlgItem); int PostMessageA(int hWnd, int Msg, int wParam, int lParam); int GetParent(int hWnd); int GetWindow(int hWnd,int uCmd); #import #define WM_COMMAND 0x0111 #define WM_KEYDOWN 0x0100 #define VK_HOME 0x0024 #define VK_DOWN 0x0028 //+------------------------------------------------------------------+ //| Open a new chart | //+------------------------------------------------------------------+ int init() { OpenChart(Symbol(),Period()); return(0); } //-------------------------------------------------------------------- int OpenChart(string SymbolName, int TimeFrame) { int hFile, SymbolsTotal, hTerminal, hWnd, intCmd; hFile = FileOpenHistory("symbols.sel", FILE_BIN|FILE_READ); if(hFile < 0) return(-1); SymbolsTotal = (FileSize(hFile) - 4) / 128; FileSeek(hFile, 4, SEEK_SET); hTerminal = GetAncestor(WindowHandle(Symbol(), Period()), 2); hWnd = GetDlgItem(hTerminal, 0xE81C); hWnd = GetDlgItem(hWnd, 0x50); hWnd = GetDlgItem(hWnd, 0x8A71); PostMessageA(hWnd, WM_KEYDOWN, VK_HOME, 0); //--------------------------------------------------- switch( TimeFrame ) { case 1: intCmd = 33137; break; case 5: intCmd = 33138; break; case 15: intCmd = 33139; break; case 30: intCmd = 33140; break; case 60: intCmd = 35400; break; case 240: intCmd = 33136; break; case 1440: intCmd = 33134; break; case 10080: intCmd = 33141; break; case 43200: intCmd = 33334; break; } //-------------------------------------------------- for(int i = 0; i < SymbolsTotal; i++) { if(FileReadString(hFile, 12) == Symbol()) { PostMessageA(hTerminal, WM_COMMAND, 33160, 0); Sleep(100); PostMessageA(hTerminal,WM_COMMAND,intCmd,0); Sleep(100); PostMessageA(hTerminal, WM_COMMAND, 34800, 0 ); return(0); } PostMessageA(hWnd, WM_KEYDOWN, VK_DOWN, 0); FileSeek(hFile, 116, SEEK_CUR); } FileClose(hFile); return(-1); } //-----------------------------------------------------