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 itemscurrentSymbolstringThe current trading symbol (e.g., 'BTCUSDT')
currentSymbol // Returns 'BTCUSDT'currentExchangestringThe current exchange being used for trading (e.g., 'BINANCE', 'COINBASE')
currentExchange // Returns 'BINANCE'colorcolorThe 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 itemsyellowcolorYellow color (#FFFF00)
orangecolorOrange color (#FFA500)
purplecolorPurple color (#800080)
graycolorGray color (#808080)
blackcolorBlack color (#000000)
whitecolorWhite color (#FFFFFF)
Data Types
2 itemstimeseriesTimeSeriesThis represents time-aligned numerical data. Only timeseries data can be passed into plot().
ShapeTypeShapeTypeDefines 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_volumeDataSourceBuy/sell volume from trade data
timeseries buySellData = source("buy_sell_volume", currentSymbol, currentExchange);
timeseries buyVolume = buySellData.buy;
timeseries sellVolume = buySellData.sell;funding_rateDataSourceFunding rate aggregation data from derivatives markets
timeseries fundingData = source("funding_rate", currentSymbol, currentExchange);
// Single value data sourceliquidationsDataSourceLiquidation aggregation data from derivatives markets
timeseries liquidationData = source("liquidations", currentSymbol, currentExchange);
timeseries buyLiquidations = liquidationData.buy;
timeseries sellLiquidations = liquidationData.sell;ohlcvDataSourceOpen, 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_interestDataSourceOpen interest aggregation data from derivatives markets
timeseries openInterestData = source("open_interest", currentSymbol, currentExchange);
timeseries oiClose = openInterestData.close;
timeseries oiHigh = openInterestData.high;orderbookDataSourceOrderbook 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.
smaMoving AveragesSimple Moving Average calculation
sma(source, period, priceIndex?)emaMoving AveragesExponential Moving Average calculation
ema(source, period, priceIndex?)rsiOscillatorsRelative Strength Index oscillator
rsi(source, period, priceIndex?)plotPlotting & 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?)