Pine:如何对特定图表使用 label.new(绘制图表和下面的指标时)

发布于 2025-01-16 07:16:29 字数 781 浏览 2 评论 0原文

我想在价格图表上而不是在 CCI 图表上绘制最后一个柱的指数(“5830”,请参见下面的屏幕截图)。

到目前为止,这是我的代码:

//@version=5
indicator("Mon script", overlay=false)

// CCI

cciSource = input.source(close, "Source CCI")
cci=ta.cci(close, 20)

plot(bar_index % 2 ? na: 100, color=color.gray, style=plot.style_linebr)
plot(bar_index % 2 ? na: -100, color=color.gray, style=plot.style_linebr)
plot(cci, title="CCI",color=color.fuchsia)


if (barstate.islast)
    label.new(bar_index, open, str.tostring(bar_index, format.mintick), yloc = yloc.belowbar, style = label.style_none, textcolor = color.black, size = size.normal)

在此处输入图像描述

知道如何执行此操作吗?

此致

I would like to plot the index of the last bar ("5830", see screenshot below) on the prices chart instead of on the CCI chart.

Here is my code so far:

//@version=5
indicator("Mon script", overlay=false)

// CCI

cciSource = input.source(close, "Source CCI")
cci=ta.cci(close, 20)

plot(bar_index % 2 ? na: 100, color=color.gray, style=plot.style_linebr)
plot(bar_index % 2 ? na: -100, color=color.gray, style=plot.style_linebr)
plot(cci, title="CCI",color=color.fuchsia)


if (barstate.islast)
    label.new(bar_index, open, str.tostring(bar_index, format.mintick), yloc = yloc.belowbar, style = label.style_none, textcolor = color.black, size = size.normal)

enter image description here

Any idea on how to do this ?

Best regards

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

妄断弥空 2025-01-23 07:16:29

您已经使用了标签,因此将指标属性更改为 overlay=true

//@version=5
indicator("Mon script", overlay=true)

// CCI

cciSource = input.source(close, "Source CCI")
cci=ta.cci(close, 20)


if (barstate.islast)
    label.new(bar_index, low, str.tostring(bar_index, format.mintick), yloc = yloc.belowbar, style = label.style_label_up, textcolor = color.white, size = size.normal)

另外,您可以将其设置为表格

//@version=5
indicator("Mon script", overlay=true)

// CCI

cciSource = input.source(close, "Source CCI")
cci=ta.cci(close, 20)


var table table1 = na
var table2 = table.new(position.top_left, na, na)
if barstate.islastconfirmedhistory
    var table3 = table.new(position = position.top_right, columns = 1, rows = 1, bgcolor = color.yellow, border_width = 1)
    table.cell(table_id = table3, column = 0, row = 0, text = str.tostring(bar_index, format.mintick))

You already used label, so change the indicator properties to overlay=true

//@version=5
indicator("Mon script", overlay=true)

// CCI

cciSource = input.source(close, "Source CCI")
cci=ta.cci(close, 20)


if (barstate.islast)
    label.new(bar_index, low, str.tostring(bar_index, format.mintick), yloc = yloc.belowbar, style = label.style_label_up, textcolor = color.white, size = size.normal)

Also, you can make it as table

//@version=5
indicator("Mon script", overlay=true)

// CCI

cciSource = input.source(close, "Source CCI")
cci=ta.cci(close, 20)


var table table1 = na
var table2 = table.new(position.top_left, na, na)
if barstate.islastconfirmedhistory
    var table3 = table.new(position = position.top_right, columns = 1, rows = 1, bgcolor = color.yellow, border_width = 1)
    table.cell(table_id = table3, column = 0, row = 0, text = str.tostring(bar_index, format.mintick))
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文