//+------------------------------------------------------------------+ //| Connect Retry.mq4 | //| Copyright © 2010, Forex Trading Laboratory Kirin. | //| http://www.ftlabo.com/ | //+------------------------------------------------------------------+ #property copyright "Copyright © 2010, Forex Trading Laboratory Kirin." #property link "http://www.ftlabo.com/" #import "user32.dll" #define WM_COMMAND 0x0111 int RegisterWindowMessageA(string lpString); int GetAncestor(int hWnd, int gaFlags); int PostMessageA(int hWnd, int Msg, int wParam, int lParam); //+------------------------------------------------------------------+ //| script program start function | //+------------------------------------------------------------------+ int start() { //---- while(!IsStopped()){ if(!IsConnected()){ int hMetaTrader = GetAncestor(WindowHandle(Symbol(), Period()), 2); if(hMetaTrader != 0)PostMessageA(hMetaTrader, WM_COMMAND, 37400, 0); int hWnd = WindowHandle(Symbol(), Period()); int MT4InternalMsg = RegisterWindowMessageA("MetaTrader4_Internal_Message"); PostMessageA(hWnd, MT4InternalMsg, 2, 1); Print("DO RETRY"); } Sleep(1000); } //---- return(0); } //+------------------------------------------------------------------+