Builtins: declaration, absent values, text

SignatureReturns
indicator(name: string [, base: string]) -> voidSets the name the chart shows, which is also the title of its alert popup. At most one per script. The optional base names an open built in indicator to extend; see Extending a built in indicator.
nz(value: float [, replacement: float]) -> floatvalue when finite, otherwise replacement, default 0.
is_nan(value: float) -> boolTrue only for nan.
na(value: float) -> boolThe same as is_nan, for Pine style code.
str.concat(part: string, ... ) -> stringJoins 1 to 24 strings. Fails above 1,024 characters.
format.compact(value: float) -> stringThe chart number ladder, with K, M, B and T tiers. Empty string for nan.
format.fixed(value: float, decimals: int) -> stringFixed point text, 0 through 6 decimals. Empty string for nan.
str.tostring(value [, decimals: int]) -> stringA number with up to 8 decimals and trailing zeros trimmed, or exactly decimals (0 through 8) decimals; true or false for a bool; NaN for nan.
str.length(text: string) -> intNumber of characters
str.contains(text: string, part: string) -> boolWhether part appears in text
str.startswith(text: string, part: string) -> boolWhether text starts with part
str.endswith(text: string, part: string) -> boolWhether text ends with part
str.upper(text: string) -> stringUpper case, for the letters A to Z
str.lower(text: string) -> stringLower case, for the letters A to Z
str.substring(text: string, begin: int [, end: int]) -> stringThe characters from begin up to, not including, end

The chart

SignatureReturns
chart.is_last_bar() -> boolTrue on the newest bar of the window, the same as last_bar
chart.last_bar_index() -> intbar_index of the newest bar, the same as bar_count - 1
chart.timeframe_seconds() -> floatThe usual spacing of the bars in seconds, 0 when it cannot be told, for example on range bars
chart.tick_size() -> floatThe instrument tick, or nan when the chart did not state one

Numbers never join strings on their own. Format them first.

indicator("Delta Readout")
let caption: string = str.concat("DELTA ", format.compact(tape.delta()), " / ", format.fixed(tape.delta() / tape.volume() * 100, 1), "%")
plot.label(caption, "#E5E7EB")

Every layer of the market, Orderflow to optionflow, on one chart.

Institutional grade Orderflow data with backtesting and journaling built in. Join the waitlist for early access.

Get Access