str.startswith

The counterpart of str.endswith, looking at the front of the string instead of the back. Both arguments are required.

str.startswith(const string source, const string prefix) → const bool
str.startswith(input string source, input string prefix) → input bool
str.startswith(series string source, series string prefix) → series bool
str.startswith(simple string source, simple string prefix) → simple bool
ParameterTypeRequiredDescription
sourceconst stringyesthe string being examined
prefixconst stringyesthe opening to test for

Returns const bool or input bool or series bool or simple bool — A bool in the form of the arguments you pass.

indicator("Ticker starts with BTC")
plotshape(str.startswith(syminfo.ticker, "BTC"), title = "Starts with BTC")

See also str.contains · str.endswith · str.format_time

Part of the function index.

Ready to put this into practice?
Try GoCharting Premium
Unlock advanced orderflow, market profile, options desk, and real-time data — everything you just read about, live in your charts.
Upgrade