0
votes

I want to convert a TradingView pine script "Price Channel Strategy" to create an alert when a buy, sell or tsl signal is triggered. Can someone please help?

The code is as given below:

//@version=4
strategy("Price Channel Strategy", overlay=true)
length = input(20)
hh = highest(high, length)
ll = lowest(low, length)
if (not na(close[length]))
    strategy.entry("PChLE", strategy.long, comment="PChLE", stop=hh)
    strategy.entry("PChSE", strategy.short, comment="PChSE", stop=ll)
strategy.exit("long tsl","PChLE", trail_points = 5000, trail_offset=2000)
strategy.exit("short tsl","PChSE", trail_points = 5000, trail_offset=2000)
//plot(strategy.equity, title="equity", color=color.red, linewidth=2, style=plot.style_areabr)
1

1 Answers

0
votes

I don't believe alertcondition for custom alerts can be used in strategy scripts. You may have to convert your strategy to a study to create custom alerts.