MQL5 programming language
- 1. Fundamentals of the MQL5 programming language
- 2. How to use the MQL5 language
- 3. How to write an Expert Advisor in MQL5
- 4. Community of traders and forum
- 5. Trading signals with the help of Expert Advisors posted on the MQL5 website
- 6. Useful Materials
- 7. Conclusions
- 8. reviews
Fundamentals of the MQL5 programming language
MetaQuotes Language 5 (MQL5) is a programming language for automated trading applications developed by MetaQuotes Software Corp. The syntax of MQL5 is similar to C++ with some exceptions.
Technical indicators are written in the language of MQL5, trading robots, Advisors and other applications for trading on the forex market. MQL5 programs in the object-oriented programming (OOP) format. A special environment MetaEditor and MQL5 Storage are created for MQL5 program.
The basic components of the language are the same as in other programming languages, and there are a number of specific features. Data in the MQL5 language can be of different types - integers, boolean, literals, strings, date, time, enumerations, and others. Complex data types (abstract data types) include structures and classes.
Different operations and expressions are possible in MQL5. Operators in MQL5 are algorithms of problem solving, which form the body of the problem. Program code is written with functions.
The library of user functions is intended for storage and distribution of blocks of user programs. Included file is the source code of user files, - EAs, scripts, libraries at compile time.
The MQL5 language has a specific subsystem of the compiler, which carries out the preliminary preparation of the source code before compilation. Using the preprocessor, functions are introduced into MQL5 programs, constants are declared, files are inserted, etc.
How to use the MQL5 language
MQL5 allows creating interactive programs tailored to the individual needs of any trader.
There are three main types of programs in MQL5 - script, indicator and Expert Advisor. One script runs once on the price chart, and stops after performing its tasks. Also a script can run, performing a single operation, in an infinite loop format, until it is stopped by the trader.
There can be many indicators on the chart, they work until they are stopped. Indicators calculate values based on price data contained in indicator buffers.
Advisors and robots are designed to automate trading operations, and can also be used to analyze the current situation in the market and perform other tasks.
The MQL5 language allows you to create your own modules for building trading robots through the MQL5 Wizard.
Programs in MQL5 are created using the event-driven model. They react to any event - price change, implementation of an order, timeframe change, etc.
How to write an Expert Advisor in MQL5
The MQL5 language contains all the necessary elements for writing Expert Advisors. In general terms, step by step it looks like this. Start MetaEditor through the trading interface of MT5 (picture 1) (it is loaded on your computer simultaneously with the trading service), for example, by clicking on the appropriate icon or by pressing F4 on your keyboard. The editor will appear (fig. 2):
In MetaEditor click the "Create" button and the corresponding window with the list of applications that can be created in the editor appears (fig. 3)
In this window you can choose between "Expert Advisor (template)" and "Expert Advisor (generate)". We choose and click on the "Next" button. In both cases a window will appear in which you should first give a name to the created Expert Advisor (Fig. 4) and you can write a link to your website, email in the "Name" field:
In the version with the template, by clicking on the "Add" button, you must select the parameters that the Expert Advisor will have (Fig. 5). The selected parameters can also be deleted by clicking on the appropriate button.
Already at this stage, the trader is required to have strong skills and programming and understanding of trading.
After selecting the option, click "Next", a window will appear, in which you will be prompted to select event handlers for the Expert Advisor (Fig. 6).
Continuing to create the Expert Advisor by clicking "Next", you will need to select more test event handlers and click "Done", after which a code template will appear (Fig. 7) with the parameters set by the trader.
Additional parameters are added to the code template according to the rules, which are specified in the detailed MQL5 language manual.
If after calling the MQL Wizard the "Expert Advisor (Generate)" function is selected, then step by step select the name (the symbols and timeframe are already specified in the parameters), add parameters for signals, add trading parameters, money management parameters (Fig. 8) and after clicking "Done" the code template will appear.
The editor also has services for testing and debugging the Expert Advisor, the work of which should be studied in the detailed instructions for the MQL5 language.
Community of traders and forum
All questions on the development and use of MQL5 are addressed in the community pages. In particular, https://www.mql5.com/ru/forum - The forum of traders, where you can find answers to most, if not all, of your questions.
The problem is that the forum is very large and it takes time to find the information you need. Questions from those who are just beginning to learn the language are addressed at this address: https://www.mql5.com/ru/forum/6343
There is also a library of articles about the language at the MQL5 website: https://www.mql5.com/ru/articles
But the best way to start learning a language is with the MQL5 reference book. https://www.mql5.com/ru/docs
In the MQL5 community, you can simply buy an Expert Advisor, ask to develop a robot, or offer your own EA for sale.
Trading signals with the help of Expert Advisors posted on the MQL5 website
The MQL5 website has a signals section for MetaTrader 5 for automated trading https://www.mql5.com/ru/signals. First of all, you should read the rules of the section.
On the site, you can register as a subscriber or as a signal seller. Subscription can be paid or free, and it allows you to apply trading signals on your own trading account. Each member of MQL5.community can provide their signal for free to other traders.
A member of the community can also sell signals if he accepts the terms of the Trading Signals Broadcasting Agreement and goes through a special registration procedure.
The user selects signals according to the criteria of maximum profitability, reliability, rating and so on. He can also select a new signal.
The system also selects signals according to user requirements for certain Forex brokers or search for signals by their author. It is worth noting that the service indicates a disclaimer of responsibility for the signals (Fig. 9) - the trader subscribes to the signals only at his own risk.
Which Advisor to choose
MQL5.community offers a wide range of Expert Advisors and trading robots with source codes: https://www.mql5.com/ru/code/mt5/experts. The site has two sections - EAs designed for MetaTrader5 and EAs designed for MetaTrader4. In the service you can also download indicators, scripts and libraries.
The Expert Advisor can be selected according to a simplified rating: to the right of the list of Expert Advisors there are two sections: the latest/best. The best ones are selected according to the users' evaluation. In addition, the rating of robots is indicated to the right of each of them with asterisks from 1 to 5. By the way, the user can add his own code to the list for users to download.
But EA can be ordered and to your requirements, for this there is a freelance market: https://www.mql5.com/ru/job, or just buy (or download for free) from the trading robot store: https://www.mql5.com/ru/market. There you can also put the robot for sale.
When buying an Expert Advisor, it is better not to limit yourself to the evaluation of users, which is indicated by the stars under each robot, but to ask for feedback and, in general, do not be lazy to study the features of the robot - whether it is worth the money for which it is sold (many robots are very expensive).
There are a lot of materials on programming in MQL5 on the Internet. These are step-by-step detailed guides to creating Expert Advisors and Expert Advisors from experienced programmers. Most of the explanatory and training materials can be found on the MQL5 website.
Quite a large selection of books on the subject, in particular, "Tutorial (guide) to the MQL5 programming language" by T. Mashnina (download for free), there are free video courses and numerous lessons by enthusiasts on the traders' forums. The materials are not only for beginners, but also for users who want to deepen their knowledge.
You have to keep in mind that any lessons get outdated, the language itself is constantly evolving and improving, as well as the platform on which it is applied and look for better training materials relevant - and in this there is already some difficulty, most materials are on the network for more than one year.
By the way, since MQL5 language is close to C++ language, many experienced users recommend to read books on C++, such as Bronson G.J., A First Book of C++. A First Book of C++, Stephan R. Davis "C++ for Dummies", S. Lippman "C++ for Beginners", B.N. Pakhomov "C/C++ and MS Visual C++ 2010 for Beginners" and others - all these books can be easily downloaded from the Internet. Mastering MQL5 will not be difficult, - after mastering C++.
The MQL5 language is a well-proven tool for writing trading programs with great possibilities. At the same time, you can find statements on the Internet that MQL5 is easy to learn and can be mastered "from scratch" even in a month. There are very big doubts about such statements.
It is probably possible to learn the syntax in a short time, but it will take a long time to program, especially complex applications. And it takes even longer to learn how to program truly valuable applications.
It should also be noted that the most difficult and time-consuming option is self-learning programming from books and video courses without an experienced programmer, who can advise the important points.
Another question, which is more important, is whether it is necessary to learn. Learning to program can make sense if you intend to develop and sell the same trading robots and Expert Advisors later on.
But if it is just a question of optimizing trading, it might be more effective to be able to evaluate already developed applications and choose the ones that are really useful.
- 10 June 2021 at 17:25
- 1 April 2019 at 10:13
24 January 2019 at 09:03
- 12 July 2019 at 09:47
- 2 March 2020 at 17:09