I am having a problem in tradingview, pinescript.
I am stuck at a point, I have converted my strategy into study for alerts. Buy and Sell alerts are converted into alerts but the main problem is, I cannot convert strategy.exit
code in study with alert condition. Is there a way I can convert this also in alert?
Below is my code:
//@version=4
strategy("My Strategy", overlay=true)
strategy.entry("Buy", strategy.long, when=crossover(sma(close, 14), sma(close, 28)), comment="Buy")
strategy.exit("Buy", trail_points=100, loss=100, comment="Exit")
strategy.entry("Sell", strategy.short, when=crossover(sma(close, 14), sma(close, 28)), comment="Sell")
strategy.exit("Sell", trail_points=100, loss=100, comment="Exit")
loss
= When price comes 100 ticks away from the trigger buy/sell in loss, then exit condition comes. So loss is fixed at 100.
trail_points
= When price comes, 100 ticks positive from the buy/sell order, then at the closing of candle, the exit condition comes. Profit is variable at candle close, but trigger at 100.
Can these two exit strategies be given in alert condition? I am not able to convert this whole strategy in alert.