About the MQL4 learning curve

 

It took me months to getting started I have given up multiple times this is why : there are tons of very good but lengthly articles as well as samples codes without explanation so when a beginner who tries to understand and not just copy and paste - often it doesn't work - you have to extract the little bits from here and there to have the basic toolkit and I'm still not there as I can't even write to a file correctly :)

I would have preferred straight articles of small modules that one could easily assemble like in lego :

- how to write to log panel

- how to write : append to a file

- how to write to sqlite

- how to write to sql database

etc.

with explanation instead of just sample code you have to decrypt as absolute beginner.

 
forexgenuine: I would have preferred straight articles of small modules that one could easily assemble like in lego :

- how to write to log panel

- how to write : append to a file

- how to write to sqlite

- how to write to sql database

  1. Because there is no such thing as drop in code. Every piece is dependent on the others to work.
  2. Print()
  3. Same as most languages open/seek/write
  4. not mql4
  5. not mql4
 
WHRoeder:
  1. Because there is no such thing as drop in code. Every piece is dependent on the others to work.
  2. Print()
  3. Same as most languages open/seek/write
  4. not mql4
  5. not mql4

Well in other languages there are kind of common libraries packaged together as a coherent hole but that's OK because the community here is very helpfull, I just wanted to give my feedback for improvement.
 
forexgenuine:

Well in other languages there are kind of common libraries packaged together as a coherent hole but that's OK because the community here is very helpfull, I just wanted to give my feedback for improvement.

You can find plenty of examples and full code to study on almost every subject. It is a good way to learn and can save lot of headache when you don't have to write everything from scratch.

 

IMO MQL4 has a very good learning curve. Everything a beginner could ask for is right here on this website. The combination of documentation, forum topics, coding examples, codebase and not least the help the guys on this forum are willing to give those genuinely trying to learn is a goldmine of information.

The problem is too many expect to run before they can walk. They want to join this forum and get everyone to help them code an EA or fix a halfa$$ed one they downloaded from someplace, before they even understand the basic concepts of the language.

 
SDC:

IMO MQL4 has a very good learning curve. Everything a beginner could ask for is right here on this website. The combination of documentation, forum topics, coding examples, codebase and not least the help the guys on this forum are willing to give those genuinely trying to learn is a goldmine of information.

The problem is too many expect to run before they can walk. They want to join this forum and get everyone to help them code an EA or fix a halfa$$ed one they downloaded from someplace, before they even understand the basic concepts of the language.


As I said I didn't just join the forum. Problem is maybe MQL4 is not object oriented, maybe my learning would have been easier with MQL5 but many brokers doesn't support Metrader 5 yet.

Also the loop stuff is more like programming a game or dos program in the old days I'm not accustomed to that as well as coding without debugger.

Update : I just read https://forum.mql4.com/56885 this is good news to get MQL5 OOP inside MT4

 
forexgenuine:


As I said I didn't just join the forum. Problem is maybe MQL4 is not object oriented, maybe my learning would have been easier with MQL5 but many brokers doesn't support Metrader 5 yet.

Also the loop stuff is more like programming a game or dos program in the old days I'm not accustomed to that as well as coding without debugger.

Update : I just read https://forum.mql4.com/56885 this is good news to get MQL5 OOP inside MT4

I can live very happily without OOP
 

I find the issue with MQ4 is more that it is weakly typed (but pretends to be strongly typed), and is more akin to a scripting /prototyping language rather than something that facilitates robust code.

(The later of which is important when hard earned money is involved!).

It doesnt flag uninitialized variables at compile time nor array out of bounds errors at run time.

I've been caught out a few times already and I'm now in the habit of adding assertions throughout the code (esp function arguments etc).

If anyone is learning to code and writing a non-trivial EA, my hat goes off to them!

For anyone doing any non-trivial EA I recomend reading and old programming 'standard' 'Writing Solid Code' (which although dated, non MQ4, non-OO and by Microsoft ) is probably a useful read for any would be MQ4 programmer.

Also write an 'assert' function and use it generously - esp on function arguments...


I do not use debuggers, print/log statements are just fine. Especially with something that runs in batch mode (during back testing), I'n fact I often find debuggers, time consuming by comparison.

(This is after over 30 years of programming - with quite a few different languages). Set up a nice logging framework with ERROR,WARN,INFO,DEBUG,CONFIG levels etc, and actively add/remove log lines as required.

