double a = 3; double b = 5; bool c = true; bool d = false; if (a < b && c && d) { Alert("TRUE"); } else { Alert("FALSE"); }
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
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]) { OrderSend(Cross,OP_BUY, lots, MarketInfo(Cross,MODE_ASK), 1, MarketInfo(Cross,MODE_ASK)-(SL*Point), MarketInfo(Cross,MODE_ASK)+(TP*Point), "Buy Trade", magic, 0, Blue); } else {Alert("do nothing");}
- Check your return codes and find out why. What are Function return values ? How do I use them ? - MQL4 forum and Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
- Handle 4066/4073 Script Error - No Trades Are Opening - AutoTrading Enabled (nazty) - MQL4 forum
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 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....
Thanks in advace