CODESCRIPT

Arrays

57 entries. What each one takes, what it returns, and a working example.

array(...)

A new array holding the given elements.

...
any
The elements to put in the array (as many as you like; numbers, text, booleans, na may be mixed).
NOTE

Builds an array by listing elements directly; mixed types are allowed, but numeric summaries (arraySum, arrayAvg) count only the numbers.

CODESCRIPT
a = array(10, 20, 30)
plot(arraySum(a))

10+20+30 = 60 (the array sum is plotted on every bar).

CODESCRIPT
w = array(0.5, 0.3, 0.2)
plot(arraySum(w))

A weight vector: 0.5+0.3+0.2 = 1.0 (an array can be built from float values).

arrayAbs(dizi)

A NEW array holding each element's absolute value (the original is unchanged).

dizi
array
The array to take absolute values of.
NOTE

Works element-wise; non-numeric elements are copied as-is. It does not mutate the original.

CODESCRIPT
a = arrayFrom(-3, 4, -5)
b = arrayAbs(a)
plot(arraySum(b))

|−3|+|4|+|−5| = 12.

CODESCRIPT
a = arrayFrom(-2, -4, -6)
b = arrayAbs(a)
plot(arrayMax(b))

The absolute values are 2,4,6 → the largest is 6 (the biggest magnitude).

arrayAvg(dizi)

The mean of numeric elements; na if there are none.

dizi
array
The array to average.
NOTE

Counts only numbers. On an empty or fully non-numeric array it returns na (not 0).

CODESCRIPT
a = arrayFrom(10, 20, 30)
plot(arrayAvg(a))

The mean: 20.

CODESCRIPT
var w = arrayNew(0)
arrayPush(w, close)
if arraySize(w) > 10 {
  arrayShift(w)
}
plot(arrayAvg(w))

The average of the last 10 closes — an SMA(10) built by hand with an array.

arrayBinarySearch(dizi, değer)

The index of the value; -1 if not found.

dizi
array
An ASCENDING sorted numeric array.
değer
number
The value to search for.
NOTE

Assumes the array is ASCENDING sorted; on an unsorted array the result is meaningless. Much faster than linear search (arrayIndexOf) on large arrays.

CODESCRIPT
a = arrayFrom(10, 20, 30, 40)
plot(arrayBinarySearch(a, 30))

The value 30 is at position 2.

CODESCRIPT
a = arrayFrom(10, 20, 30, 40)
plot(arrayBinarySearch(a, 25))

25 is not in the sorted array → -1 (binary search found nothing). The array must be sorted.

arrayBinarySearchLeftmost(dizi, değer)

The first position equal to the value; if absent, the position where it would be inserted (leftmost insertion point).

dizi
array
An ASCENDING sorted numeric array.
değer
number
The value to search for.
NOTE

Gives the leftmost position where the value could go in a sorted array. If the value repeats it returns the first copy's index.

CODESCRIPT
a = arrayFrom(1, 2, 2, 2, 3)
plot(arrayBinarySearchLeftmost(a, 2))

The first 2 is at position 1.

CODESCRIPT
a = arrayFrom(1, 3, 5)
plot(arrayBinarySearchLeftmost(a, 4))

4 is not in the array; the (leftmost) position where it would be inserted is 2. Requires a sorted array.

arrayBinarySearchRightmost(dizi, değer)

The last position equal to the value; if absent, the position of the last element smaller than it (rightmost).

dizi
array
An ASCENDING sorted numeric array.
değer
number
The value to search for.
NOTE

Gives the position of the value's last copy, or of the last element smaller than it, in a sorted array.

CODESCRIPT
a = arrayFrom(1, 2, 2, 2, 3)
plot(arrayBinarySearchRightmost(a, 2))

The last 2 is at position 3.

CODESCRIPT
a = arrayFrom(1, 2, 3, 4)
plot(arrayBinarySearchRightmost(a, 3))

3 occurs once → the rightmost match is that same position: 2. With duplicates it would give the rightmost one.

arrayClear(dizi)

Returns nothing (na); it empties the array in place.

dizi
array
The array to empty.
NOTE

Deletes all elements, size becomes 0; the array itself (the reference) is kept.

CODESCRIPT
a = arrayFrom(1, 2, 3)
arrayClear(a)
plot(arraySize(a))

Emptied → size 0.

CODESCRIPT
var w = arrayNew(0)
arrayPush(w, close)
if arraySize(w) >= 10 {
  arrayClear(w)
}
plot(arraySize(w))

When the size reaches 10 the array is cleared → a 1..10 sawtooth (a periodic bucket).

