faiyaz7283

_2d

faiyaz7283 Atualizado   
Library "_2d"
A library containing helper functions for 2d Array.

_presetInfo(int) Get preset _info key.
  Parameters:
    int: idx
  Returns: _info key.

_presetInfo(string) Get preset index number of an _info key.
  Parameters:
    string: key
  Returns: Index value.

_presetSortBy(int) Get preset _sort_by key.
  Parameters:
    int: idx
  Returns: _sort_by key.

_presetSortBy(string) Get preset index number of an _sort_by key.
  Parameters:
    string: key
  Returns: Index value.

_presetStructure(int) Get preset internal key.
  Parameters:
    int: idx
  Returns: Internal key.

_presetStructure(string) Get preset index number of an internal key.
  Parameters:
    string: key
  Returns: Index value.

_presetStructureKeysTotal() This number is set manually by just counting the above keys.
  Returns: Internal structure's total size.

_initInfo(int) Initialize _info key and its values.
  Parameters:
    int: key_total Total size of initial keys.
  Returns: A string array of _info keys and values.

_initKeyIdx(array) Initialize _key_ids keys and values.
  Parameters:
    array: keys A string array of keys.
  Returns: A string array of _key_ids keys and values.

_initOrderBy(int) Initialize _order_by values.
  Parameters:
    int: key_total Total size of keys.
  Returns: A string array of _order_by values.

_initSortBy() Initialize _sort_by keys and values.
  Returns: A string array of _sort_by keys and values.

_initStructure(array, array, array, array, array, array) Initialize a 2d array structure.
  Parameters:
    array: info A string array of _info keys and values.
    array: keys A string array of keys.
    array: key_ids A string array of keys with their ids.
    array: order_by A string array of array index values in order.
    array: sort_by A string array of _sort_by key and values.
    array: values A string array of values.
  Returns: 2d array structured out with internal keys.

_init(array) Initialize the complete 2d array.
  Parameters:
    array: keys A string array of keys.
  Returns: 2d array with internal keys and values. Values are iniatialized with "NaN".

_info(string, array) Get value from _info.
  Parameters:
    string: key The searching key.
    array: arr 2d array.
  Returns: The value of the searched key.

_info(string, string, array) Set string value for given _info key.
  Parameters:
    string: key The setter key.
    string: value A string value.
    array: arr 2d array.
  Returns: Void.

_info(string, int, array) Set integer value for given _info key.
  Parameters:
    string: key The setter key.
    int: value An integer value.
    array: arr 2d array.
  Returns: Void.

_info(array, array, array) Set multiple string values for _info keys.
  Parameters:
    array: key A string array of keys.
    array: value A string array of values.
    array: arr 2d array.
  Returns: Void.

_info(array, array, array) Set multiple ineger values for _info keys.
  Parameters:
    array: key A string array of keys.
    array: value An integer array of values.
    array: arr 2d array.
  Returns: Void.

_keys(array) Get all the keys.
  Parameters:
    array: arr 2d array.
  Returns: An array of keys.

_orderedKeys(array) Get all ordered keys.
  Parameters:
    array: arr 2d array.
  Returns: An array of ordered index.

_keyIdx(string, array) Get the index of a key.
  Parameters:
    string: key The searching key.
    array: arr 2d array.
  Returns: Int index value.

_keyIdx(int, array) Get the key of an index.
  Parameters:
    int: idx The searching index.
    array: arr 2d array.
  Returns: The key.

_orderBy(array) Get all the index values from the _order_by key.
  Parameters:
    array: arr 2d array.
  Returns: An array of ordered index.

_orderBy(array, array) Set the _order_by key with index array.
  Parameters:
    array: idx A string array of index.
    array: arr 2d array.
  Returns: Void.

_orderBy(array, array) Set the _order_by key with keys array.
  Parameters:
    array: keys A string array of keys.
    array: arr 2d array.
  Returns: Void.

_sortBy(string, array) Get value from _sort_by key.
  Parameters:
    string: key The searching key.
    array: arr 2d array.
  Returns: The value of the searched key.

