Article-12905-MQL5-Account-.../Article-12905-MQL5-Account-Info-PrintFormat.mq5
artmedia70 5361950509
2026-03-06 19:05:45 +07:00

654 lines
36 KiB
MQL5

//+------------------------------------------------------------------+
//| Art12905_PrintFormat.mq5 |
//| Copyright 2026, MetaQuotes Ltd. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
//--- Print trading account properties in the journal
AccountInfoPrint(20,2);
/* Sample output:
AccountInfoInteger properties:
Login: 68008618
Trade mode: Demo
Leverage: 1:100
Limit orders: 200
StopOut mode: Percent
Trade allowed: Yes
Trade expert: Yes
Margin mode: Retail hedging
Currency digits: 2
FIFO close: No
Hedge allowed: Yes
AccountInfoDouble properties:
Balance: 10015.00 USD
Credit: 0.00 USD
Profit: 2.11 USD
Equity: 10017.11 USD
Margin: 25.61 USD
Margin free: 9991.50 USD
Margin level: 39114.06 %
Margin Call: 50.00 %
Margin Stop Out: 30.00 %
Margin initial: 0.00 USD
Margin maintenance: 0.00 USD
Assets: 0.00 USD
Liabilities: 0.00 USD
Comission blocked: 0.00 USD
AccountInfoString properties:
Name: Artem
Server: MetaQuotes-Demo
Currency: USD
Company: MetaQuotes Software Corp.
*/
}
//+------------------------------------------------------------------+
//| Print a description of the account number into the journal |
//+------------------------------------------------------------------+
void AccountLoginPrint(const uint header_width=0,const uint indent=0)
{
//--- Define the header text and the width of the header field
//--- If the header width is passed to the function equal to zero, then the width will be the size of the header line + 1
string header="Login:";
uint w=(header_width==0 ? header.Length()+1 : header_width);
//--- Print the property value in the log with a header with the required width and indentation
PrintFormat("%*s%-*s%-s",indent,"",w,header,(string)AccountInfoInteger(ACCOUNT_LOGIN));
/* Sample output:
Login: 68008618
*/
}
//+------------------------------------------------------------------+
//| Print a trading account type into the journal |
//+------------------------------------------------------------------+
void AccountTradeModePrint(const uint header_width=0,const uint indent=0)
{
//--- Get the value of the trading account type
ENUM_ACCOUNT_TRADE_MODE trade_mode=(ENUM_ACCOUNT_TRADE_MODE)AccountInfoInteger(ACCOUNT_TRADE_MODE);
//--- "Cut out" the name of the trading account type from the line obtained from enum
string mode=StringSubstr(EnumToString(trade_mode),19);
//--- Convert the characters of the resulting line to lower case and replace the first letter from small to capital
if(mode.Lower())
mode.SetChar(0,ushort(mode.GetChar(0)-0x20));
//--- Define the header text and the width of the header field
//--- If the header width is passed to the function equal to zero, then the width will be the size of the header line + 1
string header="Trade mode:";
uint w=(header_width==0 ? header.Length()+1 : header_width);
//--- Print the property value in the log with a header with the required width and indentation
PrintFormat("%*s%-*s%-s",indent,"",w,header,mode);
/* Sample output:
Trade mode: Demo
*/
}
//+------------------------------------------------------------------+
//| Print a description of the provided leverage size in the journal |
//+------------------------------------------------------------------+
void AccountLeveragePrint(const uint header_width=0,const uint indent=0)
{
//--- Define the header text and the width of the header field
//--- If the header width is passed to the function equal to zero, then the width will be the size of the header line + 1
string header="Leverage:";
uint w=(header_width==0 ? header.Length()+1 : header_width);
//--- Print the property value in the log with a header with the required width and indentation
PrintFormat("%*s%-*s1:%-s",indent,"",w,header,(string)AccountInfoInteger(ACCOUNT_LEVERAGE));
/* Sample output:
Leverage: 1:100
*/
}
//+------------------------------------------------------------------+
//| Print a description of the maximum allowed |
//| number of active pending orders |
//+------------------------------------------------------------------+
void AccountLimitOrdersPrint(const uint header_width=0,const uint indent=0)
{
//--- Define the header text and the width of the header field
//--- If the header width is passed to the function equal to zero, then the width will be the size of the header line + 1
string header="Limit orders:";
uint w=(header_width==0 ? header.Length()+1 : header_width);
//--- Print the property value in the log with a header with the required width and indentation
PrintFormat("%*s%-*s%-s",indent,"",w,header,(string)AccountInfoInteger(ACCOUNT_LIMIT_ORDERS));
/* Sample output:
Limit orders: 200
*/
}
//+------------------------------------------------------------------+
//| Print a description of the mode for setting a minimal |
//| accepted level of collateral in the journal |
//+------------------------------------------------------------------+
void AccountMarginSOModePrint(const uint header_width=0,const uint indent=0)
{
//--- Get the value of the mode for setting the minimum available collateral
ENUM_ACCOUNT_STOPOUT_MODE so_mode=(ENUM_ACCOUNT_STOPOUT_MODE)AccountInfoInteger(ACCOUNT_MARGIN_SO_MODE);
//--- "Cut out" the mode name from the line obtained from enum
string mode=StringSubstr(EnumToString(so_mode),21);
//--- Convert the characters of the resulting line to lower case and replace the first letter from small to capital
if(mode.Lower())
mode.SetChar(0,ushort(mode.GetChar(0)-0x20));
//--- Define the header text and the width of the header field
//--- If the header width is passed to the function equal to zero, then the width will be the size of the header line + 1
string header="StopOut mode:";
uint w=(header_width==0 ? header.Length()+1 : header_width);
//--- Print the property value in the log with a header with the required width and indentation
PrintFormat("%*s%-*s%-s",indent,"",w,header,mode);
/* Sample output:
StopOut mode: Percent
*/
}
//+------------------------------------------------------------------+
//| Print a description |
//| of allowing trading for the current account in the journal |
//+------------------------------------------------------------------+
void AccountTradeAllowedPrint(const uint header_width=0,const uint indent=0)
{
//--- Define the header text and the width of the header field
//--- If the header width is passed to the function equal to zero, then the width will be the size of the header line + 1
string header="Trade allowed:";
uint w=(header_width==0 ? header.Length()+1 : header_width);
//--- Print the property value in the log with a header with the required width and indentation
//--- Depending on the bool value of the property, pass the "Yes" or "No" line as a parameter
PrintFormat("%*s%-*s%-s",indent,"",w,header,((bool)AccountInfoInteger(ACCOUNT_TRADE_ALLOWED) ? "Yes" : "No"));
/* Sample output:
Trade allowed: Yes
*/
}
//+------------------------------------------------------------------+
//| Print a description |
//| allowing trading for an EA |
//+------------------------------------------------------------------+
void AccountTradeExpertPrint(const uint header_width=0,const uint indent=0)
{
//--- Define the header text and the width of the header field
//--- If the header width is passed to the function equal to zero, then the width will be the size of the header line + 1
string header="Trade expert:";
uint w=(header_width==0 ? header.Length()+1 : header_width);
//--- Print the property value in the log with a header with the required width and indentation
//--- Depending on the bool value of the property, pass the "Yes" or "No" line as a parameter
PrintFormat("%*s%-*s%-s",indent,"",w,header,((bool)AccountInfoInteger(ACCOUNT_TRADE_EXPERT) ? "Yes" : "No"));
/* Sample output:
Trade expert: Yes
*/
}
//+------------------------------------------------------------------+
//| Print a description of the margin calculation mode in the journal|
//+------------------------------------------------------------------+
void AccountMarginModePrint(const uint header_width=0,const uint indent=0)
{
//--- Get the value of the margin calculation mode
ENUM_ACCOUNT_MARGIN_MODE margin_mode=(ENUM_ACCOUNT_MARGIN_MODE)AccountInfoInteger(ACCOUNT_MARGIN_MODE);
//--- "Cut out" the mode name from the line obtained from enum
string mode=StringSubstr(EnumToString(margin_mode),20);
//--- Convert the characters of the resulting line to lower case and replace the first letter from small to capital
if(mode.Lower())
mode.SetChar(0,ushort(mode.GetChar(0)-0x20));
//--- Replace all underscore characters with space in the resulting line
StringReplace(mode,"_"," ");
//--- Define the header text and the width of the header field
//--- If the header width is passed to the function equal to zero, then the width will be the size of the header line + 1
string header="Margin mode:";
uint w=(header_width==0 ? header.Length()+1 : header_width);
//--- Print the property value in the log with a header with the required width and indentation
PrintFormat("%*s%-*s%-s",indent,"",w,header,mode);
/* Sample output:
Margin mode: Retail hedging
*/
}
//+------------------------------------------------------------------+
//| Print a description of the number of |
//| decimal places for an account currency |
//+------------------------------------------------------------------+
void AccountCurrencyDigitsPrint(const uint header_width=0,const uint indent=0)
{
//--- Define the header text and the width of the header field
//--- If the header width is passed to the function equal to zero, then the width will be the size of the header line + 1
string header="Currency digits:";
uint w=(header_width==0 ? header.Length()+1 : header_width);
//--- Print the property value in the log with a header with the required width and indentation
PrintFormat("%*s%-*s%-s",indent,"",w,header,(string)AccountInfoInteger(ACCOUNT_CURRENCY_DIGITS));
/* Sample output:
Currency digits: 2
*/
}
//+------------------------------------------------------------------+
//| Print a description of the flag indicating |
//| that positions can only be closed using the FIFO rule |
//+------------------------------------------------------------------+
void AccountFIFOClosePrint(const uint header_width=0,const uint indent=0)
{
//--- Define the header text and the width of the header field
//--- If the header width is passed to the function equal to zero, then the width will be the size of the header line + 1
string header="FIFO close:";
uint w=(header_width==0 ? header.Length()+1 : header_width);
//--- Print the property value in the log with a header with the required width and indentation
//--- Depending on the bool value of the property, pass the "Yes" or "No" line as a parameter
PrintFormat("%*s%-*s%-s",indent,"",w,header,((bool)AccountInfoInteger(ACCOUNT_FIFO_CLOSE) ? "Yes" : "No"));
/* Sample output:
FIFO close: No
*/
}
//+------------------------------------------------------------------+
//| Print a description of the flag indicating |
//| opposite positions are allowed on a single symbol |
//+------------------------------------------------------------------+
void AccountHedgeAllowedPrint(const uint header_width=0,const uint indent=0)
{
//--- Define the header text and the width of the header field
//--- If the header width is passed to the function equal to zero, then the width will be the size of the header line + 1
string header="Hedge allowed:";
uint w=(header_width==0 ? header.Length()+1 : header_width);
//--- Print the property value in the log with a header with the required width and indentation
//--- Depending on the bool value of the property, pass the "Yes" or "No" line as a parameter
PrintFormat("%*s%-*s%-s",indent,"",w,header,((bool)AccountInfoInteger(ACCOUNT_HEDGE_ALLOWED) ? "Yes" : "No"));
/* Sample output:
Hedge allowed: Yes
*/
}
//+------------------------------------------------------------------------------------+
//| Print a description of the account balance in the deposit currency in the journal |
//+------------------------------------------------------------------------------------+
void AccountBalancePrint(const uint header_width=0,const uint indent=0)
{
//--- Get the balance, the number of decimal places for the symbol and its name
double ballance=AccountInfoDouble(ACCOUNT_BALANCE);
int digits=(int)AccountInfoInteger(ACCOUNT_CURRENCY_DIGITS);
string currency=AccountInfoString(ACCOUNT_CURRENCY);
//--- Define the header text and the width of the header field
//--- If the header width is passed to the function equal to zero, then the width will be the size of the header line + 1
string header="Balance:";
uint w=(header_width==0 ? header.Length()+1 : header_width);
//--- Print the property value in the log with a header with the required width and indentation
//--- To display the value correctly, replace the asterisk in the format line with the digits value for the symbol
PrintFormat("%*s%-*s%-.*f %-s",indent,"",w,header,digits,ballance,currency);
/* Sample output:
Balance: 10015.00 USD
*/
}
//+------------------------------------------------------------------+
//| Print a description of account credit size |
//| in a deposit currency |
//+------------------------------------------------------------------+
void AccountCreditPrint(const uint header_width=0,const uint indent=0)
{
//--- Get the credit, the number of decimal places for the symbol and its name
double credit=AccountInfoDouble(ACCOUNT_CREDIT);
int digits=(int)AccountInfoInteger(ACCOUNT_CURRENCY_DIGITS);
string currency=AccountInfoString(ACCOUNT_CURRENCY);
//--- Define the header text and the width of the header field
//--- If the header width is passed to the function equal to zero, then the width will be the size of the header line + 1
string header="Credit:";
uint w=(header_width==0 ? header.Length()+1 : header_width);
//--- Print the property value in the log with a header with the required width and indentation
//--- To display the value correctly, replace the asterisk in the format line with the digits value for the symbol
PrintFormat("%*s%-*s%-.*f %-s",indent,"",w,header,digits,credit,currency);
/* Sample output:
Credit: 0.00 USD
*/
}
//+------------------------------------------------------------------+
//| Print a description |
//| of the current profit in the deposit currency |
//+------------------------------------------------------------------+
void AccountProfitPrint(const uint header_width=0,const uint indent=0)
{
//--- Get the current profit, the number of decimal places for the symbol and its name
double profit=AccountInfoDouble(ACCOUNT_PROFIT);
int digits=(int)AccountInfoInteger(ACCOUNT_CURRENCY_DIGITS);
string currency=AccountInfoString(ACCOUNT_CURRENCY);
//--- Define the header text and the width of the header field
//--- If the header width is passed to the function equal to zero, then the width will be the size of the header line + 1
string header="Profit:";
uint w=(header_width==0 ? header.Length()+1 : header_width);
//--- Print the property value in the log with a header with the required width and indentation
//--- To display the value correctly, replace the asterisk in the format line with the digits value for the symbol
PrintFormat("%*s%-*s%-.*f %-s",indent,"",w,header,digits,profit,currency);
/* Sample output:
Profit: 0.00 USD
*/
}
//+------------------------------------------------------------------+
//| Print a description of the value of |
//| equity on an account in a deposit currency |
//+------------------------------------------------------------------+
void AccountEquityPrint(const uint header_width=0,const uint indent=0)
{
//--- Get the equity, the number of decimal places for the symbol and its name
double equity=AccountInfoDouble(ACCOUNT_EQUITY);
int digits=(int)AccountInfoInteger(ACCOUNT_CURRENCY_DIGITS);
string currency=AccountInfoString(ACCOUNT_CURRENCY);
//--- Define the header text and the width of the header field
//--- If the header width is passed to the function equal to zero, then the width will be the size of the header line + 1
string header="Equity:";
uint w=(header_width==0 ? header.Length()+1 : header_width);
//--- Print the property value in the log with a header with the required width and indentation
//--- To display the value correctly, replace the asterisk in the format line with the digits value for the symbol
PrintFormat("%*s%-*s%-.*f %-s",indent,"",w,header,digits,equity,currency);
/* Sample output:
Equity: 10015.00 USD
*/
}
//+------------------------------------------------------------------+
//| Print a description of |
//| reserved collateral funds on the account in a deposit currency |
//+------------------------------------------------------------------+
void AccountMarginPrint(const uint header_width=0,const uint indent=0)
{
//--- Get the reserved collateral, the number of decimal places for the symbol and its name
double margin=AccountInfoDouble(ACCOUNT_MARGIN);
int digits=(int)AccountInfoInteger(ACCOUNT_CURRENCY_DIGITS);
string currency=AccountInfoString(ACCOUNT_CURRENCY);
//--- Define the header text and the width of the header field
//--- If the header width is passed to the function equal to zero, then the width will be the size of the header line + 1
string header="Margin:";
uint w=(header_width==0 ? header.Length()+1 : header_width);
//--- Print the property value in the log with a header with the required width and indentation
//--- To display the value correctly, replace the asterisk in the format line with the digits value for the symbol
PrintFormat("%*s%-*s%-.*f %-s",indent,"",w,header,digits,margin,currency);
/* Sample output:
Margin: 0.00 USD
*/
}
//+--------------------------------------------------------------------------------------+
//| Print a description of the free funds, |
//| available for opening a position on an account in a deposit currency, in the journal |
//+--------------------------------------------------------------------------------------+
void AccountMarginFreePrint(const uint header_width=0,const uint indent=0)
{
//--- Get the reserved collateral, the number of decimal places for the symbol and its name
double margin_free=AccountInfoDouble(ACCOUNT_MARGIN_FREE);
int digits=(int)AccountInfoInteger(ACCOUNT_CURRENCY_DIGITS);
string currency=AccountInfoString(ACCOUNT_CURRENCY);
//--- Define the header text and the width of the header field
//--- If the header width is passed to the function equal to zero, then the width will be the size of the header line + 1
string header="Margin free:";
uint w=(header_width==0 ? header.Length()+1 : header_width);
//--- Print the property value in the log with a header with the required width and indentation
//--- To display the value correctly, replace the asterisk in the format line with the digits value for the symbol
PrintFormat("%*s%-*s%-.*f %-s",indent,"",w,header,digits,margin_free,currency);
/* Sample output:
Margin free: 10015.00 USD
*/
}
//+------------------------------------------------------------------+
//| Print a description |
//| of the collateral level on an account in % |
//+------------------------------------------------------------------+
void AccountMarginLevelPrint(const uint header_width=0,const uint indent=0)
{
//--- Define the header text and the width of the header field
//--- If the header width is passed to the function equal to zero, then the width will be the size of the header line + 1
string header="Margin level:";
uint w=(header_width==0 ? header.Length()+1 : header_width);
//--- Print the property value in the log with a header with the required width and indentation
//--- The value is set with 'digits' equal to 2 and the fact that the property is displayed in % is specified
PrintFormat("%*s%-*s%-.2f %%",indent,"",w,header,AccountInfoDouble(ACCOUNT_MARGIN_LEVEL));
/* Sample output:
Margin level: 0.00 %
*/
}
//+----------------------------------------------------------------------------+
//| Print a description of the collateral level, |
//| at which a deposit to an account is required (Margin Call), in the journal |
//+----------------------------------------------------------------------------+
void AccountMarginSOCallPrint(const uint header_width=0,const uint indent=0)
{
//--- Get the MarginCall level values, the number of decimal places for the symbol and its name
double margin_so_call=AccountInfoDouble(ACCOUNT_MARGIN_SO_CALL);
int digits=(int)AccountInfoInteger(ACCOUNT_CURRENCY_DIGITS);
string currency=AccountInfoString(ACCOUNT_CURRENCY);
//--- If the level of collateral for MarginCall is calculated as %,
//--- specify 'currency' in % rather than in account currency, while 'digits' will be equal to 2
if(AccountInfoInteger(ACCOUNT_MARGIN_SO_MODE)==ACCOUNT_STOPOUT_MODE_PERCENT)
{
currency="%";
digits=2;
}
//--- Define the header text and the width of the header field
//--- If the header width is passed to the function equal to zero, then the width will be the size of the header line + 1
string header="Margin Call:";
uint w=(header_width==0 ? header.Length()+1 : header_width);
//--- Print the property value in the log with a header with the required width and indentation
//--- To display the value correctly, replace the asterisk in the format line with the digits value obtained above
PrintFormat("%*s%-*s%-.*f %s",indent,"",w,header,digits,margin_so_call,currency);
/* Sample output:
Margin Call: 50.00 %
*/
}
//+------------------------------------------------------------------+
//| Print a description of the collateral level, |
//| upon reaching which |
//| the most loss-making position is forcefully closed (Stop Out) |
//+------------------------------------------------------------------+
void AccountMarginStopOutPrint(const uint header_width=0,const uint indent=0)
{
//--- Get the StopOut level values, the number of decimal places for the symbol and its name
double margin_so_so=AccountInfoDouble(ACCOUNT_MARGIN_SO_SO);
int digits=(int)AccountInfoInteger(ACCOUNT_CURRENCY_DIGITS);
string currency=AccountInfoString(ACCOUNT_CURRENCY);
//--- If the level of collateral for StopOut is calculated as %,
//--- specify 'currency' in % rather than in account currency, while 'digits' will be equal to 2
if(AccountInfoInteger(ACCOUNT_MARGIN_SO_MODE)==ACCOUNT_STOPOUT_MODE_PERCENT)
{
currency="%";
digits=2;
}
//--- Define the header text and the width of the header field
//--- If the header width is passed to the function equal to zero, then the width will be the size of the header line + 1
string header="Margin Stop Out:";
uint w=(header_width==0 ? header.Length()+1 : header_width);
//--- Print the property value in the log with a header with the required width and indentation
//--- To display the value correctly, replace the asterisk in the format line with the digits value obtained above
PrintFormat("%*s%-*s%-.*f %s",indent,"",w,header,digits,margin_so_so,currency);
/* Sample output:
Margin Stop Out: 30.00 %
*/
}
//+------------------------------------------------------------------+
//| Print a description of the funds |
//| reserved on the account for security |
//| of a guarantee amount for all pending orders |
//+------------------------------------------------------------------+
void AccountMarginInitialPrint(const uint header_width=0,const uint indent=0)
{
//--- Get the amount of the reserved funds, the number of decimal places for the symbol and its name
double margin_initial=AccountInfoDouble(ACCOUNT_MARGIN_INITIAL);
int digits=(int)AccountInfoInteger(ACCOUNT_CURRENCY_DIGITS);
string currency=AccountInfoString(ACCOUNT_CURRENCY);
//--- Define the header text and the width of the header field
//--- If the header width is passed to the function equal to zero, then the width will be the size of the header line + 1
string header="Margin initial:";
uint w=(header_width==0 ? header.Length()+1 : header_width);
//--- Print the property value in the log with a header with the required width and indentation
//--- To display the value correctly, replace the asterisk in the format line with the digits value for the symbol
PrintFormat("%*s%-*s%-.*f %-s",indent,"",w,header,digits,margin_initial,currency);
/* Sample output:
Margin initial: 0.00 USD
*/
}
//+------------------------------------------------------------------+
//| Print a description of the funds |
//| reserved on the account for security |
//| of the min amount of all open positions |
//+------------------------------------------------------------------+
void AccountMarginMaintenancePrint(const uint header_width=0,const uint indent=0)
{
//--- Get the amount of the reserved funds, the number of decimal places for the symbol and its name
double margin_maintenance=AccountInfoDouble(ACCOUNT_MARGIN_MAINTENANCE);
int digits=(int)AccountInfoInteger(ACCOUNT_CURRENCY_DIGITS);
string currency=AccountInfoString(ACCOUNT_CURRENCY);
//--- Define the header text and the width of the header field
//--- If the header width is passed to the function equal to zero, then the width will be the size of the header line + 1
string header="Margin maintenance:";
uint w=(header_width==0 ? header.Length()+1 : header_width);
//--- Print the property value in the log with a header with the required width and indentation
//--- To display the value correctly, replace the asterisk in the format line with the digits value for the symbol
PrintFormat("%*s%-*s%-.*f %-s",indent,"",w,header,digits,margin_maintenance,currency);
/* Sample output:
Margin maintenance: 0.00 USD
*/
}
//+----------------------------------------------------------------------------+
//| Print a description of the current asset size on the account in the journal|
//+----------------------------------------------------------------------------+
void AccountAssetsPrint(const uint header_width=0,const uint indent=0)
{
//--- Get the current asset size on the account, the number of decimal places for the symbol and its name
double assets=AccountInfoDouble(ACCOUNT_ASSETS);
int digits=(int)AccountInfoInteger(ACCOUNT_CURRENCY_DIGITS);
string currency=AccountInfoString(ACCOUNT_CURRENCY);
//--- Define the header text and the width of the header field
//--- If the header width is passed to the function equal to zero, then the width will be the size of the header line + 1
string header="Assets:";
uint w=(header_width==0 ? header.Length()+1 : header_width);
//--- Print the property value in the log with a header with the required width and indentation
//--- To display the value correctly, replace the asterisk in the format line with the digits value for the symbol
PrintFormat("%*s%-*s%-.*f %-s",indent,"",w,header,digits,assets,currency);
/* Sample output:
Assets: 0.00 USD
*/
}
//+------------------------------------------------------------------+
//| Print a description |
//| of the current liabilities on the account |
//+------------------------------------------------------------------+
void AccountLiabilitiesPrint(const uint header_width=0,const uint indent=0)
{
//--- Get the current liabilities on the account, the number of decimal places for the symbol and its name
double liabilities=AccountInfoDouble(ACCOUNT_LIABILITIES);
int digits=(int)AccountInfoInteger(ACCOUNT_CURRENCY_DIGITS);
string currency=AccountInfoString(ACCOUNT_CURRENCY);
//--- Define the header text and the width of the header field
//--- If the header width is passed to the function equal to zero, then the width will be the size of the header line + 1
string header="Liabilities:";
uint w=(header_width==0 ? header.Length()+1 : header_width);
//--- Print the property value in the log with a header with the required width and indentation
//--- To display the value correctly, replace the asterisk in the format line with the digits value for the symbol
PrintFormat("%*s%-*s%-.*f %-s",indent,"",w,header,digits,liabilities,currency);
/* Sample output:
Liabilities: 0.00 USD
*/
}
//+------------------------------------------------------------------+
//| Print a description |
//| of the current sum of blocked commissions on an account |
//+------------------------------------------------------------------+
void AccountComissionBlockedPrint(const uint header_width=0,const uint indent=0)
{
//--- Get the current blocked commissions on the account, the number of decimal places for the symbol and its name
double commission_blocked=AccountInfoDouble(ACCOUNT_COMMISSION_BLOCKED);
int digits=(int)AccountInfoInteger(ACCOUNT_CURRENCY_DIGITS);
string currency=AccountInfoString(ACCOUNT_CURRENCY);
//--- Define the header text and the width of the header field
//--- If the header width is passed to the function equal to zero, then the width will be the size of the header line + 1
string header="Comission blocked:";
uint w=(header_width==0 ? header.Length()+1 : header_width);
//--- Print the property value in the log with a header with the required width and indentation
//--- To display the value correctly, replace the asterisk in the format line with the digits value for the symbol
PrintFormat("%*s%-*s%-.*f %-s",indent,"",w,header,digits,commission_blocked,currency);
/* Sample output:
Comission blocked: 0.00 USD
*/
}
//+------------------------------------------------------------------+
//| Print a description of the client name into the journal |
//+------------------------------------------------------------------+
void AccountNamePrint(const uint header_width=0,const uint indent=0)
{
//--- Define the header text and the width of the header field
//--- If the header width is passed to the function equal to zero, then the width will be the size of the header line + 1
string header="Name:";
uint w=(header_width==0 ? header.Length()+1 : header_width);
//--- Print the property value in the log with a header with the required width and indentation
PrintFormat("%*s%-*s%-s",indent,"",w,header,AccountInfoString(ACCOUNT_NAME));
/* Sample output:
Name: Artem
*/
}
//+------------------------------------------------------------------+
//| Print a description of the trade server name into the journal |
//+------------------------------------------------------------------+
void AccountServerPrint(const uint header_width=0,const uint indent=0)
{
//--- Define the header text and the width of the header field
//--- If the header width is passed to the function equal to zero, then the width will be the size of the header line + 1
string header="Server:";
uint w=(header_width==0 ? header.Length()+1 : header_width);
//--- Print the property value in the log with a header with the required width and indentation
PrintFormat("%*s%-*s%-s",indent,"",w,header,AccountInfoString(ACCOUNT_SERVER));
/* Sample output:
Server: MetaQuotes-Demo
*/
}
//+------------------------------------------------------------------+
//| Print a description of a deposit currency name |
//+------------------------------------------------------------------+
void AccountCurrencyPrint(const uint header_width=0,const uint indent=0)
{
//--- Define the header text and the width of the header field
//--- If the header width is passed to the function equal to zero, then the width will be the size of the header line + 1
string header="Currency:";
uint w=(header_width==0 ? header.Length()+1 : header_width);
//--- Print the property value in the log with a header with the required width and indentation
PrintFormat("%*s%-*s%-s",indent,"",w,header,AccountInfoString(ACCOUNT_CURRENCY));
/* Sample output:
Currency: USD
*/
}
//+------------------------------------------------------------------+
//| Print a description of the company name, |
//| serving an account, into the journal |
//+------------------------------------------------------------------+
void AccountCompanyPrint(const uint header_width=0,const uint indent=0)
{
//--- Define the header text and the width of the header field
//--- If the header width is passed to the function equal to zero, then the width will be the size of the header line + 1
string header="Company:";
uint w=(header_width==0 ? header.Length()+1 : header_width);
//--- Print the property value in the log with a header with the required width and indentation
PrintFormat("%*s%-*s%-s",indent,"",w,header,AccountInfoString(ACCOUNT_COMPANY));
/* Sample output:
Company: MetaQuotes Software Corp.
*/
}
//+------------------------------------------------------------------+
//| Print account data into the journal |
//+------------------------------------------------------------------+
void AccountInfoPrint(const uint header_width=0,const uint indent=0)
{
//--- Display descriptions of integer properties according to their location in ENUM_ACCOUNT_INFO_INTEGER
Print("AccountInfoInteger properties:");
AccountLoginPrint(header_width,indent);
AccountTradeModePrint(header_width,indent);
AccountLeveragePrint(header_width,indent);
AccountLimitOrdersPrint(header_width,indent);
AccountMarginSOModePrint(header_width,indent);
AccountTradeAllowedPrint(header_width,indent);
AccountTradeExpertPrint(header_width,indent);
AccountMarginModePrint(header_width,indent);
AccountCurrencyDigitsPrint(header_width,indent);
AccountFIFOClosePrint(header_width,indent);
AccountHedgeAllowedPrint(header_width,indent);
//--- Display descriptions of real properties according to their location in ENUM_ACCOUNT_INFO_DOUBLE
Print("AccountInfoDouble properties:");
AccountBalancePrint(header_width,indent);
AccountCreditPrint(header_width,indent);
AccountProfitPrint(header_width,indent);
AccountEquityPrint(header_width,indent);
AccountMarginPrint(header_width,indent);
AccountMarginFreePrint(header_width,indent);
AccountMarginLevelPrint(header_width,indent);
AccountMarginSOCallPrint(header_width,indent);
AccountMarginStopOutPrint(header_width,indent);
AccountMarginInitialPrint(header_width,indent);
AccountMarginMaintenancePrint(header_width,indent);
AccountAssetsPrint(header_width,indent);
AccountLiabilitiesPrint(header_width,indent);
AccountComissionBlockedPrint(header_width,indent);
//--- Display descriptions of string properties according to their location in ENUM_ACCOUNT_INFO_STRING
Print("AccountInfoString properties:");
AccountNamePrint(header_width,indent);
AccountServerPrint(header_width,indent);
AccountCurrencyPrint(header_width,indent);
AccountCompanyPrint(header_width,indent);
}
//+------------------------------------------------------------------+