I want Tradescript code for below Condition to Scan stock on EOD basis in Zerodha Pi

Buy

If Today’s Open <= Previous day’s low

& today’s close > previous day’s open or close whichever is higher

Sell

If Today’s Open >= Previous day’s high

& Today’s close < previous day’s open or close whichever is lower

As per the above query use day timeframe

Buy Script:

OPEN < REF(LOW,1) OR CLOSE > REF(OPEN,1) OR CLOSE > REF(CLOSE,1)


Sell Script:

OPEN > REF(HIGH,1) OR CLOSE < REF(OPEN,1) OR CLOSE < REF(CLOSE,1)

what to select in data source?
Periodicity, bar intervals, days?

this code is showing all scripts in buy as well as sell.