arrayConcat(dizi1, dizi2)

The extended dizi1 (same reference).

dizi1
array
The target array to extend (the result is appended here).
dizi2
array
The source array whose elements are appended.
NOTE

Appends dizi2's elements to the end of dizi1 and mutates dizi1. dizi2 is left untouched.

CODESCRIPT
a = arrayFrom(1, 2)
b = arrayFrom(3, 4)
arrayConcat(a, b)
plot(arraySize(a))

dizi1 grew to 4 elements.

CODESCRIPT
a = arrayFrom(1, 2)
b = arrayFrom(3, 4, 5)
arrayConcat(a, b)
plot(arrayAvg(a))

The two arrays are merged (1,2,3,4,5) → average 3 (merge, then reduce).

arrayCopy(dizi)

An independent new array with the same elements.

dizi
array
The array to copy.
NOTE

Returns a shallow copy; mutating the copy does not affect the original. Used to preserve the original before in-place functions (arraySort, arrayReverse).

CODESCRIPT
a = arrayFrom(3, 1, 2)
b = arrayCopy(a)
arraySort(b, true)
plot(arrayFirst(a))

The copy is sorted; the original's first element is still 3.

CODESCRIPT
a = arrayFrom(1, 2, 3)
b = arrayCopy(a)
arrayPush(b, 4)
plot(arraySize(a))

An element is pushed to the copy but the original is untouched → the original size is still 3 (an independent copy).

arrayCovariance(dizi1, dizi2, biased?)

The covariance of the two arrays; na if fewer than 2 common numeric elements.

dizi1
array
The first numeric array.
dizi2
array
The second numeric array.
biased
bool
true for biased (divide by n), false for unbiased (n-1) (optional; defaults to true).
NOTE

Measures the direction and strength with which two series move together. If the arrays differ in length they are paired up to the shorter one. The default divisor is biased (n).

CODESCRIPT
a = arrayFrom(1, 2, 3)
b = arrayFrom(2, 4, 6)
plot(arrayCovariance(a, b))

Two arrays rising together → positive covariance (≈1.33, biased).

CODESCRIPT
a = arrayFrom(1, 2, 3)
b = arrayFrom(6, 4, 2)
plot(arrayCovariance(a, b))

As one rises the other falls → negative covariance (≈ -1.33).

arrayEvery(dizi)

true if all elements are truthy/non-zero; false for an empty array.

dizi
array
The array to check.
NOTE

Evaluates each element for truthiness: 0/na/false count as false. Returns false for an empty array.

CODESCRIPT
a = arrayFrom(1, 1, 1)
plot(arrayEvery(a) ? 1 : 0)

All elements are non-zero → true.

CODESCRIPT
a = arrayFrom(1, 0, 1)
plot(arrayEvery(a) ? 1 : 0)

One element is 0 → arrayEvery is false (0). Not all elements are non-zero.

arrayFill(dizi, değer, başla?, bitir?)

Returns nothing (na); it fills the array in place.

dizi
array
The array to fill.
değer
any
The value to write into the range.
başla
number
Start index (inclusive; optional, defaults to 0; negative = from the end).
bitir
number
End index (exclusive; optional, defaults to array end; negative = from the end).
NOTE

Writes the same value into every element of the range; it does not change the size. Fills the whole array if no range is given.

CODESCRIPT
a = arrayNew(5, 0)
arrayFill(a, 9, 1, 3)
plot(arraySum(a))

Elements 1 and 2 set to 9 → sum is 18.

CODESCRIPT
a = arrayNew(4, 1)
arrayFill(a, 0)
plot(arraySum(a))

With no range given the whole array is filled with 0 → sum 0 (a bulk reset).

arrayFirst(dizi)

The first element; na if the array is empty.

dizi
array
The array to read the first element of.
NOTE

Same as arrayGet(array, 0) but reads clearer; it does not modify the array.

CODESCRIPT
a = arrayFrom(11, 22, 33)
plot(arrayFirst(a))

The first element: 11.

CODESCRIPT
var w = arrayNew(0)
arrayPush(w, close)
if arraySize(w) > 5 {
  arrayShift(w)
}
plot(arrayFirst(w))

The first (oldest) element of a 5-bar rolling window — the close from 5 bars ago.

arrayFrom(...değerler)

A new array made from the given values.

...
any
The values to place into the array.
NOTE

Does the same job as array; use whichever reads better to you.

CODESCRIPT
a = arrayFrom(3, 1, 2)
plot(arrayMax(a))

The largest value in the array: 3.

CODESCRIPT
a = arrayFrom(5, 1, 9, 3, 7)
plot(arrayMedian(a))

