faiyaz7283

_helpers

faiyaz7283 Mis à jour   
Library "_helpers"
A library containing helper functions.

_arrayFill(int, string) Fill a string array with given size and value.
  Parameters:
    int: size Total size of array.
    string: value The value used for filling. (`NaN` is used if no argument is supplied).
  Returns: A string array filled with given value.

_arrayFill(int, float) Fill a float array with given size and value.
  Parameters:
    int: size Total size of array.
    float: value The value used for filling.
  Returns: A float array filled with given value.

_arrayFill(int, int) Fill an int array with given size and value.
  Parameters:
    int: size Total size of array.
    int: value The value used for filling.
  Returns: A int array filled with given value.

_arrayFill(int, bool) Fill a boolean array with given size and value.
  Parameters:
    int: size Total size of array.
    bool: value The value used for filling.
  Returns: A boolean array filled with given value.

_bool(bool) Convert bool to bool.
  Parameters:
    bool: val A boolean value.
  Returns: Bool.

_bool(string) Convert string to bool.
  Parameters:
    string: val A string value.
  Returns: Bool.

_bool(float) Convert float to bool.
  Parameters:
    float: val A float value.
  Returns: Bool.

_bool(int) Convert integer to bool.
  Parameters:
    int: val An integer value.
  Returns: Bool.

_float(bool) Convert bool to float.
  Parameters:
    bool: val A boolean value.
  Returns: Float.

_float(string) Convert string number to float.
  Parameters:
    string: val A string value.
  Returns: Float.

_float(float) Convert float to float.
  Parameters:
    float: val A float value.
  Returns: Float.

_float(int) Convert integer to float.
  Parameters:
    int: val An integer value.
  Returns: Float.

_int(bool) Convert bool to int.
  Parameters:
    bool: val A boolean value.
  Returns: Int.

_int(string) Convert string number to int.
  Parameters:
    string: val A string value.
  Returns: Int.

_int(float) Convert float to int.
  Parameters:
    float: val A float value.
  Returns: Int.

_int(int) Convert int to int.
  Parameters:
    int: val An int value.
  Returns: Int.

_str(bool) Convert bool value to string.
  Parameters:
    bool: val A boolean value.
  Returns: String.

_str(str) Convert string value to string.
  Parameters:
    str: val A string value.
  Returns: String.

_str(float) Convert float value to string.
  Parameters:
    float: val A float value.
  Returns: String.

_str(int) Convert int value to string.
  Parameters:
    int: val An integer value.
  Returns: String.

_join(array, string) Convert a string array to a string using the given separator.
  Parameters:
    array: arr A string array.
    string: separator A separator. (`,` is used if no argument is supplied).
  Returns: A string.

_join(array, string) Convert an int array to a string using the given separator.
  Parameters:
    array: arr An integer array.
    string: separator A separator. (`,` is used if no argument is supplied).
  Returns: A tring.

_join(array, string) Convert a float array to a string using the given separator.
  Parameters:
    array: arr A float array.
    string: separator A separator. (`,` is used if no argument is supplied).
  Returns: A string.

_join(array, string) Convert a boolean array to a string using the given separator.
  Parameters:
    array: arr A bool array.
    string: separator A separator. (`,` is used if no argument is supplied).
  Returns: A string.

_commaSplit(string) Split a string by comma.
  Parameters:
    string: val A comma separated string value.
  Returns: An array.

_commaSplit(string, int) Get an item of a given index from a comma separated value.
  Parameters:
    string: val A comma separated string value.
    int: idx The index of the searching item.
  Returns: String.

_commaSplitPair(string) Get the first pair of values as tuple from a comma separated value.
  Parameters:
    string: val A comma separated string value.
  Returns: String tuple - .

_commaSplitShift(string) Get an array from given comma separated value, minus the first item.
  Parameters:
    string: val A comma separated string value.
  Returns: An array.

_colonSplit(string) Split a string by colon.
  Parameters:
    string: val A colon separated string value.
  Returns: An array.

_colonSplit(string, int) Get an item of a given index from a colon separated value.
  Parameters:
    string: val A colon separated string value.
    int: idx The index of the searching item.
  Returns: String.

_colonSplitPair(string) Get the first pair of values as tuple from a colon separated value.
  Parameters:
    string: val A colon separated string value.
  Returns: String tuple - .

_colonSplitShift(string) Get an array from given colon separated value, minus the first item.
  Parameters:
    string: val A colon separated string value.
  Returns: An array.

_print(bool, string, string) Print a bool value using table.
  Parameters:
    bool: val A bool value.
    string: text_size The size of the text value. ç
    string: position The positioin of the printing table. (`position.middle_center` is used if no argument is supplied).
  Returns: Table cell.

_print(array, string, string) Print a bool array using table.
  Parameters:
    array: arr A bool array.
    string: text_size The size of the text value. (`size.auto` is used if no argument is supplied).
    string: position The positioin of the printing table. (`position.middle_center` is used if no argument is supplied).
  Returns: Table cells.

_print(string, string, string) Print a string value using table.
  Parameters:
    string: val A string value.
    string: text_size The size of the text value. (`size.auto` is used if no argument is supplied).
    string: position The positioin of the printing table. (`position.middle_center` is used if no argument is supplied).
  Returns: Table cell.

