Pi TradeScript : Stop Loss

In Tradescript,I am trying to add Stoploss based on

  1. ATR values(consider x)

  2. Fixed SL , ex : Buying @ 500 means, I can change ‘x’ hardcoded value as ‘-5’ or ‘-10’, so SL will be 495 or 490 accordingly

  3. SL based on last candles low

How to code this and especially where I need to add this in Tradescript , under which tab in 4 tabs given under ‘Tradescripts’?

1 Like

Buy :

TR(14) > REF(LOW,1)

Sell :

TR(14) < REF(LOW,1)

you can change the Average True Range values if you want ,

go to backtest and enter the above code in sell and buy

Thanks for your answer. But Stoploss also needs to be added under Buy, Sell only ?