范围Pine脚本中的最高高

发布于 2025-01-20 09:15:00 字数 479 浏览 2 评论 0原文

我正在尝试标记和更改该范围内最高条的颜色。取而代之的是,它用颜色绘制所有条形图,并且不会在最高条上绘制标签,而是在最后一个栏上绘制标签?

//@version=5
indicator(title='Label', overlay=true)

highestHigh = ta.highest(high, 20)
lowestLows = ta.lowest(low, 20)

PmeU = if highestHigh
    label.new(bar_index, na, "Highest pirce was: " + str.tostring(highestHigh), color=color.green, textcolor=color.black, style=label.style_label_down, yloc=yloc.abovebar)

label.delete(PmeU[1])

barcolor(highestHigh ? color.blue : na)

I am trying to label and change the color of the highest bar in the range. Instead, it paints all bars with the color and does not plot the label on the highest bar but on the last bar?

//@version=5
indicator(title='Label', overlay=true)

highestHigh = ta.highest(high, 20)
lowestLows = ta.lowest(low, 20)

PmeU = if highestHigh
    label.new(bar_index, na, "Highest pirce was: " + str.tostring(highestHigh), color=color.green, textcolor=color.black, style=label.style_label_down, yloc=yloc.abovebar)

label.delete(PmeU[1])

barcolor(highestHigh ? color.blue : na)

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

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

发布评论

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

评论(1

执笏见 2025-01-27 09:15:00

ta.highest() 返回回溯期内的最高价格。如果当前 high 是最高的,则不会返回。您需要对此进行额外检查。

说到标签的问题,这是因为你总是删除前一个标签。我认为您不想删除案例中的任何标签。

//@version=5
indicator(title='Label', overlay=true)

highestHigh = ta.highest(high, 20)
lowestLows = ta.lowest(low, 20)

is_high = high >= highestHigh

PmeU = if is_high
    label.new(bar_index, na, "Highest pirce was: " + str.tostring(highestHigh), color=color.green, textcolor=color.black, style=label.style_label_down, yloc=yloc.abovebar)

barcolor(is_high ? color.blue : na)

输入图片此处描述

ta.highest() returns the highest price within the lookback period. It does not return if the current high is the highest. You need an additional check for that.

Coming to the issue with the label, it is because you always delete the previous one. I don't think you want to delete any label in your case.

//@version=5
indicator(title='Label', overlay=true)

highestHigh = ta.highest(high, 20)
lowestLows = ta.lowest(low, 20)

is_high = high >= highestHigh

PmeU = if is_high
    label.new(bar_index, na, "Highest pirce was: " + str.tostring(highestHigh), color=color.green, textcolor=color.black, style=label.style_label_down, yloc=yloc.abovebar)

barcolor(is_high ? color.blue : na)

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文