Variables & Constants

Core variables, data types, and constants available in kScript for market data access and styling.

Core Data Variables

8 items
currentSymbolstring

The current trading symbol (e.g., 'BTCUSDT')

currentExchangestring

The current exchange being used for trading (e.g., 'BINANCE', 'COINBASE')

currentCoinstring

The current trading coin (e.g., "BTC")

barIndexnumber

Current bar index in the timeseries during the per-bar loop. Represents the position in the data array, starting from 0. Useful for indicator warm-up periods and conditional logic based on bar position.

isLastBarboolean

True when processing the last bar in the dataset (most recent bar). Useful for one-time calculations, alerts, or actions that should only occur on the most recent data point.

isLiveUpdateboolean

True during live data updates with new market data. Distinguishes between initial script run and live trading updates. Note that the script can run multiple times on the same last bar during live updates.

Color Constants

17 items
yellowcolor

Yellow color (#FFFF00)

orangecolor

Orange color (#FFA500)

purplecolor

Purple color (#800080)

graycolor

Gray color (#808080)

blackcolor

Black color (#000000)

whitecolor

White color (#FFFFFF)

Data Types

3 items
timeseriesTimeSeries

This represents time-aligned numerical data. Only timeseries data can be passed into plot().

ShapeTypeShapeType

Defines the type of shape to render when using plotShape function. Currently supports 'circle' with more shapes potentially available.

staticstatic

Variable that gets declared once and its value persists across bar iterations.

Data Sources

18 items
binance_treasury_balanceDataSource

Value of asset held by Binance. Updated monthly. Available for BTC, ETH, SOL, USDT & USDC

buy_sell_volumeDataSource

Buy/sell volume from trade data

cme_oiDataSource

Open Interest for crypto futures contracts on the Chicago Mercantile Exchange, Only available for BTC and ETH

deribit_implied_volatilityDataSource

Implied volatility of ticker on Deribit. Available to only BTC and ETH coins. Returns tenors of 1W, 1M and 3M

deribit_volatility_indexDataSource

Measure of implied or historical price volatility for a specific asset on Deribit. Limited to ETH and BTC coins. Returns OHLC data

etf_flowDataSource

Net inflow or outflow of capital into an ETF. Only available on 1D intervals

Function Categories

Explore technical indicators, mathematical functions, and utilities organized by category.

📖
Introduction
Overview of kScript language
🔍
Overview
Complete technical documentation
🚀
Quick Start
Get started with kScript basics
📋
Function Reference
Complete API reference guide
📚
Type System
Understanding kScript data types
General FAQ
Frequently asked questions about kScript
Best Practices
Guidelines for writing efficient kScript code
⚠️
Limitations
Known constraints and workarounds
🆕
Updates
v1 vs v2 differences and improvements
🔧
Core Concepts
Variables, data types & data sources
⚙️
Execution Model
Per-bar execution lifecycle and phases
🏷️
Keyword Arguments
Named parameters for clear function calls
🔗
Field Accessors
Dot notation for timeseries field access
🛠️
User-Defined Functions
Create custom reusable functions
🔗
Script Definition
Defining inputs and metadata
TimeSeries Management
Working with time-aligned data
🎯
Utility Functions
Helper functions and calculations
📈
Moving Averages
SMA, EMA and trend-following indicators
📊
Oscillators
RSI, Stochastic and momentum indicators
📈
Trend Indicators
Trend direction and strength analysis
📉
Volume Indicators
Volume-based analysis tools
📦
Orderbook Functions
Market depth analysis tools
🎨
Plotting & Visualization
Chart rendering and styling
🌈
Color Functions
Color manipulation and styling
📊
Data Subscriptions
Subscribe to OHLCV, trades, and orderbook data
🔄
Loops
For loops and while loops for iteration
🧮
Math Functions
Mathematical functions and constants
🏠
Go Home
Return to main landing page