Please help me in coding my stratergy

Buy: Intraday chart 30 minutes candle stick.
Stock should not be in a up trend for at least 5 days. Trade should not happen after 2:30 p.m.
There should be two swing lows where as latest swing low must be lower than the previous swing low and trade should happen at when ever it crosses at previous swing high.
SL: 20% of the entered price
Exit Buy: When the stock reaches 20 % profit of the stock price or trailing stop loss at previous candle low when ever stock reaches 20 % of the profit.

Sell:  Stock should not be in a down trend for at least 5 days. Trade should not happen after 2:30 p.m
There should be two swing highs, latest swing high must be higher than the previous swing high and sell should happen when ever it crosses at latest swing low.
SL: 20 % of the stock price.
Exit Sell: When the stock reaches 20 % of profit or trailing stop loss at previous candle high when the stock reaches 20 % of the profit.


trailing can't be coded with tradescript and candles are formed based on OHLC

Please leave trailing and code what can be done.