Neither this "case 1<5:" (it might always be 1)
nor this "if(0<x<5)" is working in MQL4/5 - just place the cursor above switch and press F1 and start reading..
florenceale:
would like to know if with switch function i can use a range instead of a precise value
The documentation page for switch is helpful.
https://www.mql5.com/en/docs/basis/operators/switch
- Jack

Documentation on MQL5: Language Basics / Operators / Switch Operator
- www.mql5.com
can be marked with an integer constant, a literal constant or a constant expression. The constant expression can't contain variables or function calls. Expression of the variant...
Jack Thomas:
The documentation page for switch is helpful.
https://www.mql5.com/en/docs/basis/operators/switch
- Jack
i checked this page before writing here, but it doesnt show the example of a range.
i know how to do with if, but i wanted to know if i can do also with switch/case
florenceale: i checked this page before writing here, but it doesnt show the example of a range.
case 1: case 2: case 3: case 4: case 5: res=i;break;
Carl Schreiber: nor this "if(0<x<5)" is working in MQL4/5 - just place the cursor above switch and press F1 and start reading..
True = 1 and false = 0 so you getif( 3 < 2 < 1 ) if( false < 1 ) if( 0 < 1 ) if( true ) | if( 3 > 2 > 1 ) if( true > 1 ) if( 1 > 1 ) if( false ) |

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
Hi
would like to know if with switch function i can use a range instead of a precise value
like this
ora i have to use if