Sidechair

yloc.* constants

Browse the reference

How label.new places a label vertically: at its y price, or above or below the bar.

Try it in the editor

yloc.* constants go in the yloc argument of label.new and label.set_yloc. yloc.price (the default) puts the label at the y value you give. yloc.abovebar and yloc.belowbar attach it above the high or below the low of its bar and ignore the y value.

That makes the bar-attached forms handy for signals: you do not need to know the price, and the label follows the bar when the scale changes.

Constants

NameValueDescription
yloc.abovebarAbove the bar's high; the y value is ignored.
yloc.belowbarBelow the bar's low; the y value is ignored.
yloc.priceAt the y price you pass; the default.

Remarks

  • Only labels have yloc. Lines and boxes always use prices on the y axis.

Example

Pine ScriptSignals above and below barsOpen in editor
//@version=6
indicator("Yloc", overlay = true)
up = close > open and close[1] < open[1]
down = close < open and close[1] > open[1]
if up
    label.new(bar_index, na, "up", yloc = yloc.belowbar, style = label.style_label_up, color = color.green, textcolor = color.white)
if down
    label.new(bar_index, na, "dn", yloc = yloc.abovebar, style = label.style_label_down, color = color.red, textcolor = color.white)
plot(close, "Close", color.gray)

See also

Runs on Sidechair