Newbie / Learning - # and ;

 

Hi all,

I'm very new to MQL4 and have no C or C++ knowledge. I do know a fair bit of VBA.

I have 2 questions on MQL4:

1) What is # used for? I saw some examples and it seemed like comments to me. Is it the same as //?

2) Does all codes in MQL4 ends with ;? (semicolon).


Thanks in advance!

 
dcmb: I'm very new to MQL4 and have no C or C++ knowledge. I do know a fair bit of VBA. I have 2 questions on MQL4:
  1. What is # used for? I saw some examples and it seemed like comments to me. Is it the same as //?
  2. Does all codes in MQL4 ends with ;? (semicolon).

When in doubt read the documentation. It is there so that you can learn!

  1. "#" are not comments. They are for compile time preprocessing - MQL4 Reference Language Basics Preprocessor
  2. Yes, most of the time. It follows the same rules as "C" and "C++" - MQL4 Reference Language Basics

Also, I highly recommend that you build up your coding skills and basic coding experience by practicing with "C" coding. Since this is in regards to MQL4, I suggest that you do the following:

  • First learn the basics of coding in "C". Here are a few links for sites that offer tutorials and learning for "C" that can help:
  • Then read and follow the Book/Tutorial (even though it is old and out of date).
  • At the same time, read the entire documentation with special attention to the MQL4 Updates that are not mentioned in the Book/Tutorial.
  • Then you should study several examples of code for Indicators, Expert Advisors (EAs) and Scripts in the user Code Base.
  • Then you can start making your own, but very simple Indicators and slowly build on them until fully able to understand and make more complex Indicators.
  • Then you can start making your own, but very simple EAs and slowly build on them until fully able to understand and make more complex EAs.

You should not skip any of these necessary steps! Consider this as a very important lesson!

Please note that I edited this post and is now a little different from its initial outline.

EDIT2: PS! NB! Since, it is the opinion of several users that MetaTrader 4 / MQL4 is not going to be updated any further, it may be more beneficial to start learning MQL5 instead of MQL4.

 
Fernando Carreiro:

Also, I highly recommend that you build up your coding skills and basic coding experience by practicing with "C" coding. Here are a few links for sites that offer tutorials and learning for "C" that can help:

This is also a really nice introduction to C, written for the Raspberry Pi community but a great starting point nevertheless:

https://www.raspberrypi.org/magpi/issues/essentials-c-v1/ 

Learn C Essentials - The MagPi Magazine
Learn C Essentials - The MagPi Magazine
  • www.raspberrypi.org
The C programming language been used to program everything from the tiny microcontrollers used in watches and toasters up to huge software systems – most of Linux (and Raspbian itself) is written in it. Learn to code with C on your Raspberry Pi across 13 packed chapters: Create variables & do arithmetic Control the flow of your C programs For...
 
honest_knave:

This is also a really nice introduction to C, written for the Raspberry Pi community but a great starting point nevertheless:

https://www.raspberrypi.org/magpi/issues/essentials-c-v1/ 

Thank you for all your answers and suggestions.

I did not go into C because I googled and there's are mixed sentiments about the need to learn C first before MQL4 or even C++.

That's a lot of materials but I will try to go through them.

cheers :)

 
dcmb:

Thank you for all your answers and suggestions.

I did not go into C because I googled and there's are mixed sentiments about the need to learn C first before MQL4 or even C++.

That's a lot of materials but I will try to go through them.

cheers :)

You don't need to learn C or C++ to learn mql4. It's an urban legend.
 
Alain Verleyen:
You don't need to learn C or C++ to learn mql4. It's an urban legend.

This is true, but if someone has no previous coding knowledge it would be a very steep learning curve to dive straight in to MQL. This is because the available information for absolute beginners in MQL is somewhat lacking (to put it mildly) and many information sources are now hopelessly outdated.

Given that the OP has knowledge of VBA should sidestep many of the issues a beginner would encounter.

Good luck dcmb - you'll find plenty of information and help on these forums along the way (particularly from the 2 other posters in this thread). 

 
honest_knave:

This is true, but if someone has no previous coding knowledge it would be a very steep learning curve to dive straight in to MQL. This is because the available information for absolute beginners in MQL is somewhat lacking (to put it mildly) and many information sources are now hopelessly outdated.

Given that the OP has knowledge of VBA should sidestep many of the issues a beginner would encounter.

Good luck dcmb - you'll find plenty of information and help on these forums along the way (particularly from the 2 other posters in this thread). 

I would never advice someone who "has no previous coding knowledge" to start with C or C++ which are by the way the very different language. (To be honest I don't even understand why C is mentioned here, it's low level language which has not relation at all with mql). Remains C++, do you know it ? I saw so many people complaining about mql5 as a complex language, imagine what they will say about C++.

I really don't understand Fernando or your recommendations to learn C. The guys who comes here, in the best cases, want to learn some coding to automated their strategy or to try some ideas... advising them to learn C (or C++) is like advising someone who want to be rescuer to learn surgery.

The resources on mql available on this site (and mql4.com including the Book, even outdated) are sufficient enough.

 
Alain Verleyen:

