Skip to content
ChartDeck ChartScript docs Account Open the terminal

heatmap

Heatmaps: a drawing of coloured cells over time and price, painted by the chart as one image (not as boxes). Up to 8 per script and 500,000 cells in all (CS5120).

#Functions

#heatmap.addfunction

Adds a heatmap.column (from liq.heat or book.heat) at its own time and span.

heatmap.add(id: heatmap, column: heatmap.column, { width?: int = na })
ParameterTypeDescription
idheatmapThe heatmap.
columnheatmap.columnThe column.
widthintdefault naOverrides the width (na = the column's span).

Example

ChartScriptFragmentOpen in editor
const hm = heatmap.new()
const col = liq.heat()
if (!na(col)) {
    hm.add(col)
}

Since ChartScript 1

#heatmap.cellfunction

Adds one cell from low to high.

heatmap.cell(id: heatmap, x: int, low: float, high: float, value: float, { width?: int = na })
ParameterTypeDescription
idheatmapThe heatmap.
xintA time or a bar index (the heatmap's xloc).
lowfloatThe bottom price.
highfloatThe top price.
valuefloatThe value (above 0).
widthintdefault naThe width (na = one bar).

Example

ChartScriptFragmentOpen in editor
const hm = heatmap.new()
hm.cell(time, low, high, volume)

Since ChartScript 1

#heatmap.clearfunction

Removes every column of the heatmap.

heatmap.clear(id: heatmap)
ParameterTypeDescription
idheatmapThe heatmap.

Example

ChartScriptFragmentOpen in editor
const hm = heatmap.new()
hm.clear()

Since ChartScript 1

#heatmap.columnfunction

Adds a column of equal cells. The non-empty cells count toward the 500,000-cell budget (CS5120).

heatmap.column

Example

ChartScriptFragmentOpen in editor
const hm = heatmap.new()
hm.column(time, low, (high - low) / 4, array.from(1.0, 3.0, 2.0, 1.0))

Since ChartScript 1

#heatmap.deletefunction

Deletes the heatmap.

heatmap.delete(id: heatmap)
ParameterTypeDescription
idheatmapThe heatmap.

Example

ChartScriptFragmentOpen in editor
const hm = heatmap.new()
hm.delete()

Since ChartScript 1

#heatmap.newfunction

A new heatmap. Columns are added with column, add or cell; the chart paints all of them as one image per pane, coloured by value on the palette.

heatmap.new({ palette?: string = heatmap.palette_heat, min?: float = na, max?: float = na, scale?: string = heatmap.scale_linear, floor?: float = 0.05, gamma?: float = 0.9, reference?: float = 92, opacity?: int = 100, color?: color = na, xloc?: simple string = xloc.bar_time, smooth?: bool = false, intensity?: float = 1 }): heatmap
ParameterTypeDescription
palettestringdefault heatmap.palette_heatThe colours: heatmap.palette_heat (the liquidation heatmap's), palette_bid, palette_ask (the order-book heatmap's), palette_viridis, palette_magma, or palette_mono (transparent to color).
minfloatdefault naThe value drawn at the bottom of the palette; na = 0.
maxfloatdefault naThe value drawn at the top of the palette; na = automatic: the reference percentile of the cells in view, as the built-in heatmaps do.
scalestringdefault heatmap.scale_linearHow values map to the palette: heatmap.scale_linear, scale_sqrt or scale_log.
floorfloatdefault 0.05Cells below this share of the range (0 to 0.99) stay transparent.
gammafloatdefault 0.9The palette curve above the floor (1 = even; below 1 brightens weak cells).
referencefloatdefault 92With max = na: the percentile (50 to 100) of the visible cells that reaches the top of the palette.
opacityintdefault 100The opacity of the whole heatmap, 0 to 100.
colorcolordefault naThe colour of heatmap.palette_mono.
xlocsimple stringdefault xloc.bar_timexloc.bar_time (x is a time; width a duration in ms) or xloc.bar_index (x is a bar index; width a number of bars).
smoothbooldefault falsetrue = smooth the image between cells when it is stretched.
intensityfloatdefault 1Brightness: values are multiplied by it before they meet the palette (2 = twice as bright; the built-in liquidation heatmap Intensity).

Returns heatmap.

Example

ChartScriptFragmentOpen in editor
const hm = heatmap.new({ palette: heatmap.palette_viridis, scale: heatmap.scale_sqrt })

Since ChartScript 1

#heatmap.set_intensityfunction

Sets the intensity (brightness multiplier).

heatmap.set_intensity(id: heatmap, intensity: float)
ParameterTypeDescription
idheatmapThe heatmap.
intensityfloatThe multiplier, 0.01 to 100.

Example

ChartScriptFragmentOpen in editor
const hm = heatmap.new()
hm.set_intensity(1.5)

Since ChartScript 1

#heatmap.set_opacityfunction

Sets the opacity, 0 to 100.

heatmap.set_opacity(id: heatmap, opacity: int)
ParameterTypeDescription
idheatmapThe heatmap.
opacityintThe opacity.

Example

ChartScriptFragmentOpen in editor
const hm = heatmap.new()
hm.set_opacity(60)

Since ChartScript 1

#heatmap.set_rangefunction

Sets the values at the bottom and the top of the palette (na = automatic).

heatmap.set_range(id: heatmap, min: float, max: float)
ParameterTypeDescription
idheatmapThe heatmap.
minfloatThe bottom value.
maxfloatThe top value.

Example

ChartScriptFragmentOpen in editor
const hm = heatmap.new()
hm.set_range(0, 1000000)

Since ChartScript 1

#heatmap.sizefunction

The number of non-empty cells the heatmap holds.

heatmap.size(id: heatmap): int
ParameterTypeDescription
idheatmapThe heatmap.

Returns int.

Example

ChartScriptFragmentOpen in editor
const hm = heatmap.new()
const cells = hm.size()

Since ChartScript 1

#Variables

#heatmap.allvariable

The script's heatmaps, oldest first.

heatmap.all: array<heatmap>

Type series array<heatmap>.

Example

ChartScriptFragmentOpen in editor
const n = heatmap.all.size()

Since ChartScript 1

#Constants

NameTypeDescription
heatmap.palette_askstringThe order-book heatmap's ask colours.
heatmap.palette_bidstringThe order-book heatmap's bid colours.
heatmap.palette_heatstringThe liquidation heatmap's colours (follows the chart theme).
heatmap.palette_magmastringMagma: black to light yellow.
heatmap.palette_monostringFrom transparent to the heatmap's color.
heatmap.palette_viridisstringViridis: dark blue to yellow.
heatmap.scale_linearstringValues map evenly onto the palette.
heatmap.scale_logstringLogarithmic: for values over several orders of magnitude.
heatmap.scale_sqrtstringSquare root: weak cells stand out more.

The ChartScript documentation is in English for now; translations will follow.