如何让我的 toString 在 pinescript 中显示带小数点的值
how can I make my toString to show the value with decimal in pinescript
现在字符串只显示为“234,234”。这是音量值。我需要它来显示小数点的音量,但只有 2-3 位数字(如“234k”)就可以了。现在已经用了几个小时了......感谢任何帮助!
study("Vol", overlay=true, format=format.volume, precision=3)
.....
label1 = label.new(bar_index[rightbars], high[rightbars], text=tostring(volume[rightbars], ""), style=label.style_labeldown, color=color.new(color.white, 100), textcolor=color.new(color.blue, 20))
str.format()
或round
+tostring
可以做到:
//@version=4
study("Vol", overlay=true, format=format.volume, precision=3)
val = 234.234
str = str.format( "{0, number, integer}K", val)
// str = tostring( round(val, 0)) + "K" // same
label.new(bar_index, high, str)
plot(close)
添加卷格式(K/M/B)
//@version=4
study("My Script")
val = 123456789.12345
str = tostring(x, format.volume)
label.new(barstate.islast?bar_index:na, high, str)
plot(close)
现在字符串只显示为“234,234”。这是音量值。我需要它来显示小数点的音量,但只有 2-3 位数字(如“234k”)就可以了。现在已经用了几个小时了......感谢任何帮助!
study("Vol", overlay=true, format=format.volume, precision=3)
.....
label1 = label.new(bar_index[rightbars], high[rightbars], text=tostring(volume[rightbars], ""), style=label.style_labeldown, color=color.new(color.white, 100), textcolor=color.new(color.blue, 20))
str.format()
或round
+tostring
可以做到:
//@version=4
study("Vol", overlay=true, format=format.volume, precision=3)
val = 234.234
str = str.format( "{0, number, integer}K", val)
// str = tostring( round(val, 0)) + "K" // same
label.new(bar_index, high, str)
plot(close)
添加卷格式(K/M/B)
//@version=4
study("My Script")
val = 123456789.12345
str = tostring(x, format.volume)
label.new(barstate.islast?bar_index:na, high, str)
plot(close)