Function Inventory - OakScriptJS
February 25, 2026 ยท View on GitHub
This document tracks the implementation status of all PineScript v6 functions against the official language reference (docs/official/language-reference/functions/).
Last Updated: February 2026 (v0.2.1)
Architecture Overview
OakScriptJS is a simplified PineScript-like library providing:
- Core Functions (array-based): Pure calculation functions from
ta.*,math.*,array.*, etc. - Series Class: Lazy evaluation with operator chaining for native PineScript-like syntax
- BarData: Versioned wrapper for automatic cache invalidation
- materialize(): Breaks closure chains for memory efficiency
- TA-Series Wrappers: Series-based wrappers around core TA functions
- Metadata Types: Type definitions for indicator results (plots, hlines, fills)
No DSL Layer: This library focuses on the computational core. For ready-to-use indicators, see the @oakscript/indicators package.
Summary
Official PineScript v6 reference: 457 function doc files across ~20 namespaces.
In-Scope Namespaces
| Namespace | Official Functions | Implemented | Not Implemented | Completion % |
|---|---|---|---|---|
| ta | 59 | 59 (+2 custom) | 0 | 100% |
| math | 24 | 24 | 0 | 100% |
| array | 55 | 54 (+1 custom) | 1 | 98.2% |
| matrix | 50 | 50 (+1 custom) | 0 | 100% |
| str | 18 | 18 (+4 custom) | 0 | 100% |
| time + timeframe | 5 | 1 (+2 custom) | 4 | 20% |
| color | 7 | 7 (+1 custom) | 0 | 100% |
| line | 21 | 19 | 2 | 90.5% |
| box | 29 | 27 | 2 | 93.1% |
| label | 21 | 19 | 2 | 90.5% |
| linefill | 5 | 5 | 0 | 100% |
| chartPoint | 5 | 4 | 1 | 80% |
| polyline | 2 | 2 (+1 custom) | 0 | 100% |
| map | 11 | 0 | 11 | 0% |
| TOTAL | 312 | 289 | 23 | 92.6% |
Out-of-Scope Namespaces (Platform/Rendering/Data)
These namespaces exist in the official PineScript v6 reference but are outside the library's computational scope:
| Namespace | Official Functions | Reason |
|---|---|---|
| strategy | 47 | Trading execution engine |
| table | 22 | Rendering-only (no getters) |
| input | 13 | UI/platform interaction |
| request | 10 | External data fetching |
| ticker | 9 | Symbol/ticker construction |
| log | 3 | Runtime logging |
| syminfo | 2 | Platform symbol metadata |
| Standalone | ~34 | Mixed: plot, indicator, alert, na, nz, fill, time helpers, type constructors, etc. |
| TOTAL | ~140 | -- |
ta (Technical Analysis)
Implemented (59 official + 2 custom = 61 functions)
alma()- Arnaud Legoux Moving Averageatr()- Average True Rangebarssince()- Number of bars since condition was truebb()- Bollinger Bandsbbw()- Bollinger Bands Widthcci()- Commodity Channel Indexchange()- Difference between current and previous valuecmo()- Chande Momentum Oscillatorcog()- Center of Gravitycorrelation()- Correlation coefficient between two seriescross()- Detects when two series crosscrossover()- Detects when series1 crosses over series2crossunder()- Detects when series1 crosses under series2cum()- Cumulative sumdev()- Mean absolute deviationdmi()- Directional Movement Indexema()- Exponential Moving Averagefalling()- Tests if series is fallinghighest()- Highest value over a periodhighestbars()- Offset to the highest valuehma()- Hull Moving Averageichimoku()- Ichimoku Kinko Hyo (custom, not in official PineScript v6)kc()- Keltner Channelskcw()- Keltner Channels Widthlinreg()- Linear regressionlowest()- Lowest value over a periodlowestbars()- Offset to the lowest valuemacd()- Moving Average Convergence Divergencemax()- Maximum of two valuesmedian()- Median value over a periodmfi()- Money Flow Indexmin()- Minimum of two valuesmode()- Mode (most frequently occurring value)mom()- Momentumpercentile_linear_interpolation()- Percentile using linear interpolationpercentile_nearest_rank()- Percentile using nearest rankpercentrank()- Percent rank over a periodpivot_point_levels()- Pivot point levels (Traditional, Fibonacci, Woodie, Classic, DM, Camarilla)pivothigh()- Detects pivot high pointspivotlow()- Detects pivot low pointsrange()- High-Low Rangerci()- Rank Correlation Index (Spearman's rank correlation)rising()- Tests if series is risingrma()- Relative Moving Average (exponential moving average with alpha = 1 / length)roc()- Rate of Changersi()- Relative Strength Indexsar()- Parabolic SARsma()- Simple Moving Averagestdev()- Standard deviationstoch()- Stochastic oscillatorsupertrend()- SuperTrend indicatorswma()- Symmetrically Weighted Moving Averagetr()- True Rangetsi()- True Strength Indexvaluewhen()- Returns value when condition was truevariance()- Variancevwap()- Volume Weighted Average Pricevwma()- Volume Weighted Moving Averagewma()- Weighted Moving Averagewpr()- Williams %Rzigzag()- ZigZag indicator (custom, not in official PineScript v6)
Not Implemented (0 official functions)
All 59 official ta functions are implemented. ichimoku() and zigzag() are custom additions beyond the official API.
math (Mathematics)
Implemented (24 functions)
abs()- Absolute valueacos()- Arc cosine (inverse cosine)asin()- Arc sine (inverse sine)atan()- Arc tangent (inverse tangent)avg()- Average of argumentsceil()- Ceiling (round up)cos()- Cosineexp()- Exponential (e^x)floor()- Floor (round down)log()- Natural logarithm (ln)log10()- Base-10 logarithmmax()- Maximum of argumentsmin()- Minimum of argumentspow()- Power (x^y)random()- Random number (NOTE: seed parameter not implemented)round()- Round to nearest integer or precisionround_to_mintick()- Round to nearest tick sizesign()- Sign of number (-1, 0, 1)sin()- Sinesqrt()- Square rootsum()- Sum over a series/windowtan()- Tangenttodegrees()- Convert radians to degreestoradians()- Convert degrees to radians
Constants: pi, e, phi, rphi
Not Implemented (0 functions)
All 24 official math functions are implemented.
array (Array Operations)
Implemented (54 official + 1 custom = 55 functions)
abs()- Absolute values of elementsavg()- Average of array elementsbinary_search()- Binary search for valuebinary_search_leftmost()- Binary search returning leftmost indexbinary_search_rightmost()- Binary search returning rightmost indexclear()- Remove all elementsconcat()- Concatenate two arrayscopy()- Create a shallow copycovariance()- Covariance of two arraysevery()- Test if all elements satisfy conditionfill()- Fill array with valuefirst()- Get first elementfrom()- Create array from existing oneget()- Get element at indexincludes()- Check if array contains valueindexof()- Find first index of valueinsert()- Insert value at indexjoin()- Join elements into stringlast()- Get last elementlastindexof()- Find last index of valuemax()- Maximum value in arraymedian()- Median value in arraymin()- Minimum value in arraymode()- Most frequent value in arraynew_array()- Create new array (custom generic wrapper, not in official API)new_bool()- Create new boolean arraynew_box()- Create new box arraynew_color()- Create new color arraynew_float()- Create new float arraynew_int()- Create new int arraynew_label()- Create new label arraynew_line()- Create new line arraynew_linefill()- Create new linefill arraynew_string()- Create new string arraynewtype()- Create array of user-defined type (placeholder)percentile_linear_interpolation()- Percentile using linear interpolationpercentile_nearest_rank()- Percentile using nearest rankpercentrank()- Percent rank of value in arraypop()- Remove and return last elementpush()- Add element to endrange()- Difference between max and minremove()- Remove element at indexreverse()- Reverse array in placeset()- Set element at indexshift()- Remove and return first elementsize()- Get array lengthslice()- Get sub-arraysome()- Test if any element satisfies conditionsort()- Sort array in placesort_indices()- Get indices that would sort the arraystandardize()- Standardize array (z-score normalization)stdev()- Standard deviation of arraysum()- Sum of array elementsunshift()- Add element to beginningvariance()- Variance of array
Not Implemented (1 function)
new_table()- Create new table array (no computational value - tables have no getters in PineScript)
matrix (Matrix Operations)
Implemented (50 official + 1 custom = 51 functions)
Phase 1 - Foundation:
new_matrix()- Create new matrix (custom wrapper, official API usesmatrix.newtype)get()- Get element at positionset()- Set element at positionrows()- Get number of rowscolumns()- Get number of columnselements_count()- Total number of elementsrow()- Get row as arraycol()- Get column as arraycopy()- Create a deep copyfill()- Fill matrix with valueis_square()- Test if squareis_zero()- Test if zero matrixis_binary()- Test if binary
Phase 2 - Manipulation (Row/Column Operations):
14. add_row() - Add row to matrix
15. add_col() - Add column to matrix
16. remove_row() - Remove row from matrix
17. remove_col() - Remove column from matrix
18. swap_rows() - Swap two rows
19. swap_columns() - Swap two columns
Phase 2 - Manipulation (Matrix Transformations):
20. transpose() - Matrix transpose
21. concat() - Concatenate matrices
22. submatrix() - Extract submatrix
23. reshape() - Reshape matrix
24. reverse() - Reverse matrix
25. sort() - Sort matrix by column
Phase 2 - Manipulation (Element-wise Arithmetic):
26. sum() - Matrix addition (matrix or scalar)
27. diff() - Matrix subtraction (matrix or scalar)
Phase 2 - Manipulation (Statistical Functions):
28. avg() - Average of all elements
29. min() - Minimum element
30. max() - Maximum element
31. median() - Median element
32. mode() - Mode (most frequent element)
33. trace() - Matrix trace (sum of diagonal)
Phase 2 - Manipulation (Boolean Checks):
34. is_diagonal() - Test if diagonal matrix
35. is_identity() - Test if identity matrix
36. is_symmetric() - Test if symmetric
37. is_antisymmetric() - Test if antisymmetric (skew-symmetric)
38. is_triangular() - Test if triangular
39. is_antidiagonal() - Test if antidiagonal
40. is_stochastic() - Test if stochastic
Phase 3 - Linear Algebra:
41. mult() - Matrix multiplication (matrix x matrix, matrix x scalar, matrix x vector)
42. pow() - Matrix power using repeated squaring
43. det() - Determinant using LU decomposition with partial pivoting
44. inv() - Matrix inverse using Gauss-Jordan elimination
45. pinv() - Moore-Penrose pseudo-inverse for any matrix shape
46. rank() - Matrix rank via row echelon form
47. eigenvalues() - Eigenvalues using QR algorithm
48. eigenvectors() - Eigenvectors using inverse iteration
49. kron() - Kronecker (tensor) product
50. newtype() - Create matrix of user-defined type
Not Implemented (0 official functions)
All 50 official matrix functions are implemented. new_matrix() is a custom convenience wrapper.
str (String Operations)
Implemented (18 official + 4 custom = 22 functions)
charAt()- Get character at index (custom addition)concat()- Concatenate strings (custom addition)contains()- Check if string contains substringendswith()- Check if string ends with suffixformat()- Format string with argumentsformat_time()- Format timestamp with PineScript format specifierslength()- Get string lengthlower()- Convert to lowercasematch()- Match regular expressionpos()- Find position of substringrepeat()- Repeat string N times with optional separatorreplace()- Replace first occurrencereplace_all()- Replace all occurrencessplit()- Split string into arraystartswith()- Check if string starts with prefixsubstring()- Extract substringtonumber()- Convert string to numbertostring()- Convert value to stringtrim()- Remove whitespace from both endstrimLeft()- Remove whitespace from left (custom addition)trimRight()- Remove whitespace from right (custom addition)upper()- Convert to uppercase
Not Implemented (0 functions)
All 18 official str functions are implemented.
time + timeframe (Time Operations)
Implemented (1 official + 2 custom = 3 functions)
time()- Convert time components to timestamp (basic implementation)timestamp()- Custom addition for conveniencenow()- Custom addition for convenience
Not Implemented (4 functions)
time_close()- Returns UNIX time of the current bar's close for a given timeframe/sessiontimeframe.change()- Detects changes in a specified timeframe (returns bool on first bar of new timeframe)timeframe.from_seconds()- Converts a number of seconds into a valid timeframe stringtimeframe.in_seconds()- Converts a timeframe string into seconds
color (Color Operations)
Implemented (7 official + 1 custom = 8 functions)
b()- Extract blue componentfrom_gradient()- Create color from gradient between two colorsfrom_hex()- Create color from hex string (custom addition, not in official API)g()- Extract green componentnew()- Create new color with transparency (aliased asnew_color)r()- Extract red componentrgb()- Create RGB colort()- Extract transparency component
Constants: All standard PineScript color constants are implemented (red, green, blue, yellow, etc.)
Not Implemented (0 official functions)
All 7 official color functions are implemented.
line (Line Drawing Objects)
Implemented (19 functions)
Core Functions:
new()- Create new line with coordinatesget_price()- Get price at bar index via linear interpolationget_x1()- Get first x coordinateget_y1()- Get first y coordinateget_x2()- Get second x coordinateget_y2()- Get second y coordinatecopy()- Create copy of linedelete()- Delete line (no-op in JS)
Setters:
9. set_x1() - Set first x coordinate
10. set_y1() - Set first y coordinate
11. set_x2() - Set second x coordinate
12. set_y2() - Set second y coordinate
13. set_xy1() - Set first point coordinates
14. set_xy2() - Set second point coordinates
15. set_xloc() - Set x location mode and coordinate
16. set_extend() - Set line extension mode
17. set_color() - Set line color
18. set_style() - Set line style
19. set_width() - Set line width
Not Implemented (2 functions)
set_first_point()- Set first point via chart.point objectset_second_point()- Set second point via chart.point object
box (Box Drawing Objects)
Implemented (27 functions)
Core Functions:
new()- Create new box with coordinatesget_left()- Get left border coordinateget_top()- Get top border priceget_right()- Get right border coordinateget_bottom()- Get bottom border pricecopy()- Create copy of boxdelete()- Delete box (no-op in JS)
Coordinate Setters:
8. set_left() - Set left border
9. set_top() - Set top border
10. set_right() - Set right border
11. set_bottom() - Set bottom border
12. set_lefttop() - Set left-top corner
13. set_rightbottom() - Set right-bottom corner
14. set_top_left_point() - Set top-left point
15. set_bottom_right_point() - Set bottom-right point
16. set_extend() - Set extension mode
Styling Setters:
17. set_border_color() - Set border color
18. set_border_width() - Set border width
19. set_border_style() - Set border style
20. set_bgcolor() - Set background color
Text Setters:
21. set_text() - Set box text content
22. set_text_size() - Set text size
23. set_text_color() - Set text color
24. set_text_halign() - Set horizontal alignment
25. set_text_valign() - Set vertical alignment
26. set_text_wrap() - Set text wrapping
27. set_text_font_family() - Set text font
Not Implemented (2 functions)
set_text_formatting()- Set text formatting (bold/italic viatext.format_bold,text.format_italic)set_xloc()- Set x-location mode and update left/right borders
label (Label Drawing Objects)
Implemented (19 functions)
Core Functions:
new()- Create new labelget_x()- Get x coordinateget_y()- Get y coordinateget_text()- Get text contentcopy()- Create copy of labeldelete()- Delete label (no-op in JS)
Position Setters:
7. set_x() - Set x coordinate
8. set_y() - Set y coordinate
9. set_xy() - Set both coordinates
10. set_xloc() - Set x location mode
11. set_yloc() - Set y location mode
Content Setters:
12. set_text() - Set text content
13. set_tooltip() - Set tooltip text
Styling Setters:
14. set_color() - Set label color
15. set_textcolor() - Set text color
16. set_style() - Set label style
17. set_size() - Set label size
18. set_textalign() - Set text alignment
19. set_text_font_family() - Set text font
Not Implemented (2 functions)
set_point()- Set label position via chart.point objectset_text_formatting()- Set text formatting (bold/italic viatext.format_bold,text.format_italic)
linefill (Linefill Drawing Objects)
Implemented (5 functions)
new()- Create new linefill between two linesget_line1()- Get first line referenceget_line2()- Get second line referenceset_color()- Set fill colordelete()- Delete linefill (no-op in JS)
Not Implemented (0 functions)
All 5 official linefill functions are implemented.
chartPoint (Chart Point Objects)
Implemented (4 functions)
new()- Create a new chart point with time, index, and price coordinatesfrom_time()- Create a chart point from timestamp and pricefrom_index()- Create a chart point from bar index and pricecopy()- Create a copy of a chart point
Not Implemented (1 function)
now()- Create a chart point at the current bar withindexandtimeauto-filled (price defaults toclose)
polyline (Polyline Drawing Objects)
Implemented (2 official + 1 custom = 3 functions)
new()- Create a new polyline connecting multiple chart pointsdelete()- Delete a polylineget_all()- Get all active polylines (custom addition, not in official API)
Not Implemented (0 official functions)
All 2 official polyline functions are implemented.
Note: curved parameter is accepted but curved polylines are not yet supported.
map (Map/Dictionary Operations) -- NEW
Implemented (0 functions)
No map functions are implemented yet.
Not Implemented (11 functions)
clear()- Remove all key-value pairscontains()- Check if map contains a keycopy()- Create a shallow copyget()- Get value by keykeys()- Get array of all keysnew()(newtypetype) - Create a new map with specified key/value typesput()- Add or update a key-value pairput_all()- Add all key-value pairs from another mapremove()- Remove a key-value pairsize()- Get number of entriesvalues()- Get array of all values
Note: Maps are a core data structure in PineScript v6, useful for key-value lookups in computational contexts (e.g., symbol-to-weight mappings, level tracking).
All Not-Implemented Functions (Summary)
| # | Namespace | Function | Description |
|---|---|---|---|
| 1 | array | new_table() | Table array (no computational value) |
repeat() | |||
| 3 | time | time_close() | Bar close time for timeframe/session |
| 4 | timeframe | change() | Detect timeframe boundary changes |
| 5 | timeframe | from_seconds() | Seconds to timeframe string |
| 6 | timeframe | in_seconds() | Timeframe string to seconds |
| 7 | line | set_first_point() | Set first point via chart.point |
| 8 | line | set_second_point() | Set second point via chart.point |
| 9 | box | set_text_formatting() | Bold/italic text formatting |
| 10 | box | set_xloc() | Set x-location mode with borders |
| 11 | label | set_point() | Set position via chart.point |
| 12 | label | set_text_formatting() | Bold/italic text formatting |
| 13 | chartPoint | now() | Chart point at current bar |
| 14 | map | clear() | Clear all entries |
| 15 | map | contains() | Check key existence |
| 16 | map | copy() | Shallow copy |
| 17 | map | get() | Get value by key |
| 18 | map | keys() | Get all keys |
| 19 | map | new() | Create typed map |
| 20 | map | put() | Set key-value |
| 21 | map | put_all() | Merge maps |
| 22 | map | remove() | Remove entry |
| 23 | map | size() | Entry count |
| 24 | map | values() | Get all values |
Total: 23 official functions not yet implemented across in-scope namespaces.
Custom Additions (Not in Official PineScript v6 API)
These functions are implemented in OakScriptJS but do not exist in the official PineScript v6 reference:
| Namespace | Function | Purpose |
|---|---|---|
| ta | ichimoku() | Ichimoku Kinko Hyo indicator |
| ta | zigzag() | ZigZag trend reversal indicator |
| array | new_array() | Generic array constructor |
| str | charAt() | Get character at index |
| str | concat() | Concatenate strings |
| str | trimLeft() | Trim left whitespace |
| str | trimRight() | Trim right whitespace |
| color | from_hex() | Create color from hex string |
| matrix | new_matrix() | Generic matrix constructor |
| polyline | get_all() | Get all active polylines |
| time | timestamp() | Convenience timestamp helper |
| time | now() | Current time helper |
Notes
-
Two API Levels:
- Core TA (
taCore): Array-based functions liketaCore.sma(priceArray, 14) - TA-Series (
ta): Series-based wrappers liketa.sma(closeSeries, 14)
- Core TA (
-
Series Class: The
Seriesclass provides lazy evaluation and operator chaining. When used with the Babel plugin, it enables native PineScript-like syntax:(close - open) / (high - low). -
Deterministic Random:
math.random()accepts a seed parameter but doesn't implement deterministic randomness yet. -
Type-Specific Arrays:
new_bool(),new_int(),new_float(),new_string(), and drawing object arrays are type-specific wrappers aroundnew_array().
Contributing
When implementing new functions:
- Match PineScript v6 API signatures exactly
- Add comprehensive JSDoc comments
- Include examples in documentation
- Add unit tests with expected outputs from PineScript
- Update this inventory file
- If the function accepts arrays, implement it in the core namespace (e.g.,
src/ta/) - Add a Series-based wrapper in
src/ta-series.tsif the function is commonly used with Series
For questions about priorities or implementation details, see the PineScript v6 reference documentation in docs/official/language-reference/.