Discussing the article: "Introduction to MQL5 (Part 7): Beginner's Guide to Building Expert Advisors and Utilizing AI-Generated Code in MQL5"
Check out the new article: Introduction to MQL5 (Part 7): Beginner's Guide to Building Expert Advisors and Utilizing AI-Generated Code in MQL5.
Author: Israel Pelumi Abioye
Enlightening information, sir, thank you very much.
Hi! First of all thanks for this guide. I saw it earlier this week and went through it in search of quick and simple way to get to know MQL5, and your work has been useful. I have a very specific task to do, and now I'm looking for a way to complete it. I know my trading strategy, I know how I would like to streamline my trading with automation, I know what my algorithm / robot / EA has to do, and I've decomposed the whole process into simple steps, so I know how to translate it into MQL5. I want to program it myself (as opposed to pay somebody to do it or ask GPT to write it for me) because I want to know how to change the code whenever I need. I will try to write that down, but it seems that on multiple occasions I will have some specific questions. Is there a MQL5 forum? Or any other platform where users exchange thoughts? Much appreciated
OK, I see the MQL5 Forum, are there any others, anything noteworthy? Thanks!
I’ve been following your series and I must say the explanations are great and I’m looking forward to learning more from project based articles like this
Hello Oluwatosin, I look forward to sharing the next part with you. If you have any questions about the article, please feel free to reach out to me.
And why would a beginner's guide immediately teach them to code incorrectly?
Firstly, there are efficiency problems that will become noticeable as soon as a person starts writing something a bit more complex and realistic (but continues to use the same technique). On every tick, a StringToTime conversion of the same strings is called three times. It would be possible to clean up for the AI - make the conversion once in global variables:
input string Alarm1 = "00:00:00"; // Default value for first alarm input string Alarm2 = "00:00:00"; // Default value for second alarm input string Alarm3 = "00:00:00"; // Default value for third alarm input string Sound = "alert.wav"; // Default sound file // Define globals for persistent values datetime first_Alarm, second_Alarm, third_Alarm; int OnInit() { // Initialization function, executed once when the EA is launched // Make conversions only once per inputs first_Alarm = StringToTime(Alarm1); second_Alarm = StringToTime(Alarm2); third_Alarm = StringToTime(Alarm3); return 0; // Return 0 to indicate successful initialization } void OnTick() { // Get current local time datetime Time = TimeLocal(); // Check if current time matches any of the alarm times if(first_Alarm == Time || second_Alarm == Time || third_Alarm == Time) // another logical error here (see below) { // Play sound if any alarm time is reached PlaySound(Sound); } }
Secondly, there is no guarantee that the tick times will match the given alert times - most likely this code will miss them in the if-times. And even if we had made checks in the OnTimer handler, it would not guarantee that we would "catch" the necessary moments, because all events (OnTick, OnTimer, etc.) come from the queue, which is emptied as fast as possible, but may slow down if some other programme is doing heavy calculations. Therefore, the condition of checking the occurrence of alerts must be rewritten thoroughly, and at least without additional variables is not possible (in the future, it is suggested to remake alerts under classes, but of course not in this article).

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Check out the new article: Introduction to MQL5 (Part 7): Beginner's Guide to Building Expert Advisors and Utilizing AI-Generated Code in MQL5.
Discover the ultimate beginner's guide to building Expert Advisors (EAs) with MQL5 in our comprehensive article. Learn step-by-step how to construct EAs using pseudocode and harness the power of AI-generated code. Whether you're new to algorithmic trading or seeking to enhance your skills, this guide provides a clear path to creating effective EAs.
Learning all the ins and outs of MQL5 at once might be overwhelming. Instead, focusing on projects can make the learning process more manageable and enjoyable. Begin by mastering fundamental concepts like variables, loops, conditions, functions, and all the other basic concepts discussed in previous articles. Once you have a solid grasp of these basics, start exploring projects that interest you, such as building expert advisors or custom indicators. Every project you work on will present fresh difficulties and teach you priceless lessons. Through project-based learning, you can put your theoretical knowledge to use in real-world scenarios, which helps you better grasp the complexities of MQL5. You will progressively acquire the knowledge and abilities required to handle the complexity of MQL5 programming as you work on a variety of projects.
Accepting this method of learning gives you the ability to advance as a programmer in a steady and self-assured manner. Instead of feeling intimidated by MQL5's vastness, you'll tackle it project by project, gradually increasing your proficiency. Therefore, accept the project-based learning journey; it is the most reliable way to master MQL5. I decided to use project-based learning throughout this series because of its effectiveness. Instead of throwing you headfirst into MQL5 complexities, we'll focus on practical projects that allow you to learn through experience. Working on real-world projects will help you better understand the topic and develop useful skills that will improve your trading strategies.
We will begin with basic, beginner-friendly projects and work our way up to more complex ones. By following this methodical approach, you can ensure that you have a solid understanding of MQL5 programming before advancing to more complex topics. You'll pick up new skills and ideas with each project, which will help you gradually improve. The project we will be working on for this article will act as a hands-on example of the sequential procedure for generating Expert Advisors in MQL5. We'll also look at optimizing the benefits of AI-generated code in the context of MQL5.
Author: Israel Pelumi Abioye