The input may be unordered: sorted it is 1,3,5,7,9 → the exact middle (median) is 5.

arrayGet(dizi, i)

The element at i; returns na if the index is out of range (no error).

dizi
array
The array to read from.
i
number
Element index; 0 is the first element, a negative value counts from the end (-1 is the last).
NOTE

Negative index reaches from the end. An out-of-range index does not crash, it yields na — you can check the result with na().

CODESCRIPT
a = arrayFrom(10, 20, 30)
plot(arrayGet(a, -1))

The last element: 30.

CODESCRIPT
a = arrayFrom(close, close[1], close[2])
plot(arrayGet(a, 0) > arrayGet(a, 2) ? 1 : 0)

Access by positive index: 1 if the current close (element 0) is above the close two bars ago (element 2).

arrayIncludes(dizi, değer)

true if the value is in the array, false otherwise.

dizi
array
The array to search in.
değer
any
The value whose presence is queried.
NOTE

Uses type-strict equality: numbers match numbers, text matches text, booleans match booleans.

CODESCRIPT
a = arrayFrom(1, 2, 3)
plot(arrayIncludes(a, 2) ? 1 : 0)

2 is in the array → true (plotted as 1).

CODESCRIPT
a = arrayFrom(1, 5, 9)
plot(arrayIncludes(a, 4) ? 1 : 0)

4 is not in the array → false (plotted as 0) — the negative case of a membership test.

arrayIndexOf(dizi, değer)

The index of the first match; -1 if not found.

dizi
array
The array to search in.
değer
any
The value whose position is sought.
NOTE

Scans from the front and returns the first match's position. Applies type-strict equality. To search from the end, use arrayLastIndexOf.

CODESCRIPT
a = arrayFrom(5, 6, 7)
plot(arrayIndexOf(a, 7))

The value 7 is at position 2.

CODESCRIPT
a = arrayFrom(5, 6, 7)
plot(arrayIndexOf(a, 99))

99 is not in the array → -1 (the not-found sentinel).

arrayInsert(dizi, i, değer)

Returns nothing (na); it grows the array in place.

dizi
array
The array to insert into.
i
number
Insert position (negative = from the end; clamped to front/back if out of range).
değer
any
The value to insert.
NOTE

Inserts an element at the position; following elements shift right. If the position exceeds the size it goes to the end, if too small to the front.

CODESCRIPT
a = arrayFrom(1, 3)
arrayInsert(a, 1, 2)
plot(arrayGet(a, 1))

2 inserted at position 1 → array is 1,2,3.

CODESCRIPT
a = arrayFrom(1, 2, 3)
arrayInsert(a, 0, 0)
plot(arrayFirst(a))

0 is inserted at position 0 (the front) → the new first element is 0.

arrayJoin(dizi, ayraç?)

A single text of the elements joined by the separator.

dizi
array
The array to turn into text.
ayraç
string
The separator placed between elements (optional; defaults to ",").
NOTE

Converts each element to text and joins with the separator. Uses a comma when none is given.

CODESCRIPT
a = arrayFrom(1, 2, 3)
s = arrayJoin(a, "-")
plot(s == "1-2-3" ? 1 : 0)

Elements joined with "-" → "1-2-3".

CODESCRIPT
a = arrayFrom(1, 2, 3)
s = arrayJoin(a)
plot(s == "1,2,3" ? 1 : 0)

With no separator given, the default is a comma → "1,2,3".

arrayLast(dizi)

The last element; na if the array is empty.

dizi
array
The array to read the last element of.
NOTE

Same as arrayGet(array, -1) but reads clearer; it does not modify the array.

CODESCRIPT
a = arrayFrom(11, 22, 33)
plot(arrayLast(a))

The last element: 33.

CODESCRIPT
var w = arrayNew(0)
arrayPush(w, high)
plot(arrayLast(w))

high is pushed every bar; the last element is the most recently added (current) high.

arrayLastIndexOf(dizi, değer)

The index of the last match; -1 if not found.

dizi
array
The array to search in.
değer
any
The value whose position is sought.
NOTE

Scans from the end toward the front and returns the last match's position. Applies type-strict equality.

CODESCRIPT
a = arrayFrom(5, 6, 5)
plot(arrayLastIndexOf(a, 5))

The last 5 is at position 2.

CODESCRIPT
a = arrayFrom(5, 6, 5)
plot(arrayLastIndexOf(a, 9))

9 is not in the array at all → -1 (a last-index search also finds nothing).

arrayMax(dizi)

The largest numeric element; na if there are none.

