Skip to content
Algo Trade Analytics Docs
Pine library page — review pending. This page is preserved for compatibility but is not part of the reviewed search index. Check the official Pine Script v6 reference before relying on its explanation, signature, or example.

string() - Pine Script Function

string() casts a const or simple value to a const string. It is typically used when you must supply a literal text argument—such as the default title for a plot—constructed from compile-time constants.

string(x) → const string
NameTypeDescription
xconst int/float/bool/colorValue to convert into a string literal at compile time.

const string — Textual representation of the argument.

  • Because the result is a const string, string() cannot process series or runtime values. For dynamic conversion, use str.tostring() instead.
  • When you need to concatenate constants (e.g., indicator(string("My") + " Strategy")), casting with string() ensures Pine treats the result as a literal.
//@version=6
indicator(string("Breakout ") + "Monitor", overlay=true)
length = input.int(20, "Range length")
upper = ta.highest(high, length)
lower = ta.lowest(low, length)
plot(upper, "Upper band")
plot(lower, "Lower band")