if this is the hole function you have copied i guess its an spaghetti code or something to make the code kind of messy and un-understandable.
Hello friends, I am new member and not sure if this topic has been discussed before. I recently studying some other people's coding, and went across this part:
I know that the "if" conditions are comparing between close prices & open prices between bars, but why inside the "if" conditions, there are no statements at all? What is the result of this code actually?
That's a really good question and this code suggests that it was written by a novice programmer. You never want to use nesting levels in place of logical and (&&). This is how it should look.
void function() { if (iClose(Symbol(), PERIOD_H1, 0) > iClose(Symbol(), PERIOD_H1, 2) && iClose(Symbol(), PERIOD_H1, 0) < iClose(Symbol(), PERIOD_H1, 2) && iClose(Symbol(), PERIOD_H1, 0) > iClose(Symbol(), PERIOD_H1, 1) && iClose(Symbol(), PERIOD_H1, 0) < iClose(Symbol(), PERIOD_H1, 1) && iOpen(Symbol(), 0, 0) > iOpen(Symbol(), 0, 1) && iOpen(Symbol(), 0, 0) < iOpen(Symbol(), 0, 1)) && iClose(Symbol(), 0, 0) > iClose(Symbol(), 0, 1) && iClose(Symbol(), 0, 0) >= iClose(Symbol(), 0, 1) ){ //do work } }
Then you have the issue of multiple function calls with the same args. If you're calling a function more than once with the same args you need to assign its value to a variable.
Finally, we get to the worst part of the code. This logic can never resolve to true because the close of the current bar can never be simultaneously greater than AND less than the close of another bar. This might as well have been written as
if (false) { }
- www.mql5.com
the purpose is nothing. look at the first and second ifs, they are totally opposite means it wont ether enter the first one or the second one. third and 4th are that way too and rest of them so on.
if this is the hole function you have copied i guess its an spaghetti code or something to make the code kind of messy and un-understandable.
That's a really good question and this code suggests that it was written by a novice programmer. You never want to use nesting levels in place of logical and (&&). This is how it should look.
Then you have the issue of multiple function calls with the same args. If you're calling a function more than once with the same args you need to assign its value to a variable.
Finally, we get to the worst part of the code. This logic can never resolve to true because the close of the current bar can never be simultaneously greater than AND less than the close of another bar. This might as well have been written as
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I know that the "if" conditions are comparing between close prices & open prices between bars, but why inside the "if" conditions, there are no statements at all? What is the result of this code actually?