| Concept | Lipi | MQL4 | MQL5 | NinjaScript | Pine Script | thinkScript |
|---|---|---|---|---|---|---|
| Create an array | array.new, array.from, array.new_float, array.new_int | Caveat | Caveat | Caveat | Caveat | Absent |
| Arrays of drawing objects | array.new_line, array.new_label, array.new_box | Absent | Caveat | Caveat | Exact | Absent |
| Read and write an element | array.get, array.set | Caveat | Caveat | Caveat | Differs | Absent |
| Number of elements | array.length | Exact | Exact | Caveat | Caveat | Absent |
| Add or remove at the end | array.push, array.pop | Absent | Caveat | Caveat | Caveat | Absent |
| Add or remove at the start | array.unshift, array.shift | Absent | Caveat | Caveat | Caveat | Absent |
| Insert or remove at a position | array.insert, array.remove | Absent | Caveat | Caveat | Caveat | Absent |
| Empty or fill an array | array.clear, array.fill | Caveat | Caveat | Caveat | Exact | Absent |
| First and last element | array.first, array.last | Absent | Absent | Caveat | Exact | Absent |
| Find an element | array.includes, array.indexof, array.lastindexof, array.binary_search | Differs | Differs | Caveat | Caveat | Absent |
| Copy, slice and join arrays | array.copy, array.slice, array.concat | Caveat | Caveat | Caveat | Caveat | Absent |
| Sort and reverse | array.sort, array.sort_indices, array.reverse | Caveat | Caveat | Caveat | Caveat | Absent |
| Statistics of an array | array.sum, array.avg, array.min, array.max, array.median, array.stdev, array.variance | Differs | Differs | Caveat | Caveat | Absent |
| Array to text | array.join | Absent | Absent | Caveat | Exact | Absent |
| Test all or any elements | array.every, array.some | Absent | Absent | Caveat | Exact | Absent |
Create an array
Creates an array of the given length. In Lipi:array.new, array.from, array.new_float, array.new_int.
| Language | Construct | Relation | Note |
|---|---|---|---|
| MQL4 | type name[n] declaration, ArrayResize, ArrayInitialize | Equivalent, with a caveat | Fixed size at declaration, or a dynamic array sized with ArrayResize; fill values with ArrayInitialize. No from-values constructor. State and side effects: elements added by ArrayResize hold undefined values until you set them. |
| MQL5 | ArrayResize, ArrayInitialize | Equivalent, with a caveat | Declare a dynamic array, size it with ArrayResize, then fill with ArrayInitialize. A brace list initialises a fixed array. New elements are undefined until set. State and side effects: Elements added by ArrayResize are not initialised to any value. |
| NinjaScript | new List<double>() | Equivalent, with a caveat | A List<T> grows like a Lipi array. new List<double>(n) only sets capacity: add n items to reach that length. C# arrays are fixed length. |
| Pine Script | array.new<type>, array.from, array.new_float, array.new_int | Equivalent, with a caveat | Lipi caps arrays at 10000 elements versus Pine’s 100000; array.new<bool>(n) holds na in Lipi. |
| thinkScript | Not in thinkScript | No script-created array. IDataHolder is the built-in series type (close, volume); rolling windows come from functions and fold. |
Arrays of drawing objects
Creates an array ofline IDs with size elements, each set to initial_value.
In Lipi: array.new_line, array.new_label, array.new_box.
| Language | Construct | Relation | Note |
|---|---|---|---|
| MQL4 | Not in MQL4 | Objects are named, not handles: ObjectCreate takes an object_name string, so keep an array of names. | |
| MQL5 | string[] of object names with ObjectCreate | Equivalent, with a caveat | Chart objects are addressed by a name string, unique per chart. Keep the names in a string array; there are no object id handles. |
| NinjaScript | List<IDrawingTool> (a typed list of draw objects) | Equivalent, with a caveat | Draw.* methods return draw objects you can add to a List<T>; entries are added as created, not preallocated with an initial value. |
| Pine Script | array.new_line, array.new_label, array.new_box | Exact | |
| thinkScript | Not in thinkScript | No arrays and no line, label or box objects to hold in them. |
Read and write an element
Returns the element atindex.
In Lipi: array.get, array.set.
| Language | Construct | Relation | Note |
|---|---|---|---|
| MQL4 | array[index] | Equivalent, with a caveat | Index operator, zero-based; an out-of-range access stops the program. A series-flagged array reverses the index direction. History indexing: ArraySetAsSeries makes index 0 the newest element; plain arrays count from the first. |
| MQL5 | array[index] | Equivalent, with a caveat | Plain bracket indexing, 0-based; an out-of-range index stops the program. ArraySetAsSeries can flip direction so index 0 is the newest element. History indexing: With the as-series flag set, index 0 is the newest element; Lipi arrays always start at the first element. |
| NinjaScript | list[index] (List<T> indexer) | Equivalent, with a caveat | Index syntax instead of array.get and array.set; zero-based as in Lipi. Out-of-range access throws an exception. |
| Pine Script | array.get, array.set | Looks alike, behaves differently | Pine accepts negative indexes counting from the end (-1 is the last element). Lipi stops the script on any index outside 0 to length-1. History indexing: array.get(a, -1) is the last element in Pine and a runtime error in Lipi. |
| thinkScript | Not in thinkScript | No element read or write on a user array. Past bars of a series are read with [n] indexing or getValue inside fold. |
Number of elements
Returns the number of elements in the array. In Lipi:array.length.
| Language | Construct | Relation | Note |
|---|---|---|---|
| MQL4 | ArraySize | Exact | |
| MQL5 | ArraySize | Exact | |
| NinjaScript | List<T>.Count (C# arrays: Length) | Equivalent, with a caveat | A property, not a function call. A fixed-length C# array uses Length instead of Count. |
| Pine Script | array.size | Equivalent, with a caveat | Lipi has no array.size or a.size; use array.length(a) or a.length. |
| thinkScript | Not in thinkScript | No array length function; there are no user arrays. |
Add or remove at the end
Appendsvalue to the end of the array, growing it by one element.
In Lipi: array.push, array.pop.
| Language | Construct | Relation | Note |
|---|---|---|---|
| MQL4 | Not in MQL4 | No append or pop; grow with ArrayResize(array, n+1) and assign the last slot, read it and shrink to pop. | |
| MQL5 | ArrayResize | Equivalent, with a caveat | No push or pop: grow with ArrayResize and assign the last slot. To pop, read the last element, then shrink the array. State and side effects: A reserve_size argument avoids repeated reallocation; static arrays and indicator buffers cannot be resized. |
| NinjaScript | List<T>.Add() with RemoveAt(Count - 1) | Equivalent, with a caveat | Add appends like push. List<T> has no Pop: read the last element, then call RemoveAt(Count - 1). |
| Pine Script | array.push, array.pop | Equivalent, with a caveat | Pushing past 10000 elements stops a Lipi script; Pine allows 100000. |
| thinkScript | Not in thinkScript | No append or remove operations; a series cannot be grown or shrunk by script. |
Add or remove at the start
Insertsvalue at the beginning of the array.
In Lipi: array.unshift, array.shift.
| Language | Construct | Relation | Note |
|---|---|---|---|
| MQL4 | Not in MQL4 | No front insert or removal; ArrayCopy moves ranges, but copying an array onto itself is documented as undefined. | |
| MQL5 | ArrayRemove, ArrayInsert | Equivalent, with a caveat | Remove index 0 with a count of 1; it returns a bool, not the element. ArrayInsert takes elements from a source array, not one value. |
| NinjaScript | List<T>.Insert(0, value) and RemoveAt(0) | Equivalent, with a caveat | Insert(0, value) matches unshift. List<T> has no Shift: read item 0, then RemoveAt(0). Both move every later element. |
| Pine Script | array.unshift, array.shift | Equivalent, with a caveat | Unshifting past 10000 elements stops a Lipi script; Pine allows 100000. |
| thinkScript | Not in thinkScript | No insert or remove at the start of a collection. |
Insert or remove at a position
Insertsvalue at index, moving the element that was there, and every element after it, up one index.
In Lipi: array.insert, array.remove.
| Language | Construct | Relation | Note |
|---|---|---|---|
| MQL4 | Not in MQL4 | No insert or remove at a position; rebuild with ArrayCopy into a second array and ArrayResize. | |
| MQL5 | ArrayInsert, ArrayRemove | Equivalent, with a caveat | Insert copies elements from a source array at a destination index; remove takes a start and a count. Both return bool. State and side effects: On a fixed-size receiving array, the array’s own size does not change. |
| NinjaScript | List<T>.Insert() and RemoveAt() | Equivalent, with a caveat | Same effect as inserting and removing at an index; both are methods on the list. RemoveAt returns nothing, as array.remove does. |
| Pine Script | array.insert, array.remove | Equivalent, with a caveat | Pine’s array.remove returns the removed value; Lipi’s returns nothing. Pine accepts negative indexes for both; Lipi errors outside 0 to length-1. History indexing: A negative index counts from the end in Pine and stops the script in Lipi. |
| thinkScript | Not in thinkScript | No positional insert or remove on any collection. |
Empty or fill an array
Removes every element, leaving an empty array. In Lipi:array.clear, array.fill.
| Language | Construct | Relation | Note |
|---|---|---|---|
| MQL4 | ArrayFree, ArrayInitialize, ArrayFill | Equivalent, with a caveat | ArrayFree empties dynamic arrays only; ArrayFill takes a start and a count, not an end index; ArrayInitialize sets every element. History indexing: ArrayFill always runs left to right and ignores the series-direction flag. |
| MQL5 | ArrayFree, ArrayFill, ArrayInitialize | Equivalent, with a caveat | ArrayFree empties a dynamic array. ArrayFill takes a start and a count, not an end index, and ignores the as-series direction. |
| NinjaScript | List<T>.Clear() | Equivalent, with a caveat | Clear() empties the list. List<T> has no fill method; assign each index in a loop. |
| Pine Script | array.clear, array.fill | Exact | |
| thinkScript | Not in thinkScript | No clear or fill; a number passed as IDataHolder is read as a series of that constant. |
First and last element
Returns the first element of the array. In Lipi:array.first, array.last.
| Language | Construct | Relation | Note |
|---|---|---|---|
| MQL4 | Not in MQL4 | No first or last helper; read array[0] and array[ArraySize(array)-1]. | |
| MQL5 | Not in MQL5 | No dedicated functions; use index 0 and ArraySize minus 1, which swap meaning when the array is as-series. | |
| NinjaScript | list[0] and list[list.Count - 1] | Equivalent, with a caveat | No First or Last property on List<T>: index the ends directly. LINQ First() and Last() also exist. |
| Pine Script | array.first, array.last | Exact | |
| thinkScript | Not in thinkScript | No first or last element accessor on user arrays; there are none. |
Find an element
Returns true whenvalue is one of the array’s elements.
In Lipi: array.includes, array.indexof, array.lastindexof, array.binary_search.
| Language | Construct | Relation | Note |
|---|---|---|---|
| MQL4 | ArrayBsearch | Looks alike, behaves differently | Needs a sorted numeric array and, when the value is missing, returns the index of the nearest element, not -1 or false. |
| MQL5 | ArrayBsearch | Looks alike, behaves differently | Needs a sorted array and returns the nearest element’s index when the value is absent, not -1. No includes or indexof function exists. |
| NinjaScript | List<T>.Contains(), IndexOf(), LastIndexOf(), BinarySearch() | Equivalent, with a caveat | Same job with close names. BinarySearch needs a sorted list. |
| Pine Script | array.includes, array.indexof, array.lastindexof, array.binary_search | Equivalent, with a caveat | Same results, -1 when missing. Pine’s binary_search target is named val (Lipi value) and has an extra sort_field overload for arrays of user types. |
| thinkScript | Not in thinkScript | No element search on collections. Highest, Lowest and GetMaxValueOffset locate extremes in a bar window only. |
Copy, slice and join arrays
Returns a new array with the same elements. In Lipi:array.copy, array.slice, array.concat.
| Language | Construct | Relation | Note |
|---|---|---|---|
| MQL4 | ArrayCopy | Equivalent, with a caveat | Copies into an existing destination (grown as needed) and returns the copied count; slice by src_start and count, concat by dst_start. History indexing: copying runs left to right; series arrays have their start position adjusted for that. State and side effects: writes into the destination array; does not return a new array. |
| MQL5 | ArrayCopy | Equivalent, with a caveat | Copies a range into an existing destination and returns the count copied. A slice is a partial copy; concat copies at a destination offset. |
| NinjaScript | List<T>.GetRange() and AddRange() | Equivalent, with a caveat | GetRange(index, count) copies a range given a start and a count; AddRange appends another collection. |
| Pine Script | array.copy, array.slice, array.concat | Equivalent, with a caveat | Both slices are live views of the original. Pine says insertions and removals in a slice change the original; Lipi says adding may detach storage. State and side effects: Growing a slice keeps writing through to the original in Pine; in Lipi it may separate from the original. |
| thinkScript | Not in thinkScript | No copy, slice or concatenate operations on collections. |
Sort and reverse
Sorts the array in place. In Lipi:array.sort, array.sort_indices, array.reverse.
| Language | Construct | Relation | Note |
|---|---|---|---|
| MQL4 | ArraySort | Equivalent, with a caveat | Numeric arrays only, sorted in place, returning a bool. No sort_indices or reverse function. History indexing: the series-direction flag is taken into account when sorting. |
| MQL5 | ArraySort, ArrayReverse | Equivalent, with a caveat | Ascending only, in place, ignoring the as-series flag. Sort descending with ArraySort then ArrayReverse. No index-sorting function. |
| NinjaScript | List<T>.Sort() and Reverse() | Equivalent, with a caveat | Sort() and Reverse() work in place, as array.sort and array.reverse do. There is no equivalent of sort_indices. |
| Pine Script | array.sort, array.sort_indices, array.reverse | Equivalent, with a caveat | Pine array.sort and sort_indices have a sort_field overload for arrays of objects; Lipi takes only id and order. |
| thinkScript | Not in thinkScript | No sort or reverse function; Median sorts internally over a window but exposes only the middle value. |
Statistics of an array
Returns the sum of the array’s elements. In Lipi:array.sum, array.avg, array.min, array.max, array.median, array.stdev, array.variance.
| Language | Construct | Relation | Note |
|---|---|---|---|
| MQL4 | ArrayMaximum, ArrayMinimum | Looks alike, behaves differently | Return the index of the extreme element, not its value. Sum, average, median, deviation and variance have no array functions. |
| MQL5 | ArrayMaximum, ArrayMinimum, MathMean, MathMedian, MathStandardDeviation, MathVariance | Looks alike, behaves differently | ArrayMaximum and ArrayMinimum return an index, not the value. Mean, median, deviation and variance are separate Math functions; there is no array sum. History indexing: The returned index honours the as-series flag of the array. |
| NinjaScript | Enumerable.Sum(), Average(), Min(), Max() (System.Linq) | Equivalent, with a caveat | LINQ covers sum, average, min and max. Median, standard deviation and variance are not in LINQ; compute them by hand. Needs using System.Linq. |
| Pine Script | array.sum, array.avg, array.min, array.max, array.median, array.stdev, array.variance | Equivalent, with a caveat | For int arrays Pine’s avg, median, stdev and variance return int; Lipi’s return float. |
| thinkScript | Not in thinkScript | No statistics on user arrays. Rolling statistics over bars come from Sum, Average, Highest, Lowest, Median and StDev. |
Array to text
Joins the elements into one string, withseparator between them.
In Lipi: array.join.
| Language | Construct | Relation | Note |
|---|---|---|---|
| MQL4 | Not in MQL4 | No array-to-text function; loop over the elements and append with StringConcatenate or +. | |
| MQL5 | Not in MQL5 | No join function; build the text in a loop with StringConcatenate or StringAdd. | |
| NinjaScript | string.Join(separator, list) | Equivalent, with a caveat | A static string method: separator first, then the collection of elements to join. |
| Pine Script | array.join | Exact | |
| thinkScript | Not in thinkScript | No array-to-text function; there are no user arrays. |
Test all or any elements
Returns true when every element is true. In Lipi:array.every, array.some.
| Language | Construct | Relation | Note |
|---|---|---|---|
| MQL4 | Not in MQL4 | No all-or-any test over elements; loop and test each one. | |
| MQL5 | Not in MQL5 | No all-true or any-true function in the array list; loop over the elements. | |
| NinjaScript | Enumerable.All() and Any() (System.Linq) | Equivalent, with a caveat | LINQ All and Any take a condition function, so pass x => x for a list of bools. Needs using System.Linq. |
| Pine Script | array.every, array.some | Exact | |
| thinkScript | Not in thinkScript | No all/any test on collections. A fold loop with a while condition can scan a bar window. |