AlertaScript / Documentation
Strings
Format clear labels and messages.
How it works
Strings carry titles, symbols and human-readable text. Concatenate strings with + and format numeric values with str.tostring. format.mintick follows the symbol price precision and avoids arbitrary decimal counts. str.tonumber reads only plain decimals such as 1234.5 or -12; text such as 1,234 or 1e3 gives na. An na string joined with + counts as empty text. Without a format, str.tostring writes a number with at most ten decimals and no exponent, so 0.1 + 0.2 gives 0.3, and na is written as NaN. str.format reads Pine's placeholders, such as {0}, {0,number,#.##} and {0,number,percent}.
Put it into practice
Use a stable plot title and concise alert text. Creating a new label on every update can accumulate objects; retain and update an existing label for a lasting dashboard. String formatting changes presentation, not the underlying numeric calculation.
Working example
indicator("Price label", overlay=true)if barstate.islast label.new(bar_index, high, syminfo.ticker + " " + str.tostring(close, format.mintick))