Skip to content
Algo Trade Analytics Docs

str.substring() - Pine Script Function

Returns a new string that is a substring of the source string. The substring begins with the character at the index specified by begin_pos and extends to ‘end_pos - 1’ of the source string.

str.substring(source, begin_pos, end_pos) → const string
NameTypeDescription
sourceconst stringSource string from which to extract the substring.

The substring extracted from the source string.

  • Strings indexing starts from 0. If begin_pos is equal to end_pos, the function returns an empty string.
//@version=6
indicator("str.substring", overlay = true)
sym= input.symbol("NASDAQ:AAPL")pos = str.pos(sym, ":") // Get position of ":" charactertkr= str.substring(sym, pos+1) // "AAPL"
if barstate.islastconfirmedhistory
label.new(bar_index, high, text = tkr)