I would never advice someone who "has no previous coding knowledge" to start with C or C++ which are by the way the very different language. (To be honest I don't even understand why C is mentioned here, it's low level language which has not relation at all with mql). Remains C++, do you know it ? I saw so many people complaining about mql5 as a complex language, imagine what they will say about C++.

I really don't understand Fernando or your recommendations to learn C. The guys who comes here, in the best cases, want to learn some coding to automated their strategy or to try some ideas... advising them to learn C (or C++) is like advising someone who want to be rescuer to learn surgery.

The resources on mql available on this site (and mql4.com including the Book, even outdated) are sufficient enough.

In my opinion, the main reason why so many posters have so much difficulty with MQL and keep coming here with their difficulties, is not primarily with MQL issues themselves, but with the simple fact that they have no understanding and experience with basic coding knowledge and standard computer science practices.

So, in order to gain that experience and knowledge, I can't exactly tell them to go first learn it in some other language unrelated to MQL (such as Pascal, or Java or what-ever), as surely you would then criticise me for suggesting such a "stupid" thing. So, instead, I suggest that they start learning and gaining experience with a language on which MQL is based, namely "C" and "C++".

If they try to start with MQL, they would be focused on "making money" and not learning the language and the coding principles that go along with it. But if they start with another language, such as "C" (which is close to MQL), they will be forced to focus on the actual coding principals and elements instead (like the famous "Hello World!") and not the MQL equivalent of which is "Goodby, there goes my Money"!

Obviously, your opinion is different and you are entitled, but then how would you suggest a user gain proper coding experience and knowledge and not bombard this forum with constant "noob" problems that drive us nuts and make as "cranky" to the point that when we can't take it anymore and we begin to "lash out" and "become condescending" to others and have other users then accuse us (and correctly so), of being "arrogant", "know-it-all's", constantly "picking at noob questions" and not properly help them out?

So, my suggestion whether some agree or not, is that newbies first learn the basics of coding, so that when they do start with MQL and they do come here for advice, we can all be on a much more level playing field and actually have fruitful, civilised and enjoyable discussions, instead of the current highly tense, and usually unproductive one way monologues that tend to happen (yes I know monologues are "one way", but I needed to over-emphasize it).

There, now I have let go "of all my steam" and maybe you will understand why!

 
Fernando Carreiro:

In my opinion, the main reason why so many posters have so much difficulty with MQL and keep coming here with their difficulties, is not primarily with MQL issues themselves, but with the simple fact that they have no understanding and experience with basic coding knowledge and standard computer science practices.

So, in order to gain that experience and knowledge, I can't exactly tell them to go first learn it in some other language unrelated to MQL (such as Pascal, or Java or what-ever), as surely you would then criticise me for suggesting such a "stupid" thing. So, instead, I suggest that they start learning and gaining experience with a language on which MQL is based, namely "C" and "C++".

If they try to start with MQL, they would be focused on "making money" and not learning the language and the coding principles that go along with it. But if they start with another language, such as "C" (which is close to MQL), they will be forced to focus on the actual coding principals and elements instead (like the famous "Hello World!") and not the MQL equivalent of which is "Goodby, there goes my Money"!

Obviously, your opinion is different and you are entitled, but then how would you suggest a user gain proper coding experience and knowledge and not bombard this forum with constant "noob" problems that drive us nuts and make as "cranky" to the point that when we can't take it anymore and we begin to "lash out" and "become condescending" to others and have other users then accuse us (and correctly so), of being "arrogant", "know-it-all's", constantly "picking at noob questions" and not properly help them out?

So, my suggestion whether some agree or not, is that newbies first learn the basics of coding, so that when they do start with MQL and they do come here for advice, we can all be on a much more level playing field and actually have fruitful, civilised and enjoyable discussions, instead of the current highly tense, and usually unproductive one way monologues that tend to happen (yes I know monologues are "one way", but I needed to over-emphasize it).

Their, now I have let go "of all my steam" and maybe you will understand why!

Ok I understood now, you send them to C to get rid of them

Seriously, it would interesting to have some feedbacks from people who start learning mql without previous programming knowledge. I strongly doubt saying them to learn C could be a good way.

Anyway, yes I understand your point of view now, though I don't share it. No problem.

 
Fernando Carreiro:

EDIT2: PS! NB! Since, it is the opinion of several users that MetaTrader 4 / MQL4 is not going to be updated any further, it may be more beneficial to start learning MQL5 instead of MQL4.

Just a comment about your edit2. It's not an opinion, it has been announced by Metaquotes : there will not be new development on MT4/mql4.
 
Alain Verleyen:

Ok I understood now, you send them to C to get rid of them

Seriously, it would interesting to have some feedbacks from people who start learning mql without previous programming knowledge. I strongly doubt saying them to learn C could be a good way.

Anyway, yes I understand your point of view now, though I don't share it. No problem.

But you have not given an alternative answer or suggestion so as to how to motivate users to learn the principals and basic coding skills, instead of being fixated on "making money". In the end they are not being able to accomplish either of the two goals - they neither learn the MQL language properly nor do they "make money" (which also has its basic principles and skills that need be learned separately as well, and why I send them off to "BabyPips School of Pipsology").

Reason: