Pine script tradingview 最高交易量值,列中百分比

Pine script tradingview Value of highest volume with percentage on column

我正在尝试将每个卷的值放在 bar.But 的列上仍然没有解决方法 it.i 正在学习 pinescript.Please 指导我如何放置标签或直接在 column.I 上的值我附上另一个指标的照片,在 column.But 上显示值这个 incator 覆盖是错误的,我的是 true.If 我可以得到相同或接近的结果然后也可以me.I 知道在列上绘制值很棘手,但我相信也有办法做到这一点。enter image description here

这是我所知道的用 overlay = true 实现你想要的最接近的方法。您还需要确保在图表设置下将底部边距设置为零。

//@version=4
study("Volume Values", overlay = true, scale = scale.none, max_labels_count = 500)
hh = highest(volume, 500)
plot(hh * 5, color = #00000000)

col = close < close[1]? color.lime : color.red

plot(volume, color = col, style = plot.style_columns)

if volume > sma(volume, 20)
    vol_lab = label.new(x = bar_index, y = volume, style = label.style_label_down, color = #00000000, textcolor = col, size = size.tiny, text = tostring(volume))

通过 hh * 5 的不可见图(不需要为 5,根据您的需要进行调整),您可以将成交量列“展平”到图表底部 window

要获得所需格式的音量值,您必须手动将它们转换为字符串,如下所示:

f_get_volume_string(_volume) =>
    string _volume_string = na
    if _volume >= 1000000000
        _volume_digits = round((_volume / 1000000000) * 100) / 100
        _volume_string := tostring(_volume_digits) + "B"
    else if _volume >= 1000000
        _volume_digits = round((_volume / 1000000) * 100) / 100
        _volume_string := tostring(_volume_digits) + "M"
    else if _volume >= 1000
        _volume_digits = round((_volume / 1000) * 100) / 100
        _volume_string := tostring(_volume_digits) + "K"
    else
        _volume_string := tostring(round(_volume * 100) / 100)
    _volume_string
    

vol_lab = label.new(x = bar_index, y = close, style = label.style_label_left, text = f_get_volume_string(volume))
label.delete(vol_lab[1])

此函数将return音量值作为您可以在标签中使用的字符串。如果你希望它保留 3 位小数,请使用 * 1000/ 1000