Conditional “IF” Function
IF(Condition, True part, False part)
The conditional “IF” function allows you to design complex Boolean logic filters. If you paste the following script into the Script area in your trading software application, you will see a column of numbers that oscillate between 1 and -1, depending on when the closing price is greater than the opening price:
SET A = IF(CLOSE > OPEN, 1, -1)
The first argument of the “IF” function is a logical test. The second argument is the value that will be used if the condition evaluates to TRUE. Conversely, the third argument is the value that will be used if the condition evaluates to FALSE. The logical test may be any value or expression that can be evaluated to TRUE or FALSE. For example, CLOSE = OPEN is a logical expression; if the close price is the same as the opening price, the expression evaluates to TRUE. Otherwise, the expression evaluates to FALSE.