PINE LIBRARY

ToStringMx

OVERVIEW

Contains methods for conversion of matrices to string.
Supports matrices of int/float/bool/string/color/line/label/box/.

- toStringMx(matrix) - converts matrix to a string matrix converting each of its elements to string

- toS(matrix) - converts matrix to a string matrix (using toStringMx()) and outputs as string using str.tostring(matrix)

Conversion of each item to string is made using toS() function from moebius1977/ToS/1 library.

GENERAL DESCRIPTION OF FUNCTIONS

All toStringMx(matrix) and toS(matrix) methods have same parameters. The only difference will be in format parameter as explained below.

Parameters:
    this (matrix<bool>) Matrix to be converted to a string matrix.
    format (string) Format string.
    nz (string) Placeholder for na items.

format parameter depends on the type:

  For matrix<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:

--- number ---
- "" => "{0}"
- "number" => "{0}"
- "0" => "{0, number, 0 }"
- "0.0" => "{0, number, 0.0 }"
- "0.00" => "{0, number, 0.00 }"
- "0.000" => "{0, number, 0.000 }"
- "0.0000" => "{0, number, 0.0000 }"
- "0.00000" => "{0, number, 0.00000 }"
- "0.000000" => "{0, number, 0.000000 }"
- "0.0000000" => "{0, number, 0.0000000}"
--- date ---
- "date" => "{0, date, dd.MM.YY}"
- "date : time" => "{0, date, dd.MM.YY} : {0, time, HH.mm.ss}"
- "dd.MM" => "{0, date, dd:MM}"
- "dd" => "{0, date, dd}"
- "... <date> ... " in any place is substituted with "{0, date, dd.MM.YY}"
--- time ---
- "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}"
- "... <time> ... " in any place is substituted with "{0, time, HH.mm.ss}"


For matrix<line>:
    format (string): (string) (Optional) Use `x1` as placeholder for `x1` and so on. E.g. default format is `"(x1, y1) - (x2, y2)"`.

For matrix<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 matrix<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 matrix<color>:
    format (string): (string) (Optional) Options are "HEX" (e.g. "#FFFFFF33") or "RGB" (e.g. "rgb(122,122,122,23)"). Default is "HEX".

FULL LIST OF FUNCTIONS AND PARAMETERS

method toStringMx(mx, format, nz)
  Returns a string matrix made of original matrix items converted to string with toS().
  Namespace types: matrix<bool>
  Parameters:
    mx (matrix<bool>)
    format (string): (string) Like in str.format()
    nz (string): (string) If val is na and nz is not na the value of nz param is returned instead.

method toStringMx(mx, format, nz)
  Returns a string matrix made of original matrix items converted to string with toS().
  Namespace types: matrix<int>
  Parameters:
    mx (matrix<int>)
    format (string): (string) Like in str.format() with some shorthand options:
```
--- number ---
- "" => "{0}"
- "number" => "{0}"
- "0" => "{0, number, 0 }"
- "0.0" => "{0, number, 0.0 }"
- "0.00" => "{0, number, 0.00 }"
- "0.000" => "{0, number, 0.000 }"
- "0.0000" => "{0, number, 0.0000 }"
- "0.00000" => "{0, number, 0.00000 }"
- "0.000000" => "{0, number, 0.000000 }"
- "0.0000000" => "{0, number, 0.0000000}"
--- date ---
- "date" => "{0, date, dd.MM.YY}"
- "date : time" => "{0, date, dd.MM.YY} : {0, time, HH.mm.ss}"
- "dd.MM" => "{0, date, dd:MM}"
- "dd" => "{0, date, dd}"
- "... <date> ... " in any place is substituted with "{0, date, dd.MM.YY}"
--- time ---
- "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}"
- "... <time> ... " in any place is substituted with "{0, time, HH.mm.ss}"
    nz (string): (string) If val is na and nz is not na the value of nz param is returned instead.

method toStringMx(mx, format, nz)
  Returns a string matrix made of original matrix items converted to string with toS().
  Namespace types: matrix<float>
  Parameters:
    mx (matrix<float>)
    format (string): (string) Like in str.format() with some shorthand options:
```
--- number ---
- "" => "{0}"
- "number" => "{0}"
- "0" => "{0, number, 0 }"
- "0.0" => "{0, number, 0.0 }"
- "0.00" => "{0, number, 0.00 }"
- "0.000" => "{0, number, 0.000 }"
- "0.0000" => "{0, number, 0.0000 }"
- "0.00000" => "{0, number, 0.00000 }"
- "0.000000" => "{0, number, 0.000000 }"
- "0.0000000" => "{0, number, 0.0000000}"
--- date ---
- "date" => "{0, date, dd.MM.YY}"
- "date : time" => "{0, date, dd.MM.YY} : {0, time, HH.mm.ss}"
- "dd.MM" => "{0, date, dd:MM}"
- "dd" => "{0, date, dd}"
- "... <date> ... " in any place is substituted with "{0, date, dd.MM.YY}"
--- time ---
- "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}"
- "... <time> ... " in any place is substituted with "{0, time, HH.mm.ss}"
    nz (string): (string) If val is na and nz is not na the value of nz param is returned instead.

