SimpleCryptoLife

InitialiseArrays

Library "InitialiseArrays"
@description: Efficiently create arrays, populating them with an arbitrary number of elements and setting their starting values. Works with a mix of typed and na values.

A limitation of the built-in functions to create arrays is that while you can create and populate arrays with a single command, you can only set all elements to the same value in this way.
Or, you can create an array from a set of values or variables, but you can't include any na values.
Now, it's easy enough to work around this, but I wanted to make something more efficient (because I want to use lots of arrays), hence this library.
Calling a function from here is more efficient because you only do it once (assuming it's a var) and don't evaluate an if condition each run, and don't create unnecessary variables.
It's also easier to read and takes less space.

f_initialiseBoolArray()
@function f_initialiseBoolArray(string _values) Creates a boolean array, populated with the values that you specify in the input string.
@param _values is a string that contains a comma-separated list of the values that you want to initialise the boolean array with. Values other than true, false, and na are disregarded. Spaces are disregarded.
@returns Returns a boolean array of arbitrary length.

f_initialiseFloatArray()
@function f_initialiseFloatArray(string _values) Creates a float array, populated with the values that you specify in the input string.
@param _values is a string that contains a comma-separated list of the values that you want to initialise the float array with. Non-numerical entries are converted to NaN values. Spaces are disregarded.
@returns Returns a float array of arbitrary length.

f_initialiseIntArray()
@function f_initialiseIntArray(string _values) Creates an int array, populated with the values that you specify in the input string.
@param _values is a string that contains a comma-separated list of the values that you want to initialise the int array with. Floating-point numbers are rounded down to the nearest integer. Any na values are preserved. Spaces are disregarded.
@returns Returns a float array of arbitrary length.

V1 includes functions for bools, floats, and ints. I might extend it if people want.

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.