Expert Advisors • Indicators • Scripts • Libraries

MQL.RobotFX.org is the biggest collection of MetaTrader expert advisors (MT5 & MT4), indicators, scripts and libraries that can be used to improve trading results, minimize risks or simply automate trading tasks

MetaTrader 4 Libraries | Authenticate into an MT4 account from MQL4 (tested in build 880)

MetaTrader Experts, Indicators, Scripts and Libraries

Since MetaTrader 4 build 880 was released, it's no longer easy to programmatically fill values in Login dialog.

This library hides the complicated stuff and provides easy to use API to login to any MetaTrader 4 account from within MQL4 script/expert.

Any contribution appreciated.

Example:

//+------------------------------------------------------------------+
//|                                            mql4-auth-example.mq4 |
//|                                     Copyright 2015, Sergey Lukin |
//+------------------------------------------------------------------+
#include <mql4-auth.mqh>
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnStart()
  {
// Just in case...
   if(loginDialogIsOpen()) closeLoginDialog();

// Let's do it!
   if(auth("ACCOUNT_NUMBER","PASSWORD","SERVER IP/HOSTNAME"))
     {
      Print("Hooray, I found the login dialog, inserted credentials, now wait until MT4 connects :)");
     }
   else
     {
      Print("Sorry, I could not even find the Login dialog... Is your MT4 older than v880 or something?");
     }
  }
//+------------------------------------------------------------------+

Source:

13903

Best MetaTrader Indicators + Profitable Expert Advisors