I call it active debugging - try not to stare at code for more than 30 seconds, add some print lines, recompile and run ....


With MQ4 the visual mode can be quite powerful, and its worth taking the time to add code the draws trend lines, S/R lines etc that the EA may be using. (that can be toggled on/off for performance)

I have my EA draw and log at debug level for the first day or two of backtesting (if in VisualMode),after which logging is reduced to 'WARN' and 'ERROR' only, and no objects are drawn....

Then I can drill down on any issues, re-running the back test starting on the 'problem day'.


A quote borrowed from the internet (partially atributed to major contributor to programming world) - Brian Kernigan - upon whose sholders stood pretty much everyone (Gates, Jobs etc)

As Brian W. Kernighan and Rob Pike put it in their truly excellent book "The Practice of Programming"

  As personal choice, we tend not to use debuggers beyond getting a
  stack trace or the value of a variable or two. One reason is that it
  is easy to get lost in details of complicated data structures and
  control flow; we find stepping through a program less productive
  than thinking harder and adding output statements and self-checking
  code at critical places. Clicking over statements takes longer than
  scanning the output of judiciously-placed displays. It takes less
  time to decide where to put print statements than to single-step to
  the critical section of code, even assuming we know where that
  is. More important, debugging statements stay with the program;
  debugging sessions are transient.
 
RaptorUK:
I can live very happily without OOP


Sure :) I confess I'm not very good at coding but with Visual Studio even an under-average coder like me can do some OOP. I don't code often at job and personnaly I decided to code only for trading because I don't want to stare at the screen all day long ! But coding is a torture for my brain.
 
ydrol:

I find the issue with MQ4 is more that it is weakly typed (but pretends to be strongly typed), and is more akin to a scripting /prototyping language rather than something that facilitates robust code.

(The later of which is important when hard earned money is involved!).

It doesnt flag uninitialized variables at compile time nor array out of bounds errors at run time.

I've been caught out a few times already and I'm now in the habit of adding assertions throughout the code (esp function arguments etc).

If anyone is learning to code and writing a non-trivial EA, my hat goes off to them!

For anyone doing any non-trivial EA I recomend reading and old programming 'standard' 'Wrting Solid Code' (which although dated, non MQ4, non-OO and by Microsoft ) is probably a useful read for any would be MQ4 programmer.

Also write an 'assert' function and use it generously - esp on function arguments...


I do not use debuggers, print/log statements are just fine. Especially with something that runs in batch mode (during back testing), I'n fact I often find debuggers, time consuming by comparison.

(This is after over 30 years of programming - with quite a few different languages). Set up a nice logging framework with ERROR,WARN,INFO,DEBUG,CONFIG levels etc, and actively add/remove log lines as required.

I call it active debugging - try not to stare at code for more than 30 seconds, add some print lines, recompile and run ....


With MQ4 the visual mode can be quite powerful, and its worth taking the time to add code the draws trend lines, S/R lines etc that the EA may be using. (that can be toggled on/off for performance)

I have my EA draw and log at debug level for the first day or two of backtesting (if in VisualMode),after which logging is reduced to 'WARN' and 'ERROR' only, and no objects are drawn....

Then I can drill down on any issues, re-running the back test starting on the 'problem day'.

MQL4 is very powerfull for sure - I have seen so many articles on neural network stuff etc. I cannot unfortunately understand but I need to optmize my time and get things done as quickly as possible that's I prefer to export quotes and do complex processing elsewhere, maybe one day I will try to it in MQL4 but I think it will take me months if not years to experiment how to do it :)


About " It takes less time to decide where to put print statements than to single-step to the critical section of code, even assuming we know where that is." maybe for them but for not a genius like me even thinking hard about how to do thing first doesn't prevent me to make error and have difficulty to find it witout seeing the actual value within the context at runtime. Often it is because you didn't think about some contexts happening that you have bugs.


 
forexgenuine:
MQL4 is very powerfull for sure - I have seen so many articles on neural network stuff etc. I cannot unfortunately understand but I need to optmize my time and get things done as quickly as possible that's I prefer to export quotes and do complex processing elsewhere, maybe one day I will try to it in MQL4 but I think it will take me months if not years to experiment how to do it :)


That's cool, I would say stay away from the debugger in whatever IDE you are using if time is important to you! Add more logging, recompile .. re-run ...(see edits above)...

And I think the visual mode of MQ4 backtesting is powerful, but the language itself is pants :)

Reason: