Extended Array Functions
The data2d and data3d objects extend several of the built-in array functions, offering a seamless and intuitive experience for performing common array manipulations directly within these objects.
includes()
Checks if value is included. This method extends Pine Script's array.includes() function.
- Name
this
- Type
- data2d
- Description
A data2d object.
- Name
value
- Type
- object
- Description
Any object of data type string, float, integer (including Unix timestamp), boolean and color.
- Name
alt
- Type
- bool
- Description
Use true for checking alternate values, false for main values. Optional. The default is false.
- Name
returns
- Type
- bool
- Description
A boolean value.
pkIncludes()
Check if a value is included in a primary key. This method extends Pine Script's array.includes() function.
- Name
this
- Type
- data2d
- Description
A data2d object.
- Name
primaryKey
- Type
- string
- Description
A primary key used for searching.
- Name
value
- Type
- object
- Description
Any object of data type string, float, integer (including Unix timestamp), boolean and color.
- Name
alt
- Type
- bool
- Description
Use true for checking alternate values, false for main values. Optional. The default is false.
- Name
returns
- Type
- bool
- Description
A boolean value.
dkIncludes()
Check if a value is included in a data key. This method extends Pine Script's array.includes() function.
- Name
this
- Type
- data2d
- Description
A data2d object.
- Name
dataKey
- Type
- string
- Description
A data key used for searching.
- Name
value
- Type
- object
- Description
Any object of data type string, float, integer (including Unix timestamp), boolean and color.
- Name
alt
- Type
- bool
- Description
Use true for checking alternate values, false for main values. Optional. The default is false.
- Name
returns
- Type
- bool
- Description
A boolean value.
set()
Modifies the value linked to the specified key(s). This method extends Pine Script's array.set() function.
- Name
this
- Type
- object
- Description
An obect of type data2d or data3d.
- Name
key
- Type
- string
- Description
A key used for searching. This parameter is only available with data2d object; not available when using data3d object.
- Name
primaryKey
- Type
- string
- Description
A primary key used for searching. This parameter is only available with data3d object; not available when using data2d object.
- Name
dataKey
- Type
- string
- Description
A data key used for searching. This parameter is only available with data3d object; not available when using data2d object.
- Name
value
- Type
- object
- Description
Any object of data type string, float, integer (including Unix timestamp), boolean and color.
- Name
alt
- Type
- bool
- Description
Switch between main or alternate value. Use true for alternate. Optional. The default is false.
- Name
returns
- Type
- object
- Description
This data2d or data3d object.
push()
Push a new key and value pair into a data2d object. This method extends Pine Script's array.push() function.
- Name
this
- Type
- data2d
- Description
A data2d object.
- Name
key
- Type
- string
- Description
A key used for searching. This parameter is only available with data2d object; not available when using data3d object.
- Name
value
- Type
- object
- Description
Any object of data type string, float, integer (including Unix timestamp), boolean and color.
- Name
altValue
- Type
- object
- Description
Any object of data type string, float, integer (including Unix timestamp), boolean and color. It must match the data type of the kv object. Optional. The default is na.
- Name
timestamp
- Type
- bool
- Description
A boolean flag to indicate if the integer value is of timestamp data type. Use true for timestamp values. This parameter is only available with integer values (includes timestamps); for all other cases, not available. Optional. The default is na.
- Name
timezone
- Type
- string
- Description
A string representing timezone in UTC/GMT notation (e.g., "UTC-5", "GMT+0530") or as an IANA time zone database name (e.g., "America/New_York"). This parameter is only available with integer values (includes timestamps); for all other cases, not available. Optional. The default is na.
- Name
format
- Type
- string
- Description
A string format. Optional. The default is na.
- Name
returns
- Type
- data2d
- Description
This data2d object.
pkPush()
Push a new primary key and key-value pairs into a data3d object. This method extends Pine Script's array.push() function.
- Name
this
- Type
- data3d
- Description
A data3d object.
- Name
pkv
- Type
- pkv
- Description
A pkv object.
- Name
returns
- Type
- data3d
- Description
This data3d object.
remove()
Removes the key and data of the specified key. If alt is true, then removes only alternate value. This method extends Pine Script's array.remove() function.
- Name
this
- Type
- data2d
- Description
A data2d object.
- Name
key
- Type
- string
- Description
A key used for searching.
- Name
alt
- Type
- bool
- Description
Switch between main or alternate value. Use true for alternate. Optional. The default is false.
- Name
returns
- Type
- data2d
- Description
This data2d object.
pkRemove()
Removes the primary key and all its data. This method extends Pine Script's array.remove() function.
- Name
this
- Type
- data3d
- Description
A data3d object.
- Name
primaryKey
- Type
- string
- Description
A primary key used for searching.
- Name
returns
- Type
- data3d
- Description
This data3d object.
sort()
Sort data2d keys based on data2d values. This method extends Pine Script's array.sort() function.
- Name
this
- Type
- data2d
- Description
A data2d object.
- Name
asc
- Type
- bool
- Description
Use true for ascending order, false for Descending order. Optional. The default is true.
- Name
change
- Type
- bool
- Description
Sorts using change percent if true. Optional. The default is na.
- Name
returns
- Type
- data2d
- Description
A sorted data2d object.
sort()
Sort data3d primary keys based on specified data key. This method extends Pine Script's array.sort() function.
- Name
this
- Type
- data2d
- Description
A data2d object.
- Name
dataKey
- Type
- string
- Description
The data key used for sorting.
- Name
asc
- Type
- bool
- Description
Use true for ascending order, false for Descending order. Optional. The default is true.
- Name
change
- Type
- bool
- Description
Sorts using change percent if true. Optional. The default is na.
- Name
returns
- Type
- data2d
- Description
A sorted data2d object.
format()
Set custom format for an object. This method extends Pine Script's str.format() and str.format_time() functions.
- Name
this
- Type
- object
- Description
An object of type kv, data2d or data3d.
- Name
format
- Type
- string
- Description
A format string.
- Name
timezone
- Type
- string
- Description
A timezone value. This parameter is only available with kv object; for all other cases, not available. Optional. The default is na.
- Name
returns
- Type
- object
- Description
This object.