entity.line#
Create or update a keyed line entity in data coordinates (timestamp + price).
SYNTAX#
function entity.line(props: { key: string; x1: number; y1: number; x2: number; y2: number; color: string; width?: number; style?: 'solid' | 'dashed' | 'dotted'; forceOverlay?: boolean }): EntityHandleARGUMENTS#
props({ key, x1, y1, x2, y2, color, width?, style?, forceOverlay? }) —x1/x2are unix-second timestamps;y1/y2are prices.keyis the persistent identifier. SetforceOverlay: trueto render on the price pane regardless of the indicator's pane setting.
RETURNS#
EntityHandle — { set(props), delete() }. Call handle.set({...}) to replace the stored props; handle.delete() to remove the entity.
REMARKS#
The handle's key is fixed at creation — handle.set({ key: 'other' }) is a type error and silently ignored at runtime. Coordinates are data-space; the renderer projects to pixels via the chart's projection.
EXAMPLE#
function onBar(i, ctx) {
if (!ctx.isLast) return;
const right = candles[i].time;
const left = candles[Math.max(0, i - 50)].time;
entity.line({
key: 'support',
x1: left, y1: 50000,
x2: right, y2: 50000,
color: '#26a69a', width: 2, style: 'dashed'
});
}SEE ALSO#
indicator.entity.box, indicator.entity.label, indicator.entity.marker, indicator.entity.arrow, types.EntityHandle