MQL4 Reference Checkup IsConnected
Checks connection between client terminal and server.
bool IsConnected();
Returned value
It returns true if connection to the server was successfully established, otherwise, it returns false.
Example:
if(!IsConnected()) { Print("No connection!"); return(0); } // Expert body that needs the connection opened // ...