user214808
user214808

Reputation: 11

Why doesn't this 'alertcondition' get triggered?

I have loaded a public script from tradingview/scripts and have added 2 lines to add a Buy and Sell 'alertcondition', I have then created 2 the alert conditions on a short time frame to test that they work but they fail to get trigerred.

//@version=4
study("Accurate Swing Trading System",overlay=true)

no=input(3,title="Swing")
Barcolor=input(true,title="Barcolor")
Bgcolor=input(true,title="Bgcolor")

res=highest(high,no)
sup=lowest(low,no)
avd=iff(close>res[1],1,iff(close<sup[1],-1,0))
avn=valuewhen(avd!=0,avd,1)
tsl=iff(avn==1,sup,res)

Buy=close>tsl and close[1]<tsl[1]
Sell=tsl>close and tsl[1]<close[1]

plotshape(Buy,title="Buy", color=color.green,             
style=shape.arrowup,location=location.belowbar, text="Buy")
plotshape(Sell,title="Sell", color=color.red,         
style=shape.arrowdown,text="Sell")

colr = close>=tsl ? color.green : close<=tsl ? color.red : na
plot(tsl, color=colr, linewidth=3, title="TSL")
barcolor(Barcolor ? colr : na)
bgcolor(Bgcolor ? colr :na)

// My 2 lines
alertcondition(Buy, title='ASTS-BuyBTC', message='ASTS-BuyBTC 1m')
alertcondition(Sell, title='ASTS-SellBTC', message='ASTS-SellBTC 1m')

No errors on compiling, when the alerts are first created, I expected when they were saved one alert would match, and the alert and be triggered but it wasn't, I waited till the conditions on the chart matched a buy and sell signal, buy the alerts were still not triggered. I am fairly new to pine code... Though I have customized some indicators and converted a few studies to strategies and visa versa.

Upvotes: 1

Views: 424

Answers (2)

Lucas Henrique
Lucas Henrique

Reputation: 1

Good job! I've been learning a lot of thinks with ur posts!

Upvotes: 0

PineCoders-LucF
PineCoders-LucF

Reputation: 8789

Looks like you're not doing the last step: creating the alert through TV Web using ALT-A.

Upvotes: 0

Related Questions