entities reference
Chart annotation entities backed by bounded keyed pools.
Chart annotation entities backed by bounded keyed pools.
Accepted values
These named values are the complete choices accepted by parameters of each type.
Anchor
anchor.topLeftOffsets inward from the pane's top-left corner.anchor.topCenterOffsets from the center of the pane's top edge.anchor.topRightOffsets inward from the pane's top-right corner.anchor.middleLeftOffsets from the center of the pane's left edge.anchor.centerOffsets from the center of the pane.anchor.middleRightOffsets from the center of the pane's right edge.anchor.bottomLeftOffsets inward from the pane's bottom-left corner.anchor.bottomCenterOffsets from the center of the pane's bottom edge.anchor.bottomRightOffsets inward from the pane's bottom-right corner.anchor.topPins y to logical pixels down from the pane's top edge; x stays in chart space.anchor.bottomPins y to logical pixels up from the pane's bottom edge; x stays in chart space.anchor.leftPins x to logical pixels right of the pane's left edge; y stays in chart space.anchor.rightPins x to logical pixels left of the pane's right edge; y stays in chart space.FontFamily
font.appUses the normal chart application font.font.monoUses the application monospace font.entities.linePool
entities.linePool(max: int, on: Surface? = null, anchor: Anchor? = null) -> LinePoolCreates a pool of lines with a fixed limit.
Declare the pool with setup or state, then use it from any handler.
Each drawing is identified by its keys.
maxlimits the number of lines. Values outside the entity-pool limit are rejected before the script runs. Creating a new drawing when full removes the oldest one.onchooses the panel or pane for every drawing in the pool. Null uses the main price pane.anchorchooses how to position drawings. Null uses chart coordinates.
Anchors
A pane anchor, such as anchor.topLeft or anchor.center, measures both
coordinates in logical pixels from that point. An edge anchor, such as
anchor.top or anchor.left, measures one coordinate inward from the edge in
pixels and keeps the other in chart coordinates.
Contracts
max: Accepted range: 1 to MAX_ENTITY_POOL_CAP. Invalid values are rejected.
Example
script "Line Pool Example"
data chart = subscribe(data.ohlcv)
state lines = entities.linePool(max: 8)
on chart.update {
let count = lines.capacity
}Accepted values
anchor:Anchorvalues — 13 available.
entities.boxPool
entities.boxPool(max: int, on: Surface? = null, anchor: Anchor? = null) -> BoxPoolCreates a pool of boxes with a fixed limit.
Declare the pool with setup or state, then use it from any handler.
Each drawing is identified by its keys.
maxlimits the number of boxes. Values outside the entity-pool limit are rejected before the script runs. Creating a new drawing when full removes the oldest one.onchooses the panel or pane for every drawing in the pool. Null uses the main price pane.anchorchooses how to position drawings. Null uses chart coordinates.
Anchors
A pane anchor, such as anchor.topLeft or anchor.center, measures both
coordinates in logical pixels from that point. An edge anchor, such as
anchor.top or anchor.left, measures one coordinate inward from the edge in
pixels and keeps the other in chart coordinates.
Contracts
max: Accepted range: 1 to MAX_ENTITY_POOL_CAP. Invalid values are rejected.
Example
script "Box Pool Example"
data chart = subscribe(data.ohlcv)
state zones = entities.boxPool(max: 8)
on chart.update {
let count = zones.capacity
}Accepted values
anchor:Anchorvalues — 13 available.
entities.labelPool
entities.labelPool(max: int, on: Surface? = null, anchor: Anchor? = null) -> LabelPoolCreates a pool of labels with a fixed limit.
Declare the pool with setup or state, then use it from any handler.
Each drawing is identified by its keys.
maxlimits the number of labels. Values outside the entity-pool limit are rejected before the script runs. Creating a new drawing when full removes the oldest one.onchooses the panel or pane for every drawing in the pool. Null uses the main price pane.anchorchooses how to position drawings. Null uses chart coordinates.
Anchors
A pane anchor, such as anchor.topLeft or anchor.center, measures both
coordinates in logical pixels from that point. An edge anchor, such as
anchor.top or anchor.left, measures one coordinate inward from the edge in
pixels and keeps the other in chart coordinates.
Contracts
max: Accepted range: 1 to MAX_ENTITY_POOL_CAP. Invalid values are rejected.
Example
script "Label Pool Example"
data chart = subscribe(data.ohlcv)
state tags = entities.labelPool(max: 8)
on chart.update {
let count = tags.capacity
}Accepted values
anchor:Anchorvalues — 13 available.
entities.markerPool
entities.markerPool(max: int, on: Surface? = null, anchor: Anchor? = null) -> MarkerPoolCreates a pool of markers with a fixed limit.
Declare the pool with setup or state, then use it from any handler.
Each drawing is identified by its keys.
maxlimits the number of markers. Values outside the entity-pool limit are rejected before the script runs. Creating a new drawing when full removes the oldest one.onchooses the panel or pane for every drawing in the pool. Null uses the main price pane.anchorchooses how to position drawings. Null uses chart coordinates.
Anchors
A pane anchor, such as anchor.topLeft or anchor.center, measures both
coordinates in logical pixels from that point. An edge anchor, such as
anchor.top or anchor.left, measures one coordinate inward from the edge in
pixels and keeps the other in chart coordinates.
Contracts
max: Accepted range: 1 to MAX_ENTITY_POOL_CAP. Invalid values are rejected.
Example
script "Marker Pool Example"
data chart = subscribe(data.ohlcv)
state marks = entities.markerPool(max: 8)
on chart.update {
let count = marks.capacity
}Accepted values
anchor:Anchorvalues — 13 available.
entities.arrowPool
entities.arrowPool(max: int, on: Surface? = null, anchor: Anchor? = null) -> ArrowPoolCreates a pool of arrows with a fixed limit.
Declare the pool with setup or state, then use it from any handler.
Each drawing is identified by its keys.
maxlimits the number of arrows. Values outside the entity-pool limit are rejected before the script runs. Creating a new drawing when full removes the oldest one.onchooses the panel or pane for every drawing in the pool. Null uses the main price pane.anchorchooses how to position drawings. Null uses chart coordinates.
Anchors
A pane anchor, such as anchor.topLeft or anchor.center, measures both
coordinates in logical pixels from that point. An edge anchor, such as
anchor.top or anchor.left, measures one coordinate inward from the edge in
pixels and keeps the other in chart coordinates.
Contracts
max: Accepted range: 1 to MAX_ENTITY_POOL_CAP. Invalid values are rejected.
Example
script "Arrow Pool Example"
data chart = subscribe(data.ohlcv)
state arrows = entities.arrowPool(max: 8)
on chart.update {
let count = arrows.capacity
}Accepted values
anchor:Anchorvalues — 13 available.
entities.lineFillPool
entities.lineFillPool(max: int, on: Surface? = null) -> LineFillPoolCreates a pool of line fills with a fixed limit.
Declare the pool with setup or state, then use it from any handler.
Each drawing is identified by its keys.
maxlimits the number of line fills. Values outside the entity-pool limit are rejected before the script runs. Creating a new drawing when full removes the oldest one.onchooses the panel or pane for every drawing in the pool. Null uses the main price pane.
Contracts
max: Accepted range: 1 to MAX_ENTITY_POOL_CAP. Invalid values are rejected.
Example
script "LineFill Pool Example"
data chart = subscribe(data.ohlcv)
state fills = entities.lineFillPool(max: 8)
on chart.update {
let count = fills.capacity
}entities.line.set
entities.line.set(x1: time|int|float, y1: float, x2: time|int|float, y2: float, width: float = 0, color: color? = null, style: LineStyle? = null, extend: Extend? = null, text: string = "", font: FontFamily? = null, zIndex: int = 0) -> voidDraws or updates a line.
x1, y1, x2, and y2 set the endpoints.
widthaccepts 0.0 to 20.0, defaulting to 0.0. Other values stop the script with an error.colorandstyleuse chart defaults when null.extendcontinues the line toward the pane edges. Useextend.left,extend.right, orextend.bothto follow its slope horizontally, orextend.up,extend.down, orextend.verticalto extend vertically. Null leaves the line unextended.textadds a label, empty by default.fontdefaults tofont.appwhen null.zIndexsets the drawing order and defaults to 0.
Coordinates
The pool's anchor determines how coordinates are measured:
- No anchor: use chart coordinates; x can be a time value.
- A pane anchor, such as
anchor.topLeft: use finite logical-pixel offsets for both coordinates. Time values are not allowed. anchor.toporanchor.bottom: use chart x coordinates and finite pixel y offsets.anchor.leftoranchor.right: use finite pixel x offsets and chart y coordinates.
Horizontal extensions need chart x coordinates: use a pool with no anchor or
with a top/bottom edge anchor. Vertical extensions need chart y coordinates:
use a pool with no anchor or with a left/right edge anchor. A pool using pixels
for both coordinates accepts only null or extend.none.
A horizontal line with a vertical extension spans the full visible width.
Contracts
width: Accepted range: 0.0 to 20.0. Must be a finite number. Invalid values are rejected.
Example
script "Line Set Example"
data chart = subscribe(data.ohlcv)
state lines = entities.linePool(max: 8)
on chart.update {
let t = chart.time ?? time.fromUnixSeconds(0)
let price = chart.close ?? 0.0
lines.get("mid").set(
x1: t,
y1: price,
x2: t + time.bars(1),
y2: price,
width: 1.0,
color: color.blue,
)
}Accepted values
extend:Extendvalues — 7 available.font:FontFamilyvalues — 2 available.style:LineStylevalues — 4 available.
entities.box.set
entities.box.set(x1: time|int|float, y1: float, x2: time|int|float, y2: float, rounding: float = 0, color: color? = null, borderWidth: float = 0, borderColor: color? = null, borderStyle: LineStyle? = null, extend: Extend? = null, text: string = "", textColor: color? = null, textSize: float = 0, font: FontFamily? = null, textHAlign: string? = null, textVAlign: string? = null, textWrap: bool? = null, zIndex: int = 0) -> voidDraws or updates a box.
x1, y1, x2, and y2 set the corners.
roundingrounds the corners and defaults to 0.0. Negative values stop the script with an error.colorsets the fill color and defaults to null.borderWidthaccepts 0.0 to 20.0, defaulting to 0.0. Other values stop the script with an error.borderColorandborderStyledefault to null.extendstretches the box to pane edges:extend.left,extend.right,extend.both,extend.up,extend.down, orextend.vertical. Null leaves the box unextended.textadds a label, empty by default.textColordefaults to null.textSizeaccepts 0.0 to 96.0, defaulting to 0.0. Other values stop the script with an error.fontdefaults tofont.appwhen null.textHAlign,textVAlign, andtextWrapset text layout and default to null.zIndexsets the drawing order and defaults to 0.
Coordinates
The pool's anchor determines how coordinates are measured:
- No anchor: use chart coordinates; x can be a time value.
- A pane anchor, such as
anchor.topLeft: use finite logical-pixel offsets for both coordinates. Time values are not allowed. anchor.toporanchor.bottom: use chart x coordinates and finite pixel y offsets.anchor.leftoranchor.right: use finite pixel x offsets and chart y coordinates.
Horizontal extensions need chart x coordinates: use a pool with no anchor or
with a top/bottom edge anchor. Vertical extensions need chart y coordinates:
use a pool with no anchor or with a left/right edge anchor. A pool using pixels
for both coordinates accepts only null or extend.none.
Contracts
rounding: Accepted range: 0.0 or greater. Must be a finite number. Invalid values are rejected.borderWidth: Accepted range: 0.0 to 20.0. Must be a finite number. Invalid values are rejected.textSize: Accepted range: 0.0 to 96.0. Must be a finite number. Invalid values are rejected.
Example
script "Box Set Example"
data chart = subscribe(data.ohlcv)
state zones = entities.boxPool(max: 8)
on chart.update {
let t = chart.time ?? time.fromUnixSeconds(0)
zones.get("range").set(
x1: t,
y1: chart.high ?? 0.0,
x2: t + time.bars(1),
y2: chart.low ?? 0.0,
color: color.withAlpha(color.blue, 32),
borderColor: color.blue,
)
}Accepted values
extend:Extendvalues — 7 available.font:FontFamilyvalues — 2 available.borderStyle:LineStylevalues — 4 available.
entities.label.set
entities.label.set(x: time|int|float, y: float, text: string, color: color? = null, size: float = 0, font: FontFamily? = null, textAlign: string? = null, zIndex: int = 0) -> voidDraws or updates a text label.
x and y set the position. The pool's anchor also selects which point on the
label is placed at that position. text supplies the label text.
coloruses the chart default when null.sizeaccepts 0.0 to 96.0, defaulting to 0.0. Other values stop the script with an error.fontdefaults tofont.appwhen null.textAligndefaults to null.zIndexsets the drawing order and defaults to 0.
Coordinates
The pool's anchor determines how coordinates are measured:
- No anchor: use chart coordinates; x can be a time value.
- A pane anchor, such as
anchor.topLeft: use finite logical-pixel offsets for both coordinates. Time values are not allowed. anchor.toporanchor.bottom: use chart x coordinates and finite pixel y offsets.anchor.leftoranchor.right: use finite pixel x offsets and chart y coordinates.
Contracts
size: Accepted range: 0.0 to 96.0. Must be a finite number. Invalid values are rejected.
Example
script "Label Set Example"
data chart = subscribe(data.ohlcv)
state tags = entities.labelPool(max: 8)
on chart.update {
let t = chart.time ?? time.fromUnixSeconds(0)
tags.get("last").set(
x: t,
y: chart.close ?? 0.0,
text: "last",
color: color.white,
)
}Accepted values
font:FontFamilyvalues — 2 available.
entities.marker.set
entities.marker.set(x: time|int|float, y: float, shape: Shape? = null, color: color? = null, size: float = 0, zIndex: int = 0) -> voidDraws or updates a marker.
x and y set the position.
shapeandcoloruse chart defaults when null.sizeaccepts 0.0 to 96.0, defaulting to 0.0. Other values stop the script with an error.zIndexsets the drawing order and defaults to 0.
Coordinates
The pool's anchor determines how coordinates are measured:
- No anchor: use chart coordinates; x can be a time value.
- A pane anchor, such as
anchor.topLeft: use finite logical-pixel offsets for both coordinates. Time values are not allowed. anchor.toporanchor.bottom: use chart x coordinates and finite pixel y offsets.anchor.leftoranchor.right: use finite pixel x offsets and chart y coordinates.
Contracts
size: Accepted range: 0.0 to 96.0. Must be a finite number. Invalid values are rejected.
Example
script "Marker Set Example"
data chart = subscribe(data.ohlcv)
state marks = entities.markerPool(max: 8)
on chart.update {
let t = chart.time ?? time.fromUnixSeconds(0)
marks.get("breakout").set(
x: t,
y: chart.high ?? 0.0,
shape: shape.up,
color: color.green,
)
}Accepted values
shape:Shapevalues — 10 available.
entities.arrow.set
entities.arrow.set(x1: time|int|float, y1: float, x2: time|int|float, y2: float, width: float = 0, color: color? = null, style: LineStyle? = null, extend: Extend? = null, headLengthPx: float = 0, headWidthRatio: float = 0, zIndex: int = 0) -> voidDraws or updates an arrow.
x1, y1, x2, and y2 set the endpoints.
widthaccepts 0.0 to 20.0, defaulting to 0.0.colorandstyleuse chart defaults when null.extendcontinues the arrow along its slope toward a pane edge. Useextend.left,extend.right, orextend.both; null leaves it unextended.headLengthPxaccepts 0.0 to 200.0 pixels, defaulting to 0.0.headWidthRatioaccepts 0.0 to 20.0, defaulting to 0.0.zIndexsets the drawing order and defaults to 0.
A width, head length, or head width ratio outside its range stops the script with an error.
Coordinates
The pool's anchor determines how coordinates are measured:
- No anchor: use chart coordinates; x can be a time value.
- A pane anchor, such as
anchor.topLeft: use finite logical-pixel offsets for both coordinates. Time values are not allowed. anchor.toporanchor.bottom: use chart x coordinates and finite pixel y offsets.anchor.leftoranchor.right: use finite pixel x offsets and chart y coordinates.
Arrows support horizontal extensions only. The pool must use chart x
coordinates, either without an anchor or with a top/bottom edge anchor.
Other pools accept only null or extend.none. Vertical extensions are not allowed.
Contracts
width: Accepted range: 0.0 to 20.0. Must be a finite number. Invalid values are rejected.headLengthPx: Accepted range: 0.0 to 200.0. Must be a finite number. Invalid values are rejected.headWidthRatio: Accepted range: 0.0 to 20.0. Must be a finite number. Invalid values are rejected.
Example
script "Arrow Set Example"
data chart = subscribe(data.ohlcv)
state arrows = entities.arrowPool(max: 8)
on chart.update {
let t = chart.time ?? time.fromUnixSeconds(0)
arrows.get("range").set(
x1: t,
y1: chart.low ?? 0.0,
x2: t + time.bars(1),
y2: chart.high ?? 0.0,
width: 1.0,
color: color.green,
)
}Accepted values
extend:Extendvalues — 7 available.style:LineStylevalues — 4 available.
entities.lineFill.set
entities.lineFill.set(lineA: Line, lineB: Line, color: color? = null) -> voidDraws or updates a fill between two lines.
lineA and lineB must be existing, drawn lines on the same pane. Both must
use the same kind of positioning: chart coordinates, offsets from a pane
point, or offsets from an edge. Their individual anchors may differ, such as
one line anchored to the top and another to the bottom.
The fill follows both lines as they appear on the pane. color uses the chart
default when null. Deleting either line also removes the fill; a null line
cannot be used as a boundary.
Example
script "Line Fill Set Example"
data chart = subscribe(data.ohlcv)
state upper = entities.linePool(max: 8)
state lower = entities.linePool(max: 8)
state fills = entities.lineFillPool(max: 8)
on chart.update {
let t = chart.time ?? time.fromUnixSeconds(0)
let hi = chart.high ?? 0.0
let lo = chart.low ?? 0.0
let a = upper.get("band")
let b = lower.get("band")
a.set(t, hi, t + time.bars(1), hi, color: color.blue)
b.set(t, lo, t + time.bars(1), lo, color: color.blue)
fills.get("band").set(a, b, color: color.withAlpha(color.blue, 48))
}font.app
font.app: FontFamily = 0Uses the normal chart application font.
font.mono
font.mono: FontFamily = 1Uses the application monospace font.
anchor.topLeft
anchor.topLeft: Anchor = 1Offsets inward from the pane's top-left corner.
anchor.topCenter
anchor.topCenter: Anchor = 2Offsets from the center of the pane's top edge.
anchor.topRight
anchor.topRight: Anchor = 3Offsets inward from the pane's top-right corner.
anchor.middleLeft
anchor.middleLeft: Anchor = 4Offsets from the center of the pane's left edge.
anchor.center
anchor.center: Anchor = 5Offsets from the center of the pane.
anchor.middleRight
anchor.middleRight: Anchor = 6Offsets from the center of the pane's right edge.
anchor.bottomLeft
anchor.bottomLeft: Anchor = 7Offsets inward from the pane's bottom-left corner.
anchor.bottomCenter
anchor.bottomCenter: Anchor = 8Offsets from the center of the pane's bottom edge.
anchor.bottomRight
anchor.bottomRight: Anchor = 9Offsets inward from the pane's bottom-right corner.
anchor.top
anchor.top: Anchor = 10Pins y to logical pixels down from the pane's top edge; x stays in chart space.
anchor.bottom
anchor.bottom: Anchor = 11Pins y to logical pixels up from the pane's bottom edge; x stays in chart space.
anchor.left
anchor.left: Anchor = 12Pins x to logical pixels right of the pane's left edge; y stays in chart space.
anchor.right
anchor.right: Anchor = 13Pins x to logical pixels left of the pane's right edge; y stays in chart space.
entities.linePool.get
entities.linePool.get(key: int|time|duration|float|string, keys: int|time|duration|float|string...) -> LineReturns a line for the given keys.
Returns the line for key and any additional keys, creating one if needed.
The result is never null. If the pool is full, the oldest line is removed.
Call set to draw the new line.
Example
script "Line Pool Example"
data chart = subscribe(data.ohlcv)
state lines = entities.linePool(max: 8)
on chart.update {
let t = chart.time ?? time.fromUnixSeconds(0)
let price = chart.close ?? 0.0
lines.get("mid").set(t, price, t + time.bars(1), price)
let item = lines.get("extra")
}entities.linePool.has
entities.linePool.has(key: int|time|duration|float|string, keys: int|time|duration|float|string...) -> boolTests whether a line exists.
Returns true if the pool contains a line for key and any additional keys.
This does not create, change, or draw anything.
Example
script "Line Pool Example"
data chart = subscribe(data.ohlcv)
state lines = entities.linePool(max: 8)
on chart.update {
let t = chart.time ?? time.fromUnixSeconds(0)
let price = chart.close ?? 0.0
lines.get("mid").set(t, price, t + time.bars(1), price)
let live = lines.has("extra")
}entities.linePool.delete
entities.linePool.delete(key: int|time|duration|float|string, keys: int|time|duration|float|string...) -> boolDeletes a line.
Removes the line for key and any additional keys from the pool and the
chart. Returns true if it was removed, or false if those keys were not found.
Example
script "Line Pool Example"
data chart = subscribe(data.ohlcv)
state lines = entities.linePool(max: 8)
on chart.update {
let t = chart.time ?? time.fromUnixSeconds(0)
let price = chart.close ?? 0.0
lines.get("mid").set(t, price, t + time.bars(1), price)
let removed = lines.delete("extra")
}entities.linePool.clear
entities.linePool.clear(key: int|time|duration|float|string, keys: int|time|duration|float|string...) -> boolClears lines by key prefix.
Removes all lines whose keys start with key and any additional keys, both
from the pool and the chart. Returns true if at least one line was removed.
Example
script "Line Pool Example"
data chart = subscribe(data.ohlcv)
state lines = entities.linePool(max: 8)
on chart.update {
let t = chart.time ?? time.fromUnixSeconds(0)
let price = chart.close ?? 0.0
lines.get("mid").set(t, price, t + time.bars(1), price)
let removedAny = lines.clear("extra")
}entities.boxPool.get
entities.boxPool.get(key: int|time|duration|float|string, keys: int|time|duration|float|string...) -> BoxReturns a box for the given keys.
Returns the box for key and any additional keys, creating one if needed.
The result is never null. If the pool is full, the oldest box is removed. Call
set to draw the new box.
Example
script "Box Pool Example"
data chart = subscribe(data.ohlcv)
state zones = entities.boxPool(max: 8)
on chart.update {
let t = chart.time ?? time.fromUnixSeconds(0)
zones.get("range").set(t, chart.high ?? 0.0, t + time.bars(1), chart.low ?? 0.0)
let item = zones.get("extra")
}entities.boxPool.has
entities.boxPool.has(key: int|time|duration|float|string, keys: int|time|duration|float|string...) -> boolTests whether a box exists.
Returns true if the pool contains a box for key and any additional keys.
This does not create, change, or draw anything.
Example
script "Box Pool Example"
data chart = subscribe(data.ohlcv)
state zones = entities.boxPool(max: 8)
on chart.update {
let t = chart.time ?? time.fromUnixSeconds(0)
zones.get("range").set(t, chart.high ?? 0.0, t + time.bars(1), chart.low ?? 0.0)
let live = zones.has("extra")
}entities.boxPool.delete
entities.boxPool.delete(key: int|time|duration|float|string, keys: int|time|duration|float|string...) -> boolDeletes a box.
Removes the box for key and any additional keys from the pool and the
chart. Returns true if it was removed, or false if those keys were not found.
Example
script "Box Pool Example"
data chart = subscribe(data.ohlcv)
state zones = entities.boxPool(max: 8)
on chart.update {
let t = chart.time ?? time.fromUnixSeconds(0)
zones.get("range").set(t, chart.high ?? 0.0, t + time.bars(1), chart.low ?? 0.0)
let removed = zones.delete("extra")
}entities.boxPool.clear
entities.boxPool.clear(key: int|time|duration|float|string, keys: int|time|duration|float|string...) -> boolRemoves boxes whose keys start with the given keys.
Removes all boxes whose keys start with key and any additional keys, both
from the pool and the chart. Returns true if at least one box was removed.
Example
script "Box Pool Example"
data chart = subscribe(data.ohlcv)
state zones = entities.boxPool(max: 8)
on chart.update {
let t = chart.time ?? time.fromUnixSeconds(0)
zones.get("range").set(t, chart.high ?? 0.0, t + time.bars(1), chart.low ?? 0.0)
let removedAny = zones.clear("extra")
}entities.labelPool.get
entities.labelPool.get(key: int|time|duration|float|string, keys: int|time|duration|float|string...) -> LabelReturns a label for the given keys.
Returns the label for key and any additional keys, creating one if needed.
The result is never null. If the pool is full, the oldest label is removed.
Call set to draw the new label.
Example
script "Label Pool Example"
data chart = subscribe(data.ohlcv)
state tags = entities.labelPool(max: 8)
on chart.update {
let t = chart.time ?? time.fromUnixSeconds(0)
tags.get("last").set(t, chart.close ?? 0.0, "last")
let item = tags.get("extra")
}entities.labelPool.has
entities.labelPool.has(key: int|time|duration|float|string, keys: int|time|duration|float|string...) -> boolTests whether a label exists.
Returns true if the pool contains a label for key and any additional keys.
This does not create, change, or draw anything.
Example
script "Label Pool Example"
data chart = subscribe(data.ohlcv)
state tags = entities.labelPool(max: 8)
on chart.update {
let t = chart.time ?? time.fromUnixSeconds(0)
tags.get("last").set(t, chart.close ?? 0.0, "last")
let live = tags.has("extra")
}entities.labelPool.delete
entities.labelPool.delete(key: int|time|duration|float|string, keys: int|time|duration|float|string...) -> boolDeletes a label.
Removes the label for key and any additional keys from the pool and the
chart. Returns true if it was removed, or false if those keys were not found.
Example
script "Label Pool Example"
data chart = subscribe(data.ohlcv)
state tags = entities.labelPool(max: 8)
on chart.update {
let t = chart.time ?? time.fromUnixSeconds(0)
tags.get("last").set(t, chart.close ?? 0.0, "last")
let removed = tags.delete("extra")
}entities.labelPool.clear
entities.labelPool.clear(key: int|time|duration|float|string, keys: int|time|duration|float|string...) -> boolClears labels by key prefix.
Removes all labels whose keys start with key and any additional keys, both
from the pool and the chart. Returns true if at least one label was removed.
Example
script "Label Pool Example"
data chart = subscribe(data.ohlcv)
state tags = entities.labelPool(max: 8)
on chart.update {
let t = chart.time ?? time.fromUnixSeconds(0)
tags.get("last").set(t, chart.close ?? 0.0, "last")
let removedAny = tags.clear("extra")
}entities.markerPool.get
entities.markerPool.get(key: int|time|duration|float|string, keys: int|time|duration|float|string...) -> MarkerReturns a marker for the given keys.
Returns the marker for key and any additional keys, creating one if
needed. The result is never null. If the pool is full, the oldest marker is
removed. Call set to draw the new marker.
Example
script "Marker Pool Example"
data chart = subscribe(data.ohlcv)
state marks = entities.markerPool(max: 8)
on chart.update {
let t = chart.time ?? time.fromUnixSeconds(0)
marks.get("breakout").set(t, chart.high ?? 0.0, shape: shape.up)
let item = marks.get("extra")
}entities.markerPool.has
entities.markerPool.has(key: int|time|duration|float|string, keys: int|time|duration|float|string...) -> boolTests whether a marker exists.
Returns true if the pool contains a marker for key and any additional
keys. This does not create, change, or draw anything.
Example
script "Marker Pool Example"
data chart = subscribe(data.ohlcv)
state marks = entities.markerPool(max: 8)
on chart.update {
let t = chart.time ?? time.fromUnixSeconds(0)
marks.get("breakout").set(t, chart.high ?? 0.0, shape: shape.up)
let live = marks.has("extra")
}entities.markerPool.delete
entities.markerPool.delete(key: int|time|duration|float|string, keys: int|time|duration|float|string...) -> boolDeletes a marker.
Removes the marker for key and any additional keys from the pool and the
chart. Returns true if it was removed, or false if those keys were not found.
Example
script "Marker Pool Example"
data chart = subscribe(data.ohlcv)
state marks = entities.markerPool(max: 8)
on chart.update {
let t = chart.time ?? time.fromUnixSeconds(0)
marks.get("breakout").set(t, chart.high ?? 0.0, shape: shape.up)
let removed = marks.delete("extra")
}entities.markerPool.clear
entities.markerPool.clear(key: int|time|duration|float|string, keys: int|time|duration|float|string...) -> boolClears markers by key prefix.
Removes all markers whose keys start with key and any additional keys,
both from the pool and the chart. Returns true if at least one marker was
removed.
Example
script "Marker Pool Example"
data chart = subscribe(data.ohlcv)
state marks = entities.markerPool(max: 8)
on chart.update {
let t = chart.time ?? time.fromUnixSeconds(0)
marks.get("breakout").set(t, chart.high ?? 0.0, shape: shape.up)
let removedAny = marks.clear("extra")
}entities.arrowPool.get
entities.arrowPool.get(key: int|time|duration|float|string, keys: int|time|duration|float|string...) -> ArrowReturns an arrow for the given keys.
Returns the arrow for key and any additional keys, creating one if needed.
The result is never null. If the pool is full, the oldest arrow is removed.
Call set to draw the new arrow.
Example
script "Arrow Pool Example"
data chart = subscribe(data.ohlcv)
state arrows = entities.arrowPool(max: 8)
on chart.update {
let t = chart.time ?? time.fromUnixSeconds(0)
arrows.get("move").set(t, chart.low ?? 0.0, t + time.bars(1), chart.high ?? 0.0)
let item = arrows.get("extra")
}entities.arrowPool.has
entities.arrowPool.has(key: int|time|duration|float|string, keys: int|time|duration|float|string...) -> boolTests whether an arrow exists.
Returns true if the pool contains an arrow for key and any additional keys.
This does not create, change, or draw anything.
Example
script "Arrow Pool Example"
data chart = subscribe(data.ohlcv)
state arrows = entities.arrowPool(max: 8)
on chart.update {
let t = chart.time ?? time.fromUnixSeconds(0)
arrows.get("move").set(t, chart.low ?? 0.0, t + time.bars(1), chart.high ?? 0.0)
let live = arrows.has("extra")
}entities.arrowPool.delete
entities.arrowPool.delete(key: int|time|duration|float|string, keys: int|time|duration|float|string...) -> boolDeletes an arrow.
Removes the arrow for key and any additional keys from the pool and the
chart. Returns true if it was removed, or false if those keys were not found.
Example
script "Arrow Pool Example"
data chart = subscribe(data.ohlcv)
state arrows = entities.arrowPool(max: 8)
on chart.update {
let t = chart.time ?? time.fromUnixSeconds(0)
arrows.get("move").set(t, chart.low ?? 0.0, t + time.bars(1), chart.high ?? 0.0)
let removed = arrows.delete("extra")
}entities.arrowPool.clear
entities.arrowPool.clear(key: int|time|duration|float|string, keys: int|time|duration|float|string...) -> boolClears arrows by key prefix.
Removes all arrows whose keys start with key and any additional keys, both
from the pool and the chart. Returns true if at least one arrow was removed.
Example
script "Arrow Pool Example"
data chart = subscribe(data.ohlcv)
state arrows = entities.arrowPool(max: 8)
on chart.update {
let t = chart.time ?? time.fromUnixSeconds(0)
arrows.get("move").set(t, chart.low ?? 0.0, t + time.bars(1), chart.high ?? 0.0)
let removedAny = arrows.clear("extra")
}entities.lineFillPool.get
entities.lineFillPool.get(key: int|time|duration|float|string, keys: int|time|duration|float|string...) -> LineFillReturns a line fill for the given keys.
Returns the line fill for key and any additional keys, creating one if
needed. The result is never null. If the pool is full, the oldest line fill is
removed. Call set to draw the new line fill.
Example
script "Line Fill Pool Example"
data chart = subscribe(data.ohlcv)
state upper = entities.linePool(max: 8)
state lower = entities.linePool(max: 8)
state fills = entities.lineFillPool(max: 8)
on chart.update {
let t = chart.time ?? time.fromUnixSeconds(0)
let a = upper.get("band")
let b = lower.get("band")
a.set(t, chart.high ?? 0.0, t + time.bars(1), chart.high ?? 0.0)
b.set(t, chart.low ?? 0.0, t + time.bars(1), chart.low ?? 0.0)
fills.get("band").set(a, b)
let item = fills.get("extra")
}entities.lineFillPool.has
entities.lineFillPool.has(key: int|time|duration|float|string, keys: int|time|duration|float|string...) -> boolTests whether a line fill exists.
Returns true if the pool contains a line fill for key and any additional
keys. This does not create, change, or draw anything.
Example
script "Line Fill Pool Example"
data chart = subscribe(data.ohlcv)
state upper = entities.linePool(max: 8)
state lower = entities.linePool(max: 8)
state fills = entities.lineFillPool(max: 8)
on chart.update {
let t = chart.time ?? time.fromUnixSeconds(0)
let a = upper.get("band")
let b = lower.get("band")
a.set(t, chart.high ?? 0.0, t + time.bars(1), chart.high ?? 0.0)
b.set(t, chart.low ?? 0.0, t + time.bars(1), chart.low ?? 0.0)
fills.get("band").set(a, b)
let live = fills.has("extra")
}entities.lineFillPool.delete
entities.lineFillPool.delete(key: int|time|duration|float|string, keys: int|time|duration|float|string...) -> boolDeletes a line fill.
Removes the line fill for key and any additional keys from the pool and
the chart. Returns true if it was removed, or false if those keys were not
found.
Example
script "Line Fill Pool Example"
data chart = subscribe(data.ohlcv)
state upper = entities.linePool(max: 8)
state lower = entities.linePool(max: 8)
state fills = entities.lineFillPool(max: 8)
on chart.update {
let t = chart.time ?? time.fromUnixSeconds(0)
let a = upper.get("band")
let b = lower.get("band")
a.set(t, chart.high ?? 0.0, t + time.bars(1), chart.high ?? 0.0)
b.set(t, chart.low ?? 0.0, t + time.bars(1), chart.low ?? 0.0)
fills.get("band").set(a, b)
let removed = fills.delete("extra")
}entities.lineFillPool.clear
entities.lineFillPool.clear(key: int|time|duration|float|string, keys: int|time|duration|float|string...) -> boolClears line fills by key prefix.
Removes all line fills whose keys start with key and any additional keys,
both from the pool and the chart. Returns true if at least one line fill was
removed.
Example
script "Line Fill Pool Example"
data chart = subscribe(data.ohlcv)
state upper = entities.linePool(max: 8)
state lower = entities.linePool(max: 8)
state fills = entities.lineFillPool(max: 8)
on chart.update {
let t = chart.time ?? time.fromUnixSeconds(0)
let a = upper.get("band")
let b = lower.get("band")
a.set(t, chart.high ?? 0.0, t + time.bars(1), chart.high ?? 0.0)
b.set(t, chart.low ?? 0.0, t + time.bars(1), chart.low ?? 0.0)
fills.get("band").set(a, b)
let removedAny = fills.clear("extra")
}entities.linePool.isEmpty
entities.linePool.isEmpty: boolReports whether the line pool has no drawings.
Returns true when the pool contains no lines. A line created with get counts even before it is drawn with set.
Example
script "Line Pool Example"
data chart = subscribe(data.ohlcv)
state lines = entities.linePool(max: 8)
on chart.update {
let t = chart.time ?? time.fromUnixSeconds(0)
let price = chart.close ?? 0.0
lines.get("mid").set(t, price, t + time.bars(1), price)
let empty = lines.isEmpty
}entities.linePool.isFull
entities.linePool.isFull: boolReports whether the line pool is at capacity.
Returns true when the pool has reached its max count. You can still call get with new keys; doing so removes the oldest line.
Example
script "Line Pool Example"
data chart = subscribe(data.ohlcv)
state lines = entities.linePool(max: 8)
on chart.update {
let t = chart.time ?? time.fromUnixSeconds(0)
let price = chart.close ?? 0.0
lines.get("mid").set(t, price, t + time.bars(1), price)
let full = lines.isFull
}entities.linePool.len
entities.linePool.len: intCounts the lines currently in the pool.
Returns the number of lines currently in the pool, including any created with get that have not yet been drawn. Removed lines are not counted.
Example
script "Line Pool Example"
data chart = subscribe(data.ohlcv)
state lines = entities.linePool(max: 8)
on chart.update {
let t = chart.time ?? time.fromUnixSeconds(0)
let price = chart.close ?? 0.0
lines.get("mid").set(t, price, t + time.bars(1), price)
let n = lines.len
}entities.linePool.capacity
entities.linePool.capacity: intReturns the maximum number of lines in the pool.
Returns the max value accepted for the line pool at setup. The capacity does not change during the run.
Example
script "Line Pool Example"
data chart = subscribe(data.ohlcv)
state lines = entities.linePool(max: 8)
on chart.update {
let t = chart.time ?? time.fromUnixSeconds(0)
let price = chart.close ?? 0.0
lines.get("mid").set(t, price, t + time.bars(1), price)
let cap = lines.capacity
}entities.boxPool.isEmpty
entities.boxPool.isEmpty: boolReports whether the box pool has no drawings.
Returns true when the pool contains no boxes. A box created with get counts even before it is drawn with set.
Example
script "Box Pool Example"
data chart = subscribe(data.ohlcv)
state zones = entities.boxPool(max: 8)
on chart.update {
let t = chart.time ?? time.fromUnixSeconds(0)
zones.get("range").set(t, chart.high ?? 0.0, t + time.bars(1), chart.low ?? 0.0)
let empty = zones.isEmpty
}entities.boxPool.isFull
entities.boxPool.isFull: boolReports whether the box pool is at capacity.
Returns true when the pool has reached its max count. You can still call get with new keys; doing so removes the oldest box.
Example
script "Box Pool Example"
data chart = subscribe(data.ohlcv)
state zones = entities.boxPool(max: 8)
on chart.update {
let t = chart.time ?? time.fromUnixSeconds(0)
zones.get("range").set(t, chart.high ?? 0.0, t + time.bars(1), chart.low ?? 0.0)
let full = zones.isFull
}entities.boxPool.len
entities.boxPool.len: intCounts the boxes currently in the pool.
Returns the number of boxes currently in the pool, including any created with get that have not yet been drawn. Removed boxes are not counted.
Example
script "Box Pool Example"
data chart = subscribe(data.ohlcv)
state zones = entities.boxPool(max: 8)
on chart.update {
let t = chart.time ?? time.fromUnixSeconds(0)
zones.get("range").set(t, chart.high ?? 0.0, t + time.bars(1), chart.low ?? 0.0)
let n = zones.len
}entities.boxPool.capacity
entities.boxPool.capacity: intReturns the maximum number of boxes in the pool.
Returns the max value accepted for the box pool at setup. The capacity does not change during the run.
Example
script "Box Pool Example"
data chart = subscribe(data.ohlcv)
state zones = entities.boxPool(max: 8)
on chart.update {
let t = chart.time ?? time.fromUnixSeconds(0)
zones.get("range").set(t, chart.high ?? 0.0, t + time.bars(1), chart.low ?? 0.0)
let cap = zones.capacity
}entities.labelPool.isEmpty
entities.labelPool.isEmpty: boolReports whether the label pool has no drawings.
Returns true when the pool contains no labels. A label created with get counts even before it is drawn with set.
Example
script "Label Pool Example"
data chart = subscribe(data.ohlcv)
state tags = entities.labelPool(max: 8)
on chart.update {
let t = chart.time ?? time.fromUnixSeconds(0)
tags.get("last").set(t, chart.close ?? 0.0, "last")
let empty = tags.isEmpty
}entities.labelPool.isFull
entities.labelPool.isFull: boolReports whether the label pool is at capacity.
Returns true when the pool has reached its max count. You can still call get with new keys; doing so removes the oldest label.
Example
script "Label Pool Example"
data chart = subscribe(data.ohlcv)
state tags = entities.labelPool(max: 8)
on chart.update {
let t = chart.time ?? time.fromUnixSeconds(0)
tags.get("last").set(t, chart.close ?? 0.0, "last")
let full = tags.isFull
}entities.labelPool.len
entities.labelPool.len: intCounts the labels currently in the pool.
Returns the number of labels currently in the pool, including any created with get that have not yet been drawn. Removed labels are not counted.
Example
script "Label Pool Example"
data chart = subscribe(data.ohlcv)
state tags = entities.labelPool(max: 8)
on chart.update {
let t = chart.time ?? time.fromUnixSeconds(0)
tags.get("last").set(t, chart.close ?? 0.0, "last")
let n = tags.len
}entities.labelPool.capacity
entities.labelPool.capacity: intReturns the maximum number of labels in the pool.
Returns the max value accepted for the label pool at setup. The capacity does not change during the run.
Example
script "Label Pool Example"
data chart = subscribe(data.ohlcv)
state tags = entities.labelPool(max: 8)
on chart.update {
let t = chart.time ?? time.fromUnixSeconds(0)
tags.get("last").set(t, chart.close ?? 0.0, "last")
let cap = tags.capacity
}entities.markerPool.isEmpty
entities.markerPool.isEmpty: boolReports whether the marker pool has no drawings.
Returns true when the pool contains no markers. A marker created with get counts even before it is drawn with set.
Example
script "Marker Pool Example"
data chart = subscribe(data.ohlcv)
state marks = entities.markerPool(max: 8)
on chart.update {
let t = chart.time ?? time.fromUnixSeconds(0)
marks.get("breakout").set(t, chart.high ?? 0.0, shape: shape.up)
let empty = marks.isEmpty
}entities.markerPool.isFull
entities.markerPool.isFull: boolReports whether the marker pool is at capacity.
Returns true when the pool has reached its max count. You can still call get with new keys; doing so removes the oldest marker.
Example
script "Marker Pool Example"
data chart = subscribe(data.ohlcv)
state marks = entities.markerPool(max: 8)
on chart.update {
let t = chart.time ?? time.fromUnixSeconds(0)
marks.get("breakout").set(t, chart.high ?? 0.0, shape: shape.up)
let full = marks.isFull
}entities.markerPool.len
entities.markerPool.len: intCounts the markers currently in the pool.
Returns the number of markers currently in the pool, including any created with get that have not yet been drawn. Removed markers are not counted.
Example
script "Marker Pool Example"
data chart = subscribe(data.ohlcv)
state marks = entities.markerPool(max: 8)
on chart.update {
let t = chart.time ?? time.fromUnixSeconds(0)
marks.get("breakout").set(t, chart.high ?? 0.0, shape: shape.up)
let n = marks.len
}entities.markerPool.capacity
entities.markerPool.capacity: intReturns the maximum number of markers in the pool.
Returns the max value accepted for the marker pool at setup. The capacity does not change during the run.
Example
script "Marker Pool Example"
data chart = subscribe(data.ohlcv)
state marks = entities.markerPool(max: 8)
on chart.update {
let t = chart.time ?? time.fromUnixSeconds(0)
marks.get("breakout").set(t, chart.high ?? 0.0, shape: shape.up)
let cap = marks.capacity
}entities.arrowPool.isEmpty
entities.arrowPool.isEmpty: boolReports whether the arrow pool has no drawings.
Returns true when the pool contains no arrows. An arrow created with get
counts even before it is drawn with set.
Example
script "Arrow Pool Example"
data chart = subscribe(data.ohlcv)
state arrows = entities.arrowPool(max: 8)
on chart.update {
let t = chart.time ?? time.fromUnixSeconds(0)
arrows.get("move").set(t, chart.low ?? 0.0, t + time.bars(1), chart.high ?? 0.0)
let empty = arrows.isEmpty
}entities.arrowPool.isFull
entities.arrowPool.isFull: boolReports whether the arrow pool is at capacity.
Returns true when the pool has reached its max count. You can still call get with new keys; doing so removes the oldest arrow.
Example
script "Arrow Pool Example"
data chart = subscribe(data.ohlcv)
state arrows = entities.arrowPool(max: 8)
on chart.update {
let t = chart.time ?? time.fromUnixSeconds(0)
arrows.get("move").set(t, chart.low ?? 0.0, t + time.bars(1), chart.high ?? 0.0)
let full = arrows.isFull
}entities.arrowPool.len
entities.arrowPool.len: intCounts the arrows currently in the pool.
Returns the number of arrows currently in the pool, including any created with get that have not yet been drawn. Removed arrows are not counted.
Example
script "Arrow Pool Example"
data chart = subscribe(data.ohlcv)
state arrows = entities.arrowPool(max: 8)
on chart.update {
let t = chart.time ?? time.fromUnixSeconds(0)
arrows.get("move").set(t, chart.low ?? 0.0, t + time.bars(1), chart.high ?? 0.0)
let n = arrows.len
}entities.arrowPool.capacity
entities.arrowPool.capacity: intReturns the maximum number of arrows in the pool.
Returns the max value accepted for the arrow pool at setup. The capacity does not change during the run.
Example
script "Arrow Pool Example"
data chart = subscribe(data.ohlcv)
state arrows = entities.arrowPool(max: 8)
on chart.update {
let t = chart.time ?? time.fromUnixSeconds(0)
arrows.get("move").set(t, chart.low ?? 0.0, t + time.bars(1), chart.high ?? 0.0)
let cap = arrows.capacity
}entities.lineFillPool.isEmpty
entities.lineFillPool.isEmpty: boolReports whether the line fill pool has no drawings.
Returns true when the pool contains no line fills. A line fill created with get counts even before it is drawn with set.
Example
script "Line Fill Pool Example"
data chart = subscribe(data.ohlcv)
state upper = entities.linePool(max: 8)
state lower = entities.linePool(max: 8)
state fills = entities.lineFillPool(max: 8)
on chart.update {
let t = chart.time ?? time.fromUnixSeconds(0)
let a = upper.get("band")
let b = lower.get("band")
a.set(t, chart.high ?? 0.0, t + time.bars(1), chart.high ?? 0.0)
b.set(t, chart.low ?? 0.0, t + time.bars(1), chart.low ?? 0.0)
fills.get("band").set(a, b)
let empty = fills.isEmpty
}entities.lineFillPool.isFull
entities.lineFillPool.isFull: boolReports whether the line fill pool is at capacity.
Returns true when the pool has reached its max count. You can still call get with new keys; doing so removes the oldest line fill.
Example
script "Line Fill Pool Example"
data chart = subscribe(data.ohlcv)
state upper = entities.linePool(max: 8)
state lower = entities.linePool(max: 8)
state fills = entities.lineFillPool(max: 8)
on chart.update {
let t = chart.time ?? time.fromUnixSeconds(0)
let a = upper.get("band")
let b = lower.get("band")
a.set(t, chart.high ?? 0.0, t + time.bars(1), chart.high ?? 0.0)
b.set(t, chart.low ?? 0.0, t + time.bars(1), chart.low ?? 0.0)
fills.get("band").set(a, b)
let full = fills.isFull
}entities.lineFillPool.len
entities.lineFillPool.len: intCounts the line fills currently in the pool.
Returns the number of line fills currently in the pool, including any created with get that have not yet been drawn. Removed line fills are not counted.
Example
script "Line Fill Pool Example"
data chart = subscribe(data.ohlcv)
state upper = entities.linePool(max: 8)
state lower = entities.linePool(max: 8)
state fills = entities.lineFillPool(max: 8)
on chart.update {
let t = chart.time ?? time.fromUnixSeconds(0)
let a = upper.get("band")
let b = lower.get("band")
a.set(t, chart.high ?? 0.0, t + time.bars(1), chart.high ?? 0.0)
b.set(t, chart.low ?? 0.0, t + time.bars(1), chart.low ?? 0.0)
fills.get("band").set(a, b)
let n = fills.len
}entities.lineFillPool.capacity
entities.lineFillPool.capacity: intReturns the maximum number of line fills in the pool.
Returns the max value accepted for the line fill pool at setup. The capacity does not change during the run.
Example
script "Line Fill Pool Example"
data chart = subscribe(data.ohlcv)
state upper = entities.linePool(max: 8)
state lower = entities.linePool(max: 8)
state fills = entities.lineFillPool(max: 8)
on chart.update {
let t = chart.time ?? time.fromUnixSeconds(0)
let a = upper.get("band")
let b = lower.get("band")
a.set(t, chart.high ?? 0.0, t + time.bars(1), chart.high ?? 0.0)
b.set(t, chart.low ?? 0.0, t + time.bars(1), chart.low ?? 0.0)
fills.get("band").set(a, b)
let cap = fills.capacity
}