Reputation: 987
I'm trying to implement an answer of this question, but somehow no labels are displayed nor a single error message. Outside this code, all the bunch of labels are displayed so the label.new()
instance itself works well.
What do I do wrong?
var label HighRSILabel = na
if(rsi > 70)
if(na(HighRSILabel)) //Does not exist, create one
HighRSILabel := label.new(bar_index, high, color=color.orange, text="RSI", textcolor=color.black, tooltip="RSI > 70", style=label.style_label_down)
else
label.set_x(HighRSILabel, bar_index)
Upvotes: 0
Views: 581
Reputation: 333
Are you sure your symbol(e.g. BTCUSD) ever hit 70 rsi? Because if it never hit 70 rsi no label will be created. I tried your code with the symbol DOTEUR (1day) and it works as it should.
You can use tradingviews "<<Replay" function to see how the label moves through time for easier debugging.
Here is the code:
//@version=5
indicator("rsi last")
var label HighRSILabel = na
rsi = ta.rsi(close, 10)
plot(rsi)
hline(70)
hline(30)
if(rsi > 70)
if(na(HighRSILabel)) //Does not exist, create one
HighRSILabel := label.new(bar_index, rsi, color=color.orange, text="RSI", textcolor=color.black, tooltip="RSI > 70", style=label.style_label_down)
else
label.set_x(HighRSILabel, bar_index)
Upvotes: 1