dizi
array
The array to find the maximum of.
NOTE

Compares only numbers; text/na are skipped.

CODESCRIPT
a = arrayFrom(7, 3, 9)
plot(arrayMax(a))

The maximum: 9.

CODESCRIPT
var w = arrayNew(0)
arrayPush(w, high)
if arraySize(w) > 20 {
  arrayShift(w)
}
plot(arrayMax(w))

The highest high of the last 20 bars — a rolling resistance (Donchian upper band).

arrayMedian(dizi)

The median value; na if empty. For an even count it is the average of the middle two.

dizi
array
The array to find the median of.
NOTE

Sorts the values and takes the middle; it is less sensitive to outliers than the mean.

CODESCRIPT
a = arrayFrom(1, 2, 3, 4)
plot(arrayMedian(a))

Average of the middle two: (2+3)/2 = 2.5.

CODESCRIPT
a = arrayFrom(5, 1, 9, 3, 7)
plot(arrayMedian(a))

An odd number of elements: sorted 1,3,5,7,9 → the exact middle 5 (unlike the even-count case).

arrayMin(dizi)

The smallest numeric element; na if there are none.

dizi
array
The array to find the minimum of.
NOTE

Compares only numbers; text/na are skipped.

CODESCRIPT
a = arrayFrom(7, 3, 9)
plot(arrayMin(a))

The minimum: 3.

CODESCRIPT
var w = arrayNew(0)
arrayPush(w, low)
if arraySize(w) > 20 {
  arrayShift(w)
}
plot(arrayMin(w))

The lowest low of the last 20 bars — a rolling support (Donchian lower band).

arrayMode(dizi)

The most frequent numeric value; the smallest on a tie; na if empty.

dizi
array
The array to find the most frequent value in.
NOTE

If several values share the top frequency it returns the smallest. Counts only numeric elements.

CODESCRIPT
a = arrayFrom(2, 2, 1, 1)
plot(arrayMode(a))

1 and 2 tie in frequency → the smaller: 1.

CODESCRIPT
a = arrayFrom(1, 3, 3, 3, 2)
plot(arrayMode(a))

The value 3 occurs three times → the most frequent (mode) is 3 (a clear winner).

arrayNew(boyut, başlangıç?)

A new array of size elements, each equal to the initial value.

boyut
number
Number of elements the array will have.
başlangıç
any
Initial value for every element (optional; defaults to 0).
NOTE

Used to allocate a fixed-size array up front, then fill it with arraySet/arrayFill. Elements are 0 when no initial value is given.

CODESCRIPT
a = arrayNew(4, 5)
plot(arraySum(a))

All 4 elements are 5 → sum is 20.

CODESCRIPT
a = arrayNew(3, 2)
arrayPush(a, 4)
plot(arrayAvg(a))

Three elements are built with 2, then a 4 is pushed → average (2+2+2+4)/4 = 2.5.

arrayNewBool(boyut, başlangıç?)

A new array of size elements, each equal to the initial value.

boyut
number
Number of elements.
başlangıç
bool
Initial value for each element (optional).
NOTE

Behaves the same as arrayNew; signals a boolean array. Defaults to 0 (acts falsy) when no initial value is given.

CODESCRIPT
a = arrayNewBool(3, true)
plot(arrayEvery(a) ? 1 : 0)

All elements true → arrayEvery is true.

CODESCRIPT
a = arrayNewBool(3, false)
arraySet(a, 1, true)
plot(arraySome(a) ? 1 : 0)

Three elements are built as false, then element 1 is set to true → arraySome is true (1).

arrayNewBox(boyut, başlangıç?)

A new box array of size elements.

boyut
number
Number of elements.
başlangıç
any
Initial value for each element (optional; defaults to 0).
NOTE

Behaves the same as arrayNew; a type-specific constructor signaling intent to hold box. Elements are 0 if no initial value is given (usually filled by passing na/an initial).

CODESCRIPT
a = arrayNewBox(2)
plot(arraySize(a))

A 2-element array is allocated.

CODESCRIPT
var kutular = arrayNewBox(0)
plot(arraySize(kutular))

An empty (0-element) box-handle store kept with var — carried across bars, starting at size 0.

arrayNewColor(boyut, başlangıç?)

A new color array of size elements.

boyut
number
Number of elements.
başlangıç
any
Initial value for each element (optional; defaults to 0).
NOTE

Behaves the same as arrayNew; a type-specific constructor signaling intent to hold color. Elements are 0 if no initial value is given (usually filled by passing na/an initial).

CODESCRIPT
a = arrayNewColor(2)
plot(arraySize(a))

A 2-element array is allocated.

CODESCRIPT
var palet = arrayNewColor(2, "#26a69a")
arraySet(palet, 1, "#ef5350")
plot(arraySize(palet))

Two colors are allocated, element 1 is replaced with a sell color → a buy/sell palette, size 2.

arrayNewFloat(boyut, başlangıç?)

A new array of size numeric elements, each equal to the initial value.

boyut
number
Number of elements.
başlangıç
number
Initial value for each element (optional; defaults to 0).
NOTE

Behaves the same as arrayNew; signals a numeric (float) array. Defaults to 0 when no initial value is given.

CODESCRIPT
a = arrayNewFloat(3, 1.5)
plot(arraySum(a))

All 3 elements are 1.5 → sum is 4.5.

CODESCRIPT
a = arrayNewFloat(3, close)
plot(arrayGet(a, 0))

Three elements are built with the current close → element 0 is that bar's close (the initial value can be a series).

arrayNewInt(boyut, başlangıç?)

A new array of size elements, each equal to the initial value.

boyut
number
Number of elements.
başlangıç
number
Initial value for each element (optional; defaults to 0).
NOTE

Behaves the same as arrayNew; signals an integer array. Numeric storage is floating-point; using values as integers is up to you.

CODESCRIPT
a = arrayNewInt(4, 2)
plot(arraySum(a))

All 4 elements are 2 → sum is 8.

CODESCRIPT
a = arrayNewInt(3, 10)
arraySet(a, 0, 5)
plot(arrayMin(a))

Three elements are built with 10, then element 0 is set to 5 → the minimum is 5.

arrayNewLabel(boyut, başlangıç?)

A new label array of size elements.

boyut
number
Number of elements.
başlangıç
any
Initial value for each element (optional; defaults to 0).
NOTE

Behaves the same as arrayNew; a type-specific constructor signaling intent to hold label. Elements are 0 if no initial value is given (usually filled by passing na/an initial).

CODESCRIPT
a = arrayNewLabel(2)
plot(arraySize(a))

A 2-element array is allocated.

CODESCRIPT
a = arrayNewLabel(3)
arrayPop(a)
plot(arraySize(a))

Three label slots are allocated, one is popped → size 2.

arrayNewLine(boyut, başlangıç?)

A new line array of size elements.

boyut
number
Number of elements.
başlangıç
any
Initial value for each element (optional; defaults to 0).
NOTE

Behaves the same as arrayNew; a type-specific constructor signaling intent to hold line. Elements are 0 if no initial value is given (usually filled by passing na/an initial).

CODESCRIPT
a = arrayNewLine(2)
plot(arraySize(a))

A 2-element array is allocated.

CODESCRIPT
a = arrayNewLine(4)
arrayRemove(a, 0)
plot(arraySize(a))

Four line slots are allocated, element 0 is removed → size 3.

arrayNewLinefill(boyut, başlangıç?)

A new line fill array of size elements.

boyut
number
Number of elements.
başlangıç
any
Initial value for each element (optional; defaults to 0).
NOTE

Behaves the same as arrayNew; a type-specific constructor signaling intent to hold line fill. Elements are 0 if no initial value is given (usually filled by passing na/an initial).

CODESCRIPT
a = arrayNewLinefill(2)
plot(arraySize(a))

A 2-element array is allocated.

CODESCRIPT
a = arrayNewLinefill(2)
arrayClear(a)
plot(arraySize(a))

Two linefill slots are allocated, then the array is cleared → size 0.

arrayNewString(boyut, başlangıç?)

A new array of size elements, each equal to the initial text.

boyut
number
Number of elements.
başlangıç
string
Initial text for each element (optional; empty text "" if omitted).
NOTE

Builds a text array. Unlike the other arrayNew families: when no initial value is given the element is EMPTY TEXT (""), not 0.

CODESCRIPT
a = arrayNewString(2)
plot(arrayGet(a, 0) == "" ? 1 : 0)

No initial value → elements are empty text.

CODESCRIPT
a = arrayNewString(2, "AL")
arraySet(a, 1, "SAT")
plot(arrayIndexOf(a, "SAT"))

Two elements are built as "AL", then element 1 is set to "SAT" → "SAT" is at position 1.

arrayNewTable(boyut, başlangıç?)

A new table array of size elements.

boyut
number
Number of elements.
başlangıç
any
Initial value for each element (optional; defaults to 0).
NOTE

Behaves the same as arrayNew; a type-specific constructor signaling intent to hold table. Elements are 0 if no initial value is given (usually filled by passing na/an initial).

CODESCRIPT
a = arrayNewTable(2)
plot(arraySize(a))

A 2-element array is allocated.

CODESCRIPT
a = arrayNewTable(1)
b = arrayNewTable(2)
arrayConcat(a, b)
plot(arraySize(a))

A 1-element and a 2-element table array are concatenated → size 3.

arrayPercentRank(dizi, indeks)

The 0–100 percentile rank of element i; na if the index is invalid/non-numeric; 0 with fewer than 2 numeric elements.

dizi
array
The array to rank a position within.
indeks
number
Index of the element whose percentile rank is computed.
NOTE

Tells what percentile the given element sits at relative to the array: how many elements are less than or equal to it. 0 = smallest, 100 = largest.

CODESCRIPT
a = arrayFrom(10, 20, 30, 40, 50)
plot(arrayPercentRank(a, 2))

The value 30 sits at the 50th percentile of the array.

CODESCRIPT
a = arrayFrom(10, 20, 30, 40, 50)
plot(arrayPercentRank(a, 4))

The largest element (50, index 4) sits at the 100th percentile of the array.

arrayPercentileLinearInterpolation(dizi, yüzde)

The linearly interpolated percentile value; na if empty.

dizi
array
The array to take the percentile of.
yüzde
number
Percentile between 0–100 (optional; defaults to 50 = median).
NOTE

Finds the position among sorted values by linear interpolation; the result may not be an actual array element. Gives a smoother/continuous percentile.

CODESCRIPT
a = arrayFrom(1, 2, 3, 4)
plot(arrayPercentileLinearInterpolation(a, 50))

The 50th percentile (median) = 2.5.

CODESCRIPT
a = arrayFrom(1, 2, 3, 4)
plot(arrayPercentileLinearInterpolation(a, 25))

The 25th percentile with linear interpolation = 1.75 (a slice other than the median).

arrayPercentileNearestRank(dizi, yüzde)

The percentile value by the nearest-rank method; na if empty.

dizi
array
The array to take the percentile of.
yüzde
number
Percentile between 0–100 (optional; defaults to 50).
NOTE

Rounds the rank matching the percentile up and returns the ACTUAL element at that position; it does not produce interpolated values.

CODESCRIPT
a = arrayFrom(1, 2, 3, 4)
plot(arrayPercentileNearestRank(a, 50))

The 50th nearest-rank → actual array value 2.

CODESCRIPT
a = arrayFrom(10, 20, 30, 40, 50)
plot(arrayPercentileNearestRank(a, 90))

The 90th percentile by nearest rank → the real value at the top end, 50.

arrayPop(dizi)

The removed last element; na if the array is empty.

dizi
array
The array to remove the last element from.
NOTE

Shortens the array by one element and returns the removed value. On an empty array it does not crash, it returns na.

CODESCRIPT
a = arrayFrom(1, 2, 3)
x = arrayPop(a)
plot(x)

The last element is removed and returned: 3.

CODESCRIPT
a = arrayFrom(1, 2, 3, 4)
arrayPop(a)
arrayPop(a)
plot(arrayLast(a))

The last element is popped twice (4, then 3) → the remaining last element is 2 (LIFO).

arrayPush(dizi, değer)

The new element count after the append.

dizi
array
The array to append to.
değer
any
The value to add at the end.
NOTE

Grows the array by one element. The core tool for continuous accumulation (a log, a results list).

CODESCRIPT
a = arrayNew(0)
arrayPush(a, close)
plot(arraySize(a))

close is appended each bar; the size grows with the bar count.

CODESCRIPT
var sinyaller = arrayNew(0)
if crossover(close, sma(close, 20)) {
  arrayPush(sinyaller, close)
}
plot(arraySize(sinyaller))

close is pushed only on an up-cross of the 20-SMA; the size is the number of signals so far.

arrayRange(dizi)

The difference between the largest and smallest numeric element (max - min); na if empty.

dizi
array
The array to measure the range of.
NOTE

The simplest spread measure; very sensitive to a single outlier.

CODESCRIPT
a = arrayFrom(3, 7, 1)
plot(arrayRange(a))

7 - 1 = 6.

CODESCRIPT
a = arrayFrom(-5, 0, 5, 10)
plot(arrayRange(a))

Max - min = 10 - (-5) = 15 (works with negative values too).

arrayRemove(dizi, i)

The removed element; na if the index is out of range.

dizi
array
The array to remove from.
i
number
Index to remove (negative = from the end).
NOTE

Removes the element at the position, shifts the rest left, and returns the removed value.

CODESCRIPT
a = arrayFrom(5, 6, 7)
x = arrayRemove(a, 1)
plot(x)

