Doug
Doug

Reputation: 35

Pine V5 type issues : Display RSI value on tradingview chart

I'm trying to display the RSI value above each bar in trading view. I'm not able to do so because no matter what I try I get the following error.

Cannot call 'plotshape' with argument 'text'='vt_rsi_str'. An argument of 'series string' type was used but a 'const string' is expected

I'm clearly going about this wrong, but I feel like displaying the RSI value is something that should be possible, no?

The latest grasping at straws syntax I've tried is below. Any suggestions would appreciated!

vt_rsi = ta.rsi(close,14)
vt_rsi_str = str.format("{0,number,#}", str.tostring(vt_rsi[0]))
plotshape(vt_rsi_up, style=shape.arrowup, color=#1848cc, title="RSI Up", location=location.top, text=vt_rsi_str)

Upvotes: 0

Views: 5890

Answers (1)

vitruvius
vitruvius

Reputation: 21342

That is not supported with plot() functions. Please see my answer here for more details.

However, you can use labels instead.

//@version=5
indicator("My Script", overlay=true)
vt_rsi = ta.rsi(close,14)
vt_rsi_str = str.format("{0,number,#.##}", vt_rsi)
label1 = label.new(bar_index, high, text=vt_rsi_str, style=label.style_triangledown, size=size.tiny, color=#1848cc, textcolor=#1848cc)
label.set_xloc(label1, time, xloc.bar_time)
label.set_y(label1, high)
label.set_text(label1, vt_rsi_str)

enter image description here

Upvotes: 2

Related Questions