I want cod for scan this condition in intraday

a list of stock which are trading above privious day high or below privious days low and second condation is below or above 200 sma vice varsa

As per the above conditions

1st condition

LAST > REF(HIGH,1) OR LAST < REF(LOW,1)

2nd condition

LAST > SMA(CLOSE,200) OR LAST < SMA(CLOSE,200)