Moves a label sideways to a new bar or time, keeping its price where it is.
The new x is read in the label's current scale, a bar index or a timestamp. The price stays put, so the label slides along a horizontal line.
Pass a value larger than bar_index to push the label ahead of the latest bar. When both coordinates change, label.set_xy() does it in one call.
Syntax
label.set_x(id: series label, x: series int) -> void
label.set_x(x: series int) -> voidArguments
| Name | Type | Default | Description |
|---|---|---|---|
| id | series label | required | The label that moves sideways. Its price, text and look stay as they were. |
| x | series int | required | The new bar index, or a millisecond timestamp when the label's xloc is xloc.bar_time. A value past bar_index lands right of the last bar. |
Returns
Nothing.
Remarks
- On Sidechair: a timestamp later than the last loaded bar is placed ahead of it in steps of the chart's bar length, and one earlier than the first bar sits on the first bar.
Example
//@version=6
indicator("label.set_x: trailing marker", overlay = true)
var label axis = label.new(bar_index, close, "start", style = label.style_label_left, color = color.gray)
label.set_x(axis, bar_index + 3)See also
Runs on Sidechair