Better Programmer (Part 02): Stop doing these 5 things to become a successful MQL5 programmer

Omega J Msigwa | 6 August, 2021

Introduction


I use the word noob a lot in this article series to describe someone with less experience in MQL5 programming (don't get offended by that). It makes it easy to relate to. This doesn't mean that this article is only for noobs. Absolutely not! This is for everyone, regardless of the programming experience you have, because what makes you a noob or not is your coding habits and behaviors... not years of coding.

noobs_vs_professional coder 


The first article is here for those who haven't read it, so let me continue this mission to turn noobs to professionals.

01: Stop thinking you are better than others


So you've been coding for a while now and managed to create several great EAs and indicators for yourself and your customers on the freelance, codebase or something, so now you are good. It's good if you notice your progress and use that to increase your confidence to tackle huge challenges to improve more and not use it in an arrogance manner. Keep in mind that:

"An arrogant person considers himself perfect. This is the chief harm of ignorance. It interferes with a person's main task in life — becoming a better person."

— Leo Tolstoy

It's so easy to feel super smart and to criticize someone else's code without fully understanding it, or rushing to respond to their questions in the forum in offensive way to show how you are a badass coder and that person who just asked the question on the forum sucks at coding. I have seen a lot of times where people ask a question on the forum and they post their code and describe what they have tried before that is not working. Then suddenly a noob pops up with an explanation that this person is terribly wrong, without offering a solution or offering a solution (code in this case) less accurate than the code that was provided by the topic starter in the first place. OMG!


noobs answer


Instead of jumping straight to describing that the topic starter is terribly wrong then providing code that's not even in the right format, why not start with explanations on why there is a problem than explain what needs to be done in a detailed and clear way?

There is no fun being in the forum starting topics. I'm sure anybody who starts a topic on the forum already knows that they are wrong in someway and that's why they are not getting the desired results. Chances are high that the topic starter is a noob and they have been struggling with a problem for hours if not days (I know how it feels) .

Even jumping straight and dragging down non-explained or unclear code won't fix their problem in the long run. It's like giving pain killer to someone who needs a surgery. By doing this you will be teaching noobs the worst habit that I first described in the first article of this series—the Copy and Paste Habit—by making them think like "so its working this way here, I have a problem I post my code in the forum and I'll be given the code to replace the bad one … this is cool!" 

Always make sure that you explain the solution in a clear, detailed and beginner friendly way because most of them are. Also keep in mind there is a lot of noobs who will stumble upon the same problem in the future so they will probably need a solution from that topic. 

Apart from that example, thinking we are better than other causes wrong answers in the forum and false reviews on the codebase. By thinking you are better than the author of that particular system just because you see the code is not much complicated the way you think it should be or the way that you like and familiar with, we tend to refuse to fully understand how and why the code was written in the first place, hence leading to ignorance.

02: Avoid having the fixed mindset 


Stop thinking that there is no way that you can become good in a particular area.

"Insanity is doing the same thing over and over again and expecting different results."
—Albert Einstein


Don't be stuck into making the same type of Expert Advisors, indicators, scripts or whatever else. This destroys your creativity and keeps stuck in the same place. Thinking you were not born to be good in a particular programming area just because its too complex or tough is self limiting. Just know that your brain is flexible. It's designed to adapt and change to new stimuli. The more you challenge it the better you will become at that particular subject. You can become good at:

and everything you can think of. But you have to put enough work to make it happen.

Yes, of course, there is no holy grail EA (I haven't seen it myself) or indicator so far, but that should not stop you from improving your systems to the best they can be by changing your approaches.

On my early days of MQL5 programming, I was so scared when I downloaded something like simple moving average from the CodeBase and found out the code was over 1000 lines or more  because that was the first thing that I was looking in the code. I thought that was too complex. I think its the same issue that noobs are facing.

I'm a bit experienced now. All I can say is that it might be hard now but that's ok. Everything in life is like that in the beginning but it will be easy, only time and effort will tell.

03: Stop writing code that will be used someday


So you have been creating your EA(s) or indicator(s) on your project. You now have too many lines of code right. Without much attention and careful re-reading your code, there is a big chance that there is unwanted and unused code.


"Those who have knowledge don't predict. Those who predict don't have knowledge."
— Lao Tzu

Always less code means 

  • Fewer bugs
  • Less time to read 
  • Easy to compile 
  • Fast to review 
  • Fast shipping
  • Maintainable 
  • Easy to debug
Don't spend much time writing code that is not needed right now.

I hope that at least once in MQL5 programming you have seen something like this, from someone's else code

int MathRandInt(int mini, int maxi)
  {
   double f   = (MathRand() / 32768.0);
   return mini + (int)(f * (maxi - mini));
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void chart_random()
 {
//---
  string background[]={"clrBlack"};
  string bulls[]={"clrGreen","clrDeepPink","clrYellow","clrCrimson","clrMediumBlue","clrKhaki","clrYellow"};
  string bears[]={"clrDarkViolet","clrDarkOrange","clrIndigo","clrWhite","clrSilver","clrMediumPurple","clrBlue"};
//---
   ChartSetInteger(ChartID(), CHART_MODE, CHART_CANDLES);
   ChartSetInteger(ChartID(), CHART_SHOW_GRID, false);
   ChartSetInteger(ChartID(), CHART_AUTOSCROLL, true);
   ChartSetInteger(ChartID(), CHART_SHOW_PERIOD_SEP, true);
   ChartSetInteger(ChartID(), CHART_SHIFT, true);
   ChartSetInteger(ChartID(), CHART_SHOW_ASK_LINE, true);
   ChartSetInteger(ChartID(), CHART_SHOW_BID_LINE, true);
   ChartSetInteger(ChartID(), CHART_COLOR_ASK, clrBlue);
   ChartSetInteger(ChartID(), CHART_COLOR_BID, clrCrimson);
   ChartSetInteger(ChartID(), CHART_SCALE, 2);
   ChartSetInteger(ChartID(), CHART_FOREGROUND, true);
   ChartSetInteger(ChartID(), CHART_COLOR_FOREGROUND,clrWhite);
//---
/*
 for (int i=0; i<ArraySize(background); i++){
     int maxi=ArraySize(background);
     int random_=MathRandInt(0,maxi);
    ChartSetInteger(0,CHART_COLOR_BACKGROUND,StringToColor(background[random_]));
    }
  for (int i=0; i<ArraySize(bulls); i++){
    ChartSetInteger(0,CHART_COLOR_CANDLE_BULL,StringToColor(bulls[MathRandInt(0,ArraySize(bulls))]));
    ChartSetInteger(0,CHART_COLOR_CHART_UP,StringToColor(bulls[MathRandInt(0,ArraySize(bulls))]));
   }
  for (int i=0; i<ArraySize(bears); i++){
    ChartSetInteger(0,CHART_COLOR_CANDLE_BEAR,StringToColor(bears[MathRandInt(0,ArraySize(bears))]));
    ChartSetInteger(0,CHART_COLOR_CHART_DOWN,StringToColor(bears[MathRandInt(0,ArraySize(bears))]));
   } */
//---
   int y_distance=70;
   int font_size=30; 
   int width=(int)ChartGetInteger(ChartID(),CHART_WIDTH_IN_PIXELS);
   int padding=70;
   int x=width/3;
//---
    string label_name= MQLInfoString(MQL_PROGRAM_NAME);
    ObjectCreate(0, "name", OBJ_LABEL, 0, 0, 0);
    ObjectSetString(0,"name",OBJPROP_TEXT,label_name); 
    ObjectSetString(0,"name",OBJPROP_FONT,"Lucida Console"); 
    ObjectSetInteger(0,"name",OBJPROP_CORNER,CORNER_RIGHT_LOWER);
    ObjectSetInteger(0,"name",OBJPROP_XDISTANCE,x+padding); 
    ObjectSetInteger(0,"name",OBJPROP_YDISTANCE,y_distance); 
    ObjectSetInteger(0,"name",OBJPROP_FONTSIZE,font_size); 
    ObjectSetInteger(0,"name", OBJPROP_SELECTABLE, false);
 }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+

The example image is too small—I have seen over 200 lines of code that was commented (hidden) and was unnecessary inside the program.

MetaEditor detects unnecessary variables at a function level by warning you of unused variables so that you can choose between keep them and their warning at the same time if it pleases you or to get rid of them.

But for the rest of code we have to check that out for ourselves to make sure that we don't have these unwanted code.

If you don't use it - you don't need it - then delete it.

Unused code causes confusion and not to mention they increase your scrolling time to necessary code when they are in the middle of your program's code.

04: You don't have to always be right.

"A man who has committed a mistake and doesn't correct it, is making another mistake." 
— Confucius

The main reason to why noobs run immediately to the Forum to drag down their code and provide fewer non clear description to what and why they were coding that way and what they wanted, is because they are too afraid to expose themselves to more problems. This is not wise, my dear noobs!

The coding career is full of problems and never-ending challenges, and there is no better way to become great at it if not to solve as many problem as you can get exposed to. I don't mean you should not post in the forum your problems (don't get me wrong). But make sure you've tried a bit solving it on your own that's why its a good practice before you start a topic you describe things you've tried. The reason behind this is to get your mind focused to it and by challenging yourself to different methods on your own not only might solve the puzzle but also you might discover things that you did not know the first time and learn more.

Once the mistake is fixed, make sure you understand it and how to avoid it the next time.


05: Give up the idea of overnight success

"If you look closely most overnight success took a long time."
— Steve Jobs

Ok I understand that you have been coding for a while now but you feel like you are not making any progress, you don't feel like you are going no where. Right?

This feeling happens a lot of times to noobs, because most of them expected the results to be immediately but the world doesn't work that way.

Sit back, relax, and enjoy the process. You are actually making a progress; your doubts are just part of the journey but they should not stop you. I would recommend to work on your favorite projects so that you can have a lot of fun while still learning but don't get stuck there. Make sure you stay open to new ideas and possibilities as I have explained on the second point.

Put the work in, and the progress will come automatically as an end product.

Remember

Success doesn't come from what you do occasionally. It comes from what you do consistently.

 

Conclusion

To be honest I'm not this magnificent, not perfect in MQL5 programming or in my web development career. I'm still a student in this Coding thing and there is no ending to learning it, because it never stops teaching. I always strive to improve and to become better at it everyday. The reason I have the guts to share this with you (to teach while being a student) is to help people with the same passion as me to Become a Better Programmer.

Let's walk this journey together!