@deepentropy/oakscriptjs@0.1.3Built and signed on GitHub ActionsBuilt and signed on GitHub Actions
OakScriptJS is a TypeScript/JavaScript library that mirrors PineScript's calculation and indicator API, maintaining exact function signatures and behavior. This library focuses on the computational core of PineScript
Returns the absolute value of a number.
Absolute value of array elements
Returns the average of all elements (numeric arrays only)
Binary Search
Binary Search Leftmost
Binary Search Rightmost
Removes all elements from the array
Concatenates two arrays
Returns a shallow copy of the array
Covariance
Tests whether all elements in the array pass the test implemented by the provided function
Fills the array with the specified value
Returns the first element of the array
Creates a new array from existing one (alias for copy)
Returns the element at the specified index
Returns true if the array contains the value
Returns the index of the first occurrence of the value
Inserts a value at the specified index
Joins all elements into a string
Returns the last element of the array
Returns the index of the last occurrence of the value
Returns the maximum value (numeric arrays only)
Returns the median value (numeric arrays only)
Returns the minimum value (numeric arrays only)
Returns the mode (most frequent value)
Creates a new array with initial size and default value
Create new boolean array
Create new box array
Create new color array
Create new float array
Create new integer array
Create new label array
Create new line array
Create new linefill array
Create new string array
New Type (User-Defined Type Array)
Percentile Linear Interpolation
Percentile Nearest Rank
Percent Rank
Removes and returns the last element of the array
Appends a value to the end of the array
Range of array values
Removes the element at the specified index
Reverses the array in place
Sets the value of the element at the specified index
Removes and returns the first element of the array
Returns the number of elements in an array
Returns a slice of the array
Tests whether at least one element in the array passes the test implemented by the provided function
Sorts array elements (numeric)
Sort Indices
Standardize
Returns the standard deviation
Returns the sum of all elements (numeric arrays only)
Inserts a value at the beginning of the array
Returns the variance
Average True Range - returns the RMA (Relative Moving Average) of true range.
Returns the average (arithmetic mean) of the arguments.
Bar index series (0, 1, 2, ...)
Equivalent to PineScript's bar_index
Bollinger Bands - a technical analysis tool defined by lines plotted two standard deviations away from a simple moving average.
Box object - Represents a rectangular area on the chart
Creates a copy of the box object.
Deletes the box object.
Returns the bottom border price level.
Returns the left border x coordinate.
Returns the right border x coordinate.
Returns the top border price level.
Creates a new box object.
Sets the background fill color.
Sets the border color.
Sets the border style.
Sets the border width.
Sets the bottom border price level.
Sets the horizontal extension mode.
Sets the left border x coordinate.
Sets the left and top coordinates.
Sets the right border x coordinate.
Sets the right and bottom coordinates.
Sets the text content.
Sets the text color.
Sets the text font family.
Sets the horizontal text alignment.
Sets the text size.
Sets the vertical text alignment.
Sets the text wrapping mode.
Sets the top border price level.
Sets the coordinate system for the box.
Returns the smallest integer greater than or equal to a given number (rounds up).
Change - calculates the difference between the current value and its value length bars ago.
Close price series
Equivalent to PineScript's close
Aqua/Cyan color constant
Extracts the blue component from a color.
Black color constant
Blue color constant
Creates a color from a gradient based on value position.
Creates a color from a hexadecimal string with optional transparency.
Fuchsia/Magenta color constant
Extracts the green component from a color.
Gray color constant
Green color constant (same as lime)
Lime color constant (same as green)
Maroon color constant
Creates a new color with modified transparency, preserving RGB components.
Olive color constant
Orange color constant
Purple color constant
Extracts the red component from a color.
Red color constant
Creates a color from RGB values with optional transparency.
Silver color constant
Extracts the transparency component from a color.
Teal color constant
White color constant
Yellow color constant
Compile registered indicator into chart-bindable object
Configuration for creating a context with implicit data. Can accept either explicit ChartData or an array of Bars.
Returns the cosine of an angle in radians.
Creates a context with implicit data for cleaner function calls.
Factory function to create an indicator controller
Crossover - returns true when series1 crosses over series2 (moves from below to above).
Crossunder - returns true when series1 crosses under series2 (moves from above to below).
Exponential Moving Average - returns the exponentially weighted moving average.
Returns e (Euler's number) raised to the power of value.
Returns the largest integer less than or equal to a given number (rounds down).
Creates a color from a hexadecimal string with optional transparency.
Gets close prices from OHLC
Get the current runtime context
Gets high prices from OHLC
Gets low prices from OHLC
Gets open prices from OHLC
High price series
Equivalent to PineScript's high
(high + low) / 2
Equivalent to PineScript's hl2
(high + low + close) / 3
Equivalent to PineScript's hlc3
(high + low + close + close) / 4
Equivalent to PineScript's hlcc4
Draw a horizontal line at a specific price level
Type definition for Lightweight Charts IChartApi
Declare an indicator
Controller class for managing indicator lifecycle and rendering
Interface for controlling an indicator's lifecycle
Options for indicator() function
Core types for OakScriptJS These types mirror the PineScript type system
Type definition for Lightweight Charts ISeriesApi
Creates a copy of the label object.
Deletes the label object.
Returns the label text content.
Returns the x coordinate.
Returns the y coordinate (price level).
Creates a new label object.
Sets the label color (border and arrow).
Sets the label size.
Sets the label style.
Sets the text content.
Sets the text font family.
Sets the text alignment.
Sets the text color.
Sets the tooltip text.
Sets the x coordinate.
Sets the x-axis coordinate system.
Sets both x and y coordinates.
Sets the y coordinate (price level).
Sets the y-axis positioning mode.
Creates a copy of the line object.
Deletes the line object.
Returns the price level of a line at a given bar index.
Returns the first point's x coordinate.
Returns the second point's x coordinate.
Returns the first point's y coordinate (price level).
Returns the second point's y coordinate (price level).
Creates a new line object.
Sets the line color.
Sets the extension mode of the line.
Sets the line style.
Sets the line width.
Sets the first point's x coordinate.
Sets the second point's x coordinate.
Sets the coordinate system for the line.
Sets both coordinates of the first point.
Sets both coordinates of the second point.
Sets the first point's y coordinate (price level).
Sets the second point's y coordinate (price level).
Deletes the linefill object.
Returns the first line reference.
Returns the second line reference.
Creates a new linefill object that fills the area between two lines.
Sets the fill color.
Returns the natural logarithm (base e) of a number.
Low price series
Equivalent to PineScript's low
Moving Average Convergence Divergence - trend-following momentum indicator showing relationship between two moving averages.
Returns the absolute value of a number.
Returns the arccosine (inverse cosine) of a number.
Returns the arcsine (inverse sine) of a number.
Returns the arctangent (inverse tangent) of a number.
Returns the average (arithmetic mean) of the arguments.
Returns the smallest integer greater than or equal to a given number (rounds up).
Returns the cosine of an angle in radians.
Returns e (Euler's number) raised to the power of value.
Returns the largest integer less than or equal to a given number (rounds down).
Returns the natural logarithm (base e) of a number.
Returns the base-10 logarithm of a number.
Returns the maximum value from the arguments.
Returns the minimum value from the arguments.
Returns base raised to the power of exponent.
Returns a pseudo-random number.
Returns the value rounded to the nearest integer or to a specified precision.
Rounds a value to the nearest mintick.
Returns the sign of a number.
Returns the sine of an angle in radians.
Returns the square root of a number.
Returns the sum of values over a sliding window.
Returns the tangent of an angle in radians.
Converts an angle from radians to degrees.
Converts an angle from degrees to radians.
Creates a new matrix
Returns the maximum value from the arguments.
Returns the minimum value from the arguments.
Creates a new color with modified transparency, preserving RGB components.
(open + high + low + close) / 4
Equivalent to PineScript's ohlc4
Creates OHLC data from bar array
Open price series
Equivalent to PineScript's open
Plot a series on the chart
Returns base raised to the power of exponent.
Reset the global context Used when re-executing indicator script
Creates a color from RGB values with optional transparency.
Returns the value rounded to the nearest integer or to a specified precision.
Relative Strength Index - momentum oscillator measuring speed and magnitude of price changes.
Returns the sine of an angle in radians.
Simple Moving Average - returns the moving average (sum of last y values divided by y).
Returns the square root of a number.
Standard Deviation - measures the amount of variation or dispersion of values.
Returns the character at a specific position in a string.
Concatenates multiple strings into one.
Checks if a string contains a substring.
Checks if a string ends with a specific suffix.
Formats a string by replacing numbered placeholders with values.
Formats a timestamp as a string according to the specified format.
Returns the length of a string.
Converts all characters in a string to lowercase.
Tests if a string matches a regular expression pattern.
Returns the position of the first occurrence of a substring.
Replaces occurrences of a substring with another string.
Replaces all occurrences of a target string with a replacement string.
Splits a string into an array of substrings using a separator.
Checks if a string starts with a specific prefix.
Extracts a substring from a string.
Converts a string to a number (float).
Converts a value to its string representation.
Removes whitespace from both ends of a string.
Removes whitespace from the left (start) of a string.
Removes whitespace from the right (end) of a string.
Converts all characters in a string to uppercase.
Returns the sum of values over a sliding window.
Arnaud Legoux Moving Average (ALMA)
Average True Range - returns the RMA (Relative Moving Average) of true range.
Bars Since - returns number of bars since condition was true.
Bollinger Bands - a technical analysis tool defined by lines plotted two standard deviations away from a simple moving average.
Bollinger Bands Width - measures the width of Bollinger Bands.
Commodity Channel Index (CCI) - measures deviation from average price.
Change - calculates the difference between the current value and its value length bars ago.
Chande Momentum Oscillator - momentum indicator similar to RSI.
Center of Gravity (COG)
Correlation Coefficient - measures degree to which two series deviate from their means together.
Cross - returns true when two series cross each other (either direction).
Crossover - returns true when series1 crosses over series2 (moves from below to above).
Crossunder - returns true when series1 crosses under series2 (moves from above to below).
Cumulative Sum - returns the total sum of all elements from the beginning.
Mean Absolute Deviation - measure of difference between series and its SMA.
Directional Movement Index - returns Directional Movement indicators.
Exponential Moving Average - returns the exponentially weighted moving average.
Falling - returns true if source is falling for length bars.
Highest Value - returns the highest value over a specified number of bars.
Highest Bars
Hull Moving Average (HMA) - improved moving average with reduced lag.
Keltner Channels - volatility-based envelope indicator.
Keltner Channels Width (KCW)
Linear Regression - line that best fits prices using least squares method.
Lowest Value - returns the lowest value over a specified number of bars.
Lowest Bars
Moving Average Convergence Divergence - trend-following momentum indicator showing relationship between two moving averages.
Maximum of Two Values
Median - returns the median (middle value) of the series.
Money Flow Index (MFI) - volume-weighted RSI measuring buying and selling pressure.
Minimum of Two Values
Mode (Most Frequent Value)
Momentum (MOM) - difference between current value and value length bars ago.
Percentile (Linear Interpolation Method)
Percentile (Nearest Rank Method)
Percent Rank - percentage of how many previous values were less than or equal to current value.
Pivot Point Levels
Pivot High - detects pivot high points in the price series.
Pivot Low - detects pivot low points in the price series.
Range (High - Low)
Rank Correlation Index (RCI)
Rising - returns true if source is rising for length bars.
Relative Moving Average (RMA) - exponentially weighted moving average with alpha = 1 / length.
Rate of Change (ROC) - percentage change between current value and value length bars ago.
Relative Strength Index - momentum oscillator measuring speed and magnitude of price changes.
Parabolic SAR (Stop and Reverse) - trend-following indicator.
Simple Moving Average - returns the moving average (sum of last y values divided by y).
Standard Deviation - measures the amount of variation or dispersion of values.
Stochastic Oscillator - momentum indicator comparing closing price to price range.
SuperTrend Indicator - a trend-following indicator that helps identify trend direction.
Symmetrically Weighted Moving Average (SWMA) - fixed length 4 with symmetric weights.
True Range - measures market volatility by calculating the greatest of three price ranges.
True Strength Index - momentum oscillator based on double smoothed momentum.
Value When - returns the value when condition was true.
Variance - expectation of squared deviation from mean.
Volume Weighted Average Price (VWAP)
Volume Weighted Moving Average (VWMA) - moving average weighted by volume.
Weighted Moving Average (WMA) - moving average with linearly decreasing weights.
Williams %R (Williams Percent Range)
Table object - Represents a table for displaying data
Average True Range
Bollinger Bands
Change (difference from previous value)
Crossover detection
Crossunder detection
Exponential Moving Average
Moving Average Convergence Divergence
Momentum
Rate of Change
Relative Strength Index
Simple Moving Average
Standard Deviation
True Range
Weighted Moving Average
Returns the tangent of an angle in radians.
Returns the current time in milliseconds
Returns timestamp for a specific date/time
Time series (timestamp in milliseconds)
Equivalent to PineScript's time
True Range - measures market volatility by calculating the greatest of three price ranges.
Volume series
Equivalent to PineScript's volume