Code for script in PI

how to put stop loss in exit long/short sript. let’s say i want to exit my long/short position if there is a loss of 50 points.

You can use price alert indicator and keep stoploss for 50points

https://zerodha.com/expert-advisors/code/price-alert-indicator

there are the columns to add the buy exit and sell exit in pi backtest.