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:
//@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
| Pine | ChartScript | Notes |
|---|---|---|
//@version=6 | //@chartscript 1 | The 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 * 2 | const x = close * 2 | A plain declaration, fresh on every bar. Use let when you change it later. See Variables |
float x = na | let x: float = na | The type goes after the name |
x := 5, x += 1 | x = 5, x += 1, x++ | Reassignment is =; x++ / x-- only as a statement of their own |
var count = 0 | state count = 0 | Set once, kept between bars. var itself is an error (CS1050) |
varip ticks = 0 | live state ticks = 0 | Kept between the updates of the live bar |
const float X = 1.0 | const X: float = 1.0 | A compile-time constant |
simple int n = 5 | let n: simple int = 5 | Qualifiers go in the type annotation |
[a, b] = f() | const [a, b] = f() | Tuples; _ skips a value |
a and b, a or b, not a | a && b, a || b, !a | They give a bool and skip their right side when the left side decides, as in version 6 |
a == b, a != b | a == 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 |
na | na (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 : b | Same |
if c + indented block, else if, else | if (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 - 1 | for (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 arr | for (const x of arr), for (const [i, x] of arr) | Also for (const [k, v] of m) for a map |
while c | while (c) { … } | break and continue as before |
f(x) => x * 2 | const 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) => + block | function f(a: float, n: simple int = 14) { … return v } | return only as the last statement |
method w(Zone this) => this.top - this.bottom | method 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.0 | type 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 T | import * 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 bracket | A 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
| Pine | ChartScript | Notes |
|---|---|---|
na, nz, fixnan | na, nz, fixnan | Same; 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.error | runtime.error, log.info, log.warning, log.error | Same |
#Market information (syminfo.*)
Every syminfo.* name becomes a market.* name. ChartDeck markets are written VENUE:SYMBOL, for example BINANCE:BTCUSDT.
| Pine | ChartScript | Notes |
|---|---|---|
syminfo.tickerid | market.id | VENUE:SYMBOL |
syminfo.ticker | market.symbol | Renamed |
syminfo.prefix | market.venue | Renamed |
syminfo.basecurrency | market.base | Renamed |
syminfo.currency | market.quote | Renamed |
syminfo.mintick | market.tick | Renamed |
syminfo.type | market.kind | "perp", "spot" or "other"; never "crypto" |
syminfo.pointvalue | market.pointvalue | Renamed |
syminfo.timezone | market.timezone | UTC for crypto markets |
syminfo.description | market.description | Renamed |
syminfo.root | market.root | Renamed |
syminfo.pricescale | market.pricescale | Renamed |
syminfo.minmove | market.minmove | Renamed |
syminfo.mincontract | market.min_qty | Renamed |
syminfo.main_tickerid | market.main_id | Renamed |
syminfo.session | session.regular | Renamed |
tickerid, ticker (version 4) | market.id, market.symbol | Renamed |
other syminfo.* fields (fundamentals, analyst data …) | — | Not available: the importer writes na |
bid, ask | — | Not available yet: the importer writes na |
#Chart information (chart.*)
| Pine | ChartScript | Notes |
|---|---|---|
chart.bg_color, chart.fg_color | chart.bg_color, chart.fg_color | Same |
chart.is_heikinashi, chart.is_standard | chart.is_heikinashi, chart.is_standard | Same |
chart.is_renko, is_kagi, is_pnf, is_linebreak, is_range | chart.is_renko, chart.is_kagi, chart.is_pnf, chart.is_linebreak, chart.is_range | Same names; always false |
chart.point.new, from_index, from_time, now, copy | chart.point.new, chart.point.from_index, chart.point.from_time, chart.point.now, chart.point.copy | Same |
chart.left_visible_bar_time, chart.right_visible_bar_time | — | Not available yet |
| — | chart.theme | ChartScript 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.
| Pine | ChartScript | Notes |
|---|---|---|
open high low close volume | open high low close volume | Same; volume is in base units |
hl2 hlc3 ohlc4 hlcc4 | hl2 hlc3 ohlc4 hlcc4 | Same |
bar_index, last_bar_index, last_bar_time | bar_index, last_bar_index, last_bar_time | Same |
time, time_close, timenow, time_tradingday | time, time_close, timenow, time_tradingday | Same; UTC |
year month weekofyear dayofmonth dayofweek hour minute second | year month weekofyear dayofmonth dayofweek hour minute second | Same; 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.islastconfirmedhistory | Same |
timeframe.period, timeframe.multiplier | timeframe.period, timeframe.multiplier | Same; a daily chart is "1D" |
timeframe.isintraday isdaily isweekly ismonthly isdwm isminutes isseconds isticks | timeframe.isintraday timeframe.isdaily timeframe.isweekly timeframe.ismonthly timeframe.isdwm timeframe.isminutes timeframe.isseconds timeframe.isticks | Same |
timeframe.change, in_seconds, from_seconds, main_period | timeframe.change, timeframe.in_seconds, timeframe.from_seconds, timeframe.main_period | Same |
period, interval, isintraday … (version 4) | timeframe.period, timeframe.multiplier, timeframe.isintraday … | Renamed |
session.ismarket ispremarket ispostmarket isfirstbar islastbar | session.ismarket session.ispremarket session.ispostmarket session.isfirstbar session.islastbar | Same; on 24/7 markets the session is the UTC day |
session.isfirstbar_regular, session.islastbar_regular | session.isfirstbar_regular, session.islastbar_regular | Same |
session.regular, session.extended | session.regular, session.extended | Same |
#Other timeframes and markets (request.*, ticker.*)
See Other timeframes and markets for the at modes (passed as { at: … }).
| Pine | ChartScript | Notes |
|---|---|---|
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.close | Changed: request.close is the default and never repaints |
lookahead = barmerge.lookahead_on with expr[1] | at: request.close with expr | Changed: the usual no-repaint form |
lookahead = barmerge.lookahead_on with a value known at the open | at: request.start | Changed: 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.live | ChartScript extra: whether a requested context updates live |
security(...) (version 4) | request.tf / request.market | As above |
ticker.new, ticker.modify, ticker.inherit, ticker.standard | ticker.new, ticker.modify, ticker.inherit, ticker.standard | Same |
ticker.heikinashi (heikinashi in version 4) | ticker.heikinashi | Same |
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
| Pine | ChartScript | Notes |
|---|---|---|
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_bar | alert.freq_once_per_bar | Same (the default of alert.send) |
alert.freq_once_per_bar_close, alert.freq_all | alert.freq_once_per_bar_close, alert.freq_all | Same |
{{ticker}}, {{close}} … placeholders | same | Same; see Alerts |
#Inputs
| Pine | ChartScript | Notes |
|---|---|---|
input(defval, title) | input(defval, title) | Same; the importer turns it into a typed input |
input.int | input.int | Same |
input.float | input.float | Same |
input.bool | input.bool | Same |
input.string | input.string | Same |
input.text_area | input.text_area | Same |
input.color | input.color | Same |
input.source | input.source | Same |
input.timeframe | input.timeframe | Same |
input.session | input.session | Same |
input.time | input.time | Same |
input.price | input.price | Same |
input.enum | input.enum | Same |
input.symbol | input.market | Renamed; VENUE:SYMBOL |
input.resolution (version 4) | input.timeframe | Renamed |
input(..., type = input.integer) (version 4) | input.int | Renamed (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 display | same names | Same 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).
| Pine | ChartScript | Notes |
|---|---|---|
plot | plot | Same; up to 128 plots per script |
plotshape | plotshape | Same |
plotchar | plotchar | Same |
plotarrow | plotarrow | Same |
plotcandle | plotcandle | Same |
plotbar | plotbar | Same |
hline | hline | Same |
fill | fill | Same, including the gradient form |
bgcolor | bgcolor | Same |
barcolor | barcolor | Same |
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_histogram | Renamed |
#Colors
| Pine | ChartScript | Notes |
|---|---|---|
color.new, color.rgb, color.from_gradient | color.new, color.rgb, color.from_gradient | Same |
color.r, color.g, color.b, color.t | color.r, color.g, color.b, color.t | Same |
| the 17 named colors | color.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.yellow | Same 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.theme | ChartScript 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).
| Pine | ChartScript | Notes |
|---|---|---|
label.new, label.set_*, label.get_*, label.delete, label.all | label.new, label.set_text …, label.get_text …, label.delete, label.all | Same; up to 1,000 labels |
label.style_* | label.style_label_down … | Same, all styles |
| — | label.get_tooltip | ChartScript extra |
line.new, line.set_*, line.get_*, line.delete | line.new, line.set_xy1 …, line.get_price …, line.delete | Same; up to 1,000 lines |
box.new, box.set_*, box.get_*, box.delete | box.new, box.set_right …, box.get_top …, box.delete | Same; up to 1,000 boxes |
table.new, table.cell, table.cell_set_*, table.merge_cells | table.new, table.cell, table.cell_set_text …, table.merge_cells | Same; up to 50 tables |
linefill.new, linefill.set_color, linefill.delete | linefill.new, linefill.set_color, linefill.delete | Same |
polyline.new, polyline.delete | polyline.new, polyline.delete | Same; 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.
| Pine | ChartScript | Notes |
|---|---|---|
every ta.* function | alma 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 wpr | Same names. In version 4: ema(…) → ta.ema(…) |
ta.tr, ta.vwap, ta.obv … (variables) | tr vwap obv accdist iii nvi pvi pvt wad wvad | Same. In version 4: tr → ta.tr |
ta.cog, ta.rci, ta.min, ta.max, ta.pivot_point_levels | ta.cog, ta.rci, ta.min, ta.max, ta.pivot_point_levels | Same |
ta.ema, ta.rma | ta.ema, ta.rma | Same 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_ashi | ChartScript extras |
#Maths, strings and collections
These namespaces are the same as in Pine, name for name.
#Strategies
| Pine | ChartScript | Notes |
|---|---|---|
strategy(...) | indicator(...) for now | Strategies 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.
| Area | Names |
|---|---|
| Settings layout | settings.tab, settings.section, settings.row, settings.note, settings.validate, settings.preset |
| Named styles | style.plot, style.line, style.label, style.variant |
| Line dashes and text | dash.custom, dash.dashdot, textstyle.new, font.mono |
| Gradients and palettes | gradient.new, gradient.at, palette.new, palette.get |
| Translations | i18n.add |