Global names
Built-in variables and functions that are not inside a namespace: the bar's prices, the script declaration, plots and the core helpers.
#Functions
#barcolorfunction
Colours the chart candles on each bar (na: the chart's own colour). When several scripts colour the same candle, the last one added wins.
barcolor(color: color, { offset?: input int = 0, editable?: const bool = true, show_last?: const int = na, title?: const string = "", display?: input display = display.all })| Parameter | Type | Description |
|---|---|---|
color | color | The colour. |
offset | input intdefault 0 | Shift the output this many bars to the right (negative: left). |
editable | const booldefault true | Accepted and ignored (styles are always editable). |
show_last | const intdefault na | Accepted and ignored in this version. |
title | const stringdefault "" | The name shown in the settings, legend and data window. |
display | input displaydefault display.all | Where the value is shown (display.*). |
Example
barcolor(close > ta.sma(close, 20) ? color.up : na)Since ChartScript 1
#bgcolorfunction
Colours the pane background on each bar (na: no colour).
bgcolor(color: color, { offset?: input int = 0, editable?: const bool = true, show_last?: const int = na, title?: const string = "", display?: input display = display.all, force_overlay?: const bool = false, format?: const format = na, precision?: const int = na })| Parameter | Type | Description |
|---|---|---|
color | color | The colour. |
offset | input intdefault 0 | Shift the output this many bars to the right (negative: left). |
editable | const booldefault true | Accepted and ignored (styles are always editable). |
show_last | const intdefault na | Accepted and ignored in this version. |
title | const stringdefault "" | The name shown in the settings, legend and data window. |
display | input displaydefault display.all | Where the value is shown (display.*). |
force_overlay | const booldefault false | Accepted and ignored in this version. |
format | const formatdefault na | Accepted for compatibility with imported scripts (a background has no values to format). |
precision | const intdefault na | Accepted for compatibility with imported scripts (a background has no values to format). |
Example
bgcolor(close > open ? color.new(color.up, 90) : na)Since ChartScript 1
#boolfunction
Converts to bool: na and 0 are false.
bool(x: T): bool| Parameter | Type | Description |
|---|---|---|
x | T | The value. |
Returns bool.
Example
const b = bool(volume)Since ChartScript 1
#dayofmonthfunction
The day of the month of the bar open (UTC). The dayofmonth of a time in a time zone.
dayofmonth(time: int, { timezone?: string = "UTC" }): int| Parameter | Type | Description |
|---|---|---|
time | int | A time in milliseconds since 1970 (UTC). |
timezone | stringdefault "UTC" | An IANA time zone such as "UTC" or "America/New_York". |
Returns int.
Example
const v = dayofmonth(time, "UTC")Since ChartScript 1
#fillfunction
Fills between two plots or two hlines; the gradient form colours each bar from top_color at top_value to bottom_color at bottom_value.
fill(hline1: hline, hline2: hline, { color?: color = na, title?: const string = "", editable?: const bool = true, fillgaps?: const bool = false, display?: input display = display.all, role?: const string = "", look?: const string = "", variant?: const string = "" })fill(plot1: plot, plot2: plot, { color?: color = na, title?: const string = "", editable?: const bool = true, show_last?: const int = na, fillgaps?: const bool = false, display?: input display = display.all, role?: const string = "", look?: const string = "", variant?: const string = "" })fill(plot1: plot, plot2: plot, top_value: float, bottom_value: float, top_color: color, bottom_color: color, { title?: const string = "", display?: input display = display.all, fillgaps?: const bool = false, editable?: const bool = true, role?: const string = "", look?: const string = "", variant?: const string = "" })| Parameter | Type | Description |
|---|---|---|
hline1 | hline | The first hline. |
hline2 | hline | The second hline. |
color | colordefault na | The colour. |
title | const stringdefault "" | The name shown in the settings, legend and data window. |
editable | const booldefault true | Accepted and ignored (styles are always editable). |
fillgaps | const booldefault false | Accepted and ignored. |
display | input displaydefault display.all | Where the value is shown (display.*). |
role | const stringdefault "" | What the color of this output means, for the color presets of the Colors tab: "up", "down", "neutral" or "accent". Empty = guessed from the role of its style (look), the theme color, the title and the hue (a teal line counts as up). Another value is error CS2014. |
look | const stringdefault "" | A style made with style.plot / style.line / style.marker / style.fill (its look, shared and user-editable). |
variant | const stringdefault "" | The name of one of the style's variants (style.variant). |
plot1 | plot | The first plot. |
plot2 | plot | The second plot. |
show_last | const intdefault na | Accepted and ignored in this version. |
top_value | float | The value of the top colour. |
bottom_value | float | The value of the bottom colour. |
top_color | color | The colour at top_value. |
bottom_color | color | The colour at bottom_value. |
Example
const a = plot(high)
const b = plot(low)
fill(a, b, color.new(color.accent, 80))Since ChartScript 1
#fixnanfunction
The value, or the last value that was not na.
fixnan(source: T): T| Parameter | Type | Description |
|---|---|---|
source | T | The series to read. |
Returns T.
Example
const pv = fixnan(ta.pivothigh(high, 5, 5))Since ChartScript 1
#floatfunction
Converts to float; also types an na.
float(x: num): float| Parameter | Type | Description |
|---|---|---|
x | num | The value. |
Returns float.
Example
const f = float(na)Since ChartScript 1
#hourfunction
The hour of the bar open (UTC). The hour of a time in a time zone.
hour(time: int, { timezone?: string = "UTC" }): int| Parameter | Type | Description |
|---|---|---|
time | int | A time in milliseconds since 1970 (UTC). |
timezone | stringdefault "UTC" | An IANA time zone such as "UTC" or "America/New_York". |
Returns int.
Example
const v = hour(time, "UTC")Since ChartScript 1
#indicatorfunction
Declares the script as an indicator: its name, pane and number format.
indicator(title: const string, { shorttitle?: const string = "", overlay?: const bool = false, format?: const format = format.inherit, precision?: const int = na, scale?: const scale = na, max_bars_back?: const int = 500, timeframe?: const string = "", timeframe_gaps?: const bool = true, explicit_plot_zorder?: const bool = false, max_lines_count?: const int = 50, max_labels_count?: const int = 50, max_boxes_count?: const int = 50, max_polylines_count?: const int = 50, dynamic_requests?: const bool = true, behind_chart?: const bool = false, calc_bars_count?: const int = na })| Parameter | Type | Description |
|---|---|---|
title | const string | The name shown in the settings, legend and data window. |
shorttitle | const stringdefault "" | The short name used in the legend. |
overlay | const booldefault false | true: draw on the price pane; false: in its own pane. |
format | const formatdefault format.inherit | The number format (format.*). |
precision | const intdefault na | Decimals shown. |
scale | const scaledefault na | The price scale (scale.*). |
max_bars_back | const intdefault 500 | History kept for dynamic offsets (1-10,000). |
timeframe | const stringdefault "" | A timeframe such as "60", "240", "1D" or "1W"; "" is the chart's. |
timeframe_gaps | const booldefault true | Accepted and ignored. |
explicit_plot_zorder | const booldefault false | true = plots, horizontal levels and fills are layered in the order they appear in the script (default: by kind, as in imported scripts). |
max_lines_count | const intdefault 50 | How many lines are kept (1-1,000; the oldest goes first). |
max_labels_count | const intdefault 50 | How many labels are kept (1-1,000; the oldest goes first). |
max_boxes_count | const intdefault 50 | How many boxes are kept (1-1,000; the oldest goes first). |
max_polylines_count | const intdefault 50 | How many polylines are kept (1-500; the oldest goes first). |
dynamic_requests | const booldefault true | Allow markets and timeframes that change at run time in requests (on by default; false = simple strings only). |
behind_chart | const booldefault false | true = an overlay script draws behind the price candles; false (the ChartDeck default) = in front of them. |
calc_bars_count | const intdefault na | The number of bars the script runs on: the newest N bars of the chart's market and timeframe, fetched for the script (5,000 when left out). Your plan's bars per run is the most (Beginner 5,000, Plus 7,500, Pro 10,000, Elite 20,000; a phone 2,000). Chart bars older than the run show no script values; scrolling back never extends the run. |
Example
//@chartscript 1
indicator("My script", { overlay: true })Since ChartScript 1
#intfunction
Converts to int (truncates toward zero); also types an na.
int(x: num): int| Parameter | Type | Description |
|---|---|---|
x | num | The value. |
Returns int.
Example
const n = int(close)Since ChartScript 1
#libraryfunction
Declares the script as a library: its exported functions, methods, types, enums and constants can be imported by other scripts.
library(title: const string, { overlay?: const bool = false, dynamic_requests?: const bool = true })| Parameter | Type | Description |
|---|---|---|
title | const string | The name shown in the settings, legend and data window. |
overlay | const booldefault false | true: draw on the price pane; false: in its own pane. |
dynamic_requests | const booldefault true | Allow markets and timeframes that change at run time in requests (on by default; false = simple strings only). |
Example
//@chartscript 1
library("Tools")
export const double = (x: float) => x * 2Since ChartScript 1
#max_bars_backfunction
Sets the history kept for one variable (compile time only).
max_bars_back(var: T, num: const int)| Parameter | Type | Description |
|---|---|---|
var | T | The variable. |
num | const int | The number of bars of history. |
Example
const x = close - open
max_bars_back(x, 1000)Since ChartScript 1
#minutefunction
The minute of the bar open (UTC). The minute of a time in a time zone.
minute(time: int, { timezone?: string = "UTC" }): int| Parameter | Type | Description |
|---|---|---|
time | int | A time in milliseconds since 1970 (UTC). |
timezone | stringdefault "UTC" | An IANA time zone such as "UTC" or "America/New_York". |
Returns int.
Example
const v = minute(time, "UTC")Since ChartScript 1
#monthfunction
The month of the bar open (1-12, UTC). The month of a time in a time zone.
month(time: int, { timezone?: string = "UTC" }): int| Parameter | Type | Description |
|---|---|---|
time | int | A time in milliseconds since 1970 (UTC). |
timezone | stringdefault "UTC" | An IANA time zone such as "UTC" or "America/New_York". |
Returns int.
Example
const v = month(time, "UTC")Since ChartScript 1
#nafunction
true when the value is na (missing).
na(x: T): bool| Parameter | Type | Description |
|---|---|---|
x | T | The value. |
Returns bool.
Example
const missing = na(close[1])Since ChartScript 1
#nzfunction
The value, or the replacement (0 by default) when it is na.
nz(source: num, { replacement?: num = 0 }): numnz(source: T, replacement: T): T| Parameter | Type | Description |
|---|---|---|
source | num | The series to read. |
replacement | numdefault 0 | The replacement. |
Returns num.
Example
const chg = nz(close - close[1])Since ChartScript 1
#plotarrowfunction
Draws an up arrow for positive values and a down arrow for negative ones.
plotarrow(series: float, { title?: const string = "", colorup?: input color = color.up, colordown?: input color = color.down, offset?: input int = 0, minheight?: const int = 5, maxheight?: const int = 100, editable?: const bool = true, show_last?: const int = na, display?: input display = display.all, format?: const format = na, precision?: const int = na, force_overlay?: const bool = false })| Parameter | Type | Description |
|---|---|---|
series | float | The value to draw on each bar. |
title | const stringdefault "" | The name shown in the settings, legend and data window. |
colorup | input colordefault color.up | The colour of up arrows. |
colordown | input colordefault color.down | The colour of down arrows. |
offset | input intdefault 0 | Shift the output this many bars to the right (negative: left). |
minheight | const intdefault 5 | The smallest arrow height in pixels. |
maxheight | const intdefault 100 | The largest arrow height in pixels. |
editable | const booldefault true | Accepted and ignored (styles are always editable). |
show_last | const intdefault na | Accepted and ignored in this version. |
display | input displaydefault display.all | Where the value is shown (display.*). |
format | const formatdefault na | The number format (format.*). |
precision | const intdefault na | Decimals shown. |
force_overlay | const booldefault false | Accepted and ignored in this version. |
Example
plotarrow(close - open, "Body")Since ChartScript 1
#plotbarfunction
Draws OHLC bars.
plotbar(open: float, high: float, low: float, close: float, { title?: const string = "", color?: color = na, editable?: const bool = true, show_last?: const int = na, display?: input display = display.all, format?: const format = na, precision?: const int = na, force_overlay?: const bool = false })| Parameter | Type | Description |
|---|---|---|
open | float | The open value. |
high | float | The high value. |
low | float | The low value. |
close | float | The close value. |
title | const stringdefault "" | The name shown in the settings, legend and data window. |
color | colordefault na | The colour. |
editable | const booldefault true | Accepted and ignored (styles are always editable). |
show_last | const intdefault na | Accepted and ignored in this version. |
display | input displaydefault display.all | Where the value is shown (display.*). |
format | const formatdefault na | The number format (format.*). |
precision | const intdefault na | Decimals shown. |
force_overlay | const booldefault false | Accepted and ignored in this version. |
Example
plotbar(open, high, low, close, "Bars")Since ChartScript 1
#plotcandlefunction
Draws candles.
plotcandle(open: float, high: float, low: float, close: float, { title?: const string = "", color?: color = na, wickcolor?: color = na, editable?: const bool = true, show_last?: const int = na, bordercolor?: color = na, display?: input display = display.all, format?: const format = na, precision?: const int = na, force_overlay?: const bool = false })| Parameter | Type | Description |
|---|---|---|
open | float | The open value. |
high | float | The high value. |
low | float | The low value. |
close | float | The close value. |
title | const stringdefault "" | The name shown in the settings, legend and data window. |
color | colordefault na | The colour. |
wickcolor | colordefault na | The wick colour. |
editable | const booldefault true | Accepted and ignored (styles are always editable). |
show_last | const intdefault na | Accepted and ignored in this version. |
bordercolor | colordefault na | The border colour. |
display | input displaydefault display.all | Where the value is shown (display.*). |
format | const formatdefault na | The number format (format.*). |
precision | const intdefault na | Decimals shown. |
force_overlay | const booldefault false | Accepted and ignored in this version. |
Example
plotcandle(open, high, low, close, "Candles", close > open ? color.up : color.down)Since ChartScript 1
#plotcharfunction
Draws one character on bars where the series is true (or not na).
plotchar(series: bool, { title?: const string = "", char?: input string = "★", location?: input location = location.abovebar, color?: color = na, offset?: input int = 0, text?: input string = "", textcolor?: color = na, editable?: const bool = true, size?: input size = size.auto, show_last?: const int = na, display?: input display = display.all, format?: const format = na, precision?: const int = na, force_overlay?: const bool = false, role?: const string = "", look?: const string = "", variant?: const string = "", textstyle?: input string = "", text_formatting?: input int = text.format_none })plotchar(series: float, { title?: const string = "", char?: input string = "★", location?: input location = location.abovebar, color?: color = na, offset?: input int = 0, text?: input string = "", textcolor?: color = na, editable?: const bool = true, size?: input size = size.auto, show_last?: const int = na, display?: input display = display.all, format?: const format = na, precision?: const int = na, force_overlay?: const bool = false, role?: const string = "", look?: const string = "", variant?: const string = "", textstyle?: input string = "", text_formatting?: input int = text.format_none })| Parameter | Type | Description |
|---|---|---|
series | bool | The value to draw on each bar. |
title | const stringdefault "" | The name shown in the settings, legend and data window. |
char | input stringdefault "★" | One character to draw. |
location | input locationdefault location.abovebar | Where the shape sits (location.*). |
color | colordefault na | The colour. |
offset | input intdefault 0 | Shift the output this many bars to the right (negative: left). |
text | input stringdefault "" | Text drawn with the shape. |
textcolor | colordefault na | The colour of the text. |
editable | const booldefault true | Accepted and ignored (styles are always editable). |
size | input sizedefault size.auto | The number of elements. |
show_last | const intdefault na | Accepted and ignored in this version. |
display | input displaydefault display.all | Where the value is shown (display.*). |
format | const formatdefault na | The number format (format.*). |
precision | const intdefault na | Decimals shown. |
force_overlay | const booldefault false | Accepted and ignored in this version. |
role | const stringdefault "" | What the color of this output means, for the color presets of the Colors tab: "up", "down", "neutral" or "accent". Empty = guessed from the role of its style (look), the theme color, the title and the hue (a teal line counts as up). Another value is error CS2014. |
look | const stringdefault "" | A style made with style.plot / style.line / style.marker / style.fill (its look, shared and user-editable). |
variant | const stringdefault "" | The name of one of the style's variants (style.variant). |
textstyle | input stringdefault "" | The text's style (textstyle.new or input.textstyle): size, font, weight, italic, colour, halo, background. |
text_formatting | input intdefault text.format_none | text.format_bold, text.format_italic or both added. |
Example
plotchar(close > open, "Up", "*", location.top, color.up)Since ChartScript 1
#plotshapefunction
Draws a shape on bars where the series is true (or not na).
plotshape(series: bool, { title?: const string = "", style?: input shape_style = shape.xcross, location?: input location = location.abovebar, color?: color = na, offset?: input int = 0, text?: input string = "", textcolor?: color = na, editable?: const bool = true, size?: input size = size.auto, show_last?: const int = na, display?: input display = display.all, format?: const format = na, precision?: const int = na, force_overlay?: const bool = false, role?: const string = "", look?: const string = "", variant?: const string = "", textstyle?: input string = "", text_formatting?: input int = text.format_none })plotshape(series: float, { title?: const string = "", style?: input shape_style = shape.xcross, location?: input location = location.abovebar, color?: color = na, offset?: input int = 0, text?: input string = "", textcolor?: color = na, editable?: const bool = true, size?: input size = size.auto, show_last?: const int = na, display?: input display = display.all, format?: const format = na, precision?: const int = na, force_overlay?: const bool = false, role?: const string = "", look?: const string = "", variant?: const string = "", textstyle?: input string = "", text_formatting?: input int = text.format_none })| Parameter | Type | Description |
|---|---|---|
series | bool | The value to draw on each bar. |
title | const stringdefault "" | The name shown in the settings, legend and data window. |
style | input shape_styledefault shape.xcross | The style constant. |
location | input locationdefault location.abovebar | Where the shape sits (location.*). |
color | colordefault na | The colour. |
offset | input intdefault 0 | Shift the output this many bars to the right (negative: left). |
text | input stringdefault "" | Text drawn with the shape. |
textcolor | colordefault na | The colour of the text. |
editable | const booldefault true | Accepted and ignored (styles are always editable). |
size | input sizedefault size.auto | The number of elements. |
show_last | const intdefault na | Accepted and ignored in this version. |
display | input displaydefault display.all | Where the value is shown (display.*). |
format | const formatdefault na | The number format (format.*). |
precision | const intdefault na | Decimals shown. |
force_overlay | const booldefault false | Accepted and ignored in this version. |
role | const stringdefault "" | What the color of this output means, for the color presets of the Colors tab: "up", "down", "neutral" or "accent". Empty = guessed from the role of its style (look), the theme color, the title and the hue (a teal line counts as up). Another value is error CS2014. |
look | const stringdefault "" | A style made with style.plot / style.line / style.marker / style.fill (its look, shared and user-editable). |
variant | const stringdefault "" | The name of one of the style's variants (style.variant). |
textstyle | input stringdefault "" | The text's style (textstyle.new or input.textstyle): size, font, weight, italic, colour, halo, background. |
text_formatting | input intdefault text.format_none | text.format_bold, text.format_italic or both added. |
Example
plotshape(ta.crossover(close, ta.sma(close, 20)), "Cross", shape.triangleup, location.belowbar, color.up)Since ChartScript 1
#secondfunction
The second of the bar open (UTC). The second of a time in a time zone.
second(time: int, { timezone?: string = "UTC" }): int| Parameter | Type | Description |
|---|---|---|
time | int | A time in milliseconds since 1970 (UTC). |
timezone | stringdefault "UTC" | An IANA time zone such as "UTC" or "America/New_York". |
Returns int.
Example
const v = second(time, "UTC")Since ChartScript 1
#stringfunction
Types a string value (string(na)).
string(x: string): string| Parameter | Type | Description |
|---|---|---|
x | string | The value. |
Returns string.
Example
const s = string(na)Since ChartScript 1
#timefunction
The open time of the bar (ms, UTC). The open time of the bar in a timeframe, or na outside the session; bars_back reads a chart bar that many bars ago, timeframe_bars_back steps back whole periods of the timeframe.
time({ timeframe?: simple string = "", session?: simple string = "", timezone?: simple string = "UTC", bars_back?: int = 0, timeframe_bars_back?: int = 0 }): int| Parameter | Type | Description |
|---|---|---|
timeframe | simple stringdefault "" | A timeframe such as "60", "240", "1D" or "1W"; "" is the chart's. |
session | simple stringdefault "" | A session such as "0930-1600" (UTC unless timezone is given). |
timezone | simple stringdefault "UTC" | An IANA time zone such as "UTC" or "America/New_York". |
bars_back | intdefault 0 | Chart bars back (0 = this bar). |
timeframe_bars_back | intdefault 0 | Periods of the timeframe back (0 = this period). |
Returns int.
Example
const t = time("1D")Since ChartScript 1
#time_closefunction
The close time of the bar (ms, UTC). The close time of the bar in a timeframe.
time_close({ timeframe?: simple string = "", session?: simple string = "", timezone?: simple string = "UTC", bars_back?: int = 0, timeframe_bars_back?: int = 0 }): int| Parameter | Type | Description |
|---|---|---|
timeframe | simple stringdefault "" | A timeframe such as "60", "240", "1D" or "1W"; "" is the chart's. |
session | simple stringdefault "" | A session such as "0930-1600" (UTC unless timezone is given). |
timezone | simple stringdefault "UTC" | An IANA time zone such as "UTC" or "America/New_York". |
bars_back | intdefault 0 | Chart bars back (0 = this bar). |
timeframe_bars_back | intdefault 0 | Periods of the timeframe back (0 = this period). |
Returns int.
Example
const t = time_close("1D")Since ChartScript 1
#timestampfunction
A time in milliseconds (UTC unless a time zone is given).
timestamp(year: int, month: int, day: int, { hour?: int = 0, minute?: int = 0, second?: int = 0 }): inttimestamp(timezone: string, year: int, month: int, day: int, { hour?: int = 0, minute?: int = 0, second?: int = 0 }): inttimestamp(dateString: string): int| Parameter | Type | Description |
|---|---|---|
year | int | The year. |
month | int | The month (1-12). |
day | int | The day of the month. |
hour | intdefault 0 | The hour (0-23). |
minute | intdefault 0 | The minute. |
second | intdefault 0 | The second. |
timezone | string | An IANA time zone such as "UTC" or "America/New_York". |
dateString | string | A date such as "2024-01-31" or "2024-01-31T09:30:00Z". |
Returns int.
Example
const t0 = timestamp(2024, 1, 31)Since ChartScript 1
#weekofyearfunction
The ISO week of the bar open (UTC). The weekofyear of a time in a time zone.
weekofyear(time: int, { timezone?: string = "UTC" }): int| Parameter | Type | Description |
|---|---|---|
time | int | A time in milliseconds since 1970 (UTC). |
timezone | stringdefault "UTC" | An IANA time zone such as "UTC" or "America/New_York". |
Returns int.
Example
const v = weekofyear(time, "UTC")Since ChartScript 1
#yearfunction
The year of the bar open (UTC). The year of a time in a time zone.
year(time: int, { timezone?: string = "UTC" }): int| Parameter | Type | Description |
|---|---|---|
time | int | A time in milliseconds since 1970 (UTC). |
timezone | stringdefault "UTC" | An IANA time zone such as "UTC" or "America/New_York". |
Returns int.
Example
const v = year(time, "UTC")Since ChartScript 1
#Variables
#bar_indexvariable
The bar number: 0 = the first bar of the run.
bar_index: intType series int.
Example
const v = bar_indexSince ChartScript 1
#closevariable
The close of the bar (the last price on the live bar).
close: floatType series float.
Example
const v = closeSince ChartScript 1
#dayofmonthvariable
The day of the month of the bar open (UTC). The dayofmonth of a time in a time zone.
dayofmonth(time: int, { timezone?: string = "UTC" }): intType series int.
Example
const v = dayofmonthSince ChartScript 1
#highvariable
The high of the bar.
high: floatType series float.
Example
const v = highSince ChartScript 1
#hl2variable
(high + low) / 2.
hl2: floatType series float.
Example
const v = hl2Since ChartScript 1
#hlc3variable
(high + low + close) / 3.
hlc3: floatType series float.
Example
const v = hlc3Since ChartScript 1
#hlcc4variable
(high + low + close + close) / 4.
hlcc4: floatType series float.
Example
const v = hlcc4Since ChartScript 1
#hourvariable
The hour of the bar open (UTC). The hour of a time in a time zone.
hour(time: int, { timezone?: string = "UTC" }): intType series int.
Example
const v = hourSince ChartScript 1
#last_bar_indexvariable
The bar_index of the last bar.
last_bar_index: intType series int.
Example
const v = last_bar_indexSince ChartScript 1
#last_bar_timevariable
The open time of the last bar of the chart (ms, UTC).
last_bar_time: intType series int.
Example
const v = last_bar_timeSince ChartScript 1
#lowvariable
The low of the bar.
low: floatType series float.
Example
const v = lowSince ChartScript 1
#minutevariable
The minute of the bar open (UTC). The minute of a time in a time zone.
minute(time: int, { timezone?: string = "UTC" }): intType series int.
Example
const v = minuteSince ChartScript 1
#monthvariable
The month of the bar open (1-12, UTC). The month of a time in a time zone.
month(time: int, { timezone?: string = "UTC" }): intType series int.
Example
const v = monthSince ChartScript 1
#ohlc4variable
(open + high + low + close) / 4.
ohlc4: floatType series float.
Example
const v = ohlc4Since ChartScript 1
#openvariable
The open of the bar.
open: floatType series float.
Example
const v = openSince ChartScript 1
#secondvariable
The second of the bar open (UTC). The second of a time in a time zone.
second(time: int, { timezone?: string = "UTC" }): intType series int.
Example
const v = secondSince ChartScript 1
#timevariable
The open time of the bar (ms, UTC). The open time of the bar in a timeframe, or na outside the session; bars_back reads a chart bar that many bars ago, timeframe_bars_back steps back whole periods of the timeframe.
time({ timeframe?: simple string = "", session?: simple string = "", timezone?: simple string = "UTC", bars_back?: int = 0, timeframe_bars_back?: int = 0 }): intType series int.
Example
const v = timeSince ChartScript 1
#time_closevariable
The close time of the bar (ms, UTC). The close time of the bar in a timeframe.
time_close({ timeframe?: simple string = "", session?: simple string = "", timezone?: simple string = "UTC", bars_back?: int = 0, timeframe_bars_back?: int = 0 }): intType series int.
Example
const v = time_closeSince ChartScript 1
#time_tradingdayvariable
The start of the trading day of the bar (crypto: 00:00 UTC of the bar's day).
time_tradingday: intType series int.
Example
const v = time_tradingdaySince ChartScript 1
#timenowvariable
The current time (ms, UTC); differs between runs.
timenow: intType series int.
Example
const v = timenowSince ChartScript 1
#volumevariable
The volume of the bar (base units).
volume: floatType series float.
Example
const v = volumeSince ChartScript 1
#weekofyearvariable
The ISO week of the bar open (UTC). The weekofyear of a time in a time zone.
weekofyear(time: int, { timezone?: string = "UTC" }): intType series int.
Example
const v = weekofyearSince ChartScript 1
#yearvariable
The year of the bar open (UTC). The year of a time in a time zone.
year(time: int, { timezone?: string = "UTC" }): intType series int.
Example
const v = yearSince ChartScript 1
#Not supported
#alertconditionfunction
Not supported in ChartScript.
Use alert.on(condition, title, message).
Since ChartScript 1
#studyfunction
Not supported in ChartScript.
Use indicator(...).
Since ChartScript 1
#varipvariable
Not supported in ChartScript.
Not supported: use live state (same meaning: not rolled back between ticks).
Since ChartScript 1