PI CODE- for backtesting

Hi, Plz help me with this code for PI backtesting

  1. BUY when candle closes above SMA 20 (high)

  2. SELL when candle closes below SMA 20 ( low )

It automatically reverses the positions

As per the above condition

BuyScript:

CLOSE>SMA(HIGH,20)

SellScript:

CLOSE<SMA(LOW,20)

Thanks sir, Plz give me code for 1% Sl and 1% tgt,thanks