Skip to content
ChartDeck ChartScript docs Account Open the terminal

Pine to ChartScript names

A Pine to ChartScript lookup table: every renamed keyword, variable and function, what stays the same, and what is not available yet.

Use this page to look up a Pine construct or name and find its ChartScript counterpart. Each ChartScript name links to its entry in the reference manual. The importer does all of this for you; this page is for when you write or fix code by hand.

ChartScript's syntax looks like JavaScript (braces, const / let, &&, options objects), but the model underneath is Pine's: the script runs once per bar, values are series with history (x[1]), na is a value of every type, state (Pine's var) keeps a value between bars, and every ta.* call keeps its own state. A few JavaScript habits therefore do not carry over: conditions must be bool (write x != 0, not if (x)), && and || always give a bool, and there are no function values or classes. The first section below maps Pine's syntax; the sections after it map names.

Three kinds of rows appear in the name tables:

  • Renamed: same meaning, different name (syminfo.ticker → market.symbol).
  • Changed: a different form or behavior; the linked pages explain it (request.security → request.tf).
  • Same: the name and meaning are unchanged. Most of the built-in names are in this group.

Behavior that differs under the same name is on Known differences.

A short example that uses several of them at once:

ChartScriptOpen in editor
//@chartscript 1
indicator("Renames at work", { overlay: true })
const tf = input.timeframe("1D", "Higher timeframe")
live state updates: int = 0
updates += 1
const htfClose = request.tf(tf, close)
plot(htfClose, "Higher close", { color: color.orange })
plotchar(market.kind == "perp", "Perp", "P", location.top)
alert.on(ta.cross(close, htfClose), "Cross", "Close crossed the higher-timeframe close")

#Syntax

PineChartScriptNotes
//@version=6//@chartscript 1The first line of every script
indicator("X", overlay = true)indicator("X", { overlay: true })Named arguments go in an options object, always the last argument
plot(x, "MA", color = c, linewidth = 2)plot(x, "MA", { color: c, linewidth: 2 })Same argument names; positional arguments work as before; { color } is short for { color: color }
study(...) (version 4)indicator(...)Renamed
strategy(...)indicator(...)Strategies are not available yet; the importer converts one as an indicator
library("Tools")library("Tools")Same
x = close * 2const x = close * 2A plain declaration, fresh on every bar. Use let when you change it later. See Variables
float x = nalet x: float = naThe type goes after the name
x := 5, x += 1x = 5, x += 1, x++Reassignment is =; x++ / x-- only as a statement of their own
var count = 0state count = 0Set once, kept between bars. var itself is an error (CS1050)
varip ticks = 0live state ticks = 0Kept between the updates of the live bar
const float X = 1.0const X: float = 1.0A compile-time constant
simple int n = 5let n: simple int = 5Qualifiers go in the type annotation
[a, b] = f()const [a, b] = f()Tuples; _ skips a value
a and b, a or b, not aa && b, a || b, !aThey give a bool and skip their right side when the left side decides, as in version 6
a == b, a != ba == b, a != b (=== / !== mean the same)x == na is an error: write na(x)
nz(x, 0)nz(x, 0) or x ?? 0?? is short for nz
nana (or null)Same value
close[1]close[1]Same, but [1] must be on the same line as close
c ? a : b, iff(c, a, b) (version 4)c ? a : bSame
if c + indented block, else if, elseif (c) { … } else if (d) { … } else { … }Braces make the block; indentation is free. See Conditionals
x = if c …const x = if (c) { a } else { b }if and switch still work as values; the ternary is usually shorter
switch s with "a" => … and => …switch (s) { case "a": … default: … }Cases never fall through; no break needed
switch (no subject)switch (true) { case cond: … }The first true case runs
for i = 0 to n - 1for (let i = 0; i < n; i++) { … }The usual loop. See Loops
for i = a to b (direction decided when the loop starts)for (let i = a to b) { … }The range loop keeps Pine's exact meaning: inclusive, counts down when a > b, by for the step
for x in arr, for [i, x] in arrfor (const x of arr), for (const [i, x] of arr)Also for (const [k, v] of m) for a map
while cwhile (c) { … }break and continue as before
f(x) => x * 2const f = (x) => x * 2 or function f(x) { return x * 2 }Top level only; there are no function values. See Functions
f(float a, simple int n = 14) => + blockfunction f(a: float, n: simple int = 14) { … return v }return only as the last statement
method w(Zone this) => this.top - this.bottommethod Zone.w() { return this.top - this.bottom }The receiver type goes before the name; this inside. See User types, enums and methods
type Zone + indented fields float top = 0.0type Zone { top: float = 0.0; bottom: float }Fields separated by ;, , or line breaks
enum Side + long = "Long"enum Side { long = "Long", short = "Short" }
Zone.new(h, l)Zone.new(h, l) (or new Zone(h, l))
import user/Tools/3 as Timport * as T from "@user/Tools@3"Also import { mid, Zone } from "@user/Tools@3"; user is the ChartDeck handle. See Libraries
export f(x) =>export function f(x) { … }Also export method, export type, export enum, export const
"RSI " + str.tostring(v)`RSI ${v}`Template literals; they may span lines. See Strings and formatting
// comment// comment, /* comment */
a wrapped line (continuation by indentation)end the line with an operator, , or an open bracketA line break ends a statement unless the line ends with an operator, , or an open bracket, or the next line starts with ., &&, ||, ?, : and the like. ; is optional

#Keywords and built-ins

PineChartScriptNotes
na, nz, fixnanna, nz, fixnanSame; x == na is an error, write na(x)
int(), float(), bool(), string(), color()int(), float(), bool(), string(), color()Same
max_bars_back(x, n)max_bars_back(x, n)Same; up to 10,000
runtime.error, log.info, log.warning, log.errorruntime.error, log.info, log.warning, log.errorSame

#Market information (syminfo.*)

Every syminfo.* name becomes a market.* name. ChartDeck markets are written VENUE:SYMBOL, for example BINANCE:BTCUSDT.

PineChartScriptNotes
syminfo.tickeridmarket.idVENUE:SYMBOL
syminfo.tickermarket.symbolRenamed
syminfo.prefixmarket.venueRenamed
syminfo.basecurrencymarket.baseRenamed
syminfo.currencymarket.quoteRenamed
syminfo.mintickmarket.tickRenamed
syminfo.typemarket.kind"perp", "spot" or "other"; never "crypto"
syminfo.pointvaluemarket.pointvalueRenamed
syminfo.timezonemarket.timezoneUTC for crypto markets
syminfo.descriptionmarket.descriptionRenamed
syminfo.rootmarket.rootRenamed
syminfo.pricescalemarket.pricescaleRenamed
syminfo.minmovemarket.minmoveRenamed
syminfo.mincontractmarket.min_qtyRenamed
syminfo.main_tickeridmarket.main_idRenamed
syminfo.sessionsession.regularRenamed
tickerid, ticker (version 4)market.id, market.symbolRenamed
other syminfo.* fields (fundamentals, analyst data …)—Not available: the importer writes na
bid, ask—Not available yet: the importer writes na

#Chart information (chart.*)

PineChartScriptNotes
chart.bg_color, chart.fg_colorchart.bg_color, chart.fg_colorSame
chart.is_heikinashi, chart.is_standardchart.is_heikinashi, chart.is_standardSame
chart.is_renko, is_kagi, is_pnf, is_linebreak, is_rangechart.is_renko, chart.is_kagi, chart.is_pnf, chart.is_linebreak, chart.is_rangeSame names; always false
chart.point.new, from_index, from_time, now, copychart.point.new, chart.point.from_index, chart.point.from_time, chart.point.now, chart.point.copySame
chart.left_visible_bar_time, chart.right_visible_bar_time—Not available yet
—chart.themeChartScript extra: "dark", "light" or "hc"

#Bars, time and timeframes

All the names in this group are the same as in Pine. Times are in UTC unless you pass a time zone.

PineChartScriptNotes
open high low close volumeopen high low close volumeSame; volume is in base units
hl2 hlc3 ohlc4 hlcc4hl2 hlc3 ohlc4 hlcc4Same
bar_index, last_bar_index, last_bar_timebar_index, last_bar_index, last_bar_timeSame
time, time_close, timenow, time_tradingdaytime, time_close, timenow, time_tradingdaySame; UTC
year month weekofyear dayofmonth dayofweek hour minute secondyear month weekofyear dayofmonth dayofweek hour minute secondSame; UTC unless you pass a time zone
timestamp(...)timestamp(...)Same
dayofweek.monday …dayofweek.monday …Same
barstate.*barstate.isfirst barstate.islast barstate.isconfirmed barstate.isrealtime barstate.isnew barstate.ishistory barstate.islastconfirmedhistorySame
timeframe.period, timeframe.multipliertimeframe.period, timeframe.multiplierSame; a daily chart is "1D"
timeframe.isintraday isdaily isweekly ismonthly isdwm isminutes isseconds istickstimeframe.isintraday timeframe.isdaily timeframe.isweekly timeframe.ismonthly timeframe.isdwm timeframe.isminutes timeframe.isseconds timeframe.isticksSame
timeframe.change, in_seconds, from_seconds, main_periodtimeframe.change, timeframe.in_seconds, timeframe.from_seconds, timeframe.main_periodSame
period, interval, isintraday … (version 4)timeframe.period, timeframe.multiplier, timeframe.isintraday …Renamed
session.ismarket ispremarket ispostmarket isfirstbar islastbarsession.ismarket session.ispremarket session.ispostmarket session.isfirstbar session.islastbarSame; on 24/7 markets the session is the UTC day
session.isfirstbar_regular, session.islastbar_regularsession.isfirstbar_regular, session.islastbar_regularSame
session.regular, session.extendedsession.regular, session.extendedSame

#Other timeframes and markets (request.*, ticker.*)

See Other timeframes and markets for the at modes (passed as { at: … }).

PineChartScriptNotes
request.security(syminfo.tickerid, tf, expr)request.tf(tf, expr)Changed: the chart's own market
request.security("VENUE:SYMBOL", tf, expr)request.market("VENUE:SYMBOL", tf, expr)Changed: another market
lookahead = barmerge.lookahead_off (the default)at: request.developing or request.closeChanged: request.close is the default and never repaints
lookahead = barmerge.lookahead_on with expr[1]at: request.close with exprChanged: the usual no-repaint form
lookahead = barmerge.lookahead_on with a value known at the openat: request.startChanged: the compiler checks the value is known
gaps = barmerge.gaps_on / gaps_off{ gaps: true } / { gaps: false }Changed form
request.security_lower_tf(sym, tf, expr)request.lower_tf(tf, expr)Renamed; the chart's market
calc_bars_count = N on request.security / request.security_lower_tf (named or by position){ calc_bars_count: N }Changed: kept by the import, and it sets the context's depth (N bars of its timeframe, up to 20,000) instead of only limiting it; N must be a constant (CS2103). See How far back a request reaches
—request.liveChartScript extra: whether a requested context updates live
security(...) (version 4)request.tf / request.marketAs above
ticker.new, ticker.modify, ticker.inherit, ticker.standardticker.new, ticker.modify, ticker.inherit, ticker.standardSame
ticker.heikinashi (heikinashi in version 4)ticker.heikinashiSame
ticker.renko, ticker.kagi, ticker.linebreak, ticker.pointfigure—Not available yet
request.financial, request.economic, request.earnings, request.dividends, request.splits—Not available: the importer writes na
request.quandl, request.seed, request.currency_rate, request.footprint, currency =—Not available

#Alerts

PineChartScriptNotes
alertcondition(cond, title, message)alert.on(cond, title, message)Renamed; evaluated on closed bars by default
alert(message, freq)alert.send(message, freq)Renamed
alert.freq_once_per_baralert.freq_once_per_barSame (the default of alert.send)
alert.freq_once_per_bar_close, alert.freq_allalert.freq_once_per_bar_close, alert.freq_allSame
{{ticker}}, {{close}} … placeholderssameSame; see Alerts

#Inputs

PineChartScriptNotes
input(defval, title)input(defval, title)Same; the importer turns it into a typed input
input.intinput.intSame
input.floatinput.floatSame
input.boolinput.boolSame
input.stringinput.stringSame
input.text_areainput.text_areaSame
input.colorinput.colorSame
input.sourceinput.sourceSame
input.timeframeinput.timeframeSame
input.sessioninput.sessionSame
input.timeinput.timeSame
input.priceinput.priceSame
input.enuminput.enumSame
input.symbolinput.marketRenamed; VENUE:SYMBOL
input.resolution (version 4)input.timeframeRenamed
input(..., type = input.integer) (version 4)input.intRenamed (also float, bool, string, source, color …)
active = cond{ enabled_if: cond }Renamed argument; there is also visible_if
minval maxval step options tooltip inline group confirm displaysame namesSame arguments, in the options object: { minval: 1, group: "Lengths" }

ChartScript has inputs Pine does not: input.ma_type, input.size, input.font, input.linestyle, input.textstyle, input.shape, input.position, input.range, input.list, input.duration, input.gradient, input.palette. See Inputs.

#Plots and other outputs

The output functions keep their Pine names and argument names (named arguments go in the options object).

PineChartScriptNotes
plotplotSame; up to 128 plots per script
plotshapeplotshapeSame
plotcharplotcharSame
plotarrowplotarrowSame
plotcandleplotcandleSame
plotbarplotbarSame
hlinehlineSame
fillfillSame, including the gradient form
bgcolorbgcolorSame
barcolorbarcolorSame
transp = 50 (version 4)color.new(c, 50)Changed: transparency goes into the color
plot.style_*, plot.linestyle_*plot.style_line …, plot.linestyle_dashed …Same
hline.style_*hline.style_dashed …Same
shape.*, location.*, size.*shape.triangleup, location.abovebar, size.small …Same
display.*display.all, display.pane, display.price_scale …Same, including + / - between them
style = histogram (versions 1-3)plot.style_histogramRenamed

#Colors

PineChartScriptNotes
color.new, color.rgb, color.from_gradientcolor.new, color.rgb, color.from_gradientSame
color.r, color.g, color.b, color.tcolor.r, color.g, color.b, color.tSame
the 17 named colorscolor.aqua color.black color.blue color.fuchsia color.gray color.green color.lime color.maroon color.navy color.olive color.orange color.purple color.red color.silver color.teal color.white color.yellowSame names, version 6 shades (red, teal and yellow differ from version 5)
red, green … (versions 1-3)color.red, color.green …Renamed
—color.up color.down color.accent color.muted color.text color.grid, color.themeChartScript extras that follow the chart theme

#Drawings

Drawing types and functions keep their Pine names. Defaults follow version 6 (a blue label with white text).

PineChartScriptNotes
label.new, label.set_*, label.get_*, label.delete, label.alllabel.new, label.set_text …, label.get_text …, label.delete, label.allSame; up to 1,000 labels
label.style_*label.style_label_down …Same, all styles
—label.get_tooltipChartScript extra
line.new, line.set_*, line.get_*, line.deleteline.new, line.set_xy1 …, line.get_price …, line.deleteSame; up to 1,000 lines
box.new, box.set_*, box.get_*, box.deletebox.new, box.set_right …, box.get_top …, box.deleteSame; up to 1,000 boxes
table.new, table.cell, table.cell_set_*, table.merge_cellstable.new, table.cell, table.cell_set_text …, table.merge_cellsSame; up to 50 tables
linefill.new, linefill.set_color, linefill.deletelinefill.new, linefill.set_color, linefill.deleteSame
polyline.new, polyline.deletepolyline.new, polyline.deleteSame; up to 500 polylines
extend.*, xloc.*, yloc.*, text.*, font.*, position.*extend.both, xloc.bar_index, yloc.price, text.align_left, font.family_monospace, position.top_right …Same

#Technical analysis (ta.*)

Every ta.* function and variable keeps its Pine name. Version 4 scripts wrote them without the namespace; add ta. in front.

PineChartScriptNotes
every ta.* functionalma atr barssince bb bbw cci change cmo cog correlation cross crossover crossunder cum dev dmi ema falling highest highestbars hma kc kcw linreg lowest lowestbars macd median mfi mode mom percentile_linear_interpolation percentile_nearest_rank percentrank pivothigh pivotlow range rising rma roc rsi sar sma stdev stoch supertrend swma tsi valuewhen variance vwma wma wprSame names. In version 4: ema(…) → ta.ema(…)
ta.tr, ta.vwap, ta.obv … (variables)tr vwap obv accdist iii nvi pvi pvt wad wvadSame. In version 4: tr → ta.tr
ta.cog, ta.rci, ta.min, ta.max, ta.pivot_point_levelsta.cog, ta.rci, ta.min, ta.max, ta.pivot_point_levelsSame
ta.ema, ta.rmata.ema, ta.rmaSame names; they start from the average of the first values ({ seed: "first" } on ta.ema for a first-value start)
—ta.ma ta.kama ta.zlema ta.dema ta.tema ta.squeeze ta.wavetrend ta.heikin_ashiChartScript extras

#Maths, strings and collections

These namespaces are the same as in Pine, name for name.

PineChartScriptNotes
every math.* functionabs acos asin atan avg ceil cos exp floor log log10 max min pow random round round_to_mintick sign sin sqrt sum tan todegrees toradiansSame. In version 4: abs(…) → math.abs(…)
math.pi, math.e, math.phi, math.rphimath.pi, math.e, math.phi, math.rphiSame
math.random()math.randomSame name; the default seed is fixed per script
tostring, tonumber (version 4)str.tostring, str.tonumberRenamed
every str.* functiontostring tonumber format format_time length contains startswith endswith substring replace replace_all split pos match upper lower trim repeatSame
—str.tplChartScript extra
array.*new<T> new_float from push pop get set size insert remove shift unshift clear sort sort_indices avg sum max min includes indexof slice copy join …Same, all of them, also as methods (a.push(x))
map.*new<K,V> put get contains remove size keys values copy put_all clearSame
matrix.*new<T> get set rows columns row col add_row add_col transpose mult inv det …Same, all 49
order.ascending, order.descendingorder.ascending, order.descendingSame

#Strategies

PineChartScriptNotes
strategy(...)indicator(...) for nowStrategies are not available yet
strategy.entry, strategy.exit, strategy.close, strategy.order, strategy.cancel—Not available yet; the importer keeps these lines as comments
strategy.position_size, strategy.equity, strategy.opentrades …—Not available yet

To keep a strategy's signals visible, see A strategy you want to keep watching.

#ChartScript extras with no Pine name

These are additions; they do not replace anything in Pine.

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