范围内最高的松字

Highest high in a range pine script

我正在尝试标记和更改范围内最高条的颜色。相反,它用颜色绘制所有条形图,而不是在最高条形图上绘制标签,而是在最后一个条形图上绘制标签?

//@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)

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

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

//@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)