Creating a global variable in MetaTrader 5

Global Variables

Global variables allow you to quickly exchange small amounts of data between different experts in the platform and ensure that several experts can work simultaneously without conflicts.
 
Among the distinguishing features of global variables are the following:
  • their existence does not depend on experts, unlike variables that are declared in the source texts of experts (even if these variables are declared on at the global level);
  • The values of global variables are retained even after the platform is closed and restarted.;
  • Any floating point number can be used as a global variable.;
  • access to global variables is maintained for 4 weeks after the last interaction with the expert or change of the variable.
 
In order to work with global variables in the platform, you can use one of two ways:
  1. go to the Tools menu and select "Global Variables";
  2. press the F3 key.
 
Global Variables
On this tab you will find information about global variables:
 
  • variable name — the name of the global variable;
  • The value of a variable is a floating—point number that is assigned to a global variable;
  • Time — the date and time when the global variable was last changed or called.
 
To create a new global variable, follow these steps:
 
  1. Click the "Add" button, which is located on the right panel.
  2. A new row will appear in the table.
  3. Specify the name and value of the new global variable in the line.
 
To make changes to already created global variables, do the following:
 
  1. Double-click on the desired cell in the table.
  2. Make the necessary edits.
  3. When you edit a variable, the time of its last call is updated automatically.
 
To delete a global variable:
 
  1. Select the variable you want to delete.
  2. Click the "Delete" button.