if condition with && doesn't work

26

I have a problem with if condition and && operator.

This simple code alway give "true" as result, when must give "false". Any idea about the problem? I'm getting crazy....

```double a=3;
double b=5;
bool c=true;
bool d=false;

if ((a<b)&&(c=true)&&(d=true))
else
5143

```double  a = 3;
double  b = 5;
bool    c = true;
bool    d = false;

if (a < b && c && d)
{
}
else
{
}```

In your version you have (d=true) will assign true to d and then always be true

Maybe you meant....

```if (a < b && c == true && d == true)
{
}

// but using d == true is not necessary as b is already boolean therefore you should just use

if (a < b && c && d)
{
}
```
```// Also note, there is no need to add loads of extra () surrounding normal conditions unless they contain || expressions that might need to be separated
```
26

jamescater:

In your version you have (d=true) will assign true to d and then always be true

Maybe you meant....

Great! Thanks a lot..it works very good now... but I've got another little problem now... one hour ago it worked well, now it doesn't open any order... I didn't modify the code...

```if (Stoc[0])
{
OrderSend(Cross,OP_SELL, lots, MarketInfo(Cross,MODE_BID), 1, MarketInfo(Cross,MODE_BID)+(SL*Point), MarketInfo(Cross,MODE_BID)-(TP*Point), "Sell Trade", magic, 0, Red);
}
else

if (Stoc[1])
{