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

Line(key, opts) -> handle
key is a unique string identifying this line’s slot. Calling Line with the same key replaces the prior line. See entities overview for the slot model.

Quick example

const support = Line("support", {
  x1: 0,  y1: 42000,
  x2: 50, y2: 42000,
  color: "#22c55eFF",
  width: 2,
  style: "solid",
  label: "Support",
});

onBar(() => {
  // Extend the line to the current bar
  support.set({ x2: ctx.i() });
});

Options

x1
number
required
Start x coordinate as a bar index.
y1
number
required
Start y coordinate as a price level.
x2
number
required
End x coordinate as a bar index.
y2
number
required
End y coordinate as a price level.
color
string
Line color as #RRGGBBAA hex. Default: chart accent color.
width
number
Line width in pixels. Default: 1.
style
string
Line style. One of: "solid", "dotted", "dashed", "arrow.right", "arrow.left", "arrow.both". Default: "solid".
label
string
Optional text label rendered near the line midpoint.
zIndex
number
Stacking order. Higher values render on top. Default: 0.
forceOverlay
boolean
When true, renders in the main price pane even if the indicator is on a sub-pane. Default: false.

Style enum values

ValueDescription
"solid"Continuous line
"dotted"Dotted line
"dashed"Dashed line
"arrow.right"Arrowhead at the end (x2, y2)
"arrow.left"Arrowhead at the start (x1, y1)
"arrow.both"Arrowheads at both ends
You can also use the linestyle.* constants:
Line("trend", { ..., style: linestyle.dashed });

Handle methods

const line = Line("sr", { x1: 0, y1: 42000, x2: 10, y2: 42000, color: "#22c55eFF" });

// Mutate in place
line.set({ color: "#ef4444FF", y1: 41800, y2: 41800 });

// Clone to a new key
const copy = line.clone("sr-copy");

// Delete
line.delete();

Dynamic S/R line example

// Draw an arrow.right line from each new pivot high
onBar(() => {
  const ph = ta.pivothigh(ctx.high, 5, 5);
  if (na(ph)) return;

  const pivotBar = ctx.i() - 5; // pivot high is 5 bars in the past
  Line(`ph_${pivotBar}`, {
    x1: pivotBar, y1: ph,
    x2: ctx.i(),  y2: ph,
    color: "#ef4444FF",
    style: "arrow.right",
    label: str.format("{}", math.round(ph, 1)),
  });
});

LineFill

Shade the area between two Line entities.

Box

Rectangular zone - use when you need width and height.

Constants

linestyle.* enum values.

Support/resistance example

Full working example using Line entities.