How to get MetaTrader account details from from EA code

How to access account number and broker server address in EA?

for example :

account number : 15632547

broker address FXCM-ECN1

This piece of code will show you how to programatically get MetaTrader account details from within your EA:

//+------------------------------------------------------------------+ 
//| Script program start function                                    | 
//+------------------------------------------------------------------+ 
void OnStart() 
  { 
//--- Name of the company 
   string company=AccountInfoString(ACCOUNT_COMPANY); 
//--- Name of the client 
   string name=AccountInfoString(ACCOUNT_NAME); 
//--- Account number 
   long login=AccountInfoInteger(ACCOUNT_LOGIN); 
//--- Name of the server 
   string server=AccountInfoString(ACCOUNT_SERVER); 
//--- Account currency 
   string currency=AccountInfoString(ACCOUNT_CURRENCY); 
//--- Demo, contest or real account 
   ENUM_ACCOUNT_TRADE_MODE account_type=(ENUM_ACCOUNT_TRADE_MODE)AccountInfoInteger(ACCOUNT_TRADE_MODE); 
//--- Now transform the value of  the enumeration into an understandable form 
   string trade_mode; 
   switch(account_type) 
     { 
      case  ACCOUNT_TRADE_MODE_DEMO: 
         trade_mode="demo"; 
         break; 
      case  ACCOUNT_TRADE_MODE_CONTEST: 
         trade_mode="contest"; 
         break; 
      default: 
         trade_mode="real"; 
         break; 
     } 
//--- Stop Out is set in percentage or money 
   ENUM_ACCOUNT_STOPOUT_MODE stop_out_mode=(ENUM_ACCOUNT_STOPOUT_MODE)AccountInfoInteger(ACCOUNT_MARGIN_SO_MODE); 
//--- Get the value of the levels when Margin Call and Stop Out occur 
   double margin_call=AccountInfoDouble(ACCOUNT_MARGIN_SO_CALL); 
   double stop_out=AccountInfoDouble(ACCOUNT_MARGIN_SO_SO); 
//--- Show brief account information 
   PrintFormat("The account of the client '%s' #%d %s opened in '%s' on the server '%s'", 
               name,login,trade_mode,company,server); 
   PrintFormat("Account currency - %s, MarginCall and StopOut levels are set in %s", 
               currency,(stop_out_mode==ACCOUNT_STOPOUT_MODE_PERCENT)?"percentage":" money"); 
   PrintFormat("MarginCall=%G, StopOut=%G",margin_call,stop_out); 
  }