_sortBy(string, string, array) Set the _sort_by key with value.
  Parameters:
    string: key The setter key.
    string: value A string value for the key.
    array: arr 2d array.
  Returns: Void.

_sortBy(array, array, array) Set multiple keys and values for _sort_by key.
  Parameters:
    array: keys A string array of keys.
    array: values A string array of values.
    array: arr 2d array.
  Returns: Void.

_cmprKeys(array) Get all the compare keys.
  Parameters:
    array: arr 2d array.
  Returns: An array of data keys.

_cmprKeys(string, array) Set _cmpr_keys with a new key.
  Parameters:
    string: key A key.
    array: arr 2d array.
  Returns: Void.

_cmprKeys(array, array) Set _cmpr_keys with keys.
  Parameters:
    array: keys A string array of keys.
    array: arr 2d array.
  Returns: Void.

_rmCmprKeys(array, array) Remove keys from _cmpr_keys.
  Parameters:
    array: keys A string array of keys.
    array: arr 2d array.
  Returns: Void.

_rmCmprKeys(array) Remove all keys from _cmpr_keys.
  Parameters:
    array: arr 2d array.
  Returns: Void.

_rmCmprKeys(string, array) Remove key from _cmpr_keys.
  Parameters:
    string: key The key to be removed.
    array: arr 2d array.
  Returns: Void.

_keyExist(string, array) Check if a given key exist.
  Parameters:
    string: key The searching key.
    array: arr 2d array.
@return Bool.

_cmprKeyExist(string, array) Check if the given compare key exist.
  Parameters:
    string: key The searching key.
    array: arr 2d array.
  Returns: Bool.

_cmprKeysExist(array) Check if any compare keys exist.
  Parameters:
    array: arr 2d array.
  Returns: Bool.

_sort(string, array) Sort 2d array.
  Parameters:
    string: sort The order of sort. Use "asc" for ascending order and "desc" for descending order.
    array: arr 2d array.
  Returns: Void.

_values(array) Get all string values.
  Parameters:
    array: arr 2d array.
  Returns: A string array.

_values(array, array) Set all string values.
  Parameters:
    array: values Array of strings.
    array: arr 2d array.
  Returns: Void.

_values(array, array) Set all float values.
  Parameters:
    array: values Array of floats.
    array: arr 2d array.
  Returns: Void.

_values(array, array) Set all integer values.
  Parameters:
    array: values Array of integers.
    array: arr 2d array.
  Returns: Void.

_values(array, array) Set all boolean values.
  Parameters:
    array: values Array of booleans.
    array: arr 2d array.
  Returns: Void.

_floatValues(array) Get all float values.
  Parameters:
    array: arr 2d array.
  Returns: A float array.

_intValues(array) Get all integer values.
  Parameters:
    array: arr 2d array.
  Returns: An int array.

_boolValues(array) Get all boolean values.
  Parameters:
    array: arr 2d array.
  Returns: A bool array.

_append(array, array, array) Append keys with string values.
  Parameters:
    array: keys Keys array.
    array: values String array.
    array: arr 2d array.
  Returns: Void.

_append(array, array, array) Append keys with float values.
  Parameters:
    array: keys Keys array.
    array: values Float array.
    array: arr 2d array.
  Returns: Void.

_append(array, array, array) Append keys with integer values.
  Parameters:
    array: keys Keys array.
    array: values Int array.
    array: arr 2d array.
  Returns: Void.

_append(array, array, array) Append keys with boolean values.
  Parameters:
    array: keys Keys array.
    array: values Bool array.
    array: arr 2d array.
  Returns: Void.

_append(string, string, array) Append a key with string value.
  Parameters:
    string: key The key.
    string: value String value.
    array: arr 2d array.
  Returns: Void.

_append(string, float, array) Append a key with float value.
  Parameters:
    string: key The key.
    float: value Float value.
    array: arr 2d array.
  Returns: Void.

_append(string, int, array) Append a key with integer value.
  Parameters:
    string: key The key.
    int: value Int value.
    array: arr 2d array.
  Returns: Void.

