MetaEditor Help

Structure of Application Files

Structure of Application Files

The files should be arranged carefully when developing MQL4/MQL5 applications. It is recommended to place files related to a particular application into a separate directory. The subfolders that are created in the folders of Expert Advisors, indicators, etc. will be further recognized by the "Navigator" windows of the MetaEditor and the client terminal.

Projects

All files that refer to the "Tetris" project are stored in a separate folder.

Creation of Folders and Placement of Files

Subfolders can be created both by using the standard functions of the operating system explorer or through the "Navigator" window. In order to create a subfolder one should choose the catalog in which it is necessary to  create a subfolder, and execute the "New Folder" command in the context menu or press the "Insert" key. After that it is necessary to specify the name of the folder and press the "Enter" key or click with the mouse anywhere outside the name field.

Once the subfolder is created different files can be moved to it. This action can also be done both via the explorer and via the navigator. All you need is to select a necessary file and move it to the end folder using the Drag'n'Drop technology.

Peculiarities of Files Placement

Each executable file (*.EX4 or *.EX5) that is obtained as a result of compilation is placed to the same folder where the main file of the source code of the program (*.MQ4 or *.MQ5) is located.

If different files (*.MQH) are included to the code of a program it is necessary to consider their location. If an included file is located in the same folder as the main one then the following construction must be used:

#include "file_name.mqh"

If it is necessary to search the include file in the directory where the permanent files of the terminal (executable file, libraries, etc.) are stored, the construction must be the following:

#include <file_name.mqh>

Also there is a possibility to specify a relative path to the file:

#include "../folder_name/file_name.mqh"

All the changes made to the structure of files and folders using the explorer of the operating system are automatically displayed in the "Navigator" window. If the changes are not displayed immediately for some reasons, one can execute the "Refresh" command in the context menu of the navigator or press the "F5" key.

Main File of an Application

The main file of an application is the MQ4 or MQ5 file that contains the so-called entry points, the set of predefined functions that initialize the working of application (for example, OnInit(), OnStart(), OnChartEvent(), etc.). Other MQ4, MQ5 and MQH files can also be included in the main file. In order to obtain an executable file (*.EX4 or *.EX5) one should compile the main MQ4 or MQ5 file exactly.