Robot catalog

What is a global variable?

Monday, 3 July 2017 08:57

If you run several advisors in MetaTrader 4 platform simultaneously, you will probably need to build a particular exchange of information between them. The global variables were created for it.

Global variables are used for quick transfer of small amounts of data between advisors as well as for providing conflict-free simultaneous operation of several advisors in the platform. Global variables exist independently (including those declared on the global level) in their source texts; they are saved between platform runs. Any floating point number can serve as a global variable; they are available within four weeks since the last operation or modification.

It is useful to know that the global variable of the client terminal and the global variable are different variables with similar names. The scope of global variables is one program in which this variable is declared, and the scope of global variables of the client terminal is all programs that are simultaneously run on the MT4 platform. These are quite distinctive differences.

To manage global variables click on the “Global Variables” in the "Tools" menu or press F3.