如何向我的脚本添加数字后缀? K 千, M 百万

How do I add a number suffix to my script? K thousands, M million

默认情况下,Tradingview 将交易量显示为 (K) 千和 (M) 百万。如何将其添加到我创建的自定义脚本中?

例如,如果我在柱上看到净交易量为 1740654.0000,我更希望它显示为 1.74M。

studyprecision 值为 0 将有助于: https://www.tradingview.com/study-script-reference/#fun_study

//@version=3
study("My Script", precision=0)
plot(volume)

在 Pine Script v4 中,我能够使用 study 函数的 format 参数以这种方式格式化数字。

来自documentation

format (const string) type of formatting study values on the price axis. Possible values are: format.inherit, format.price, format.volume. Default is format.inherit.

//@version=4
study("My indicator", format=format.volume)