Reference
Comprehensive reference for all kScript functions, variables, and data types. Build powerful trading algorithms with our extensive library of technical indicators and utilities.
Variables & Constants
Core variables, data types, and constants available in kScript for market data access and styling.
Core Data Variables
4 itemscurrentSymbol
stringThe current trading symbol (e.g., 'BTCUSDT')
currentSymbol // Returns 'BTCUSDT'
currentExchange
stringThe current exchange being used for trading (e.g., 'BINANCE', 'COINBASE')
currentExchange // Returns 'BINANCE'
color
colorThe color to use for plotting (e.g., 'red', 'blue')
plotLine(ema20, ["blue"], 2);
color[]
color[]Storing an array of color
let colors = ["red", "green", "blue"];
Color Constants
17 itemsyellow
colorYellow color (#FFFF00)
orange
colorOrange color (#FFA500)
purple
colorPurple color (#800080)
gray
colorGray color (#808080)
black
colorBlack color (#000000)
white
colorWhite color (#FFFFFF)
Data Types
2 itemstimeseries
TimeSeriesThis represents time-aligned numerical data. Only timeseries data can be passed into plot().
ShapeType
ShapeTypeDefines the type of shape to render when using plotShape function. Currently supports 'circle' with more shapes potentially available.
plotShape(signals, "circle", ["red"], 2, true);
Data Sources
6 itemsbuy_sell_volume
DataSourceBuy/sell volume from trade data
timeseries buySellData = source("buy_sell_volume", currentSymbol, currentExchange);
timeseries buyVolume = buySellData.buy;
timeseries sellVolume = buySellData.sell;
funding_rate
DataSourceFunding rate aggregation data from derivatives markets
timeseries fundingData = source("funding_rate", currentSymbol, currentExchange);
// Single value data source
liquidations
DataSourceLiquidation aggregation data from derivatives markets
timeseries liquidationData = source("liquidations", currentSymbol, currentExchange);
timeseries buyLiquidations = liquidationData.buy;
timeseries sellLiquidations = liquidationData.sell;
ohlcv
DataSourceOpen, High, Low, Close, Volume data from trade aggregations
timeseries ohlcv = source("ohlcv", currentSymbol, currentExchange);
timeseries close = ohlcv.close;
timeseries volume = ohlcv.volume;
timeseries high = ohlcv.high;
open_interest
DataSourceOpen interest aggregation data from derivatives markets
timeseries openInterestData = source("open_interest", currentSymbol, currentExchange);
timeseries oiClose = openInterestData.close;
timeseries oiHigh = openInterestData.high;
orderbook
DataSourceOrderbook heatmap snapshot aggregation data
timeseries orderbookData = source("orderbook", currentSymbol, currentExchange);
// Use with orderbook functions like sumBids(), sumAsks()
Function Categories
Explore technical indicators, mathematical functions, and utilities organized by category.
Moving Averages
4 functionsTrend-following indicators that smooth price data
Oscillators
3 functionsMomentum indicators that fluctuate between bounded values
Volume Indicators
2 functionsIndicators that incorporate volume data in their calculations
Trend Indicators
4 functionsIndicators that help identify trend direction and strength
Utility Functions
8 functionsHelper functions for statistical calculations and data manipulation
Plotting & Visualization
5 functionsFunctions for rendering data on charts
TimeSeries Management
3 functionsFunctions for creating, transforming and merging time series data
Script Definition
4 functionsFunctions for defining script metadata and input parameters
Color Functions
6 functionsFunctions for manipulating and transforming colors
Orderbook Functions
6 functionsFunctions for working with orderbook data
Popular Functions
Commonly used functions for quick access and reference.
sma
Moving AveragesSimple Moving Average calculation
sma(source, period, priceIndex?)
ema
Moving AveragesExponential Moving Average calculation
ema(source, period, priceIndex?)
rsi
OscillatorsRelative Strength Index oscillator
rsi(source, period, priceIndex?)
plot
Plotting & VisualizationUniversal plotting function for all visualization types. The primary way to display your calculated data on charts.
plot(series, type?, colors?, width?, fill?, smooth?, showPriceDisplay?)