Skip to content

charton API


charton API / @chart-on/core / index / TradeLineOptions

Interface: TradeLineOptions ​

Defined in: packages/core/src/annotations/types.ts:245

Options of an order or position line. Interaction is opt-in: a line can be dragged only with onDrag or onChange, and buttons appear only with onAction.

Extends ​

Properties ​

actions ​

actions: TradeAction[]

Defined in: packages/core/src/annotations/types.ts:271

Buttons on the entry block, left to right. Default: ['cancel'] for orders, ['reverse', 'close'] for positions.


actionsReadOnly? ​

optional actionsReadOnly?: boolean

Defined in: packages/core/src/annotations/types.ts:237

No action buttons.

Inherited from ​

TradeLineReadOnly.actionsReadOnly


bracketActions ​

bracketActions: TradeAction[]

Defined in: packages/core/src/annotations/types.ts:273

Buttons on the take-profit and stop-loss blocks. Default: ['cancel'].


bracketReadOnly? ​

optional bracketReadOnly?: boolean

Defined in: packages/core/src/annotations/types.ts:235

No bracket handle.

Inherited from ​

TradeLineReadOnly.bracketReadOnly


color? ​

optional color?: string

Defined in: packages/core/src/annotations/types.ts:254

Default: the theme's up colour for buys, down for sells.


confirmChanges? ​

optional confirmChanges?: boolean

Defined in: packages/core/src/annotations/types.ts:282

A drag released at a new price waits for confirmation: the part shows the new price with confirm and discard buttons, and onChange fires only on confirm. Discard or Escape restores the price. Default: true for orders, false for positions.


dragReadOnly? ​

optional dragReadOnly?: boolean

Defined in: packages/core/src/annotations/types.ts:233

No dragging of the entry, take-profit or stop-loss.

Inherited from ​

TradeLineReadOnly.dragReadOnly


formatPnl? ​

optional formatPnl?: (pnl) => string

Defined in: packages/core/src/annotations/types.ts:269

Format the P&L, e.g. to apply a contract multiplier or a currency. Default: signed price format.

Parameters ​

pnl ​

number

Returns ​

string


kind ​

kind: TradeLineKind

Defined in: packages/core/src/annotations/types.ts:246


label? ​

optional label?: string

Defined in: packages/core/src/annotations/types.ts:252

First segment of the label block. Default: Buy / Sell for orders, Long / Short for positions.


labelAnchor? ​

optional labelAnchor?: LabelAnchor

Defined in: packages/core/src/annotations/types.ts:160

Where the label block sits: right (default, next to the price axis), center or left. Brackets follow their order.

Inherited from ​

LineLabelOptions.labelAnchor


lineOnly? ​

optional lineOnly?: boolean

Defined in: packages/core/src/annotations/types.ts:164

Only the line: no label block, no hit testing. For dense ladders of many orders.

Inherited from ​

LineLabelOptions.lineOnly


lineStyle ​

lineStyle: LineStyle

Defined in: packages/core/src/annotations/types.ts:257

Default: dashed for orders, solid for positions.


lineWidth ​

lineWidth: number

Defined in: packages/core/src/annotations/types.ts:255


onAction? ​

optional onAction?: (e) => void

Defined in: packages/core/src/annotations/types.ts:289

A button was pressed. Without it, no buttons are shown.

Parameters ​

e ​

TradeActionEvent

Returns ​

void


onBracketCreate? ​

optional onBracketCreate?: (e) => void

Defined in: packages/core/src/annotations/types.ts:296

The entry block gets a handle while a take-profit or stop-loss is unset: dragging it away from the entry proposes one (above a buy is a take-profit, below a stop-loss; the other way round for a sell). The proposal shows until the next applyOptions on the line, which answers it.

Parameters ​

e ​

BracketCreateEvent

Returns ​

void


onChange? ​

optional onChange?: (e) => void

Defined in: packages/core/src/annotations/types.ts:287

Drag released at a new price (confirmed, with confirmChanges). The line keeps the new price.

Parameters ​

e ​

TradeLineChangeEvent

Returns ​

void


onClick? ​

optional onClick?: (e) => void

Defined in: packages/core/src/annotations/types.ts:152

Pressed and released on the line or its block without dragging it. Never after a drag.

Parameters ​

e ​

LinePointerEvent<TradeLine>

Returns ​

void

Inherited from ​

LineInteractionOptions.onClick


onDrag? ​

optional onDrag?: (e) => void

Defined in: packages/core/src/annotations/types.ts:275

While dragging, whenever the snapped price changes (and once more after Escape).

Parameters ​

e ​

TradeLineDragEvent

Returns ​

void


onHover? ​

optional onHover?: (e) => void

Defined in: packages/core/src/annotations/types.ts:148

The pointer moved onto the line or its label block. Once per enter.

Parameters ​

e ​

LinePointerEvent<TradeLine>

Returns ​

void

Inherited from ​

LineInteractionOptions.onHover


onHoverEnd? ​

optional onHoverEnd?: () => void

Defined in: packages/core/src/annotations/types.ts:150

The pointer left the line and its block. Once per leave.

Returns ​

void

Inherited from ​

LineInteractionOptions.onHoverEnd


pnl ​

pnl: boolean

Defined in: packages/core/src/annotations/types.ts:267

Positions: show profit / loss against the series' last price.


price ​

price: number

Defined in: packages/core/src/annotations/types.ts:247


priceAxisLabel? ​

optional priceAxisLabel?: boolean

Defined in: packages/core/src/annotations/types.ts:162

The price label on the axis. Default true.

Inherited from ​

LineLabelOptions.priceAxisLabel


quantity? ​

optional quantity?: string | number

Defined in: packages/core/src/annotations/types.ts:250

Shown in the label block; a number also feeds the position P&L.


readOnly? ​

optional readOnly?: boolean

Defined in: packages/core/src/annotations/types.ts:231

No dragging, no buttons and no bracket handle.

Inherited from ​

TradeLineReadOnly.readOnly


series? ​

optional series?: Series<object>

Defined in: packages/core/src/annotations/types.ts:263

Series whose price scale and pane the line follows. Default: the main series.


side ​

side: OrderSide

Defined in: packages/core/src/annotations/types.ts:248


stopLoss? ​

optional stopLoss?: number | null

Defined in: packages/core/src/annotations/types.ts:261

Linked stop-loss price; null or omitted hides the line.


takeProfit? ​

optional takeProfit?: number | null

Defined in: packages/core/src/annotations/types.ts:259

Linked take-profit price; null or omitted hides the line.


tickSize? ​

optional tickSize?: number

Defined in: packages/core/src/annotations/types.ts:265

Dragged prices snap to multiples of this. Default: one unit of the series precision.


tooltip? ​

optional tooltip?: string | string[]

Defined in: packages/core/src/annotations/types.ts:154

Text shown while hovering the line; several strings are several lines.

Inherited from ​

LineInteractionOptions.tooltip