Reputation: 11
I've tried to create my own indicator in pinescript, however when adding alerts they don't seem to be triggering. The buy/sell signal will come up on the chart, however once I initiate the condition nothing will is triggered.
Attached below is my code, in the last 2 lines are the alert conditions.
I've tried various different ways through different tutorials but they are either outdated and won't let me save or it simply won't work.
//@version=4
study(title="Tenkan Kijun Cross Alert", shorttitle="Kijun Cross Crypto", overlay=true)
conversionPeriods = input(3, minval=1, title="Conversion Line Periods"),
basePeriods = input(60, minval=1, title="Base Line Periods")
donchian(len) => avg(lowest(len), highest(len))
conversionLine = donchian(conversionPeriods)
baseLine = donchian(basePeriods)
spanColor = conversionLine>=baseLine ? #FFFF00 : #800000
plot(conversionLine, color=spanColor, title="Conversion Line")
plot(baseLine, color=spanColor, title="Base Line")
plotshape(crossover(conversionLine, baseLine), style=shape.triangleup, size=size.tiny, color=#008000, text="Buy", title="Buy", location=location.belowbar)
plotshape(crossover(baseLine, conversionLine), style=shape.triangledown, size=size.tiny, color=#FF0000, text="Sell", title="Sell")
alertcondition(crossover(conversionLine, baseLine), title="Sell", message="Sell")
alertcondition(crossover(baseLine, conversionLine), title="Buy", message="Buy")
No alert condition triggered.
Upvotes: 1
Views: 2786
Reputation: 8799
You are most probably not creating an alert in the TradingView app. Using alertcondition()
in your script only makes your script appear in the Create Alert dialog box's Condition dropdown menu; it does not create an alert that will trigger in TV. Use ALT-A to create an alert in TV.
Upvotes: 1