Element 1 is removed and returned: 6.

CODESCRIPT
a = arrayFrom(5, 6, 7)
arrayRemove(a, 0)
plot(arrayFirst(a))

Element 0 (5) is removed and the rest shift down → the new first element is 6.

arrayReverse(dizi)

Returns nothing (na); it reverses the array order in place.

dizi
array
The array to reverse.
NOTE

Flips the element order front-to-back; it mutates the array.

CODESCRIPT
a = arrayFrom(1, 2, 3)
arrayReverse(a)
plot(arrayFirst(a))

Order reversed → the first element is now 3.

CODESCRIPT
a = arrayFrom(1, 2, 3, 4)
arrayReverse(a)
plot(arrayLast(a))

The order is reversed → the last element is now the original first, 1.

arraySet(dizi, i, değer)

Returns nothing (na); it modifies the array in place.

dizi
array
The array to modify.
i
number
Index to write (negative = from the end).
değer
any
The value to store.
NOTE

Overwrites an existing position; it does not grow the array. If the index is out of range it silently does nothing.

CODESCRIPT
a = arrayNew(3, 0)
arraySet(a, 1, 9)
plot(arraySum(a))

Element 1 set to 9, others 0 → sum is 9.

CODESCRIPT
a = arrayNew(3, 0)
arraySet(a, 0, high)
arraySet(a, 2, low)
plot(arrayGet(a, 0) - arrayGet(a, 2))

high is written to element 0 and low to element 2; their difference is the bar's range (high - low).

arrayShift(dizi)

The removed first element; na if the array is empty.

dizi
array
The array to remove the first element from.
NOTE

Removes from the front and shifts the rest forward. Used in queue (FIFO) fashion.

CODESCRIPT
a = arrayFrom(1, 2, 3)
x = arrayShift(a)
plot(x)

The first element is removed and returned: 1.

CODESCRIPT
a = arrayFrom(10, 20, 30)
arrayShift(a)
plot(arrayFirst(a))

One element is dropped from the front (10) → the new first element is 20.

arraySize(dizi)

The number of elements in the array.

dizi
array
The array to measure.
NOTE

Returns 0 for an empty array. Used for loop bounds and emptiness checks.

CODESCRIPT
a = arrayFrom(5, 6, 7)
plot(arraySize(a))

3 elements.

CODESCRIPT
var w = arrayNew(0)
arrayPush(w, close)
if arraySize(w) > 20 {
  arrayShift(w)
}
plot(arraySize(w) == 20 ? 1 : 0)

1 once the 20-bar rolling window is full (ready), 0 for the first 20 bars — a warmup gate.

arraySlice(dizi, başla, bitir?)

A new copy array of the start..end range.

dizi
array
The source array (unchanged).
başla
number
Start index (inclusive; negative = from the end).
bitir
number
End index (exclusive; optional, defaults to array end; negative = from the end).
NOTE

Does NOT modify the source; returns an independent sub-array copy. end is exclusive.

CODESCRIPT
a = arrayFrom(0, 1, 2, 3, 4)
b = arraySlice(a, 1, 3)
plot(arraySize(b))

Elements 1 and 2 → a 2-element copy.

CODESCRIPT
a = arrayFrom(1, 2, 3, 4, 5)
b = arraySlice(a, 2)
plot(arraySum(b))

From element 2 to the end (no end given) → 3,4,5; sum 12.

arraySome(dizi)

true if at least one element is truthy/non-zero; false if none is (or if empty).

dizi
array
The array to check.
NOTE

Evaluates each element for truthiness; becomes true at the first truthy element. false for an empty array.

CODESCRIPT
a = arrayFrom(0, 0, 1)
plot(arraySome(a) ? 1 : 0)

One element is non-zero → true.

CODESCRIPT
a = arrayFrom(0, 0, 0)
plot(arraySome(a) ? 1 : 0)

All elements are 0 → arraySome is false (0). There is no non-zero element.

arraySort(dizi, artan?)

Returns nothing (na); it sorts the array in place.

dizi
array
The array to sort.
artan
bool
true for ascending, false for descending (optional; defaults to true).
NOTE

Sorts only numeric elements; non-numeric ones go to the end in their original order. It mutates the array — use arrayCopy first if you need a copy.

CODESCRIPT
a = arrayFrom(30, 10, 20)
arraySort(a, true)
plot(arrayFirst(a))

Sorted ascending → the first element is the smallest: 10.

CODESCRIPT
a = arrayFrom(30, 10, 20, 40)
arraySort(a, false)
plot(arrayFirst(a))

