MQL5 Project Types Uses and Best Practice advice needed

 

Hi


I am trying to find out about all the project types supported by meta editor, just came across services which was new to me even though been coding mql5 over a year.

So i am curious about Library project too. Whats it for. Looked in a library project folder and saw it had only mql5 program.

Please explain what is mql library project for and when is it useful.


Also in general give tip/advice as to what project type is best suited to what, for example, indicator project is obvious, expert project is obvious.


But when you come to the meaning and uses of Script/Service and library  projects , i would like to know what the pros use these for. 

cheers

 
JamesWoods: Hi I am trying to find out about all the project types supported by meta editor, just came across services which was new to me even though been coding mql5 over a year. So i am curious about Library project too. Whats it for. Looked in a library project folder and saw it had only mql5 program. Please explain what is mql library project for and when is it useful. Also in general give tip/advice as to what project type is best suited to what, for example, indicator project is obvious, expert project is obvious. But when you come to the meaning and uses of Script/Service and library  projects , i would like to know what the pros use these for. 

cheers

  1. There are no "best practices" for MQL, because MetaQuotes never provided such conventions. Everyone just does what they please based on their own experience, whether it be coding style, naming conventions, or what-ever.
  2. Scripts are best used for one-off tasks. You attach it to a chart, it carries out a task and then terminates.
  3. Services were introduced much later in the MQL5 development, but MetaQuotes did nothing more for it. No explanation, no examples, nothing. The annoying thing about it, is that it has no event-handling features and uses the same entry point as a Script, which is basically the same as running a one-off task and terminating instead of what one would expect of a true service like program of running 24/7 and responding to events. So, to use it, you have to create an endless loop, to prevent it terminating and keep it running, and then use indirect methods to monitor states, to carry out tasks and then communicate with other programs (which is a pain to implement). In other words, MetaQuotes botched it.
  4. Libraries are the same concept as for any other computer languages. Given that MQL is based on C/C++, the best is for you to read up on the concept for C/C++ and you will understand what it does for MQL. Basically it is a way of compartmentalising code so that it can be reused in different projects. Libraries can be pre-compiled or included as source code at compile time. The advantages and disadvantages of both types are the same as when done so with C/C++. So, researching C/C++ libraries will get you to understand the concept here too.
 
thank you very much for the detailed explanation, much appreciated.
 

Maybe this helps you:

Introduction to MQL5: How to write simple Expert Advisor and Custom Indicator

https://www.mql5.com/en/articles/35
Tips from a professional programmer (Part  I): Code storing, debugging and compiling. Working with projects and logs
https://www.mql5.com/en/articles/9266
Tips from a professional programmer (Part II): Storing and exchanging parameters between an Expert Advisor, scripts and external programs
https://www.mql5.com/en/articles/9327
Tips from a professional programmer (Part III): Logging. Connecting to the Seq log collection and analysis system
https://www.mql5.com/en/articles/10475

There is almost nothing that has not been programmed for MT4/5 already. So first search instead of inventing the wheel the tenth time...

Introduction to MQL5: How to write simple Expert Advisor and Custom Indicator
Introduction to MQL5: How to write simple Expert Advisor and Custom Indicator
  • www.mql5.com
MetaQuotes Programming Language 5 (MQL5), included in MetaTrader 5 Client Terminal, has many new possibilities and higher performance, compared to MQL4. This article will help you to get acquainted with this new programming language. The simple examples of how to write an Expert Advisor and Custom Indicator are presented in this article. We will also consider some details of MQL5 language, that are necessary to understand these examples.