#property copyright "Copyright 2025, MetaQuotes Ltd."
#property link ""
#property version "1.00"
#define GV_NAME "TestGlobalVariableSet"
#define GV_VALUE 1.23456
//+------------------------------------------------------------------+
//| 脚本程序起始函数 |
//+------------------------------------------------------------------+
void OnStart()
{
//--- 将新的 GV_VALUE 值设置到名为 GV_NAME 的客户端终端的全局变量
//--- 如果变量尚不存在,则将创建它
if(GlobalVariableSet(GV_NAME, GV_VALUE)==0)
{
Print("GlobalVariableSet() failed. Error ", GetLastError());
return;
}
//--- 检查结果并将其打印在日志中
double value=0;
if(GlobalVariableGet(GV_NAME, value))
{
PrintFormat("The global variable of the client terminal named \"%s\" is set to %.5f", GV_NAME, value);
}
/*
结果:
The global variable of the client terminal named "TestGlobalVariableSet" is set to 1.23456
*/
}
|