Discussing the article: "Understanding functions in MQL5 with applications"

 

Check out the new article: Understanding functions in MQL5 with applications.

Functions are critical things in any programming language, it helps developers apply the concept of (DRY) which means do not repeat yourself, and many other benefits. In this article, you will find much more information about functions and how we can create our own functions in MQL5 with simple applications that can be used or called in any system you have to enrich your trading system without complicating things.

Let's say that we need the software to perform the task of closing all open orders if the equity reached a maximum drawdown and we need to perform this task in many parts of the software, it will be better here to create a function and include all needed code or logic to perform this task then call this function in other parts but it will be not good or overwhelmed to write and repeat the same code in many parts to do the task.

If you are asking why we need to use this type of function, the answer to this question will lead us to learn the features of using user-defined functions and the following is for that:

  • It helps to apply the concept of DRY (do not repeat yourself): By using user-defined functions will help us to not repeat the same code over and over but we will create a function that can perform our task one time and then call it in any suitable part in software.
  • Reusability: After creating our function we can reuse it at any time.
  • It helps to apply the concept of divide and conquer: When we create software the code can be complex to solve a problem but if we divide the big problem into small ones and solve each one through functions this can be very helpful to achieve our objective in solving the big problem.
  • It helps that the code is more readable and understandable: When we use functions, it helps that it makes our code readable as it became more organized as it has functions and everyone handles a specific problem and has a specific task.
  • It helps to apply the concept of abstraction: Using functions gives a method to abstract our code because if we do not use them we may find that we need to write more lines of code than using functions.
  • It helps to apply the concept of encapsulation: When we use functions, it allows us to secure and manage our code and data more than if we did not use them.
  • It improves the debugging process: When we use functions, it helps to improve errors exploring and solving them much easier.

According to what we mentioned about features of using functions, we can easily find how much will be beneficial when we use these user-defined functions in our software.

Author: Mohamed Abdelmaaboud

 

helpful 

many thanks

hope to find the same for pointers and related issues

 
Mohamed Hassan Mohamed Hassan Alsherbiny #:

helpful 

many thanks

hope to find the same for pointers and related issues

Thanks for your kind comment.

I'll try to do that.