# [SOLVED] Why do these 2 expressions get registered differently?

965

```if( 6 && 7  >5) // WORKS
Print("NO PARENTHESIS Yes");

if( (6 && 7)  >5) // DOESNT WORK
Print("PARENTHESIS Yes");```
Why does first case work and second case doesn't?
28880

Why does first case work and second case doesn't?

So it's easy to see why,

If you Print() it,you will see the "(6 && 7)" will return true,So true means 1 in Boolean logic,(false is 0)

So the second condition is always false,because 1 is not bigger than 5,

So if you change it to 0 as below:

```  if( (6 && 7)  >0) // Works now
Print("PARENTHESIS Yes");
```
It will work as intended,
965

So it's easy to see why,

If you Print() it,you will see the "(6 && 7)" will return true,So true means 1 in Boolean logic,(false is 0)

So the second condition is always false,because 1 is not bigger than 5,

So if you change it to 0 as below:

It will work as intended,
```Print("6 && 7 ", 6 && 7);

Print( "(6 && 7) " ,(6 && 7) );```

Both are TRUE which would mean they are both one.

Then why does

```if( 6 && 7  >5)
Print("Yes");```

work while the other one , which also means 1, doesnt?

I take it that its because its 6 whatever is true and then 7 is greater than five is also true.

However, I want to compare both 6 to 5 and also 7 to 5 without needing to do

```if( 6>5 && 7>5)
```

Is there a way to compare correctly for example

```if( 3>5 && 4>5 && 6>5 && 7>5 && 8>5)
```

Without needing to compare every single one of them to the 5, so that its sometething like all of them together compared to five?

I thought that

```if( 3>5 && 4>5 && 6>5 && 7>5 && 8>5)

could be substituted all of the individual comparisons to five like this:

if(  (3 && 4 && 5 && 6 && 7 && 8) > 5   )```

So i don't have to individually compare them all to five; you understand?

Anything like that available in mql4? Not using arrays or stuff like that; what I need is a simple syntax solution for this nothing complicated. Trying out all that occurs to me, so as to not have to repeat the >5 every single time for say 100 different numbers

A little weird to explain "cause my view is off".

Its essentially ON THE FLY creating a group of values through simple syntax way (no arrays), and then compare every individual unit of the group to 5.

The way I know how to do this involves arrays and for loops. Isn't there a simpler way?

THX
2545

Both are TRUE which would mean they are both one.

965

Still can't decipher how exactly do I create a group of values through simple syntax way (no arrays and no for loops), and then compare every individual unit of the group to 5. (Without having to do every one of them individually as explained above)

Would greatly appreciate an example.

Will have to use the more verbose approach for now unfortunately.
19863

True = non-zero and false = zero so you get
 ```if( 3 < 2 < 1 ) if( false < 1 ) if(     0 < 1 ) if(     true  )``` ```if( 3 > 2 > 1 ) if(  true > 1 ) if(     1 > 1 ) if(     false ) ```
965

William Roeder:
True = non-zero and false = zero so you get
Thanks however how do I exactly compare the individual numbers 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 to see if all of these individually are are less than 5 without having to
`if (1<5 && 2<5 && 3<5 && 4<5 && 5<5 && 6<5 && 7<5 && 8<5 && 9<5 && 10<5)`

?

Is there a way to do something like all of those compared to 5 without the array and for loop approach?

I thought

```if (     (1 && 2 && 3 && 4 && 5 && 6 && 7 && 8 && 9 && 10) < 5     )
```

would be having it recognize 5, 6, 7, 8, 9, and 10 aren't less than 5 and display FALSE. it doesn't since it just sais "1 is true and 2 is true and 3 is true and 4 is true and 5 is true and 6 is true and 7 is true and 8 is true and 9 is true and 10 is true" and since all of that is seen as true its all a huge "TRUE" inside the parenthesis, which is a 1 and would be all true (or so I think).

Any way to not have to individually compare everything to five to achieve the desired outcome of not having to use an array and a for loop in order to compare the group of values to 5?

Just wanting to escape the excess verbosity of individually comparing all to 5 without an array and a for loop

19863

1. `if (1<5 && 2<5 && 3<5 && 4<5 && 5<5 && 6<5 && 7<5 && 8<5 && 9<5 && 10<5)`
You keep using constants, so we have no idea what you really want to do. Obviously 10<5 is false and anything && false is false.

2. nadiawicket: Just wanting to escape the excess verbosity of individually comparing all to 5 without an array and a for loop

If you have ten conditions, you need to test all ten. Or, put them into an array, sort it, and test the largest one.

3. Stop telling us your reasoning. Tell us what you are trying to really do. There are no mind readers here and our crystal balls are cracked.

1554

Both are TRUE which would mean they are both one.

Then why does

work while the other one , which also means 1, doesnt?

I take it that its because its 6 whatever is true and then 7 is greater than five is also true.

However, I want to compare both 6 to 5 and also 7 to 5 without needing to do

Is there a way to compare correctly for example

Without needing to compare every single one of them to the 5, so that its sometething like all of them together compared to five?

I thought that

So i don't have to individually compare them all to five; you understand?

Anything like that available in mql4? Not using arrays or stuff like that; what I need is a simple syntax solution for this nothing complicated. Trying out all that occurs to me, so as to not have to repeat the >5 every single time for say 100 different numbers

A little weird to explain "cause my view is off".

Its essentially ON THE FLY creating a group of values through simple syntax way (no arrays), and then compare every individual unit of the group to 5.

The way I know how to do this involves arrays and for loops. Isn't there a simpler way?

THX
https://www.mql5.com/en/docs/basis/operations/rules

Learn to use your tools, do not make assumptions, but practice and verify.

Good luck.

965

William Roeder:
1. You keep using constants, so we have no idea what you really want to do. Obviously 10<5 is false and anything && false is false.

2. If you have ten conditions, you need to test all ten. Or, put them into an array, sort it, and test the largest one.

3. Stop telling us your reasoning. Tell us what you are trying to really do. There are no mind readers here and our crystal balls are cracked.

What trying to do is usable in many things for example comparing a set of bid values to the current bid value without having to use an array was what I was trying to accomplish. Also compare previous indicator data to current indicator data on the fly without needing to mess with arrays (easy for a couple of bars but you have like 15 values to compare to I start needing to use the wanted-to-avoid-arrays).

Looks like can't be done without an array

965

Soewono Effendi:
https://www.mql5.com/en/docs/basis/operations/rules

Learn to use your tools, do not make assumptions, but practice and verify.

Good luck.

Arrays necessary is what this approach had led me to believe, but I was hoping there was a less verbose approach that I didn't know about.