Returns a string made of the source repeated a number of times, with an optional separator between copies.
str.repeat("ab", 3) returns "ababab". Add a separator and it goes between copies: str.repeat("ab", 3, "-") returns "ab-ab-ab".
A count below 1 returns an empty string. Fractions are rounded down.
Syntax
str.repeat(source: const string, repeat: const int, separator: const string (optional)) -> const string
str.repeat(source: input string, repeat: input int, separator: input string (optional)) -> input string
str.repeat(source: simple string, repeat: simple int, separator: simple string (optional)) -> simple string
str.repeat(source: series string, repeat: series int, separator: series string (optional)) -> series stringArguments
| Name | Type | Default | Description |
|---|---|---|---|
| source | const/ | required | The text to copy. It is joined to itself repeat times, with separator between copies. |
| repeat | const/ | required | How many copies of source to join. 0 gives an empty string. |
| separator | const/ | "" | Text placed between copies. |
Returns
const/input/simple/series string: the repeated text.
Remarks
- Use it to draw simple text bars, for example a row of block characters sized by a value.
Example
//@version=6
indicator("Repeat")
n = math.max(1, math.round(ta.rsi(close, 14) / 10))
plot(str.length(str.repeat("#", n)), "Bar length", color = color.teal, style = plot.style_stepline)See also
Runs on Sidechair