MQL4 - automated forex trading   /  

Documentation

MQL4 Reference  Basics  Variables  Global variables

 
Use the opportunities of
MQL5 in MetaTrader 5
Study the new MQL5 language
Study the new MQL5 language.
Reference is already available

Global variables are defined at the same level as functions, i.e. they are not local in any block.

Example:

int GlobalFlag=10;   // global variable
int start()
  {
   ...
  }

Scope of global variables is the entire program. Global variables are accessible from all functions defined in the program. They are initialized with zero if no other initial value is explicitly defined. A global variable can be initialized only by a constant that corresponds with its type. Global variables can be initialized only once after program loading into client terminal memory.

Note: Variables declared at global level must not be mixed up with the Client Terminal global variables that can be accessed unsing the GlobalVariable...() functions.