plot reference
Declares plot outputs and updates them with stream or keyed rows.
Declares plot outputs and updates them with stream or keyed rows.
Accepted values
These named values are the complete choices accepted by parameters of each type.
CellCandles
cellcandles.overlayThe chart's candles are drawn as usual, behind the cells.cellcandles.sideThe chart's candles are drawn as a thin strip at the left edge of each bar, beside the cells.cellcandles.hiddenThe chart's candles are not drawn.CellFormat
cellformat.compactLarge numbers are shortened with a suffix, such as 3.21K or 53.1M.cellformat.fixedThe number is written in full, such as 3214.56.cellformat.percentThe value is a ratio written as a percentage, so 0.153 reads 15.3%.CellScale
cellscale.barA full-width cell has the largest weight on its own bar.cellscale.viewA full-width cell has the largest weight on the visible bars.cellscale.unitThe weight is the width itself, as a fraction from 0 to 1.Extend
extend.noneEntity does not extend beyond its x-range.extend.leftEntity extends leftward past its leftmost endpoint along its slope.extend.rightEntity extends rightward past its rightmost endpoint along its slope.extend.bothEntity extends in both directions.extend.upLine or box extends upward past its topmost endpoint to the pane edge.extend.downLine or box extends downward past its bottommost endpoint to the pane edge.extend.verticalLine or box extends both upward and downward to the pane edges.LineStyle
linestyle.solidSolid line style.linestyle.dottedDotted line style.linestyle.dashedDashed line style.linestyle.stepStep line style.Shape
shape.circleCircle marker shape.shape.squareSquare marker shape.shape.diamondDiamond marker shape.shape.upUp-triangle marker shape.shape.downDown-triangle marker shape.shape.leftLeft-triangle marker shape.shape.rightRight-triangle marker shape.shape.crossCross marker shape.shape.plusPlus marker shape.shape.asteriskAsterisk marker shape.plot.line
plot.line(title: string = "", color: color? = null, width: float? = null, style: LineStyle? = null, area: bool = false, offset: int = 0, showLabel: bool = true, showValue: bool = true, capacity: int = 512, on: Surface? = null) -> PlotLineCreates a line plot.
titlenames the plot.color,width, andstyleset its appearance. Null uses the theme default.widthmust be from 0.0 to 10.0, inclusive.areafills between the line and zero, using the line color.offsetshifts values along the bars, from -500 to 500. Other values are rejected before the script runs.showLabelandshowValuecontrol the legend label and value.onchooses the panel or pane. Null uses the main price pane.
Use plot(value) for values along subscribed bars. On a panel with an explicit
axis, use set(key, value). Null leaves a gap with plot or deletes the key
with set.
capacity limits keys to 512 by default, with a maximum of 4096. Adding a
new key when full stops the script with an error.
Contracts
width: Accepted range: 0.0 to 10.0. Must be a finite number. Invalid values are rejected.offset: Accepted range: -500 to 500. Invalid values are rejected.capacity: Accepted range: 1 to 4096. Invalid values are rejected.
Example
script "Line Plot"
data chart = subscribe(data.ohlcv)
plot ma = plot.line(title: "MA", color: color.blue, width: 2.0)
on chart.update {
ma.plot(ta.sma(chart.close, 20))
}Accepted values
style:LineStylevalues — 4 available.
plot.histogram
plot.histogram(title: string = "", color: color? = null, horizontal: bool = false, showLabel: bool = true, showValue: bool = true, capacity: int = 512, on: Surface? = null) -> PlotHistogramCreates a histogram or bar chart.
titlenames the plot.colorsets the bar color. Null uses the theme default.horizontaldraws sideways bars. It requires an explicit category-axis panel; other placements are rejected before the script runs.showLabelandshowValuecontrol the legend label and value.onchooses the panel or pane. Without it, a vertical histogram uses the script's shared value pane on the main chart, named after the script.
Use plot(value) for bars along subscribed data or set(key, value) on a panel
with an explicit axis. Null leaves a gap with plot or deletes the key with
set. Multiple histograms on the same keyed panel form grouped bars. Stacking
is not supported.
capacity limits keys to 512 by default, with a maximum of 4096. Adding a
new key when full stops the script with an error.
Contracts
capacity: Accepted range: 1 to 4096. Invalid values are rejected.
Example
script "Venue Volume"
data bars = subscribe(data.ohlcv)
window win = window(title: "Venues") {
byVenue: chart.panel(axis: axis.category),
}
plot vol = plot.histogram(title: "Volume", on: win.byVenue)
on bars.update {
vol.set("OKX", bars.volume)
}plot.point
plot.point(title: string = "", color: color? = null, size: float? = null, showLabel: bool = true, showValue: bool = true, capacity: int = 512, on: Surface? = null) -> PlotPointCreates a scatter plot of dots.
titlenames the plot.colorandsizeset the dots' appearance. Null uses the theme default.sizemust be from 0.5 to 30.0, inclusive. Shape and border options are not supported.showLabelandshowValuecontrol the legend label and value.onchooses the panel or pane. Null uses the main price pane.
Use plot(value) for dots along subscribed bars or set(key, value) on a panel
with an explicit axis. Null skips a dot with plot or deletes the key with set.
capacity limits keys to 512 by default, with a maximum of 4096. Adding a
new key when full stops the script with an error.
Contracts
size: Accepted range: 0.5 to 30.0. Must be a finite number. Invalid values are rejected.capacity: Accepted range: 1 to 4096. Invalid values are rejected.
Example
script "Point Plot"
data chart = subscribe(data.ohlcv)
plot dots = plot.point(title: "Signal", size: 4.0)
on chart.update {
dots.plot(chart.close)
}plot.candle
plot.candle(title: string = "", bodyColor: color? = null, wickColor: color? = null, borderColor: color? = null, offset: int = 0, showLabel: bool = true, showValue: bool = true, capacity: int = 512, on: Surface? = null) -> PlotCandleCreates a candlestick plot.
titlenames the plot.bodyColor,wickColor, andborderColorset the candle colors. Null uses the theme default.offsetshifts values along the bars, from -500 to 500. Other values are rejected before the script runs.showLabelandshowValuecontrol the legend label and value.onchooses the panel or pane. Null uses the main price pane.
Use plot for candles along subscribed bars. On a time-axis panel, use set
with your own candle times.
capacity limits keys to 512 by default, with a maximum of 4096. Adding a
new key when full stops the script with an error.
Contracts
offset: Accepted range: -500 to 500. Invalid values are rejected.capacity: Accepted range: 1 to 4096. Invalid values are rejected.
Example
script "Candle Plot"
data chart = subscribe(data.ohlcv)
plot ha = plot.candle(title: "HA")
on chart.update {
ha.plot(chart.open, chart.high, chart.low, chart.close)
}plot.bar
plot.bar(title: string = "", color: color? = null, offset: int = 0, showLabel: bool = true, showValue: bool = true, capacity: int = 512, on: Surface? = null) -> PlotBarCreates an OHLC bar plot.
titlenames the plot.colorsets the bar color. Null uses the theme default.offsetshifts values along the bars, from -500 to 500. Other values are rejected before the script runs.showLabelandshowValuecontrol the legend label and value.onchooses the panel or pane. Null uses the main price pane.capacityaccepts 1 to 4096, but does not affect this plot: OHLC bars only support subscribed bars.
Use plot to draw each bar. Placement on a panel with an explicit keyed axis
is rejected before the script runs.
Contracts
offset: Accepted range: -500 to 500. Invalid values are rejected.capacity: Accepted range: 1 to 4096. Invalid values are rejected.
Example
script "Bar Plot"
data chart = subscribe(data.ohlcv)
plot bars = plot.bar(title: "Bars")
on chart.update {
bars.plot(chart.open, chart.high, chart.low, chart.close)
}plot.marker
plot.marker(title: string = "", color: color? = null, shape: Shape? = null, size: float? = null, borderWidth: float? = null, borderColor: color? = null, offset: int = 0, showLabel: bool = true, showValue: bool = true, on: Surface? = null, anchor: Anchor? = null) -> PlotMarkerCreates a plot of shaped markers.
titlenames the plot.color,shape,size,borderWidth, andborderColorset the appearance. Null uses the theme default.sizemust be from 1.0 to 60.0 andborderWidthfrom 0.0 to 10.0, inclusive.offsetshifts values along the bars, from -500 to 500. Other values are rejected before the script runs.showLabelandshowValuecontrol the legend label and value.onchooses the panel or pane. Null uses the main price pane.
Position
Leave anchor null to position each mark at its plotted value. Use anchor.top
or anchor.bottom to pin it to that pane edge instead. The plotted value then
sets the distance inward from the edge in logical pixels. Negative distances
are allowed, but marks outside the pane are clipped. Edge-anchored marks do not
affect the vertical scale or show a legend value. Other anchors are rejected
before the script runs. showLabel and
showValue are ignored when anchored to an edge.
Use plot along subscribed bars. Null skips a bar. For a panel with an explicit
keyed axis, use a point plot instead.
Contracts
size: Accepted range: 1.0 to 60.0. Must be a finite number. Invalid values are rejected.borderWidth: Accepted range: 0.0 to 10.0. Must be a finite number. Invalid values are rejected.offset: Accepted range: -500 to 500. Invalid values are rejected.
Example
script "Marker Plot"
data chart = subscribe(data.ohlcv)
plot crossUp = plot.marker(title: "Cross", shape: shape.up, color: color.green)
on chart.update {
if chart.close > chart.open { crossUp.plot(chart.low) }
}Accepted values
anchor:Anchorvalues — 13 available.shape:Shapevalues — 10 available.
plot.label
plot.label(title: string = "", color: color? = null, size: float? = null, offset: int = 0, on: Surface? = null, anchor: Anchor? = null) -> PlotLabelCreates a plot of text labels.
titlenames the plot.colorandsizeset the text appearance. Null uses the theme default.sizemust be from 6.0 to 48.0, inclusive.offsetshifts values along the bars, from -500 to 500. Other values are rejected before the script runs.onchooses the panel or pane. Null uses the main price pane.
Position
Leave anchor null to position each mark at its plotted value. Use anchor.top
or anchor.bottom to pin it to that pane edge instead. The plotted value then
sets the distance inward from the edge in logical pixels. Negative distances
are allowed, but marks outside the pane are clipped. Edge-anchored marks do not
affect the vertical scale or show a legend value. Other anchors are rejected
before the script runs.
Use plot to place labels along subscribed bars. For persistent text placed
independently of a bar, use a label entity instead.
Contracts
size: Accepted range: 6.0 to 48.0. Must be a finite number. Invalid values are rejected.offset: Accepted range: -500 to 500. Invalid values are rejected.
Example
script "Label Plot"
data chart = subscribe(data.ohlcv)
plot tag = plot.label(title: "Pivot", size: 11.0)
on chart.update {
if chart.high > chart.high[1] { tag.plot(chart.high, "H") }
}Accepted values
anchor:Anchorvalues — 13 available.
plot.arrow
plot.arrow(title: string = "", colorUp: color? = null, colorDown: color? = null, minHeight: float? = null, maxHeight: float? = null, paddingPx: float? = null, shaftWidth: float? = null, headLengthPx: float? = null, headWidthRatio: float? = null, offset: int = 0, showLabel: bool = true, showValue: bool = true, on: Surface? = null) -> PlotArrowCreates arrows whose direction and height follow a value.
Positive and negative values choose the direction. A larger absolute value makes a taller arrow. Null skips a bar.
titlenames the plot.colorUpandcolorDownset the direction colors.minHeightandmaxHeightset the height range, each from 0.0 to 200.0 pixels.paddingPxandheadLengthPxeach accept 0.0 to 50.0 pixels.shaftWidthaccepts 0.5 to 20.0 pixels.headWidthRatioaccepts 1.0 to 5.0. Null geometry options use the theme default.offsetshifts values along the bars, from -500 to 500. Other values are rejected before the script runs.showLabelandshowValuecontrol the legend label and value.onchooses the panel or pane. Null uses the main price pane.
Contracts
minHeight: Accepted range: 0.0 to 200.0. Must be a finite number. Invalid values are rejected.maxHeight: Accepted range: 0.0 to 200.0. Must be a finite number. Invalid values are rejected.paddingPx: Accepted range: 0.0 to 50.0. Must be a finite number. Invalid values are rejected.shaftWidth: Accepted range: 0.5 to 20.0. Must be a finite number. Invalid values are rejected.headLengthPx: Accepted range: 0.0 to 50.0. Must be a finite number. Invalid values are rejected.headWidthRatio: Accepted range: 1.0 to 5.0. Must be a finite number. Invalid values are rejected.offset: Accepted range: -500 to 500. Invalid values are rejected.
Example
script "Arrow Plot"
data chart = subscribe(data.ohlcv)
plot flow = plot.arrow(title: "Delta", colorUp: color.green, colorDown: color.red)
on chart.update {
flow.plot((chart.buyVolume ?? 0.0) - (chart.sellVolume ?? 0.0))
}plot.bg
plot.bg(title: string = "", color: color? = null, on: Surface? = null) -> PlotBgCreates background highlights behind the chart.
title names the plot. color sets the tint; null uses the theme default.
on chooses the pane, with null using the main price pane.
Call plot to tint a bar across the full pane height, behind other drawings.
Skip the call to leave the bar clear. Background plots only support subscribed bars.
Example
script "Background Plot"
data chart = subscribe(data.ohlcv)
plot session = plot.bg(title: "US hours")
on chart.update {
if chart.isNew { session.plot(color: color.rgb(64, 128, 255, 24)) }
}plot.cells
plot.cells(title: string = "", columns: int = 1, scale: CellScale = cellscale.bar, color: color? = null, borderColor: color? = null, textColor: color? = null, candles: CellCandles = cellcandles.overlay, format: CellFormat = cellformat.compact, decimals: int? = null, sign: bool = false, grouping: bool = false, on: Surface? = null) -> PlotCellsCreates a plot of per-bar cell rows, such as a footprint or a per-bar profile.
Each bar holds rows of cells. A cell is a rectangle covering a price range inside the bar, with an optional width, colors, and a number shown as text.
titlenames the plot.columnssplits each bar into 1 to 4 side-by-side columns. Other values are rejected before the script runs.scalechooses what a full-width cell means.cellscale.barcompares each cell with the largest weight on its own bar,cellscale.viewwith the largest weight on the visible bars, andcellscale.unittreats the weight as a fraction from 0 to 1.color,borderColor, andtextColorset the defaults for cells that do not pass their own. A nullcolororborderColordraws no fill or no border. A nulltextColoruses the chart's text color.candleschooses how the chart's own candles are drawn while this plot is visible on the main price pane.cellcandles.overlayleaves them as they are, behind the cells.cellcandles.sidedraws them as a thin strip at the left edge of each bar, beside the cells.cellcandles.hiddendoes not draw them. The cells are drawn in the same place in every mode. It has no effect on any other pane.formatchooses how thevalueof a cell is written.cellformat.compactshortens large numbers with a suffix, so 3214.56 reads3.21K.cellformat.fixedwrites the number in full.cellformat.percenttreats the value as a ratio, so 0.153 reads15.3%.decimalsis the number of digits after the decimal point, from 0 to 8. Other values are rejected before the script runs. Null, the default, lets the chart choose.cellformat.fixedandcellformat.percentalways write that many digits, so the cells of a column line up.cellformat.compactwrites at most that many and drops trailing zeros.signwrites a+before values above zero.groupingseparates thousands with commas, so 53100000 reads53,100,000. It applies tocellformat.fixedandcellformat.percentonly.onchooses the pane. Null uses the main price pane. A panel with an explicit keyed axis is rejected before the script runs.
Use cell to add cells to a bar and clear to empty one. The legend shows no
value for a cells plot, and cells on the price pane do not change its vertical
scale.
The chart's candles keep setting the price scale, the crosshair, and the legend
whatever candles is; only their drawing changes. A chart that does not draw
its main series as candles or bars is not affected, and neither is a
plot.candle plot. When several visible cells plots on the main price pane ask
for different modes, cellcandles.hidden wins over cellcandles.side, which
wins over cellcandles.overlay.
The number format applies to every cell of the plot. It is the most detail a cell shows: when the text does not fit, the chart writes the cells of that bar with fewer digits, and shows no text only when nothing fits. Numbers are rounded half away from zero, and a value that rounds to zero is written without a sign. A cell stores its value with about seven significant digits.
Limits
Each bar holds at most 1024 cells per plot; further cells on that bar are not drawn. A script keeps a limited total number of cells across all of its cells plots, set by your plan. When the total is reached the oldest bars lose their cells first, so the most recent bars always stay drawn.
Contracts
columns: Accepted range: 1 to 4. Invalid values are rejected.decimals: Accepted range: 0 to 8. Invalid values are rejected.
Example
script "Cells Plot"
data chart = subscribe(data.ohlcv)
plot fp = plot.cells(title: "Range", columns: 2)
on chart.update {
let mid = (chart.high + chart.low) / 2.0
fp.clear()
fp.cell(chart.low, mid, weight: chart.sellVolume, color: color.red,
column: 0, align: align.right)
fp.cell(mid, chart.high, weight: chart.buyVolume, color: color.green, column: 1)
}Accepted values
candles:CellCandlesvalues — 3 available.format:CellFormatvalues — 3 available.scale:CellScalevalues — 3 available.
fill.between
fill.between(a: PlotLine, b: PlotLine, color: color? = null) -> FillCreates a fill between two line plots.
a and b must be line plots on the same pane, both using subscribed bars.
Other pairs are rejected before the script runs.
color sets the fill color; null uses the theme default. Call fill on each
update to draw the fill, optionally passing a different color. Updating either
line without calling fill leaves that span unfilled.
Example
script "Line Fill"
data chart = subscribe(data.ohlcv)
plot upper = plot.line(title: "Upper")
plot lower = plot.line(title: "Lower")
fill band = fill.between(upper, lower, color: color.rgb(33, 150, 243, 32))
on chart.update {
upper.plot(chart.high)
lower.plot(chart.low)
band.fill()
}plot.line.plot
plot.line.plot(value: float?, color: color? = null) -> voidDraws a line value on the current bar.
value sets the price; null leaves a gap. color overrides this point's color;
null keeps the plot default.
Values follow the panel's time axis: the main chart's timeframe on the main chart, or the panel's subscription timeframe in a window. A close handler places the value at the closing candle's end time.
Example
script "Line Emit"
data chart = subscribe(data.ohlcv)
plot ma = plot.line(title: "MA")
on chart.update {
ma.plot(ta.sma(chart.close, 20), color: color.blue)
}plot.histogram.plot
plot.histogram.plot(value: float?, color: color? = null) -> voidDraws a histogram bar on the current bar.
value sets the height from zero; null skips the bar. color overrides its
color, with null keeping the plot default.
Example
script "Histogram Emit"
data chart = subscribe(data.ohlcv)
plot delta = plot.histogram(title: "Delta")
on chart.update {
let net = (chart.buyVolume ?? 0.0) - (chart.sellVolume ?? 0.0)
delta.plot(net, color: net >= 0.0 ? color.green : color.red)
}plot.point.plot
plot.point.plot(value: float?, color: color? = null, size: float? = null) -> voidDraws a dot on the current bar.
value sets the price; null skips the dot. color and size override the dot's
appearance, with null keeping each plot default. A size outside its allowed
range stops the script with an error.
Calling again on the same bar replaces the dot; the last call wins.
Contracts
size: Accepted range: 0.5 to 30.0. Must be a finite number. Invalid values are rejected.
Example
script "Point Emit"
data chart = subscribe(data.ohlcv)
plot dots = plot.point(title: "VWAP Band")
on chart.update {
dots.plot(chart.close, size: 2.0)
}plot.candle.plot
plot.candle.plot(open: float?, high: float?, low: float?, close: float?, bodyColor: color? = null, wickColor: color? = null, borderColor: color? = null) -> voidDraws a candle on the current bar.
open, high, low, and close set the candle prices. If any is null, the
whole candle is skipped.
bodyColor, wickColor, and borderColor override its colors. Null keeps each
plot default.
Example
script "Candle Emit"
data chart = subscribe(data.ohlcv)
plot candles = plot.candle(title: "Source")
on chart.update {
candles.plot(chart.open, chart.high, chart.low, chart.close)
}plot.bar.plot
plot.bar.plot(open: float?, high: float?, low: float?, close: float?, color: color? = null) -> voidDraws an OHLC bar on the current bar.
open, high, low, and close set the bar prices. If any is null, the whole
bar is skipped. color overrides its color; null keeps the plot default.
Example
script "Bar Emit"
data chart = subscribe(data.ohlcv)
plot bars = plot.bar(title: "Dual-color bars")
on chart.update {
let barColor = chart.close >= chart.open ? color.up : color.down
bars.plot(chart.open, chart.high, chart.low, chart.close, color: barColor)
}plot.marker.plot
plot.marker.plot(value: float?, color: color? = null, shape: Shape? = null, size: float? = null, borderWidth: float? = null, borderColor: color? = null) -> voidDraws a marker on the current bar.
value sets the price, or the pixel distance from the pane edge when the plot
uses an edge anchor. Null skips the marker.
color, shape, size, borderWidth, and borderColor override its appearance.
Null keeps each plot default. A size or borderWidth outside its allowed range
stops the script with an error.
Contracts
size: Accepted range: 1.0 to 60.0. Must be a finite number. Invalid values are rejected.borderWidth: Accepted range: 0.0 to 10.0. Must be a finite number. Invalid values are rejected.
Example
script "Marker Emit"
data chart = subscribe(data.ohlcv)
plot crossUp = plot.marker(title: "Cross", shape: shape.up)
on chart.update {
if chart.close > chart.open { crossUp.plot(chart.low, shape: shape.up) }
}Accepted values
shape:Shapevalues — 10 available.
plot.label.plot
plot.label.plot(price: float?, text: string, color: color? = null, size: float? = null) -> voidDraws a text label on the current bar.
price sets the position, or the pixel distance from the pane edge when the
plot uses an edge anchor. Null skips the label. text supplies the label text;
several labels can use the same text.
color and size override its appearance. Null keeps each plot default. A
size outside its allowed range stops the script with an error.
Contracts
size: Accepted range: 6.0 to 48.0. Must be a finite number. Invalid values are rejected.
Example
script "Label Emit"
data chart = subscribe(data.ohlcv)
plot tag = plot.label(title: "Range")
on chart.update {
tag.plot(chart.high, str.format("range={0}", chart.high - chart.low))
}plot.arrow.plot
plot.arrow.plot(value: float?, colorUp: color? = null, colorDown: color? = null) -> voidDraws an arrow on the current bar.
value sets the arrow's height and direction; null skips the arrow. colorUp
and colorDown override the direction colors, with null keeping each plot
default. The plot declaration sets the arrow's shape and size limits.
Example
script "Arrow Emit"
data chart = subscribe(data.ohlcv)
plot flow = plot.arrow(title: "Flow")
on chart.update {
flow.plot((chart.buyVolume ?? 0.0) - (chart.sellVolume ?? 0.0))
}plot.bg.plot
plot.bg.plot(color: color? = null) -> voidTints the pane background on the bar being processed.
color sets the tint for this bar, and null keeps the default. Calling
plot marks the bar; not calling it leaves the bar clear.
Example
script "Background Emit"
data chart = subscribe(data.ohlcv)
plot session = plot.bg(title: "Open")
on chart.update {
if chart.isNew { session.plot() }
}fill.fill
fill.fill(color: color? = null, topValue: float? = null, bottomValue: float? = null, topColor: color? = null, bottomColor: color? = null) -> voidFills between the two lines on the current bar.
Pass color for a solid fill. For a vertical gradient, use topValue and
bottomValue to set its positions and topColor and bottomColor for its colors.
Do not mix solid and gradient colors in one call; this is rejected before the script runs. Null colors use the fill default.
Example
script "Fill Emit"
data chart = subscribe(data.ohlcv)
plot upper = plot.line(title: "Upper")
plot lower = plot.line(title: "Lower")
fill band = fill.between(upper, lower)
on chart.update {
upper.plot(chart.high)
lower.plot(chart.low)
band.fill(color: color.rgb(33, 150, 243, 32))
}plot.cells.cell
plot.cells.cell(from: float?, to: float?, weight: float? = null, color: color? = null, borderColor: color? = null, value: float? = null, textColor: color? = null, column: int = 0, align: Align = align.left, time: time? = null) -> voidAdds a cell to a bar.
from and to set the cell's price range, in either order. The call does
nothing when either is null or not finite, or when they are equal.
weightsets the width, compared as the plot'sscalesays. Null fills the column. A weight that is zero, negative, or not finite draws no fill; the border and text still draw.color,borderColor, andtextColoroverride the plot defaults. Null keeps each default.valueis shown as text inside the cell when it fits. Null shows no text.columnchooses the column, counting from 0. A column the plot does not have stops the script with an error.alignchooses the edge the width grows from:align.left,align.right, oralign.centerto grow both ways.timechooses the bar. Null uses the current bar. Any other time selects the bar whose period contains it. A time after the current bar stops the script with an error. A time outside the bars still kept does nothing.
The first cell or clear for a bar during one calculation step discards the
cells that bar had from earlier steps. Further cell calls in the same step
add to it. A script whose bar can go from having cells to having none calls
clear, otherwise the earlier cells stay.
A handler that runs when a period closes writes to the bar that opens next. To draw on the closed period, pass that period's own time.
Contracts
column: Accepted range: 0 to 3. Invalid values are rejected.
Example
script "Cell Emit"
data chart = subscribe(data.ohlcv)
data vol = subscribe(data.volume)
plot fp = plot.cells(title: "Footprint", columns: 2)
on chart.update {
let rows = vol.bucketsByStep(25.0)
if rows != null {
fp.clear(time: rows.time)
for r in rows {
fp.cell(r.from, r.to, weight: r.sell, value: r.sell, color: color.red,
column: 0, align: align.right, time: rows.time)
fp.cell(r.from, r.to, weight: r.buy, value: r.buy, color: color.green,
column: 1, time: rows.time)
}
}
}Accepted values
align:Alignvalues — 3 available.
plot.cells.clear
plot.cells.clear(time: time? = null) -> voidRemoves every cell this plot has on a bar.
time chooses the bar, as for cell. Null uses the current bar. A time after
the current bar stops the script with an error. A time outside the bars still
kept does nothing.
cell calls after clear in the same calculation step add to the emptied bar.
Example
script "Cell Clear"
data chart = subscribe(data.ohlcv)
plot fp = plot.cells(title: "Up bars")
on chart.update {
fp.clear()
if chart.close > chart.open {
fp.cell(chart.open, chart.close, color: color.green)
}
}plot.line.set
plot.line.set(key: Key, value: float?, color: color? = null) -> voidAdds or updates a line value at a key.
key sets the position on the panel's axis. value sets the price; null deletes
the key. color overrides this point's color, with null keeping the plot default.
Plots on the same panel share the axis. Use time keys for a custom time series.
Example
script "Line Set"
data bars = subscribe(data.ohlcv)
window win = window(title: "Curve") {
term: chart.panel(axis: axis.index),
}
plot iv = plot.line(title: "IV", on: win.term)
on bars.update {
iv.set(bars.index, bars.close)
}plot.histogram.set
plot.histogram.set(key: Key, value: float?, color: color? = null) -> voidAdds or updates a histogram bar at a key.
key sets the position on the panel's axis. value sets the height; null deletes
the key. color overrides this bar's color, with null keeping the plot default.
Category axes create bar charts; horizontal makes sideways bars. Multiple
histograms on the same panel form grouped bars. Stacking is not supported.
Example
script "Histogram Set"
data bars = subscribe(data.ohlcv)
window win = window(title: "Venues") {
venues: chart.panel(axis: axis.category),
}
plot vol = plot.histogram(title: "Volume", on: win.venues)
on bars.update {
vol.set("OKX", bars.volume, color: color.blue)
}plot.point.set
plot.point.set(key: Key, value: float?, color: color? = null, size: float? = null) -> voidAdds or updates a dot at a key.
key sets the position on the panel's axis. value sets the price; null deletes
the key. color and size override this dot's appearance, with null keeping each
plot default. A size outside its allowed range stops the script with an error.
Each key has one dot. Calling again with the same key replaces the dot.
Contracts
size: Accepted range: 0.5 to 30.0. Must be a finite number. Invalid values are rejected.
Example
script "Point Set"
data bars = subscribe(data.ohlcv)
window win = window(title: "Spreads") {
venues: chart.panel(axis: axis.category),
}
plot spread = plot.point(title: "Spread", on: win.venues)
on bars.update {
spread.set("OKX", bars.high - bars.low, size: 3.0)
}plot.candle.set
plot.candle.set(key: Key, open: float?, high: float?, low: float?, close: float?, bodyColor: color? = null, wickColor: color? = null, borderColor: color? = null) -> voidAdds or updates a candle at a time key.
key sets the candle time. open, high, low, and close set its prices.
If any price is null, the candle is deleted.
bodyColor, wickColor, and borderColor override its colors. Null keeps each
plot default. Reuse the same time key to update a custom candle while it forms.
Example
script "Candle Set"
data bars = subscribe(data.ohlcv)
window win = window(title: "Renko") {
rk: chart.panel(axis: axis.time),
}
plot bricks = plot.candle(title: "Renko", on: win.rk)
on bars.update {
let t = bars.time
if t != null { bricks.set(t, bars.open, bars.high, bars.low, bars.close) }
}linestyle.solid
linestyle.solid: LineStyle = 1Solid line style.
linestyle.dotted
linestyle.dotted: LineStyle = 2Dotted line style.
linestyle.dashed
linestyle.dashed: LineStyle = 3Dashed line style.
linestyle.step
linestyle.step: LineStyle = 4Step line style.
shape.circle
shape.circle: Shape = 1Circle marker shape.
shape.square
shape.square: Shape = 2Square marker shape.
shape.diamond
shape.diamond: Shape = 3Diamond marker shape.
shape.up
shape.up: Shape = 4Up-triangle marker shape.
shape.down
shape.down: Shape = 5Down-triangle marker shape.
shape.left
shape.left: Shape = 6Left-triangle marker shape.
shape.right
shape.right: Shape = 7Right-triangle marker shape.
shape.cross
shape.cross: Shape = 8Cross marker shape.
shape.plus
shape.plus: Shape = 9Plus marker shape.
shape.asterisk
shape.asterisk: Shape = 10Asterisk marker shape.
extend.none
extend.none: Extend = 0Entity does not extend beyond its x-range.
extend.left
extend.left: Extend = 1Entity extends leftward past its leftmost endpoint along its slope.
extend.right
extend.right: Extend = 2Entity extends rightward past its rightmost endpoint along its slope.
extend.both
extend.both: Extend = 3Entity extends in both directions.
extend.up
extend.up: Extend = 4Line or box extends upward past its topmost endpoint to the pane edge.
extend.down
extend.down: Extend = 5Line or box extends downward past its bottommost endpoint to the pane edge.
extend.vertical
extend.vertical: Extend = 6Line or box extends both upward and downward to the pane edges.
cellscale.bar
cellscale.bar: CellScale = 0A full-width cell has the largest weight on its own bar.
cellscale.view
cellscale.view: CellScale = 1A full-width cell has the largest weight on the visible bars.
cellscale.unit
cellscale.unit: CellScale = 2The weight is the width itself, as a fraction from 0 to 1.
cellcandles.overlay
cellcandles.overlay: CellCandles = 0The chart's candles are drawn as usual, behind the cells.
cellcandles.side
cellcandles.side: CellCandles = 1The chart's candles are drawn as a thin strip at the left edge of each bar, beside the cells.
cellcandles.hidden
cellcandles.hidden: CellCandles = 2The chart's candles are not drawn.
cellformat.compact
cellformat.compact: CellFormat = 0Large numbers are shortened with a suffix, such as 3.21K or 53.1M.
cellformat.fixed
cellformat.fixed: CellFormat = 1The number is written in full, such as 3214.56.
cellformat.percent
cellformat.percent: CellFormat = 2The value is a ratio written as a percentage, so 0.153 reads 15.3%.