from_n00b_to_1337
from_n00b_to_1337

Reputation: 29

TradingView Pine Script - Alert options doesn't appear in "Create Alert"

I am trying to modify a built in script with an alert function Price Channel Strategy but I can not get it to work.

My problem is that the options doesn't appear in "Create Alert" to chose my alerts xxxLONGxxx and xxxSHORTxxx

Only thing I added is (like the documentation suggests): alertcondition(hh, title='xxxLONGxxx', message='GO LONG!') alertcondition(ll, title='xxxSHORTxxx', message='GO SHORT!')

Whole script:

strategy("Price Channel Strategy", overlay=true)
length = input(120)
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)

alertcondition(hh, title='xxxLONGxxx', message='GO LONG!')
alertcondition(ll, title='xxxSHORTxxx', message='GO SHORT!')

Why it isn't working?

Upvotes: 0

Views: 1878

Answers (1)

vitruvius
vitruvius

Reputation: 21294

Alerts don't work with strategies:

While the presence of alertcondition calls in a Pine strategy script will not cause a compilation error, alerts cannot be created from them

So, convert your strategy to an indicator.

Upvotes: 1

Related Questions