str.endswith

Asks whether a string finishes with a given ending. The suffix is a string, not a pattern, and both arguments are required.

str.endswith(const string source, const string suffix) → const bool
str.endswith(input string source, input string suffix) → input bool
str.endswith(series string source, series string suffix) → series bool
str.endswith(simple string source, simple string suffix) → simple bool
ParameterTypeRequiredDescription
sourceconst stringyesthe string being examined
suffixconst stringyesthe ending 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 ends with USD")
plotshape(str.endswith(syminfo.ticker, "USD"), title = "Ends with USD")

See also str.contains · str.format_time · str.length

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