How to code ATR stop loss in zerodha Pi Tradescript?

Hi , i need help in coding ATR into tradescript

After placing my buy call,

I need to place my exit call , so

If I bought nifty futures at 11,800

and ATR is = 10

i want to place my SLM trigger order at 11790.

What is the code to do so in tradescript?

Thank you for the assistance!