Sidechair

string

Browse the reference

The type for text: labels, titles, tickers and the result of str.* functions. Join strings with +.

Try it in the editor

A string holds text. A literal is written in double or single quotes: "Close" or 'Close'. The + operator joins two strings, and str.tostring() turns a number, bool or array into one so you can add it to text: "Close: " + str.tostring(close, format.mintick).

Strings drive label text, table cells, alert messages, input titles and request.* symbols. syminfo.ticker, timeframe.period and the str.* functions all return strings.

Remarks

  • string(x) casts a value to the string type without changing it. An empty string is "", and a string variable is never na unless you assign na to it.
  • A string made from per-bar values is series string. Arguments that must be known before the first bar, such as an indicator() title, need a const string.
  • On Sidechair: string handling and the str.* functions run. Text is held as plain JavaScript strings.

Example

Pine ScriptText in a labelOpen in editor
//@version=6
indicator("Ticker label", overlay = true)
plot(close, "Close", color.gray)
if barstate.islast
    msg = syminfo.ticker + " " + str.tostring(close, "#.##")
    label.new(bar_index, high, msg, style = label.style_label_down)

See also

Runs on Sidechair