method toStringMx(mx, format, nz)
  Returns a string matrix made of original matrix items converted to string with toS().
  Namespace types: matrix<string>
  Parameters:
    mx (matrix<string>)
    format (string): (string) Like in str.format()
    nz (string): (string) If val is na and nz is not na the value of nz param is returned instead.

method toStringMx(mx, format, nz)
  Returns a string matrix made of original matrix items converted to string with toS().
  Namespace types: matrix<color>
  Parameters:
    mx (matrix<color>)
    format (string): (string) "HEX" (default) or "RGB"
    nz (string): (string) If val is na and nz is not na the value of nz param is returned instead.

method toStringMx(mx, format, nz)
  Returns a string matrix made of original matrix items converted to string with toS().
  Namespace types: matrix<line>
  Parameters:
    mx (matrix<line>)
    format (string): (string) (Optional) Format string. By default "{0}: {1}" if showIDs = true or "{1}" otherwise. (use "{0}" as a placeholder for id and "{1}" for item value)
    nz (string): (string) If val is na and nz is not na the value of nz param is returned instead.

method toStringMx(mx, format, nz)
  Returns a string matrix made of original matrix items converted to string with toS().
  Namespace types: matrix<label>
  Parameters:
    mx (matrix<label>)
    format (string): (string) (Optional) Format string. By default "{0}: {1}" if showIDs = true or "{1}" otherwise. (use "{0}" as a placeholder for id and "{1}" for item value)
    nz (string): (string) If val is na and nz is not na the value of nz param is returned instead.

method toStringMx(mx, format, nz)
  Returns a string matrix made of original matrix items converted to string with toS().
  Namespace types: matrix<box>
  Parameters:
    mx (matrix<box>)
    format (string): (string) (Optional) Format string. By default "{0}: {1}" if showIDs = true or "{1}" otherwise. (use "{0}" as a placeholder for id and "{1}" for item value)
    nz (string): (string) If val is na and nz is not na the value of nz param is returned instead.

method toS(this, format, nz)
  Converts each element of the matrix to string outputs using str.tostring(matrix)
  Namespace types: matrix<bool>
  Parameters:
    this (matrix<bool>): (matrix) Matrix to be converted to string
    format (string): (string) Format string as in str.format()
    nz (string): (string) If val is na and nz is not na the value of nz param is returned instead.export method toS(matrix<float> this, string format = "", string nz = na) => str.tostring(this.toStringMx(format, nz))

method toS(this, format, nz)
  Converts each element of the matrix to string outputs using str.tostring(matrix)
  Namespace types: matrix<float>
  Parameters:
    this (matrix<float>): (matrix) Matrix to be converted to string
    format (string): (string) Like in str.format() with some shorthand options:
