Hi, top here is the code. cause i have much if, it didn't works well. need someone to help me
Personally, I'd use a switch statement.
It's just my opinion, but a switch statement is cleaner and get's rid of that mess of "IF" statements.
https://www.mql5.com/en/docs/basis/operators/switch
Look at the example on the above link.
- Jack
- www.mql5.com
Personally, I'd use a switch statement.
It's just my opinion, but a switch statement is cleaner and get's rid of that mess of "IF" statements.
https://www.mql5.com/en/docs/basis/operators/switch
Look at the example on the above link.
- Jack
Hi thank you for the suggestion... Will it solve this issue, "The first if is the main among the other 2. if it's false then it proceed to next if. if it's false then it will proceed to next if."?
Thank you Sir
Hi thank you for the suggestion... Will it solve this issue, "The first if is the main among the other 2. if it's false then it proceed to next if. if it's false then it will proceed to next if."?
Thank you Sir
Look at the example on the page I gave you. There are two examples there.
Switch can use only integer values in conditions
bool sellA=iClose(_Symbol,_Period,1)<MA50 && iOpen(_Symbol,_Period,1)<MA50 && iHigh(_Symbol,_Period,1)<MA50 && iLow(_Symbol,_Period,1)<MA50; //--- bool sellB=iClose(_Symbol,_Period,1)<BBDn && MA5L>BBDn; //--- if(sellA && sellB) {mess_data[k][j]="TM";mess_color[k][j]=clrRed;} else if(sellA) {mess_data[k][j]="T";mess_color[k][j]=clrRed;} else if(sellB) {mess_data[k][j]="M";mess_color[k][j]=clrRed;}
bool sellA=iClose(_Symbol,_Period,1)<MA50 && iOpen(_Symbol,_Period,1)<MA50 && iHigh(_Symbol,_Period,1)<MA50 && iLow(_Symbol,_Period,1)<MA50;
Can be simplified to:
bool sellA=iHigh(_Symbol,_Period,1)<MA50;
Switch can use only integer values in conditions
Thank you sir.. what do you suggest than sir?
This exactly what i did on my code.... it doesn't work.... the first IF is true and first ELSE IF is true, and 2nd ELSE IF is false, it will appear the IF... i've tested it...
This exactly what i did on my code.... it doesn't work.... the first IF is true and first ELSE IF is true, and 2nd ELSE IF is false, it will appear the IF... i've tested it...
This was tested and works as it should.
bool Hdown=high[i]<high[i+1]; bool Cdown=close[i]<close[i+1]; bool Hup=high[i]>high[i+1]; bool Cup=close[i]>close[i+1]; Print("Hdown=",Hdown); Print("Cdown=",Cdown); Print("Lup=",Hup); Print("Cup=",Cup); if(Hdown && Cdown) {Print("Hdown && Cdown");} else if(Hdown) {Print("Hdown");} else if(Cdown) {Print("Cdown");} else if(Hup && Cup) {Print("Lup && Cup");} else if(Hup) {Print("Lup");} else if(Cup) {Print("Cup");} else {Print("none");}
It does work, exactly how you coded it. If "the first IF is true" the remaining else's are irrelevant.
Use the debugger or print out your variables, and find out why.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi, top here is the code. cause i have much if, it didn't works well. need someone to help me
this one group of signal. this for my dashboard. The first if is the main among the other 2. if it's false then it proceed to next if. if it's false then it will proceed to next if.
same goes for
and the last, if there isn't any it will show below
Thank you