Skip to content
ChartDeck ChartScript docs Account Open the terminal

Quick reference

Dense tables of ChartScript on one page - the declarations, built-in variables, ChartDeck data series with units, input kinds, drawing types and outputs.

One page to keep open while you write. Every name links to its card in the reference manual, which has the full signature, every parameter and an example. The tables below the first one are built from the same registry as the editor's help, so they always match the language.

#The shape of a script

ChartScriptOpen in editor
//@chartscript 1
indicator("Shape of a script", { overlay: true })
// 1. settings
const len = input.int(20, "Length", { minval: 1 })
// 2. calculations (run once per bar)
const avg = ta.sma(close, len)
state crosses = 0
if (ta.cross(close, avg)) {
    crosses += 1
}
// 3. outputs
plot(avg, "Average", color.accent, 2)
plotshape(ta.crossover(close, avg), "Cross up", shape.triangleup, location.belowbar, color.up)
alert.on(ta.crossover(close, avg), "Cross up", "{{ticker}} crossed its average")
“Shape of a script” on a Binance BTCUSDT perpetual 1h chart“Shape of a script” on a Binance BTCUSDT perpetual 1h chart
Result Binance BTCUSDT perpetual · 1h · 2026-10-04 → 10-09 · real output of the ChartDeck engine · a dot under a bar marks an alert condition that is true there

#Declarations

Written asWhat it doesRead more
//@chartscript 1The first line of every script: the language versionExecution model
indicator(title, { overlay, format, precision, website, max_labels_count, max_lines_count, max_boxes_count, ... })Declares an indicator; overlay: true draws on the price pane; website links your site beside the script's nameindicator
library(title) with export function ...Declares a library other scripts importLibraries
import * as T from "@user/Name@1"Uses a libraryLibraries
const h = link.script("@user/Name@1", { inputs, at })Links another script's sharesLinking scripts
const x = ..., let x = ...A value computed on every bar (let may be reassigned)Variables
state x = 0A value kept from bar to barVariables
function f(a, b = 2) { ... return v }A function; each call keeps its own stateFunctions
type Zone { lo: float \n hi: float }A user type with fieldsUser types

#Built-in variables

