第十一章 账户信息

返回当前账户参数的函数。

函数 功能
AccountInfoDouble 返回相应账户属性的双精度值
AccountInfoInteger 返回相应账户属性的整数类型值(布尔,整型或者长整型)
AccountInfoString 返回相应账户属性的字符串类型值

# 11.1 AccountInfoDouble

返回相应账户属性的双精度值

double  AccountInfoDouble( 
   int  property_id      // 属性标识符 
   );
1
2
3

参数 property_id

[in] 属性标识符,取值范围是枚举型ENUM_ACCOUNT_INFO_DOUBLE其中之一。

返回值 双精度 类型值

示例:

void OnStart() 
  { 
//--- 显示AccountInfoDouble()函数中所有有效信息 
   printf("ACCOUNT_BALANCE =  %G",AccountInfoDouble(ACCOUNT_BALANCE)); // 帐户余额
   printf("ACCOUNT_CREDIT =  %G",AccountInfoDouble(ACCOUNT_CREDIT));  // 帐户信用额
   printf("ACCOUNT_PROFIT =  %G",AccountInfoDouble(ACCOUNT_PROFIT));  // 帐户盈亏
   printf("ACCOUNT_EQUITY =  %G",AccountInfoDouble(ACCOUNT_EQUITY)); // 帐户净值
   printf("ACCOUNT_MARGIN =  %G",AccountInfoDouble(ACCOUNT_MARGIN));  // 帐户已用保证金
   printf("ACCOUNT_FREEMARGIN =  %G",AccountInfoDouble(ACCOUNT_FREEMARGIN));// 帐户可用保证金
   printf("ACCOUNT_MARGIN_LEVEL =  %G",AccountInfoDouble(ACCOUNT_MARGIN_LEVEL));//保证金比例 
   printf("ACCOUNT_MARGIN_SO_CALL = %G",AccountInfoDouble(ACCOUNT_MARGIN_SO_CALL)); 
//追加保证金水平,依据建立的ACCOUNT_MARGIN_SO_MODE,以百分比形式 或 存入货币时期表示
   printf("ACCOUNT_MARGIN_SO_SO = %G",AccountInfoDouble(ACCOUNT_MARGIN_SO_SO)); 
//保证金停用水平,依据建立的ACCOUNT_MARGIN_SO_MODE,以百分比形式 或 存入货币时期表示
  }
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

相关参考 SymbolInfoDouble , SymbolInfoString , SymbolInfoInteger , PrintFormat

# 11.2 AccountInfoInteger

返回相应账户属性的整数类型值(布尔,整型或者长整型)

long  AccountInfoInteger( 
   int  property_id      // 属性标识符 
   );
1
2
3

参数 property_id

[in] 属性标识符,取值范围是枚举型 ENUM_ACCOUNT_INFO_INTEGER其中之一。

返回值 长整型 类型值

整数

属性可以是 布尔, 整型 或者 长整型 类型中的一个。

示例:

void OnStart() 
  { 
//--- 显示AccountInfoInteger()函数中所有有效信息 
   printf("ACCOUNT_LOGIN =  %d",AccountInfoInteger(ACCOUNT_LOGIN)); 
   printf("ACCOUNT_LEVERAGE =  %d",AccountInfoInteger(ACCOUNT_LEVERAGE)); 
   bool thisAccountTradeAllowed=AccountInfoInteger(ACCOUNT_TRADE_ALLOWED); 
   bool EATradeAllowed=AccountInfoInteger(ACCOUNT_TRADE_EXPERT); 
   ENUM_ACCOUNT_TRADE_MODE tradeMode=(ENUM_ACCOUNT_TRADE_MODE)AccountInfoInteger(ACCOUNT_TRADE_MODE); 
   ENUM_ACCOUNT_STOPOUT_MODE stopOutMode=(ENUM_ACCOUNT_STOPOUT_MODE)AccountInfoInteger(ACCOUNT_MARGIN_SO_MODE); 
  
//--- 通知完成交易操作的可能性 
   if(thisAccountTradeAllowed) 
      Print("Trade for this account is permitted"); 
   else 
      Print("Trade for this account is prohibited!"); 
  
//--- 找出是否可能通过EA交易进行这个账户的交易 
   if(EATradeAllowed) 
      Print("Trade by Expert Advisors is permitted for this account"); 
   else 
      Print("Trade by Expert Advisors is prohibited for this account!"); 
  
//--- 找出账户类型 
   switch(tradeMode) 
     { 
      case(ACCOUNT_TRADE_MODE_DEMO): 
         Print("This is a demo account"); 
         break; 
      case(ACCOUNT_TRADE_MODE_CONTEST): 
         Print("This is a competition account"); 
         break; 
      default:Print("This is a real account!"); 
     } 
  
//--- 找出止损离场水平设置模式 
   switch(stopOutMode) 
     { 
      case(ACCOUNT_STOPOUT_MODE_PERCENT): 
         Print("The StopOut level is specified percentage"); 
         break; 
      default:Print("The StopOut level is specified in monetary terms"); 
     } 
  }
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43

相关参考 账户信息

# 11.3 AccountInfoString

返回相应账户属性的字符串类型值

string  AccountInfoString( 
   int  property_id      // 属性标识符 
   );
1
2
3

参数 property_id

[in] 属性标识符,取值范围是枚举型 ENUM_ACCOUNT_INFO_STRING其中之一。

返回值 字符串 类型值

示例:

void OnStart() 
  { 
//--- 显示AccountInfoString()函数中所有有效信息 
   Print("The name of the broker = ",AccountInfoString(ACCOUNT_COMPANY)); 
   Print("Deposit currency = ",AccountInfoString(ACCOUNT_CURRENCY)); 
   Print("Client name = ",AccountInfoString(ACCOUNT_NAME)); 
   Print("The name of the trade server = ",AccountInfoString(ACCOUNT_SERVER)); 
  }
1
2
3
4
5
6
7
8

相关参考 账户信息