_append(string, bool, array) Append a key with boolean value.
  Parameters:
    string: key The key.
    bool: value Bool value.
    array: arr 2d array.
  Returns: Void.

_prepend(array, array, array) Prepend keys with string values.
  Parameters:
    array: keys Keys array.
    array: values String array.
    array: arr 2d array.
  Returns: Void.

_prepend(array, array, array) Prepend keys with float values.
  Parameters:
    array: keys Keys array.
    array: values Float array.
    array: arr 2d array.
  Returns: Void.

_prepend(array, array, array) Prepend keys with integer values.
  Parameters:
    array: keys Keys array.
    array: values Int array.
    array: arr 2d array.
  Returns: Void.

_prepend(array, array, array) Prepend keys with boolean values.
  Parameters:
    array: keys Keys array.
    array: values Bool array.
    array: arr 2d array.
  Returns: Void.

_prepend(string, string, array) Prepend a key with string value.
  Parameters:
    string: key The key.
    string: value String value.
    array: arr 2d array.
  Returns: Void.

_prepend(string, float, array) Prepend a key with float value.
  Parameters:
    string: key The key.
    float: value Float value.
    array: arr 2d array.
  Returns: Void.

_prepend(string, int, array) Prepend a key with integer value.
  Parameters:
    string: key The key.
    int: value Int value.
    array: arr 2d array.
  Returns: Void.

_prepend(string, bool, array) Prepend a key with boolean value.
  Parameters:
    string: key The key.
    bool: value Bool value.
    array: arr 2d array.
  Returns: Void.

_rm(array, array) Remove keys and values for given keys.
  Parameters:
    array: keys Keys array.
    array: arr 2d array.
  Returns: Void.

_rm(string, array) Remove a key and value.
  Parameters:
    string: key The key.
    array: arr 2d array.
  Returns: Void.

_cmprValues(array) Get all compare string values.
  Parameters:
    array: arr 2d array.
  Returns: A string array.

_cmprValues(array, array) Set all compare string values.
  Parameters:
    array: values Array of strings.
    array: arr 2d array.
  Returns: Void.

_cmprValues(array, array) Set all compare float values.
  Parameters:
    array: values Array of floats.
    array: arr 2d array.
  Returns: Void.

_cmprValues(array, array) Set all compare integer values.
  Parameters:
    array: values Array of integers.
    array: arr 2d array.
  Returns: Void.

_cmprValues(array, array) Set all compare boolean.
  Parameters:
    array: values Array of booleans.
    array: arr 2d array.
  Returns: Void.

_cmprFloatValues(array) Get all compare float values.
  Parameters:
    array: arr 2d array.
  Returns: A float array.

_cmprIntValues(array) Get all compare integer values.
  Parameters:
    array: arr 2d array.
  Returns: An int array.

_cmprBoolValues(array) Get all compare boolean values.
  Parameters:
    array: arr 2d array.
  Returns: A bool array.

_rmCmprValues(array, array) Remove compare values for given keys.
  Parameters:
    array: keys Keys array.
    array: arr 2d array.
  Returns: Void.

_rmCmprValues(array) Remove all compare values.
  Parameters:
    array: arr 2d array.
  Returns: Void.

_value(string, array) Get string value of a key.
  Parameters:
    string: key The searching key.
    array: arr 2d array.
  Returns: String value.

_value(string, string, array) Set string value for a key
  Parameters:
    string: key The setter key.
    string: value A string value.
    array: arr 2d array.
  Returns: Void.

_value(string, float, array) Set float value for a key
  Parameters:
    string: key The setter key.
    float: value A float value.
    array: arr 2d array.
  Returns: Void.

_value(string, int, array) Set integer value for a key
  Parameters:
    string: key The setter key.
    int: value An int value.
    array: arr 2d array.
  Returns: Void.

_value(string, bool, array) Set boolean value for a key
  Parameters:
    string: key The setter key.
    bool: value A boolean value.
    array: arr 2d array.
  Returns: Void.

_floatValue(string, array) Get float value of a key.
  Parameters:
    string: key The searching key.
    array: arr 2d array.
  Returns: Float value.

