Pls help me in coding my stratergy for gap stratergy

Sell: Stock should be in a trend for 5 days,

Intraday opening should be gap up minimum 1 % or with inverted hammer or bearish candle.

Exit sell: at previous day closing price or when ever market stays flat.

 
 
 

Sell Script:

SET A = CLOSE-LOW
SET B = OPEN-CLOSE
SET C = HIGH-OPEN
TREND(CLOSE,10)=UP
A>=10*B
AND C/B<1
AND REF(CLOSE,1)<REF(OPEN,1) AND
OPEN<REF(CLOSE,1)

Buy Script:

REF (CLOSE, 1) > REF (OPEN,1) AND
REF(CLOSE,2) > REF(OPEN,2)

you can check this link  https://zerodha.com/expert-advisors/code/bearish-red-hanging-man