Skip to content
Algo Trade Analytics Docs

str.trim() - Pine Script Function

Constructs a new string with all consecutive whitespaces and other control characters (e.g., “\n”, “\t”, etc.) removed from the left and right of the source.

str.trim(source) → const string
NameTypeDescription
sourceconst stringString to trim.
  • Returns an empty string ("") if the result is empty after the trim or if the source is na.
//@version=6
indicator("str.trim")
trim = str.trim(" abc ") // Returns "abc"
label.new(bar_index,close,trim)