Descending sort (second argument false) → the first element is the largest: 40.

arraySortIndices(dizi, artan?)

An array of indices that would sort the array; the array itself is unchanged.

dizi
array
The array to derive the sort order of (unchanged).
artan
bool
true for ascending, false for descending (optional; defaults to true).
NOTE

Without mutating the array, gives the element positions that put it in order. Only numeric elements enter the ordering. Ideal for picking the best/worst N.

CODESCRIPT
a = arrayFrom(30, 10, 20)
b = arraySortIndices(a, true)
plot(arrayGet(b, 0))

The smallest value (10) is at position 1 → first index is 1.

CODESCRIPT
a = arrayFrom(30, 10, 20)
b = arraySortIndices(a, false)
plot(arrayGet(b, 0))

In descending order the largest value (30) is at position 0 → the first index is 0. The array itself is unchanged.

arrayStandardize(dizi)

A NEW array converting each element to its z-score (x−mean)/std; all zeros if the deviation is 0 or there are fewer than 2 elements.

dizi
array
The array to standardize.
NOTE

Rescales values to mean 0 and standard deviation 1 (using sample std). It does not mutate the original.

CODESCRIPT
a = arrayFrom(1, 2, 3)
b = arrayStandardize(a)
plot(arrayGet(b, 2))

The largest element is +1 std from the mean → 1.

CODESCRIPT
a = arrayFrom(10, 20, 30, 40, 50)
b = arrayStandardize(a)
plot(arrayGet(b, 0))

The first element (10, the smallest) is about 1.26 standard deviations below the mean → its z-score ≈ -1.26.

arrayStdev(dizi, biased?)

The sample standard deviation (square root of variance); na with fewer than 2 numeric elements.

dizi
array
The array to compute standard deviation of.
NOTE

Gives spread in the same unit as the values; the square root of arrayVariance.

CODESCRIPT
a = arrayFrom(2, 4, 4, 4, 5, 5, 7, 9)
plot(arrayStdev(a))

The sample standard deviation ≈ 2.14.

CODESCRIPT
var w = arrayNew(0)
arrayPush(w, close)
if arraySize(w) > 20 {
  arrayShift(w)
}
plot(arrayStdev(w))

The standard deviation of the last 20 closes — a rolling volatility measure.

arraySum(dizi)

The sum of numeric elements; 0 if there are no numeric elements.

dizi
array
The array to sum.
NOTE

Sums only numbers; it skips text/na elements. Yields 0 for an empty array.

CODESCRIPT
a = arrayFrom(10, 20, 30)
plot(arraySum(a))

The sum: 60.

CODESCRIPT
a = arrayFrom(close > open ? 1 : 0, close[1] > open[1] ? 1 : 0, close[2] > open[2] ? 1 : 0)
plot(arraySum(a))

Counts how many of the last 3 bars had close>open (0 to 3).

arrayUnshift(dizi, değer)

The new element count after the prepend.

dizi
array
The array to prepend to.
değer
any
The value to add at the front.
NOTE

Grows the array at the front; existing elements shift one position to the right.

CODESCRIPT
a = arrayFrom(2, 3)
arrayUnshift(a, 1)
plot(arrayFirst(a))

The new first element: 1.

CODESCRIPT
a = arrayFrom(3)
arrayUnshift(a, 2)
arrayUnshift(a, 1)
plot(arrayGet(a, 0))

2 then 1 are prepended → the array is 1,2,3; the first element is 1.

arrayVariance(dizi, biased?)

The sample variance (divided by n-1); na with fewer than 2 numeric elements.

dizi
array
The array to compute variance of.
NOTE

Measures the spread of the distribution; uses the n-1 (sample) divisor. Its square root is arrayStdev.

CODESCRIPT
a = arrayFrom(2, 4, 6)
plot(arrayVariance(a))

The sample variance: 4.

CODESCRIPT
a = arrayFrom(10, 10, 10, 10)
plot(arrayVariance(a))

All elements equal → no dispersion → variance 0.

split(metin, ayraç?)

A text array holding the parts.

metin
string
The text to split.
ayraç
string
The split separator (optional; defaults to ","; if an empty string is given each character becomes an element).
NOTE

Splits the text at the separator into an array. Uses a comma when none is given; an empty separator splits into characters.

CODESCRIPT
a = split("AL,SAT,BEKLE", ",")
plot(arraySize(a))

Split into 3 parts.

CODESCRIPT
p = split("AL,SAT,BEKLE", ",")
plot(arrayIndexOf(p, "SAT"))

The text is split on commas; among the parts "SAT" is at position 1 (parse, then find).