The client terminal recognizes program types by their location in subordinate directories.
All application programs are concentrated in the directory ClientTerminal_folder \experts.
Expert Advisors, scripts and custom indicators that a trader is going to use in his practical work should be located in corresponding directories (see Fig. 24). Expert Advisors are located right in the directory ClientTerminal_folder \experts, scripts and indicators - in subdirectories ClientTerminal_folder\experts\scripts and ClientTerminal_folder \experts\indicators.
Fig. 24. Directory for storing files, created by a user.
A user can create other directories for storing some files. However, the usage of ready programs located in such directories is not provided in the client terminal.
In MQL4 there are three types of files that carry a program code: mq4, ex4 and mqh.
Files of mq4 type represent a program source code. Files of this type contain source texts of all types of programs (Expert Advisors, scripts, indicators). For the creation of program codes MetaEditor is used. When a code is fully or partially created, it can be saved and later opened for modification. Files of mq4 type cannot be used for execution in the client terminal. For starting a program's execution, it should be first compiled. As a result of a source code compilation, a file of the same name with the extension ex4 is created.
A file of ex4 type is a compiled program ready for practical use in the client terminal. Files of this type cannot be edited. If a program needs to be modified, this should be done in its source code (a file of mq4 type): it should be edited and then compiled again. The ex4 file name does not point to the program type - whether it is a script, an Expert Advisor or an indicator. Files with ex4 extension can be used as library files.
Files of mqh type are include files. It is a source text of frequently used blocks of custom programs. Such files can be included into source texts of Expert Advisors, scripts and indicators at the stage of compilation. Usually include files contain the description of imported functions (as example, see files stdlib.mqh or WinUser32.mqh) or the description of common constants and variables (stderror.mqh or WinUser.mqh). As a rule, files of mqh type are stored in the directory ClientTerminal_folder\experts\include.
Include files are called so, because they are usually "included" at the stage of compilation to the main source file using the #include directive. Despite the fact that files of mqh type can contain a program source code and can be compiled by MetaEditor, they are not independent and self-contained, i.e. they do not require compilation for getting executable files of ex4 type. As include files, one can use mq4 files that should be stored in ClientTerminal_folder\experts\include .
Sections "Expert Advisors", "Custom Indicators" and "Scripts" of the client terminal navigator will show only the names of files that have the extension ex4 and are located in the corresponding folder. Files compiled in older versions of MetaEditor cannot be started and are displayed in a grey color.
There are other types of files that do not make a complete program, but are used in the creation of application programs. For example, a program can be created out of several separate files or using a library created earlier. A user can create libraries of custom functions intended for storing frequently used blocks of user programs. It is recommended to store libraries in the directory ClientTerminal_folder\experts\libraries. Files of mq4 and ex4 can be used as library files. Libraries cannot start by themselves. Using include files is more preferable than using libraries because of additional consumption of computer resources at library function calls.
In the first part of the book "Programming in MQL4" we will analyze mq4 files of source texts and compiled ex4 files.