Reputation: 502
For debug purpose I would show in trading view chart some variable. Every time I try to show a variable using pine I receive some kind of error , I tried using plot and label and other ways.
Suppose that I have this code
//@version=4
study("test", overlay=true)
a = 20
b = 2
ob = 40
os = -40
// Range Calculation
ll = lowest (low, a)
hh = highest (high, a)
diff = hh - ll
rdiff = close - (hh+ll)/2
avgrel = ema(ema(rdiff,b),b)
avgdiff = ema(ema(diff,b),b)
SMI = avgdiff != 0 ? (avgrel/(avgdiff/2)*100) : 0
////////////////////////////////////////
SMIsignal = ema(SMI,b)
emasignal = ema(SMI, 10)
Which is the code to show the SMIsignal and emasignal (using text) above each candle in my trading view chart ?
e.g. I tried
label.new(bar_index, high, text=emasignal)
but returns nothing
Upvotes: 0
Views: 906
Reputation: 2568
To output a number, it must be converted to a string.
label.new(bar_index, high, text=tostring(emasignal))
Upvotes: 1