NameTypeWhat it is
bar_indexintThe bar number: 0 = the first bar of the run.
barstate.isconfirmedbooltrue when the bar is closed (and on the final run of a closing bar).
barstate.isfirstbooltrue on the first bar.
barstate.ishistorybooltrue on closed bars of the history.
barstate.islastbooltrue on the last bar.
barstate.islastconfirmedhistorybooltrue on the last closed bar of the history.
barstate.isnewbooltrue on the first run of a live bar.
barstate.isrealtimebooltrue on the live bar.
chart.bg_colorcolorThe chart background colour (a theme colour).
chart.fg_colorcolorThe chart text colour (a theme colour).
chart.is_heikinashibooltrue when the chart shows Heikin-Ashi candles.
chart.is_standardbooltrue when the chart shows standard candles.
chart.left_visible_bar_timeintThe time of the leftmost visible bar (ms).
chart.right_visible_bar_timeintThe time of the rightmost visible bar (ms; the last bar when the chart shows the present).
chart.themestringThe chart theme: "dark", "light" or "hc" (the script re-runs when it changes).
closefloatThe close of the bar (the last price on the live bar).
dayofmonthintThe day of the month of the bar open (UTC).
dayofweekintThe day of the week of the bar open (dayofweek.sunday = 1, UTC).
highfloatThe high of the bar.
hl2float(high + low) / 2.
hlc3float(high + low + close) / 3.
hlcc4float(high + low + close + close) / 4.
hourintThe hour of the bar open (UTC).
last_bar_indexintThe bar_index of the last bar.
last_bar_timeintThe open time of the last bar of the chart (ms, UTC).
lowfloatThe low of the bar.
minuteintThe minute of the bar open (UTC).
monthintThe month of the bar open (1-12, UTC).
ohlc4float(open + high + low + close) / 4.
openfloatThe open of the bar.
secondintThe second of the bar open (UTC).
timeintThe open time of the bar (ms, UTC).
time_closeintThe close time of the bar (ms, UTC).
time_tradingdayintThe start of the trading day of the bar (crypto: 00:00 UTC of the bar's day).
timeframe.isdailybooltrue for day timeframes.
timeframe.isdwmbooltrue for day, week and month timeframes.
timeframe.isintradaybooltrue below one day.
timeframe.isminutesbooltrue for minute timeframes.
timeframe.ismonthlybooltrue for month timeframes.
timeframe.issecondsbooltrue for second timeframes.
timeframe.isticksbooltrue for tick charts (never on ChartDeck).
timeframe.isweeklybooltrue for week timeframes.
timeframe.main_periodstringThe chart timeframe, also inside a request.
timeframe.multiplierintThe number in the timeframe (60 for "60", 1 for "1D").
timeframe.periodstringThe chart timeframe ("60", "1D" ...).
timenowintThe current time (ms, UTC); differs between runs.
volumefloatThe volume of the bar (base units).
weekofyearintThe ISO week of the bar open (UTC).
yearintThe year of the bar open (UTC).

#ChartDeck data series

One value per bar, like close. Units, markets and plans are in ChartDeck data; a series reads na where its market or your plan has no data.

NameTypeWhat it is
basis.cb_premiumfloatCoinbase premium in percent: (Coinbase USD close ÷ Binance USDT spot close − 1) × 100 for the chart’s coin (BTC when Coinbase does not list it; OKX spot when Binance does not answer; the Coinbase premium study).
basis.pctfloatPerpetual over spot, in percent: (perp close ÷ spot close − 1) × 100, against the same exchange’s spot market or Binance spot (the Perp/spot basis study).
etf.net_flowfloatUS spot-ETF net flow for the chart’s coin, USD per US trading day (the ETF net flows study; BTC, ETH, SOL, HYPE, ZEC and a few more).
flow.agg_buyfloatTaker buys of the bar summed over every exchange ChartDeck merges for the coin, perpetuals and spot, in USD (the quote currency; the Aggregated delta / CVD study’s data).
flow.agg_cvdfloatAll-exchange cumulative delta, perpetuals and spot, in USD: flow.agg_delta summed from the first loaded bar with flow (the Aggregated delta / CVD study’s line).
flow.agg_deltafloatAll-exchange delta of the bar: flow.agg_buy minus flow.agg_sell, in USD (the Aggregated delta / CVD study’s bars).
flow.agg_perp_cvdfloatAll-exchange cumulative delta of the coin’s perpetuals only, in USD, from the first loaded bar with flow.
flow.agg_sellfloatTaker sells of the bar summed over every exchange, perpetuals and spot, in USD (see flow.agg_buy).
flow.agg_spot_cvdfloatAll-exchange cumulative delta of the coin’s spot markets only, in USD, from the first loaded bar with spot flow; na on bars where only perpetuals were recorded.
flow.big_buy_usdfloatThe value (USD) of the chart’s Big trades on taker buys in the bar: the piles the Big trades row draws (one bar, one side, prices within the pile band), at the chart’s Big trades size (Chart settings: a fixed size, else
flow.big_countfloatHow many Big trades bubbles (piles) the bar has, both sides.
flow.big_sell_usdfloatThe same for taker sells.
flow.buy_sharefloatThe taker-buy share of the bar’s volume, 0 to 1 (0.5 = balanced; the Volume study’s flow colouring).
flow.buy_volfloatTaker-buy volume of the bar, base coin (the same split as the Volume delta study).
flow.cvdfloatCumulative volume delta of the coin’s Binance perpetual, in USDT (the CVD study’s perp line): cumulative over the loaded bars, starting at the first bar with flow; na on a bar with no flow yet.
flow.deltafloatVolume delta of the bar: taker buy minus taker sell, base coin (the Volume delta study).
flow.sell_volfloatTaker-sell volume of the bar, base coin: volume minus flow.buy_vol.
flow.spot_cvdfloatCumulative volume delta of the coin’s Binance spot market, in USDT (the CVD study’s spot line); na where Binance lists no spot pair, and on tick / range charts.
fp.availablebooltrue when the bar has footprint rows (the Footprint chart’s data for the chart’s own market and timeframe).
fp.buy_volfloatBuy volume of the bar summed over its rows (trades that lifted the ask), base coin.
fp.deltafloatfp.buy_vol minus fp.sell_vol.
fp.high_deltafloatNet delta of the bar’s high zone: the top 25 % of its rows (2 at least).
fp.high_readintThe Extremes reading of the high zone: 1 = initiative (buying at the high), -1 = responsive (selling at the high), 0 = neither side clear.
fp.low_deltafloatNet delta of the bar’s low zone: the bottom 25 % of its rows (2 at least), the Footprint chart’s Extremes zone.
fp.low_readintThe Footprint chart’s Extremes reading of the low zone, with its default settings: 1 = initiative (selling at the low), -1 = responsive (buying at the low), 0 = neither side clear (the zone holds under 20 % of the bar’s
fp.max_buy_pxfloatThe middle price of the row with the most buy volume.
fp.max_buy_qtyfloatThe buy volume of that row, base coin.
fp.max_deltafloatThe delta of that row.
fp.max_delta_pxfloatThe middle price of the row with the most positive delta: where buyers lifted hardest.
fp.max_sell_pxfloatThe middle price of the row with the most sell volume.
fp.max_sell_qtyfloatThe sell volume of that row, base coin.
fp.min_deltafloatThe delta of that row (negative when sellers dominated it).
fp.min_delta_pxfloatThe middle price of the row with the most negative delta (buys minus sells): where sellers hit hardest.
fp.pocfloatThe middle price of the row with the most volume (the bar’s point of control; on a tie the lower row).
fp.row_sizefloatThe row height in price used for every fp.* value of the bar (the recorded grid: 50 rows per 1 % of price, BTC $20).
fp.sell_volfloatSell volume of the bar summed over its rows (trades that hit the bid), base coin.
fp.stack_buy_countintHow many buy stacked imbalances the bar holds, with the Footprint chart’s default rule: 3 or more rows in a row whose buys are at least 3 × the sells one row lower, the buys at least half the bar’s median row (fp.stacks
fp.stack_sell_countintHow many sell stacked imbalances the bar holds (sells at least 3 × the buys one row higher, 3 or more rows in a row; see fp.stack_buy_count).
funding.agg_meanfloatFunding across the venues listing the coin, simple mean, in percent per 8 hours (the Aggregated funding study’s line).
funding.agg_weightedfloatFunding across the venues listing the coin, weighted by open interest, in percent per 8 hours (the Aggregated funding study’s bars).
funding.interval_hoursfloatThe venue’s funding interval in hours (8 on most venues, 1 on Hyperliquid); na before the first answer.
funding.ratefloatThe funding rate in force at each bar, in percent per funding interval (the Funding rate study; see funding.interval_hours).
funding.settledbooltrue on a bar that holds a funding settlement (the Funding rate study draws those bars stronger).
hl.coveragefloatThe share of the bar’s Hyperliquid aggressor volume whose trader’s position was known, in percent (0 to 100): the part the hl.* values count.
hl.long_closefloatLong positions closed by the aggressors of the bar’s Hyperliquid trades, base coin (a sell while long, up to the size held).
hl.long_openfloatLong positions opened by the aggressors of the bar’s Hyperliquid trades, base coin (a buy while flat or long; the part of a flip beyond zero).
hl.net_long_deltafloatHyperliquid net longs delta of the bar, base coin: long positions opened minus long positions closed by the aggressor (taker) of each trade (hl.long_open − hl.long_close; the HL Net Longs Delta study summed over the bar’
hl.net_short_deltafloatHyperliquid net shorts delta of the bar, base coin: short positions opened minus short positions closed by the aggressor of each trade (hl.short_open − hl.short_close; the HL Net Shorts Delta study summed over the bar’s
hl.short_closefloatShort positions closed (covered) by the aggressors of the bar’s Hyperliquid trades, base coin (a buy while short, up to the size held).
hl.short_openfloatShort positions opened by the aggressors of the bar’s Hyperliquid trades, base coin (a sell while flat or short; the part of a flip beyond zero).
liq.long_liq_usdfloatLongs liquidated in the bar, USD, as the Liquidation candles mark them at the bar’s own timeframe: exact prints where ChartDeck records them (bars under 1 h, the last day), else hourly rows (on bars under 1 h on the bar
liq.long_usdfloatLong liquidations in USD, measured from the venues that publish them (the Liquidations study, as a positive number).
liq.short_liq_usdfloatShorts liquidated in the bar, USD (see liq.long_liq_usd).
liq.short_usdfloatShort liquidations in USD (the Liquidations study).
liq.total_usdfloatLong plus short liquidations in USD; na where neither has a value.
lsr.accountsfloatLong/short ratio of all accounts on the chart’s venue (1 = balanced; the Long/short ratio study, All accounts).
lsr.marginfloatBitfinex margin positions, long ÷ short, on the coin’s USD pair (the Long/short ratio study on a Bitfinex chart); na on other venues.
lsr.topfloatLong/short ratio of the top traders’ positions on the chart’s venue (the Long/short ratio study, Top traders).
oi.aggfloatOpen interest summed over every perpetual venue with OI history, in coins (the Aggregated open interest study).
oi.agg_usdfloatAggregated open interest in USD: oi.agg × close, per coin.
oi.closefloatOpen interest of the chart’s market, in coins: the last sample in force at each bar’s end (a step series, never interpolated; the Open interest study).
oi.deltafloatChange in open interest on the bars where a new sample landed, in coins (the OI delta study); na on bars between two samples.
oi.reffloatOpen interest of the coin’s Binance perpetual (USDT-margined), on any chart: a MEXC or BloFin chart reads Binance’s figure (the Open interest study run on Binance; the last sample in force at each bar’s end).
oi.ref_usdfloatoi.ref in USD: the Binance units × the chart’s close, per coin (a 1000PEPE unit counts 1,000 coins).
oi.usdfloatOpen interest of the chart’s market in USD: oi.close × close, per coin (a 1000PEPE or kPEPE market counts 1,000 coins per unit).

#ChartDeck record data

Lists for a bar (prints, footprint rows, liquidation events) or for now (liquidation levels, the order book).

NameReturnsWhat it is
flow.big_sinceintThe time (ms) from which the Big trades the script reads are held (bars before it read na), na without data.
flow.big_thresholdfloatThe Big trades size in use (USD): the chart’s fixed size, else the Auto size (the server’s hour of trades).
flow.big_tradesarray<flow.big_trade>The chart’s Big trades bubbles of a bar, by time: the piles the Big trades row draws (every pile, not only those a view draws), at the chart’s size and exchanges.
flow.print_thresholdfloatThe notional value (price x size) that the given share of the market's recent prints stay under: 99, 99.5 and 99.9 from the server's last hour, 95 and 98 (or when the server has too few) from the live trade tape's newest
flow.printsarray<flow.print>This bar's large trades from ChartDeck's trade tape: prints of at least min_notional (quote currency), oldest first.
flow.prints_sinceintThe time (ms) of the oldest print ChartDeck holds for this market (days back once the stored history has loaded), na when it holds none.
fp.delta_atfloatThe delta (buys minus sells) of the row holding price in a bar: 0 for a row inside the bar’s range where nothing traded, na outside its rows or where the bar has no footprint.
fp.imbalance_atintThe diagonal imbalance of the row holding price in a bar, with the rule of fp.stacks: 1 = buy imbalance, -1 = sell imbalance, 0 = none; na outside the bar’s rows or where the bar has no footprint.
fp.rowsarray<fp.row>The footprint rows of a bar on the recorded grid, low to high: an array of fp.row (at most 400; on a wider bar the 400 around its point of control).
fp.sinceintWhere the footprint history the script can read starts: the time (ms) of the first bar with footprint rows, na when there is none.
fp.stacksarray<fp.stack>The stacked imbalances of a bar, with the Footprint chart’s own rule, on the recorded grid (the same at every zoom, on the server and in alerts): rows whose buys are at least ratio × the sells one row LOWER (buy) or whos
liq.burstint1 when a minute of the bar is a liquidation BURST: the USD liquidated on that side in one minute, summed over Binance, Bybit, OKX and Gate (the exchanges ChartDeck records single liquidations of; Binance publishes at mos
liq.cascadeint1 when a minute of the bar ends a CASCADE: three rising one-minute sums of that side in a row, the last a burst (see liq.burst).
liq.climaxint1 when a minute of the bar ends a liquidation CLIMAX: the last five minutes liquidated (both sides) at least the coin’s 99.9th percentile of five-minute sums of the 30 days before that day.
liq.eventsarray<liq.event>The liquidations the Liquidation candles mark on a bar, by time: exact prints and hourly rows, on the bar the candles place them.
liq.events_sinceintThe time (ms) the liquidation data starts (7 days back, 30 on Elite), na without data.
liq.heatheatmap.columnThe liquidation model's heat over this bar (the built-in Liquidation Heatmap's data, hourly columns): a heatmap.column, or na where there is no data.
liq.is_modelbooltrue when the liquidation levels are a model estimate, false when they are observed positions of a pinned venue.
liq.levelsarray<liq.level>The liquidation model's levels now (the same data as the built-in Liquidation Levels study): an array of liq.level.
liq.updatedintWhen the liquidation data was last updated (ms), na without data.
liq.venuesstringThe venues the liquidation data covers, as text, for example "All venues (14)".
liq.windowstringThe liquidation model window: "7d" or "30d".

#Input kinds

NameReturnsWhat it is
input.boolboolAn on/off setting.
input.colorcolorA color setting: a swatch on the Inputs tab (in its section) or, without sections or tabs, on the Style tab, and always on the Colors tab, where the color presets use its role.
input.durationintA length of time ("4h", "30m", "2d", "1w" or "120b" for bars) given to the script as bars at the chart timeframe (at least 1).
input.enumTA select of the items of an enum (their titles are shown).
input.floatfloatA number setting.
input.fontstringA font setting (the fonts the terminal ships).
input.gradientstringA gradient setting (a stop editor).
input.intintA whole-number setting.
input.linestylestringA line style setting: solid, dashed, dotted, dash-dot, long dash or a custom dash.
input.listarray<string>Several choices at once (chips): an array of the chosen options, in the options' order.
input.ma_typestringA moving-average type setting (the 11 ChartDeck types; ChartDeck extra).
input.marketstringA market setting (VENUE:SYMBOL, the market search).
input.palettestringA palette setting: the member picks one of the palettes and may edit its colours.
input.positionstringA position setting (a 3 x 3 picker).
input.pricefloatA price setting.
input.rangetuple<float,float>A low / high pair (a two-thumb slider); low ≤ high always holds.
input.scriptTA setting where the member picks the script to link.
input.sessionstringA session setting ("HHMM-HHMM", UTC).
input.shapeshape_styleA shape setting (an icon grid).
input.sizesizeA text size setting: pixels, points or relative, with the named sizes as chips.
input.sourcefloatA price-source setting (close, open, high, low, volume, hl2, hlc3, ohlc4, hlcc4).
input.stringstringA text setting (a select with options).
input.text_areastringA multi-line text setting (up to 2,000 characters).
input.textstylestringA text style setting: size, font, weight, italic, colour, halo and background in one row.
input.timeintA time setting (ms, UTC).
input.timeframestringA timeframe setting.

#Drawing types

NameReturnsWhat it is
box.newboxA box between two bars and two prices.
drawing.positiondrawingA Long or Short position drawn with the drawing tools' own Long position / Short position look: the target zone, the stop zone, the entry line and the tags (target and stop with the move, % and ticks or P&L, the middle t
heatmap.newheatmapA 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.
label.newlabelA label at (x, y): a bar index (or a time with xloc.bar_time) and a price.
line.newlineA line from (x1, y1) to (x2, y2).
linefill.newlinefillFills the space between two lines (it goes when either line goes).
polyline.newpolylineA line through up to 10,000 chart.points (curved, closed and filled if asked).
table.newtableA table in a corner of the pane (position.*), one per position (9).
tag.newtagA level. tag.place_chart draws its line and writes its name on the chart beside the line’s start (as the chart’s Pivots); the axis looks put the name in a filled tag inside the pane against the price axis and the price i

#Plots, colors, alerts and the legend

NameReturnsWhat it is
alert.onA named alert condition that "Create alert" lists.
alert.sendSends an alert message from the script).
barcolorColours the chart candles on each bar (na: the chart's own colour).
bgcolorColours the pane background on each bar (na: no colour).
fillFills between two plots or two hlines; the gradient form colours each bar from top_color at top_value to bottom_color at bottom_value.
hlinehlineA horizontal level (the first 12 are editable study levels).
legend.badgeShows a small outlined badge at the end of the legend row, such as "Model estimate".
legend.infoShows text in the legend row after the script name (from the newest bar).
legend.keyShows a colour key in the legend row: a swatch and its text.
plotplotDraws a series. The result can be used by fill().
plotarrowDraws an up arrow for positive values and a down arrow for negative ones.
plotbarDraws OHLC bars.
plotcandleDraws candles.
plotcharDraws one character on bars where the series is true (or not na).
plotshapeDraws a shape on bars where the series is true (or not na).

#Sharing and linking

NameReturnsWhat it is
link.scriptTLinks another script and gives a handle to what it shares: h.<id> is a shared series (with history), h.levels.<id> the levels active on this bar (array<level>, sorted by price), h.events.<id> the events delivered on this
share.eventShares "this happened on this bar".
share.levelShares a price level (or a zone with top and bottom) that stays active until share.level_end.
share.level_endEnds an active shared level.
share.seriesShares one value per bar under an id.

Next

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