# IF Expressions

Sometimes you need conditional expressions; it means if some condition is met, a certain value will be given by the expression. And if not another value will be given. As you see in EX1.

EX1: RSI1>70 , 10 , 0

In EX2 if MA1 crosses up MA2 then it returns EXP1 and if not, it gives MA1.

EX2: MA1 CROSSUP MA2 , EXP1 , MA1

In EX3 you can see a logical “and” between 2 pairs of parentheses. As mentioned above it means that if the value of this logical expression is true then give EXP1 otherwise give EXP2.

EX3: (MA1<MA2) AND (MA3 CROSSDOWN MA4) , EXP1 , EXP2

In EX4, if the signal line of MACD is above the mainline of MACD returns 1 and otherwise returns 0.

EX4: MACD1:SIGNAL ISABOVE MACD2:MAIN , 1 , 0

In EX5 the expression EXP1 has been already defined somewhere and if its value is true, then give the value of EXP2 otherwise give the value of EXP3.

EX5: EXP1 , EXP2 , EXP3

According to these explanations, you can guess the meaning of EX6. You can use these kinds of conditions for entry points.

EX6: Spread<12Points , 1 , 0

If Wait While

Another kind of IF expressions is “If Wait While” Expressions. By default, the output of this type of IF Expression is false. If expression 1 turns to true, it waits for expression 2 to be true. After expression 1 become true, as long as condition is true, it doesn’t care to expression 1 value and only waits for expression 2. As expression 2 turns to true, output will be true. After expression 1 turns to true, if condition turns to false or max time or max number of candles reached since expression 1 are true, it goes and checks for expression 1 again.

For example:

EX7: MA1 CROSSUP MA2, RSI CROSSUP 30, MA1>MA2, 150, 10

In EX7, ESB waits for MA1 crosses up MA2 and then it waits for RSI crosses up 30. As long as MA1 is greater than MA2, it waits for RSI. Also, if it is waiting more than 150 seconds or more than 10 candles it goes and waits for MA1 crosses up again MA2.