Contains to string conversion methods arrays of int/float/bool/string/line/label/box types
- toS() - method works like array.join() with more flexibility and
- toStringAr() - converts array to string on a per item basis and returns the resulting string[] array
Conversion of each item to string is made using toS() function from moebius1977/ToS/1 library.
█ GENERAL DESCRIPTION OF LIBRARY FUNCTIONS
All toS(array) methods have same parameters. The only difference will be in format parameter as explained below.
method toS(this, index_from, index_to, separator, showIDs, format, truncate_left, size_limit, nz) Like array.join() but with string length limit. Joins elements into readable string (length capped at 4000, truncating the end or beg) Parameters: this (array<bool>): array to be converted to string index_from (int): index_from (int) (Optional) Start from this id (starting from 0, in insertion order). If omitted - start from the first item. index_to (int): index_to (int) (Optional) End with this pair (inclusive, in insertion order). If omitted - to last item. separator (string): separator (string) (Optional) String to be inserted between pairs. Default: `", "` showIDs (bool): showIDs (bool) (Optional) If true item's id is added in the form `id: value`. format (string): format (string) (Optional) Format string fo toS(). If omitted default format is used depending in the type. truncate_left (bool): truncate_left (bool) (Optional) Truncate from left or right. Default: false. size_limit (int): size_limit (int) (Optional) Max output string length. Default: 4000. nz (string): nz (string) (Optional) A string used to represent na (na values are substituted with this string).
format parameter depends on the type:
For toS(bool/int/float[]...) format parameter works in the same way as `str.format()` (i.e. you can use same format strings as with `str.format()` with `{0}` as a placeholder for the value) with some shorthand "format" options available:
--- time --- - "... <time> ... " in any place is substituted with "{0, time, HH.mm.ss}" (e.g. "<date> <time>" results in "{0, date, dd.MM.YY\} {0, time, HH.mm.ss}") - "time" => "{0, time, HH:mm:ss}" - "HH:mm" => "{0, time, HH:mm}" - "mm:ss" => "{0, time, mm:ss}" - "date time" => "{0, date, dd.MM.YY\} {0, time, HH.mm.ss}" - "date, time" => "{0, date, dd.MM.YY\}, {0, time, HH.mm.ss}" - "date,time" => "{0, date, dd.MM.YY\},{0, time, HH.mm.ss}" - "date\ntime" => "{0, date, dd.MM.YY\}\n{0, time, HH.mm.ss}"
For toS(line[]...): format (string): (string) (Optional) Use `x1` as placeholder for `x1` and so on. E.g. default format is `"(x1, y1) - (x2, y2)"`.
For toS(label[]...): format (string): (string) (Optional) Use `x1` as placeholder for `x`, `y1 - for `y` and `txt` for label's text. E.g. default format is `(x1, y1): "txt"` if ptint_text is true and `(x1, y1)` if false.
For toS(box[]... ): format (string): (string) (Optional) Use `x1` as placeholder for `x`, `y1 - for `y` etc. E.g. default format is "(x1, y1) - (x2, y2)".
For toS(color][]... ): format (string): (string) (Optional) Options are "HEX" (e.g. "#FFFFFF33") or "RGB" (e.g. "rgb(122,122,122,23)"). Default is "HEX".
All toStringAr() methods just convert each item to string using toS with same format options as described above.
Parameters: arr (array<bool>): Array to be converted to a string array. format (string): Format string. nz (string): Placeholder for na items.
█ FULL OF FUNCTIONS AND PARAMETERS
Library "ToStringAr" Contains toString/toS conversion methods for int/float/bool/string/line/label/box and arrays and matrices thereof. Also contains a string wraping function.
Dans le plus pur esprit TradingView, l'auteur a publié ce code Pine en tant que bibliothèque open-source afin que d'autres programmeurs Pine de notre communauté puissent le réutiliser. Bravo à l'auteur! Vous pouvez utiliser cette bibliothèque en privé ou dans d'autres publications à code source ouvert, mais la réutilisation de ce code dans une publication est régie par nos Règles.
Les informations et les publications ne sont pas destinées à être, et ne constituent pas, des conseils ou des recommandations en matière de finance, d'investissement, de trading ou d'autres types de conseils fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.