I guess you want a BUY when there are 3 consecutive highs and SELL when 3 consecutive lows.
BUY will be-
CLOSE > REF(HIGH,1) AND REF(HIGH,1) > REF(HIGH,2) AND REF(HIGH,2) > REF(HIGH,3)
SELL will be-
CLOSE < REF(LOW,1) AND REF(LOW,1) < REF(LOW,2) AND REF(LOW,2) < REF(LOW,3)