#property copyright "Copyright 2025, MetaQuotes Ltd."
#property link ""
#property version "1.00"
#define GV_NAME "TestGlobalVariableSet"
#define GV_VALUE 1.23456
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
//--- définit la nouvelle valeur GV_VALUE sur la variable globale du terminal client nommée GV_NAME
//--- si la variable n'existe pas encore, elle sera créée
if(GlobalVariableSet(GV_NAME, GV_VALUE)==0)
{
Print("GlobalVariableSet() failed. Error ", GetLastError());
return;
}
//--- vérifie le résultat et l'imprime dans le journal
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);
}
/*
résultat :
The global variable of the client terminal named "TestGlobalVariableSet" is set to 1.23456
*/
}
|