
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I'm gonna contribute with something very basic, but since I see it over and over again in this forum I guess a lot of people might now know... and it really hurts my eyes.
Asking about a logical expression, function or variable is per se asking if that expression, function or variable is TRUE. You do NOT have to compare it to TRUE or FALSE, i.e.:
Also, any numerical value equal to zero is considered from a logical point of view FALSE. Conversely, any value different from zero is considered logically TRUE. This allows you to do things like this in a nice and elegant way...:
I would argue, however, that sometimes you wanna do things kind of "redundant" from a syntax point of view for the sake of clarity, especially when you have thousands of lines, so that in a single look you understand better what the code is doing, i.e.,:
Maybe I'm splitting hairs here, but I'm convinced that good coding style and habits are the sum of many tiny details.
I agree and usually post:
You should be able to read your code out loud and have it make sense. You would never write if( (2+2 == 4) == true) would you? if(2+2 == 4) is sufficient. So don't write if(bool == true), just use if(bool) or if(!bool). Code becomes self documenting when you use meaningful variable names, like bool isLongEnabled where as Long_Entry sounds like a trigger price or a ticket number and “if long entry” is an incomplete sentence.
Increase Order after stoploss - MQL4 programming forum #1.3 (2017)
I will just add something about function names that has helped me, at least.
Lets say you have these functions:
These function names are verb based: count, get.
Instead, I would make the function names noun based: orders, objects. For example, not countobjects() but objectscount().
That way, if you have dozens of functions you can use the handy drop down function locator in MQL4 editor to go straight to them.