Text
23 entries. What each one takes, what it returns, and a working example.
A color in #rrggbbaa form with the opacity applied.
alpha is clamped to 0-1. If an invalid hex is given the input is returned unchanged. Ideal for making fills and backgrounds semi-transparent.
plot(close, color=color("#26a69a", 0.5))
Plots price in a half-transparent green (#26a69a80).
true if part occurs anywhere in the text, otherwise false.
Case sensitive. For classifying text such as a symbol name or a session label.
plot(iff(contains("BTCUSDT", "USD"), 1, 0))
Since "BTCUSDT" contains "USD", it plots 1.
true if the text ends with that suffix, otherwise false.
Case sensitive. Handy for spotting a quote currency (…USDT).
plot(iff(endsWith("BTCUSDT", "USDT"), 1, 0))
Since "BTCUSDT" ends with "USDT", it plots 1.
Text with placeholders filled; behaves the same as text.
An alias of text. {0} fills by index, {} in order; a decimal is trimmed to at most 4 places.
if barstate.islast { infoTable(format("O:{0} C:{1}", open, close)) } plot(close)
Joins open and close on one line and writes it into the panel.
A date-time text in "YYYY-MM-DD HH:MM" form (UTC); an empty text on invalid input.
Auto-detects a seconds or milliseconds stamp. Output is in UTC. For showing a time on a label/panel.
if barstate.islast { label(close, formatTime(time), barIndex) } plot(close)
Writes the last bar's time onto a label as a readable date-time.
gradient(value, lo, hi, loColor, hiColor)
A color blended between the two colors by mapping value across [lo,hi] (a color series if a series is given).
If value falls outside the range it is pinned to the ends. For heatmap-like coloring — e.g. showing RSI shifting color from oversold to overbought.
plot(close, color=gradient(rsi(close, 14), 30, 70, "#ef5350", "#26a69a"))
Colors price red near RSI 30 and green near 70.
The position of the first occurrence of part (0-based), or -1 if not found.
Positions count from 0. A not-found result is signalled by -1.
plot(indexOf("merhaba", "h"))
Since "h" is at position 3 in "merhaba", it plots 3.
To compare case-insensitively, normalize both sides with lower.
if barstate.islast { label(close, lower("MERHABA"), barIndex) } plot(close)
Places a label reading "merhaba" on the last bar.
The FIRST substring matching the pattern, or an empty text if there is no match.
Returns only the first match. Can be paired with toNumber to extract a number or pattern from text.
plot(toNumber(regexMatch("abc123def", "[0-9]+")))
The first digit block "123" is extracted, converted to a number, and plotted.
The text written n times in a row.
If n is zero or negative it returns an empty text. Handy for a simple progress bar / separator strip.
plot(strLength(repeat("ab", 3)))
"ab" is repeated 3 times ("ababab"); its length 6 is plotted.
The text with only the FIRST match replaced.
Replaces only the first match; use replaceAll for every match.
if barstate.islast { label(close, replace("aXbXc", "X", "-"), barIndex) } plot(close)
The first X is replaced; the label reads "a-bXc".
The text with every match replaced.
Replaces all matches; use replace to change only the first.
if barstate.islast { label(close, replaceAll("aXbXc", "X", "-"), barIndex) } plot(close)
All X's are replaced; the label reads "a-b-c".
true if the text starts with that prefix, otherwise false.
Case sensitive.
plot(iff(startsWith("BTCUSDT", "BTC"), 1, 0))
Since "BTCUSDT" starts with "BTC", it plots 1.
The text form of the value; if a series is given, an element-wise text series. na → "NaN".
Without a format it shows up to 10 decimals and trims trailing zeros. "percent" appends %, "volume" abbreviates large numbers with K/M/B/T, "mintick" rounds to the symbol's price step.
if barstate.islast { label(close, str(close, "#.##"), barIndex) } plot(close)
Converts close to text with two decimals and places it as a label on the last bar.
strFormat(şablon, ...değerler)
Text with placeholders filled; behaves the same as text/format.
Another alias of text — the formatting behavior is identical.
if barstate.islast { infoTable(strFormat("H:{0} L:{1}", high, low)) } plot(close)
Joins high and low on one line and writes it into the panel.
The number of characters in the text (a number).
Returns 0 for an empty text.
plot(strLength("merhaba"))
Since "merhaba" has 7 characters, it plots 7.
The same text if the input is text, or the na text if it is na.
Only accepts text/na; passing a number or boolean raises an error. Use str to turn a number/series into text.
plot(strLength(string("merhaba")))
The text input is returned unchanged; its length 7 is plotted.
substring(metin, başla, bitir?)
The substring in the range [start, end).
Positions are 0-based and end is excluded; if end is omitted it runs to the end of the text.
plot(strLength(substring("merhaba", 0, 3)))
The first 3 characters ("mer") are taken; their length 3 is plotted.
Text with the placeholders filled by the given values.
{0} fills by index, {} fills in order. A decimal is trimmed to at most 4 places; if a series is given its last valid value is written.
if barstate.islast { infoTable(text("Kapanis: {0}", close)) } plot(close)
On the last bar writes a "Kapanis:
label(close, text("RSI {0}", rsi(close, 14)), 50) plot(close)
Places a label at bar 50 embedding the RSI value.
The numeric value of the text, or na if it cannot be converted.
Leading/trailing spaces are ignored. Invalid text does not raise an error, it returns na.
plot(toNumber("3.14"))
Converts the text "3.14" to the number 3.14 and plots it.
The text form of the value; behaves the same as str.
An alias of str — it accepts the same format options. May be preferred for readability.
if barstate.islast { label(close, toString(rsi(close, 14)), barIndex) } plot(close)
Converts the RSI value to text and writes it as a label on the last bar.
Only removes whitespace at the ends; interior spaces are kept.
plot(strLength(trim(" ab ")))
The edge spaces are stripped; the remaining "ab" has length 2, which is plotted.
Handy for normalizing symbol names to a single form.
if barstate.islast { label(close, upper("btc"), barIndex) } plot(close)
Places a label reading "BTC" on the last bar.