Coding information needed and dynamic stoploss

Two Questions.

I am a programmer and would like to develop my own strategy and code it in PI, can you advise how do I start about writing my own code for executing orders automaticallly based on my strategy.

As of now I am playing with AI in Pi software, however I am unable to input dynamic stoploss, as to if my strategy is signalled they I want to put a stoploss at 5% of the signal generation price, how do I do that.

For Complete reference of Tradescript language go to pi help -> tradescript help

Thank you friend, you gave everything I needed in a single line.