# Algo code help for 4H strategy

Need some help in coding below strategy :

1. Store 4H close and open
2. Check 30M candle if 30M close > 4H close -> Go Long on next candle open
3. If 30M close < 4H close -> Go Short on next candle open
4. Can we plot 4H open and close line on chart in pi ?

I have this script in trading view pine script language but not able to convert same in Zerodha trade script.
Pine Script :
timeF=input(‘240’) //4H
precision=input(0.05)
openPrice = security(tickerid, timeF, open)
closePrice = security(tickerid, timeF, close)

plot(openPrice,color=red,linewidth=4)
plot(closePrice,color=green,linewidth=4)

goLongValue=(closePrice - openPrice)*100/openPrice
goShortValue=(openPrice - closePrice)*100/closePrice

longCondition = goLongValue > precision
shortCondition = goShortValue > precision

if (longCondition)
strategy.entry(“long”, strategy.long)
if (shortCondition)
strategy.entry(“short”, strategy.short)

Trade Script code tried but results are not same I am missing some thing here ?
BUY_SCRIPT :
SET CLOSE_1 = REF(CLOSE,1)
SET OPEN_4H = REF(OPEN,8)
SET LONG_CONDITION = OPEN_4H < CLOSE_1
SET LONG_VALUE = ((CLOSE_4H -OPEN_4H)*100)/OPEN_4H
LONG_VALUE > 0.05 AND LONG_CONDITION

SELL_SCRIPT :
SET CLOSE_1 = REF(CLOSE,1)
SET OPEN_4H = REF(OPEN,8)
SET SHORT_CONDITION = OPEN_4H > CLOSE_1
SET SHORT_VALUE = ((OPEN_4H -CLOSE_4H)*100)/CLOSE_4H
SHORT_VALUE > 0.05 AND SHORT_CONDITION