0
votes

Hello i am nerd of tradingview and pinescript.

My problem is that i want to exit from an order at some conditions and ADD ALSOthe stoploss, see this :

strategy.entry("Buy", true, when = crossover(sma(close, 14), sma(close, 28)) // buy order

strategy.close("Buy", when = crossunder(sma(close, 14), sma(close, 28))) // sell order at condition

NOW i can't add stoploss condition! WHY??? the only way is this:

strategy.exit("STOP","Buy", stop = 100) //sell order at stoploss

I would like to sell when crossunder but protect me with stoploss but this is impossible... or i use se strategy.close with condition but without stoploss or i use strategy.exit with stoploss and takeprofit but without conditions!

There is a method to use conditions and stoploss togheter?

Thank you to all.

1

1 Answers

0
votes

Is this lines together didn't give you what you want?

strategy.entry("Buy", true, when = crossover(sma(close, 14), sma(close, 28)) // buy order

strategy.close("Buy", when = crossunder(sma(close, 14), sma(close, 28))) // sell order at condition

strategy.exit("STOP","Buy", loss = 100) // You need use `loss` param if you whant set up offset from entry price in "points" and doesn't absolute price.