myeatrade

MQL4 Reference

MQL4 Account information

A group of functions to access to the active account information.

 

AccountBalance()

double AccountBalance()

Returns balance value of the current account (the amount of money on the account).

Sample:

Print("Account balance = ",AccountBalance());

AccountCredit()

double AccountCredit()

Returns credit value of the current account.

Sample:

Print("Account number ", AccountCredit());

AccountCompany()

string AccountCompany()

Returns the brokerage company name where the current account was registered.

Sample:

Print("Account company name ", AccountCompany());

AccountCurrency()

string AccountCurrency()

Returns currency name of the current account.

Sample:

Print("account currency is ", AccountCurrency());

AccountEquity()

double AccountEquity()

Returns equity value of the current account. Equity calculation depends on trading server settings.

Sample:

Print("Account equity = ",AccountEquity());

AccountFreeMargin()

double AccountFreeMargin()

Returns free margin value of the current account.

Sample:

Print("Account free margin = ",AccountFreeMargin());

AccountFreeMarginCheck()

double AccountFreeMarginCheck(string symbol, int cmd, double volume)

Returns free margin that remains after the specified position has been opened at the current price on the current account. If the free margin is insufficient, an error 134 (ERR_NOT_ENOUGH_MONEY) will be generated.

Parameters:

symbol - Symbol for trading operation. 
cmd    - Operation type. It can be either OP_BUY or OP_SELL. 
volume - Number of lots. 

Sample:

if(AccountFreeMarginCheck(Symbol(),OP_BUY,Lots)<=0 || GetLastError()==134) return;

AccountFreeMarginMode()

double AccountFreeMarginMode()

Calculation mode of free margin allowed to open positions on the current account. The calculation mode can take the following values:

  • 0 – floating profit/loss is not used for calculation;
  • 1 – both floating profit and loss on open positions on the current account are used for free margin calculation;
  • 2 – only profit value is used for calculation, the current loss on open positions is not considered;
  • 3 – only loss value is used for calculation, the current loss on open positions is not considered.

Sample:

if(AccountFreeMarginMode()==0)
   Print("Floating Profit/Loss do not use.");

AccountLeverage()

int AccountLeverage()

Returns leverage of the current account.

Sample:

Print("Account #",AccountNumber(), " leverage is ", AccountLeverage());

AccountMargin()

double AccountMargin()

Returns margin value of the current account.

Sample:

Print("Account margin ", AccountMargin());

AccountName()

string AccountName()

Returns the current account name.

Sample:

Print("Account name ", AccountName());

AccountNumber()

int AccountNumber()

Returns the number of the current account.

Sample:

Print("account number ", AccountNumber());

AccountProfit()

double AccountProfit()

Returns profit value of the current account.

Sample:

Print("Account profit ", AccountProfit());

AccountServer()

string AccountServer()

Returns the connected server name.

Sample:

Print("Server name is ", AccountServer());

AccountStopoutLevel()

int AccountStopoutLevel()

Returns the value of the Stop Out level.

Sample:

Print("StopOut level = ", AccountStopoutLevel());

AccountStopoutMode()

int AccountStopoutMode()

Returns the calculation mode for the Stop Out level. Calculation mode can take the following values:

  • 0 – calculation of percentage ratio between margin and equity;
  • 1 – comparison of the free margin level to the absolute value.

Sample:

int level=AccountStopoutLevel();
if(AccountStopoutMode()==0)
   Print("StopOut level = ", level, "%");
else
   Print("StopOut level = ", level, " ", AccountCurrency());
This article url: http://www.myeatrade.com/430/

Please login to post comment, if you haven't account you can register free