moebius1977

toString

moebius1977 Telah dikemas kini   
Library "toString"
Contains methods for conversion to string of int/float/bool/string/line/label/box and arrays and matrices thereof. Also contains a string wrapping function.

method getXloc(line/label/box)
  returns true if line/box/label are xloc.bar_time, false otherwise

nzs(string)
  Analogue of nz() but for strings. Returns "" is _s is na.

method wrap(string, wrap_width, breaker_prefix, breaker_postfix)
  Wraps the string to wrap_width adding breaker_prefix to the end of each line (before "\n") and breaker_postfix to the beginning of each line (after "\n")".

method toS(<int/float> val, format)
  Same as str.format() (for one argument) with additional "format" options:
- --- Number formats ---
- "number"
- "0"
- "0.0"
- "0.00"
- "0.000"
- "0.0000"
- "0.00000"
- "0.000000"
- "0.0000000"
- --- Date formats ---
- "date"
- "date : time"
- "dd.MM"
- "dd"
- --- Time formats ---
- "time"
- "HH:mm"
- "mm:ss"
- "date time"
- "date, time"
- "date,time"

method toS(<bool/ string> val, format)
  Same as str.format() (for one argument) but works for bool/string

method toS(line, format)
  Returns line's main data as a string. If the line is xloc.bar_time formats x values to "dd.MM.yy HH:mm:ss"
  Parameters:
    format (string): (string) If empty returns coordinates as "(x1, y1) - (x2, y2)". Otherwise replaces "x1", "x2", "y1", "y2" in `format` string by values. (e.g. toS(line, "x1, x2") will only return x1 and x2 separated by comma).

method toS(label, format)
  Returns label's main data as a string. If the label is xloc.bar_time formats x values to "dd.MM.yy HH:mm:ss"
  Parameters:
    format (string): (string) If empty returns coordinates and text (if _printText) as "(x, y): text = text". Otherwise replaces "x1", "x2", "txt" in `format` string by values. (e.g. toS(label, "txt") will only return text of the label)

method toS(box, format)
  Returns box's main data as a string. If the box is xloc.bar_time formats x values to "dd.MM.yy HH:mm:ss"
  Parameters:
    format (string): (string) If empty returns coordinates as "(x1, y1) - (x2, y2)". Otherwise replaces "x1", "x2", "y1", "y2" in `format` string by values. (e.g. toS(box, "x1, x2") will only return x1 and x2 separated by comma).

method toS(array<string>, _from, _to, _separator, _showIDs, _format, _truncate_left, _size_limit)
  Like join() but with string length limit. Joins elements into readable string (length capped at _size_limit or 4000, truncating the end or beg)
  Parameters:
    this (string)
    _from (int) - from this id of the array
    _to (int) - to this id of the array
    _separator (string) - add this between items
    _showIDs (bool) - add id before each item. ("id: value")
    _format (string) - apply format string (str.format() to each item
    _truncate_left (bool) - if true cuts/truncates from the beginning, if false - cuts/truncates from the end. Default: false.
    _size_limit (int) -

method toStringAr(arr, format)
  Returns a string array made of original array items converted to string using toS() using `format` string. (see format options in toS description)

method toStringMx(mx, format)
  Returns a string matrix made of original matrix items converted to string using toS() using `format` string. (see format options in toS description)
  
Nota Keluaran:
v2
Nota Keluaran:
v3 Minor bug fixes.
Nota Keluaran:
v4 Fixed toStringAr for bool. There seems to be a bug in PineScript where str.format("{0}", boolArray.get(0)) returns "1" instead of "true" or "false". So, using "str.tostring()" for bool now, and `format` argument is not functioning (does not affect the result) for toStringAr() and toS() for `bool`.
Perpustakaan Pine

Di dalam semangat sebenar TradingView, pengarang telah menerbitkan kod Pine ini sebagai perpustakaan sumber terbuka, jadi pengaturcara-pengaturcara Pine yang lain dari komuniti kami boleh menggunakannya semula. Sorakan kepada penulis! Anda boleh menggunakan perpustakaan ini secara peribadi atau pada penerbitan-penerbitan sumber terbuka lain, tetapi penggunaan semula kod ini di dalam penerbitan adalah ditadbir oleh Peraturan Dalaman.

Penafian

Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.

Mahu gunakan perpustakaan ini?

Salin garisan ini dan tampalkan ia di dalam skrip anda.