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 })| Parameter | Type | Description |
|---|---|---|
id | heatmap | The heatmap. |
column | heatmap.column | The column. |
width | intdefault na | Overrides the width (na = the column's span). |
Example
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 })| Parameter | Type | Description |
|---|---|---|
id | heatmap | The heatmap. |
x | int | A time or a bar index (the heatmap's xloc). |
low | float | The bottom price. |
high | float | The top price. |
value | float | The value (above 0). |
width | intdefault na | The width (na = one bar). |
Example
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)| Parameter | Type | Description |
|---|---|---|
id | heatmap | The heatmap. |
Example
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.columnExample
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)| Parameter | Type | Description |
|---|---|---|
id | heatmap | The heatmap. |
Example
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| Parameter | Type | Description |
|---|---|---|
palette | stringdefault heatmap.palette_heat | The 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). |
min | floatdefault na | The value drawn at the bottom of the palette; na = 0. |
max | floatdefault na | The value drawn at the top of the palette; na = automatic: the reference percentile of the cells in view, as the built-in heatmaps do. |
scale | stringdefault heatmap.scale_linear | How values map to the palette: heatmap.scale_linear, scale_sqrt or scale_log. |
floor | floatdefault 0.05 | Cells below this share of the range (0 to 0.99) stay transparent. |
gamma | floatdefault 0.9 | The palette curve above the floor (1 = even; below 1 brightens weak cells). |
reference | floatdefault 92 | With max = na: the percentile (50 to 100) of the visible cells that reaches the top of the palette. |
opacity | intdefault 100 | The opacity of the whole heatmap, 0 to 100. |
color | colordefault na | The colour of heatmap.palette_mono. |
xloc | simple stringdefault xloc.bar_time | xloc.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). |
smooth | booldefault false | true = smooth the image between cells when it is stretched. |
intensity | floatdefault 1 | Brightness: values are multiplied by it before they meet the palette (2 = twice as bright; the built-in liquidation heatmap Intensity). |
Returns heatmap.
Example
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)| Parameter | Type | Description |
|---|---|---|
id | heatmap | The heatmap. |
intensity | float | The multiplier, 0.01 to 100. |
Example
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)| Parameter | Type | Description |
|---|---|---|
id | heatmap | The heatmap. |
opacity | int | The opacity. |
Example
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)| Parameter | Type | Description |
|---|---|---|
id | heatmap | The heatmap. |
min | float | The bottom value. |
max | float | The top value. |
Example
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| Parameter | Type | Description |
|---|---|---|
id | heatmap | The heatmap. |
Returns int.
Example
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
const n = heatmap.all.size()Since ChartScript 1
#Constants
| Name | Type | Description |
|---|---|---|
heatmap.palette_ask | string | The order-book heatmap's ask colours. |
heatmap.palette_bid | string | The order-book heatmap's bid colours. |
heatmap.palette_heat | string | The liquidation heatmap's colours (follows the chart theme). |
heatmap.palette_magma | string | Magma: black to light yellow. |
heatmap.palette_mono | string | From transparent to the heatmap's color. |
heatmap.palette_viridis | string | Viridis: dark blue to yellow. |
heatmap.scale_linear | string | Values map evenly onto the palette. |
heatmap.scale_log | string | Logarithmic: for values over several orders of magnitude. |
heatmap.scale_sqrt | string | Square root: weak cells stand out more. |