Moves a label to a new bar and a new price in one call.
It sets x and y together, which is how a single var label is kept on a moving target: label.set_xy(l, bar_index, high). Separate set_x and set_y calls do the same in two steps.
x is interpreted in the label's current xloc. A label that must follow a swing that is not on the current bar takes the bar from a function such as ta.lowestbars().
Syntax
label.set_xy(id: series label, x: series int, y: series int/float) -> void
label.set_xy(x: series int, y: series int/float) -> voidArguments
| Name | Type | Default | Description |
|---|---|---|---|
| id | series label | required | The label to relocate on both axes. Its text, colors and style are untouched. |
| x | series int | required | The new bar index, or a millisecond timestamp when the label's xloc is xloc.bar_time. |
| y | series int/ | required | The new price level. Ignored while the label's yloc is yloc.abovebar or yloc.belowbar. |
Returns
Nothing.
Example
//@version=6
indicator("label.set_xy: rolling low", overlay = true)
var label lo = label.new(bar_index, low, "", style = label.style_label_up, color = color.red)
label.set_xy(lo, bar_index + ta.lowestbars(low, 50), ta.lowest(low, 50))
label.set_text(lo, str.tostring(ta.lowest(low, 50), "#.##"))See also
Runs on Sidechair