//--------------------------------------------------------------------- // How to close the trading terminal using MQL and Win API. //--------------------------------------------------------------------- #property copyright "© RickD 2006-2007" #property link "www.e2e-fx.net" #import "user32.dll" int GetParent(int hwnd); #import #include void CloseMT() { int hwnd = WindowHandle(Symbol(), Period()); int hwnd_parent = 0; while (!IsStopped()) { hwnd = GetParent(hwnd); if (hwnd == 0) break; hwnd_parent = hwnd; } if (hwnd_parent != 0) PostMessageA(hwnd_parent, WM_CLOSE, 0, 0); }