I need help in coding my strategy in tradescript.

My condition to get buy: Buy when the entire candle (OHLC) is below the Bollinger lower band and the candle is green.

Exit long: Find the range of the long entry candle, book profit equal to two times this range or book loss equal to one time this range

My Condition to sell: Sell when the entire candle (OHLC) is above the Bollinger upper band and the candle it red.

Exit short: Find the range of the short entry candle, book profit equal to two times this range or book loss equal to one time this range

I tried to code this logic in PI using AND operator and IF conditional statement but both returned errors

**Using AND operator:**

Getting “Your script generated an error”

**Long entry:**

SET O = OPEN

SET H = HIGH

SET L = LOW

SET C = CLOSE

SET BBB = BBB(CLOSE, 20, 2, EXPONENTIAL)

O < BBB AND H < BBB AND L < BBB AND C < BBB AND C > O

**Short entry:**

SET O = OPEN

SET H = HIGH

SET L = LOW

SET C = CLOSE

SET BBT = BBT(CLOSE, 20, 2, EXPONENTIAL)

O > BBT AND H > BBT AND L > BBT AND C > BBT AND C < O

**Using IF statement:**

I am getting error message “Argument of IF function not optional”

**Long entry:**

SET O = OPEN

SET H = HIGH

SET L = LOW

SET C = CLOSE

SET BBB = BBB(CLOSE, 20, 2, EXPONENTIAL)

IF(O<BBB,IF(H<BBB,IF(L<BBB,IF(C<BBB,IF(C>O, TRUE,FALSE),FALSE),FALSE),FALSE),FALSE)

**Short entry:**

SET O = OPEN

SET H = HIGH

SET L = LOW

SET C = CLOSE

SET BBT = BBT(CLOSE, 20, 2, EXPONENTIAL)

IF(O>BBT,IF(H>BBT,IF(L>BBT,IF(C>BBT,IF(C<O, TRUE,FALSE),FALSE),FALSE),FALSE),FALSE)

**Long entry exit:**

SET O = OPEN

SET H = HIGH

SET L = LOW

SET C = CLOSE

SET LONG_RANGE = ABS(H-L)

SET PROFIT = LONG_RANGE MULTIPLY 2

C = LONG_RANGE+H OR LONG_RANGE - L

**Short entry exit:**

SET O = OPEN

SET H = HIGH

SET L = LOW

SET C = CLOSE

SET SHORT_RANGE = ABS(H-L)

SET PROFIT = SHORT_RANGE MULTIPLY 2

C = SHORT_RANGE-L OR SHORT_RANGE+H