🩹Band Lines

Band API

File: band‑indicator.api.ts

Band lines are simple horizontal lines you draw at specific price levels—great for quick markers like support, resistance, entry, or alert levels. The Band helper lets you add these lines with a friendly one-liner and basic styling (color, width, dashed/solid, visibility). Under the hood it packages everything into the expected chart data structure for you.

Syntax

band.line(name, value, color, linestyle?, linewidth?, visible?)

Parameters

  • name string — Display name of the band (also used to build its id).

  • value number — The Y‑axis price/level where the horizontal line is drawn.

  • color string — Line color as hex or rgba string (e.g., "#00FF00" or "rgba(0,255,0,1)").

  • linestyle number (optional, default 2 = dashed) — Line style code used by the charting library.

  • linewidth number (optional, default 1) — Stroke width in pixels.

  • visible boolean (optional, default true) — Whether the band is initially visible on the chart.

Return Value

{ value: number; id: string } — The same value you passed and an auto‑generated id built from name (lowercased, no spaces).

Example

Tips

  • Tip: Use clear, unique names (“Support”, “Resistance 1”, “VWAP Line”)—the id is derived from name, which makes it easier to reference later.

  • Tip: Need multiple fixed levels? Just call band.line(...) multiple times—each call creates its own band block with independent styling.

Warning

  • Warning: If two bands share the same name, they’ll produce the same id (lowercased, no spaces). Give each band a unique name to avoid collisions.

  • Warning: color must be a string. Passing non‑string color objects won’t work here (convert to hex or rgba(...) first).

Good Practice

  • Good Practice: Keep default visibility true for key levels and use softer colors (or higher transparency) for secondary lines to reduce chart clutter.

  • Good Practice: Standardize your linestyle codes (e.g., 0 = solid, 2 = dashed) across your project so users see consistent styling conventions.

Last updated