Simple "IF" question on MQL

 

Hi,

 

I'm fairly new to coding. I have very simple question.

 

I'd like to run an IF() statement which executes something as long as the numbers are even. Does anyone know how to do this?

 

i.e.

 

If (even number) {

do this

 

Better yet, is it possible to do:

 

If (variable = 3 or 4 or 5) {

 do this

}

 

Cheers! 

 
 
lester_j: I'm fairly new to coding. I have very simple question.

I'd like to run an IF() statement which executes something as long as the numbers are even. Does anyone know how to do this?

if (even number) {
   do this
} 

Better yet, is it possible to do:

if(variable = 3 or 4 or 5) {
  do this
}
  1. Don't paste code
    Play video
    Please edit your post.
    For large amounts of code, attach it.

  2. You need to learn to code it, or pay someone. We're not going to code it FOR you. We are willing to HELP you when you post your attempt (using SRC) and the nature of your problem.
    Your questions are the equivalent of getting into a car to drive and asking "How to I start this thing?" but knowing nothing else like the rules of the road.
  3. if (number % 2 == 0) {
       do this
    } 
    bool IsEven(int n){ return n % 2 == 0; }
    :
    if (IsEven(number) ) {
       do this
    } 
    Or self documenting

  4. if(variable >= 3 && variable <= 5) {
      do this
    }
    Contiguous range.
    if(variable == 3 
    || variable == 5
    || variable == 7) {
      do this
    }
    None contiguous.

  5. qjol: while
    Qjol Was thinking
    for(int variable = 3; variable <= 5; ++variable){
      do this
    }
    or the equivalent
    int variable = 3;
    while(variable <= 5){
      do this
      ++variable;
    }