_print(array, string, string) Print a string array using table.
  Parameters:
    array: arr A string array.
    string: text_size The size of the text value. (`size.auto` is used if no argument is supplied).
    string: position The positioin of the printing table. (`position.middle_center` is used if no argument is supplied).
  Returns: Table cells.

_print(float, string, string) Print a float value using table.
  Parameters:
    float: val A float value.
    string: text_size The size of the text value. (`size.auto` is used if no argument is supplied).
    string: position The positioin of the printing table. (`position.middle_center` is used if no argument is supplied).
  Returns: Table cell.

_print(array, string, string) Print a float array using table.
  Parameters:
    array: arr A float array.
    string: text_size The size of the text value. (`size.auto` is used if no argument is supplied).
    string: position The positioin of the printing table. (`position.middle_center` is used if no argument is supplied).
  Returns: Table cells.

_print(int, string, string) Print an integer value using table.
  Parameters:
    int: val An integer value.
    string: text_size The size of the text value. (`size.auto` is used if no argument is supplied).
    string: position The positioin of the printing table. (`position.middle_center` is used if no argument is supplied).
  Returns: Table cell.

_print(array, string, string) Print an int array using table.
  Parameters:
    array: arr An Int array.
    string: text_size The size of the text value. (`size.auto` is used if no argument is supplied).
    string: position The positioin of the printing table. (`position.middle_center` is used if no argument is supplied).
  Returns: Table cells.

_rndmLetter() Random letter generator.
  Returns: Random integer value.

_rndmWord(int) Random word generator.
  Parameters:
    int: size Total size for word's letter count. (`0` is used if no argument is supplied, which implies random value betweek 3-10).
  Returns: Random word.

_rndmSentence(int) Random sentence generator.
  Parameters:
    int: size Total size for sentence word count. (`0` is used if no argument is supplied, which implies random value betweek 3-10).
  Returns: Random sentence.

_rndmBool() Random boolean generator.
  Returns: Random boolean value.

_rndmFloat(float, float) Random float number generator.
  Parameters:
    float: min Minimum float value. (`0` is used if no argument is supplied).
    float: max Maximum float value. (`100` is used if no argument is supplied).
  Returns: Random float value.

_rndmInt(int, int) Random integer number generator.
  Parameters:
    int: min Minimum int value. (`1` is used if no argument is supplied).
    int: max Maximum int value. (`100` is used if no argument is supplied).
  Returns: Random integer value.

_rndmStringArray(int) Random string array generator.
  Parameters:
    int: size Total array size. (`0` is used if no argument is supplied, which implies random value betweek 3-10).
  Returns: Random string array.

_rndmFloatArray(int, float, float) Random float array generator.
  Parameters:
    int: size Int value for total array size. (`0` is used if no argument is supplied, which implies random value betweek 3-10).
    float: min Minimum float value. (`3` is used if no argument is supplied).
    float: max Maximum float value. (`10` is used if no argument is supplied).
  Returns: Random float array.

_rndmIntArray(int, int, int) Random int array generator.
  Parameters:
    int: size Int value for total array size. (`0` is used if no argument is supplied, which implies random value betweek 3-10).
    int: min Minimum int value. (`3` is used if no argument is supplied).
    int: max Maximum int value. (`10` is used if no argument is supplied).
  Returns: Random int array.

_rndmBoolArray(int) Random bool array generator.
  Parameters:
    int: size Int value for total array size. (`0` is used if no argument is supplied, which implies random value betweek 3-10).
  Returns: Random bool array.
Notes de version:
v2

Updated:
_float(int, int) Convert integer to float using given precision.
  Parameters:
    int: val An integer value.
    int: precision Decimal places.
  Returns: Float.

_rndmFloat(float, float, int) Random float number generator.
  Parameters:
    float: min Minimum float value. (`0` is used if no argument is supplied).
    float: max Maximum float value. (`100` is used if no argument is supplied).
    int: precision Decimal places. (`2` is used if no argument is supplied).
  Returns: Random float value.

_rndmFloatArray(int, float, float, int) Random float array generator.
  Parameters:
    int: size Int value for total array size. (`0` is used if no argument is supplied, which implies random value betweek 3-10).
    float: min Minimum float value. (`3` is used if no argument is supplied).
    float: max Maximum float value. (`10` is used if no argument is supplied).
    int: precision Decimal places. (`2` is used if no argument is supplied).
  Returns: Random float array.
Notes de version:
v3
Notes de version:
v4

Chart update.
Notes de version:
v5

Added:
Support for converting color object to a string ("r|g|b|t") using `_colorToString(color)` or `_str(color)`, and re-convert that back to a color using `_colorFromString(string)` or `_clr(string)`.

Faiyaz Haider
Bibliothèque Pine

Dans le véritable esprit de 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 à titre privé ou dans d'autres publications open-source, mais la réutilisation de ce code dans une publication est régie par notre Règlement.

Clause de non-responsabilité

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.

Vous voulez utiliser cette bibliothèque?

Copiez le texte dans le presse-papiers et collez-le dans votre script.