MetaEditor Hilfe

Example of Program Creation

Example of Program Creation

The example of creation of a simple script using MetaEditor will be described step by step in this section.

Creation of Program by Template

It is necessary to start the MQL4/MQL5 Wizard by executing the "New New" command in the "File" menu or in the "Standard" toolbar.

Creation of Script Via Wizard

After that one should choose the "Script" option and press the "Next" button.

Specification of Script Parameters

At this stage one should specify the name of the script and the information about its author and the website address. Once the "Done" button is pressed, the new file of the script will be created in the "Scripts" folder. Further it is necessary to create a separate folder for the script. To do that one should execute the "New Folder" command in the context menu of the "Navigator" window.

Creation of Folder

The next step is to move the created file of the script (ScriptExample.mq5) to the new folder using the Drag'n'Drop technology. One can start writing the source code as soon as the file is moved:

Source Code Writing

As soon as the source code is written it is necessary to save and compile it using the "Save Save" and "Compile Compile" in the "File" menu or in the"Standard" toolbar. The result of compilation will be displayed at the "Errors" tab of the "Toolbox" window:

Compilation of Script

The executable file of the script ScriptExampe.ex5 will be created as a result of compilation as well, it will be placed to the same folder as the source file.

One can debug the script if it is necessary. In order to do it one should place a breakpoint at the necessary line by double clicking on the grey field located to the left of the line. Then it is necessary to execute the "Start Debugging Start Debugging" command in the "Debug" menu:

Start Debugging

As soon as it is done the script will be attached to the temporary chart in the client terminal, and the result of script execution will be displayed at the journal — the "Hello World!!!" inscription:

Debugging of Script

In order to finish debugging one should execute the "Stop Debugging Stop Debugging" command in the "Debug" menu.

As soon as all the necessary steps are passed the script can be used in the client terminal. To open it one should execute the "Trading Terminal Trading Terminal" command in the "Tools" menu or use the "F4" key.