MQL4 Book  Programming in MQL4

Practical Programming in MQL4



This present second part of the book considers the following issues: the order of performing trade operations, the principles of coding and use of simple scripts, Expert Advisors and indicators, as well as standard functions often used in programming in MQL4. All sections contain some examples of programs that are ready to use, but limited application field.

The section named Creation of Normal Programs gives an example you can use as a basis for designing your own simple Expert Advisor to be used in real trading.

All trading criteria given below are used for educational purposes and should not be considered as guidelines in trading on real accounts.

When programming trade operations, you should consider the requirements and limitations related to the characteristics of orders and rules accepted in your dealing center, as well as the special features of trade order execution technology. The section provides the detailed description of the order of performing trades and contains a lot of examples that explain the purposes of all trade functions used to form trade orders. The section contains some ready-made scripts intended for restricted application.

After the programmer has mastered programming of trade operations, he or she can start creating simple programs. The section deals with the general principles of creating a simple Expert Advisor and a simple custom indicator, as well as the order of sharing an Expert Advisor with various indicators. Particularly, the section describes the order of data transfer from a custom indicator into an EA. It also gives some examples of simple programs ready to be used in trading practice.

Totally, MQL4 counts over 220 standard functions, not including the functions of technical indicators. It would be rather difficult to describe in this book and give examples of each function, considering their great amount. Some functions that require detailed explanations have already been considered in the preceding sections. In this present section, we consider the most frequently used standard functions and give some examples of how to use them in programs. At the end of each subsection, we provide the full list of functions of a certain category and their brief description.

As a rule, once having practiced the coding of some simple applications in MQL4, the programmer goes to a more sophisticated project: He or she creates a convenient program intended for practical use. In some cases, simple programs do not satisfy the needs of a trading programmer for at least two reasons:

1. The limited functionality of simple programs cannot completely provide the trader with all necessary information and trading tools, which makes the application of such programs less efficient.

2. The code imperfection of simple programs makes it difficult to further upgrade them in order to increase their services.

In this present section, we represent one of possible realization versions of a trading Expert Advisor that can be used as a basis for creation of your own project.