Skip to main content

entity.box#

Create or update a keyed rectangular box in data coordinates.

SYNTAX#

function entity.box(props: { key: string; x1: number; y1: number; x2: number; y2: number; fill: string; border?: string; borderWidth?: number; forceOverlay?: boolean }): EntityHandle

ARGUMENTS#

  • props ({ key, x1, y1, x2, y2, fill, border?, borderWidth?, forceOverlay? }) — x1/x2 are unix-second timestamps; y1/y2 are prices. fill is a CSS color (use rgba for transparency). border is optional — omit for fill-only boxes.

RETURNS#

EntityHandle — { set(props), delete() }.

REMARKS#

Box rendering ships in Round 2 Track F; until then, box entities are accepted by the runtime but render as no-ops (logged once per kind).

EXAMPLE#

function onBar(i, ctx) {
  if (!ctx.isLast) return;
  entity.box({
    key: 'value-area',
    x1: candles[Math.max(0, i - 100)].time, y1: 49000,
    x2: candles[i].time,                    y2: 51000,
    fill: 'rgba(38, 166, 154, 0.15)',
    border: '#26a69a', borderWidth: 1
  });
}

SEE ALSO#

indicator.entity.line, indicator.entity.label, types.EntityHandle