_intValue(string, array) Get integer value of a key.
  Parameters:
    string: key The searching key.
    array: arr 2d array.
  Returns: Int value.

_boolValue(string, array) Get boolean value of a key.
  Parameters:
    string: key The searching key.
    array: arr 2d array.
  Returns: Bool value.

_valSpread(string, array) Get the spread containing original and compare string values.
  Parameters:
    string: key The searching key.
    array: arr 2d array.
  Returns: A tuple containing two string values.

_floatValSpread(string, array) Get the spread containing original and compare float values.
  Parameters:
    string: key The searching key.
    array: arr 2d array.
  Returns: A tuple containing two float values.

_intValSpread(string, array) Get the spread containing original and compare int values.
  Parameters:
    string: key The searching key.
    array: arr 2d array.
  Returns: A tuple containing two int values.

_boolValSpread(string, array) Get the spread containing original and compare bool values.
  Parameters:
    string: key The searching key.
    array: arr 2d array.
  Returns: A tuple containing two bool values.

_cmprValue(string, array) Get compare string value of a key.
  Parameters:
    string: key The searching key.
    array: arr 2d array.
  Returns: String value.

_cmprValue(string, string, array) Set compare string value for a key
  Parameters:
    string: key The setter key.
    string: value A string value.
    array: arr 2d array.
  Returns: Void.

_cmprValue(string, float, array) Set compare float value for a key
  Parameters:
    string: key The setter key.
    float: value A float value.
    array: arr 2d array.
  Returns: Void.

_cmprValue(string, int, array) Set compare integer value for a key
  Parameters:
    string: key The setter key.
    int: value An int value.
    array: arr 2d array.
  Returns: Void.

_cmprValue(string, bool, array) Set compare boolean value for a key.
  Parameters:
    string: key The setter key.
    bool: value A boolean value.
    array: arr 2d array.
  Returns: Void.

_cmprFloatValue(string, array) Get compare float value of a key.
  Parameters:
    string: key The searching key.
    array: arr 2d array.
  Returns: Float value.

_cmprIntValue(string, array) Get compare integer value of a key.
  Parameters:
    string: key The searching key.
    array: arr 2d array.
  Returns: Int value.

_cmprBoolValue(string, array) Get compare boolean value of a key.
  Parameters:
    string: key The searching key.
    array: arr 2d array.
  Returns: Bool value.

_cmprIsHigher(string, array) Check if compare value higher than original value.
  Parameters:
    string: key The searching key.
    array: arr 2d array.
  Returns: Bool value.

_cmprIsLower(string, array) Check if compare value lower than original value.
  Parameters:
    string: key The searching key.
    array: arr 2d array.
  Returns: Bool value.

_cmprChange(string, array) Get change value.
  Parameters:
    string: key The searching key.
    array: arr 2d array.
  Returns: Float value.

_cmprPercentChange(string, array, int) Get percent change value.
  Parameters:
    string: key The searching key.
    array: arr 2d array.
    int: precision The decimal precision.
  Returns: Float value.

_rmCmprValue(string, array) Remove compare value of a given key.
  Parameters:
    string: key The key.
    array: arr 2d array.
  Returns: Void.
Notas de Lançamento:
v2

Switched some exports into "Protected" functions to remove scope.

Faiyaz Haider
Biblioteca do Pine

No verdadeiro espírito TradingView, o autor publicou este código de Pine como uma biblioteca de código aberto para que outros programadores de Pine de nossa comunidade possam reutilizá-lo. Um brinde ao autor! Você pode usar esta biblioteca em particular ou em outras publicações de código aberto, mas a reutilização deste código em uma publicação é regida pelas Regras da Casa.

Aviso legal

As informações e publicações não devem ser e não constituem conselhos ou recomendações financeiras, de investimento, de negociação ou de qualquer outro tipo, fornecidas ou endossadas pela TradingView. Leia mais em Termos de uso.

Gostaria de usar essa biblioteca?

Copie a seguinte linha e cole-a em seu script.