Confused NuB: Series of ‘if’ statements & ‘return’ - page 3

 
I
If you don't want to learn then i wonder what you are doing here?

I am here learning MQL4 just like hundreds or thousands of others are doing.
This IS my starting point. I'm using the MQL4 Help considerably, reading the MQL4 book and ordering the new MQL4 programming book that Rosh posted in the forum. Plus figuring out code as I encounter it.
Do you expect a NuB to know as much as you or others that have done it for years?
If I already had all of the answers and it all figured out I wouldn't be asking for assistance along the way as others do.
 
mql4 is not suitable for beginners. You will advance ten times faster and write better code if you try to learn the things in the correct order in which hey are meant to be learned. mql4 is not a teaching language and it provides no tools for beginner-friendly debugging or otherwise tracing the program flow. mql4 is perceived as a hostile environment with many pitfalls even for advanced programmers and it is absolutely NO fun programming in mql4 compared to almost any other environment.

If you are at a point where you don't even know how program flow is controlled in an imperative language and what kind of constructs are usually used for that and how they behave, then you should learn this first and learn it with more beginner friendly tools.

You might want to learn a beginner friendly language like Python where programming IS FUN and you get an impression what programming can be. Python is an all-purpose language and it can even be easily interfaced with mql4, once you have done the step from learning programming to learning mql4. Your time won't be wasted.
 
Hi everyone.
Thanks to all of you for your assistance.
I'm only to well aware of how 'unuser friendly' and 'hostile' MQL4 is. As I said at one point in time about it: 'which century was this language created in'?
As to 'learning some other programming language first' to learn and understand about programming, I spent years doing custom programing for CNC (Computer Numerically Controlled) machining including doing it on a contract basis. A while back I took four refresher and upgrading courses. Each courses were 400 ~ 500 hours long. My marks were 100%, 2 x 99%, and my lowest mark was 98%. I have certificates for each course that include my marks if anyone doesn't believe me and wants to see them. They have had thousands of students go through these courses before me. I found and corrected errors in them that no one else including the instructors had discovered.
I doubt that any one here has any appreciation for just what is involved in this type of programming and what it requires to do it effectively, competently and produce effective and safe programs that consistently produce quality finished products within the VERY exacting specifications and tolerances that are required. Add to it the fact that the actual machining rarely goes 'by the book.' This is where experience and knowledge are vital and for which there is no substitute for 'time in.' Experience comes before expertise: Even in the dictionary!' Unless one had done this type of work and programming themselves, it is very unlikely that they have appreciation for what is involved and what is required. The machining is often to tolerances of 0.0001": fractions of a millimeter! I did manual machining on a very wide variety of machines, materials and workpieces for many years before I started doing it on computer controlled machines. I initially taught myself CNC programming while operating these machines and fixing, improving and optimizing these CNC programs. The consequences of errors in programming these machines can destroy work pieces in milli-seconds that are over $1,000,000 each in some cases. It is much more difficult to put the metal back on to the workpieces than it is to take it off! The machines themselves can run into several millions of dollars and can likewise to be destroyed in fractions of a second. There are very real dangers ever present and the potential consequences for very serious industrial accidents causing significant serious injuries, maiming and even death are almost ALWAYS present! I witnessed many such events while doing this type of work. It very hard to forget seeing things like arms literally torn out of the shoulder socket and completely torn off. Feet, legs, fingers and hands amputated. I saw more than one person that got there scalp torn off because of there long hair that they did not have safely tucked away so that it couldn't get caught up in the machines. They were VERY lucky that was all they lost! Molten salts at over 1,000 C. 'exploding and splashing it into their face and eyes. In one case, the person lost an eye. Likewise, they got off VERY lucky in comparison to what the consequences could of been! Everything happens so fast that like most accidents, if they are not prevented before they happen, then it is to late! Their is NO room for programming errors in this environment!
Thus though I don't know this specific language YET, I certainly understand programming and logic, program flow and, optimization. I am capable of doing this and succeeding at it and I WILL do it!
I do understand and appreciate your valid and sensible recommendations to start with another language first and only then start to learn MQL4, But unfortunately I do not have the time to do so. Perhaps if I was a 'programmer' per say and could and would apply it in numerous other ways. Frankly I don't really want to learn MQL4 either, especially with MQL5 looming large on the horizon, but am doing so out of necessity. Likely just about the time I am reasonably proficient with MQL4 they will be phasing it out and I will have to start all over again with MQL5: just like most others here. Though as a number of you have pointed out the validity of knowing an other language will make laerning MQL easier and faster. I'm fairly cetain that the transition from v4 to v5 will be easier than learning MQL4 in the first place.
I am going to get the MQL4 'Book' and most likely the OnLine 'Documentation' as well made into a booklet so that I can read and study it much more effectively. I also am going to purchase the new MQL4 EA programming book that Rosh has recently posted in the forum.
These will make a very significant difference and help me tremendously. Many others before me have learned MQL with much less programming experience than I have. I feel sorry for them, but I can and will do this!

Thanks to all of you for your help and assistance. I eventually did learn and understand what my problem was with the help from all of you: I was making a basic, fundamental mistake. Sorry for being so slow and frustrating ALL of us, including me!

Regards,
FourX
 
code
Equivalent
Note
if(Condition_1)
   if(Condition_2)
      if(Condition_3)
        if(Condition_4) something
if(Condition_1){
   if(Condition_2){
      if(Condition_3){
        if(Condition_4){ something }
      }
   }
}
Condition 2 is not evaluated unless condition 1 is. Such as avoiding divide by zero, and expensive function calls.
if(Condition_1
&& Condition_2
&& Condition_3
&& Condition_4){ something }
bool c1 = Condition_1,
     c2 = Condition_2,
     c3 = Condition_3,
     c4 = Condition_4;
if(c1) if(c2) if(c3) if(c4){ something }
Condition 2 is always evaluated regardless of condition 1.
 
FourX:  I'm only to well aware of how 'unuser friendly' and 'hostile' MQL4 is. As I said at one point in time about it: 'which century was this language created in'?
Mq4 is modeled after 'C' in 1969
Reason: