如何更具体地将label.new()定位? V5

发布于 2025-01-25 07:49:20 字数 329 浏览 2 评论 0原文

这是我的标签,与蜡烛混乱:

”标签与蜡烛混乱“

label.new(bar_index, high, color=color.red, textcolor=color.white, text="Blah Blah")

如何将其定位得更高,以便在蜡烛后面?

Here's my label, messing with the candles:

Label messing with the candles

label.new(bar_index, high, color=color.red, textcolor=color.white, text="Blah Blah")

How to position it higher, to get out behind the candles?

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

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

发布评论

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

评论(2

玩世 2025-02-01 07:49:20

当您不指定yloc label.new()的参数时,它将使用PRICE您在第二个参数中传递 - 在您的情况下,是。这就是为什么标签完全指向高价的原因。

您可以使用yloc参数与yloc.abovebarlbl_red下面),也可以将数学公式与价格一起使用(<代码> lbl_green 下面)。

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © vitruvius

//@version=5
indicator("My script", overlay=true)
is_red = close < open
is_green = not is_red

_atr = ta.atr(10) / 4

var label lbl_red = na
var label lbl_green = na

if (barstate.islast)
    lbl_red := label.new(bar_index, high, "Test", yloc=yloc.abovebar, color=color.red, style=label.style_label_down, textcolor=color.white)
    lbl_green := label.new(bar_index, low - _atr, "Test", color=color.green, style=label.style_label_up, textcolor=color.white)

    label.delete(lbl_red[1])
    label.delete(lbl_green[1])

When you don't specify the yloc argument of label.new(), it will use the price you pass in the second argument -which in your case is high. That's why the label points exactly to the high price.

You can use the yloc argument with something like yloc.abovebar (lbl_red below) or you can use a mathematical formula together with the price (lbl_green below).

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © vitruvius

//@version=5
indicator("My script", overlay=true)
is_red = close < open
is_green = not is_red

_atr = ta.atr(10) / 4

var label lbl_red = na
var label lbl_green = na

if (barstate.islast)
    lbl_red := label.new(bar_index, high, "Test", yloc=yloc.abovebar, color=color.red, style=label.style_label_down, textcolor=color.white)
    lbl_green := label.new(bar_index, low - _atr, "Test", color=color.green, style=label.style_label_up, textcolor=color.white)

    label.delete(lbl_red[1])
    label.delete(lbl_green[1])

enter image description here

望喜 2025-02-01 07:49:20

如果您需要标签y的距离,则使用一定量的最高值和最低值,然后将一定数的(最高)添加到蜡烛高(最高)

if you need the label Y distance rather consistent use the highest value and lowest value of a certain amount of bars and add a percentage of (highest - lowest) to the candle high

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