Account Properties
Overview
Retrieve current account information using the following MQL4 functions:
AccountInfoInteger(): Retrieves integer account properties.AccountInfoDouble(): Retrieves double-precision floating-point account properties.AccountInfoString(): Retrieves string account properties.These functions accept parameters from the ENUM_ACCOUNT_INFO enumerations.
ENUM_ACCOUNT_INFO_INTEGER
| Identifier | Description | Type |
| :------------------- | :--------------------------------------------------------------------------- | :--- |
| ACCOUNT_LOGIN | Account number | long |
| ACCOUNT_TRADE_MODE | Account trade mode (see ENUM_ACCOUNT_TRADE_MODE) | long |
| ACCOUNT_LEVERAGE | Account leverage | long |
| ACCOUNT_LIMIT_ORDERS | Max allowed open positions and pending orders (0 = unlimited) | int |
| ACCOUNT_MARGIN_SO_MODE | Mode for setting minimal allowed margin (see ENUM_ACCOUNT_STOPOUT_MODE) | long |
| ACCOUNT_TRADE_ALLOWED | Trade permission for the current account | bool |
| ACCOUNT_TRADE_EXPERT | Trade permission for an Expert Advisor | bool |
ENUM_ACCOUNT_INFO_DOUBLE
| Identifier | Description | Type |
| :------------------------- | :--------------------------------------------------------------------------------------------------------- | :----- |
| ACCOUNT_BALANCE | Account balance in deposit currency | double |
| ACCOUNT_CREDIT | Account credit in deposit currency | double |
| ACCOUNT_PROFIT | Current profit of account in deposit currency | double |
| ACCOUNT_EQUITY | Account equity in deposit currency | double |
| ACCOUNT_MARGIN | Account margin used in deposit currency | double |
| ACCOUNT_MARGIN_FREE | Free margin of account in deposit currency | double |
| ACCOUNT_MARGIN_LEVEL | Account margin level in percent | double |
| ACCOUNT_MARGIN_SO_CALL | Margin call level (in percent or deposit currency, depends on ACCOUNT_MARGIN_SO_MODE) | double |
| ACCOUNT_MARGIN_SO_SO | Margin stop out level (in percent or deposit currency, depends on ACCOUNT_MARGIN_SO_MODE) | double |
| ACCOUNT_MARGIN_INITIAL | Not supported | double |
| ACCOUNT_MARGIN_MAINTENANCE | Not supported | double |
| ACCOUNT_ASSETS | Not supported | double |
| ACCOUNT_LIABILITIES | Not supported | double |
| ACCOUNT_COMMISSION_BLOCKED | Not supported | double |
ENUM_ACCOUNT_INFO_STRING
| Identifier | Description | Type |
| :--------------- | :----------------------------------------- | :----- |
| ACCOUNT_NAME | Client name | string |
| ACCOUNT_SERVER | Trade server name | string |
| ACCOUNT_CURRENCY | Account currency | string |
| ACCOUNT_COMPANY| Name of company serving the account | string |
ENUM_ACCOUNT_TRADE_MODE
Defines the type of account.
| Identifier | Description |
| :--------------------- | :--------------- |
| ACCOUNT_TRADE_MODE_DEMO | Demo account |
| ACCOUNT_TRADE_MODE_CONTEST | Contest account |
| ACCOUNT_TRADE_MODE_REAL | Real account |
ENUM_ACCOUNT_STOPOUT_MODE
Defines how Stop Out level is set.
| Identifier | Description |
| :------------------------- | :------------------------------ |
| ACCOUNT_STOPOUT_MODE_PERCENT | Stop out mode in percents |
| ACCOUNT_STOPOUT_MODE_MONEY | Stop out mode in money |
Example Script
void OnStart()
{
string company = AccountInfoString(ACCOUNT_COMPANY);
string name = AccountInfoString(ACCOUNT_NAME);
long login = AccountInfoInteger(ACCOUNT_LOGIN);
string server = AccountInfoString(ACCOUNT_SERVER);
string currency = AccountInfoString(ACCOUNT_CURRENCY);
ENUM_ACCOUNT_TRADE_MODE account_type = (ENUM_ACCOUNT_TRADE_MODE)AccountInfoInteger(ACCOUNT_TRADE_MODE);
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;
}
ENUM_ACCOUNT_STOPOUT_MODE stop_out_mode = (ENUM_ACCOUNT_STOPOUT_MODE)AccountInfoInteger(ACCOUNT_MARGIN_SO_MODE);
double margin_call = AccountInfoDouble(ACCOUNT_MARGIN_SO_CALL);
double stop_out = AccountInfoDouble(ACCOUNT_MARGIN_SO_SO); 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);
}