MQL4 Reference Global Variables of the Terminal GlobalVariableSet


Sets a new value for a global variable. If the variable does not exist, the system creates a new global variable.

datetime  GlobalVariableSet(
   string  name,      // Global variable name
   double  value      // Value to set



[in]  Global variable name.


[in]  The new numerical value.

Return Value

If successful, the function returns the last modification time, otherwise 0. For more details about the error, call GetLastError().


A global variable name should not exceed 63 characters. Characters not belonging to the current code page are not allowed (characters that cannot be converted from Unicode to ANSI are replaced with '?'). If programs are to be distributed among users with different code pages, we strongly recommend using Latin characters in global variable names.

Global variables exist in the client terminal during 4 weeks since their last use, then they are automatically deleted.