GlobalVariablesTotal

返回客户端所有全局变量的数量。

int  GlobalVariablesTotal();

返回值

全局变量数量。

注释

全局变量在客户端保存自最后使用的四周,然后自动删除。调用全局变量不仅需要设立新值,也需要读取全局变量的值。

 

示例:

#property copyright "Copyright 2025, MetaQuotes Ltd."
#property link      "https://www.mql5.com"
#property version   "1.00"
//+------------------------------------------------------------------+
//| 脚本程序起始函数                                                   |
//+------------------------------------------------------------------+
void OnStart()
  {
//--- 获取并记录客户端的全局变量总数
   int total=GlobalVariablesTotal();
   Print("Total number of global variables of the client terminal: "total);
   /*
  结果:
   Total number of global variables of the client terminal20
   */
  }