```
--- number ---
- "" => "{0}"
- "number" => "{0}"
- "0" => "{0, number, 0 }"
- "0.0" => "{0, number, 0.0 }"
- "0.00" => "{0, number, 0.00 }"
- "0.000" => "{0, number, 0.000 }"
- "0.0000" => "{0, number, 0.0000 }"
- "0.00000" => "{0, number, 0.00000 }"
- "0.000000" => "{0, number, 0.000000 }"
- "0.0000000" => "{0, number, 0.0000000}"
--- date ---
- "date" => "{0, date, dd.MM.YY}"
- "date : time" => "{0, date, dd.MM.YY} : {0, time, HH.mm.ss}"
- "dd.MM" => "{0, date, dd:MM}"
- "dd" => "{0, date, dd}"
- "... <date> ... " in any place is substituted with "{0, date, dd.MM.YY}"
--- time ---
- "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}"
- "... <time> ... " in any place is substituted with "{0, time, HH.mm.ss}"
    nz (string): (string) If val is na and nz is not na the value of nz param is returned instead.export method toS(matrix<float> this, string format = "", string nz = na) => str.tostring(this.toStringMx(format, nz))

method toS(this, format, nz)
  Converts each element of the matrix to string outputs using str.tostring(matrix)
  Namespace types: matrix<string>
  Parameters:
    this (matrix<string>): (matrix) Matrix to be converted to string
    format (string): (string) Format string as in str.format()
    nz (string): (string) If val is na and nz is not na the value of nz param is returned instead.export method toS(matrix<float> this, string format = "", string nz = na) => str.tostring(this.toStringMx(format, nz))

method toS(this, format, nz)
  Converts each element of the matrix to string outputs using str.tostring(matrix)
  Namespace types: matrix<color>
  Parameters:
    this (matrix<color>): (matrix) Matrix to be converted to string
    format (string): (string) "HEX" (default) or "RGB"
    nz (string): (string) If val is na and nz is not na the value of nz param is returned instead.export method toS(matrix<float> this, string format = "", string nz = na) => str.tostring(this.toStringMx(format, nz))

method toS(this, format, nz)
  Converts each element of the matrix to string outputs using str.tostring(matrix)
  Namespace types: matrix<line>
  Parameters:
    this (matrix<line>): (matrix) Matrix to be converted to string
    format (string): (string) (Optional) Format string. By default "{0}: {1}" if showIDs = true or "{1}" otherwise. (use "{0}" as a placeholder for id and "{1}" for item value)
    nz (string): (string) If val is na and nz is not na the value of nz param is returned instead.export method toS(matrix<float> this, string format = "", string nz = na) => str.tostring(this.toStringMx(format, nz))

method toS(this, format, nz)
  Converts each element of the matrix to string outputs using str.tostring(matrix)
  Namespace types: matrix<label>
  Parameters:
    this (matrix<label>): (matrix) Matrix to be converted to string
    format (string): (string) (Optional) Format string. By default "{0}: {1}" if showIDs = true or "{1}" otherwise. (use "{0}" as a placeholder for id and "{1}" for item value)
    nz (string): (string) If val is na and nz is not na the value of nz param is returned instead.export method toS(matrix<float> this, string format = "", string nz = na) => str.tostring(this.toStringMx(format, nz))

method toS(this, format, nz)
  Converts each element of the matrix to string outputs using str.tostring(matrix)
  Namespace types: matrix<box>
  Parameters:
    this (matrix<box>): (matrix) Matrix to be converted to string
    format (string): (string) (Optional) Format string. By default "{0}: {1}" if showIDs = true or "{1}" otherwise. (use "{0}" as a placeholder for id and "{1}" for item value)
    nz (string): (string) If val is na and nz is not na the value of nz param is returned instead.export method toS(matrix<float> this, string format = "", string nz = na) => str.tostring(this.toStringMx(format, nz))
arraysmatrixstringstringstostring

Pine library

In true TradingView spirit, the author has published this Pine code as an open-source library so that other Pine programmers from our community can reuse it. Cheers to the author! You may use this library privately or in other open-source publications, but reuse of this code in a publication is governed by House rules.

Disclaimer