Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.darvas.app/llms.txt

Use this file to discover all available pages before exploring further.

Signature

Label(key, opts) -> handle
A Label is a text annotation anchored to a specific bar index and price. Unlike Box text, a Label is not confined to a rectangle - it floats at the coordinate you specify.

Quick example

const entryLabel = Label("entry", {
  x: 10, y: 42500,
  text: "Long entry",
  color: "#22c55eFF",
  size: 12.0,
  textAlign: "center",
});

Options

x
number
required
X coordinate as a bar index.
y
number
required
Y coordinate as a price level.
text
string
required
Text to display.
color
string
Text color as #RRGGBBAA. Default: white.
size
number
Font size in pixels. Default: 12.0.
textAlign
string
Text alignment: "left", "center", "right". Default: "center".
zIndex
number
Stacking order. Default: 0.
forceOverlay
boolean
Render in main price pane from a sub-pane indicator. Default: false.

Handle methods

label.set({ text: "Updated", color: "#FFFF00FF" });
label.clone("entry-alt");
label.delete();

Annotating pivot highs

onBar(() => {
  const ph = ta.pivothigh(ctx.high, 5, 5);
  if (na(ph)) return;

  const bar = ctx.i() - 5;
  Label(`ph_label_${bar}`, {
    x: bar,
    y: ph * 1.002, // slightly above the pivot
    text: str.format("{}", math.round(ph, 0)),
    color: "#ef4444FF",
    size: 11,
    textAlign: "center",
  });
});

Marker

Icon shapes instead of text.

str.*

Format numbers into label text with str.format.

Box

Box also supports embedded text via the text option.