Notice!
This is documentation for kScript v1.0, which may not include the latest features. For up-to-date documentation, see the latest version.

Overview

Script Metadata

Define script properties including name, chart placement, axis configuration, and title customization for professional indicator presentation.

• Chart placement control • Custom titles • Axis configuration

User Inputs

Create configurable parameters that users can adjust, including numbers, colors, booleans, and constrained selections for flexible indicators.

• Multiple input types • Default values • Validation constraints

Data Management

Access market data sources, manage data feeds, and implement debugging tools for robust indicator development and troubleshooting.

• OHLCV data access • Multi-source support • Debug output

Functions Reference

define - set script metadata and chart placement

define(title: string, position: 'onchart' | 'offchart', showPriceAxis?: boolean, customTitle?: string): void

Parameters:

  • title (string) - Display name of the indicator
  • position ('onchart' | 'offchart') - Chart placement - 'onchart' or 'offchart'
  • showPriceAxis (boolean) - Show price axis for off-chart indicators (default: false)
  • customTitle (string) - Custom title override

Returns:

void (configures the study)

Code Example:

input - create user-configurable parameters

input(name: string, type: string, defaultValue?: any, label?: string, constraints?: any): any

Parameters:

  • name (string) - Parameter identifier
  • type (string) - Input type ('number', 'color[]', 'boolean', 'color')
  • defaultValue (any) - Default value
  • label (string) - User-friendly label
  • constraints (any) - Validation constraints

Returns:

any (current parameter value)

Code Example:

source - create data source from market data

source(src: string, symbol: string, exchange: string): TimeSeries

Parameters:

  • src (string) - Data source type (e.g., 'ohlcv')
  • symbol (string) - Symbol for the data
  • exchange (string) - Exchange for the data

Returns:

TimeSeries (source data series)

Code Example:

print - output debug information to console

print(message: any): void

Parameters:

  • message (any) - Value to output to console for debugging

Returns:

void (outputs to console)

Code Example:

Common Usage Patterns

Complete Indicator Setup

Proper script structure with metadata, inputs, and data sources

Best Practices

🎯

Naming Convention

Use descriptive names for scripts and inputs. Good names make your indicators more professional and user-friendly.

📊

Chart Placement

Use 'onchart' for price-related indicators, 'offchart' for oscillators and volume indicators. Consider independent axes for different scales.

📖
Introduction
Overview of kScript language
🚀
Quick Start
Get started with kScript basics
📋
Function Reference
Complete API reference guide
🔧
Core Concepts
Variables, data types & data sources
🔗
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
🏠
Go Home
Return to main landing page