Overview

Chart Rendering

Plot time series data directly onto charts with multiple style options including lines, splines, points, candles, and bars for comprehensive market visualization.

• Multiple plot styles • Real-time rendering • Interactive charts

Visual Customization

Customize colors, line widths, fill areas, and smoothing options to create visually appealing and distinct indicators that stand out on your charts.

• Color arrays • Line styling • Fill effects

Advanced Effects

Apply advanced visual effects like momentum fills, smooth curves, and multi-layer plotting to create sophisticated technical analysis displays.

• Momentum fills • Smooth curves • Multi-layer plots

Functions Reference

plotCandle - render OHLC data as candlestick charts

plotCandle(value: TimeSeries, width?: number = 1, colors?: color[], colorIndex?: number, showPriceDisplay?: boolean = true, label?: string[], desc?: string[]): void

Parameters:

  • value (TimeSeries) - OHLC data series to plot as candlesticks (requires 4 values: Open, High, Low, Close)
  • width (number) - Candle width (default: 1)
  • colors (color[]) - Color array for bullish/bearish candles (theme-dependent)
  • colorIndex (number) - Index to select specific color from colors array (optional)
  • showPriceDisplay (boolean) - Show current value in price scale (default: true)
  • label (string[]) - Labels for each data series. A label must be provided for each plot as required by the script editor.
  • desc (string[]) - Descriptions for each data series. Optional but recommended - missing descriptions will generate warnings but will not prevent execution.

Returns:

void (plots candlestick chart)

Visual Example:

plotCandle - render OHLC data as candlestick charts example

Code Example:

plotBar - render data as traditional bar charts

plotBar(value: TimeSeries, width?: number = 1, colors?: color[], colorIndex?: number, showPriceDisplay?: boolean = true, label?: string[], desc?: string[]): void

Parameters:

  • value (TimeSeries) - Data series to plot as bars (uses first value if multi-value series)
  • width (number) - Bar width (default: 1)
  • colors (color[]) - Color array for bullish/bearish bars (theme-dependent)
  • colorIndex (number) - Index to select specific color from colors array (optional)
  • showPriceDisplay (boolean) - Show current value in price scale (default: true)
  • label (string[]) - Labels for each data series. A label must be provided for each plot as required by the script editor.
  • desc (string[]) - Descriptions for each data series. Optional but recommended - missing descriptions will generate warnings but will not prevent execution.

Returns:

void (plots bar chart)

Visual Example:

plotBar - render data as traditional bar charts example

Code Example:

plotLine - render data as enhanced line charts

plotLine(value: TimeSeries, width?: number = 1, colors?: color[], colorIndex?: number, fill?: boolean | 'momentum_fill' | 'default' = false, smooth?: boolean = true, showPriceDisplay?: boolean = false, label?: string[], desc?: string[]): void

Parameters:

  • value (TimeSeries) - Data series to plot as lines (uses first value if multi-value series)
  • width (number) - Line width (default: 1)
  • colors (color[]) - Color array for lines (theme-dependent)
  • colorIndex (number) - Index to select specific color from colors array (optional)
  • fill (boolean | 'momentum_fill' | 'default') - Fill area under line: false = no fill, true = solid fill, "momentum_fill" = conditional coloring based on positive/negative values with 4-color array [posLineColor, negLineColor, posFillColor, negFillColor], "default" = standard fill. Default: false
  • smooth (boolean) - Enable smooth line rendering (default: true)
  • showPriceDisplay (boolean) - Show current value in price scale (default: true)
  • label (string[]) - Labels for each data series. A label must be provided for each plot as required by the script editor.
  • desc (string[]) - Descriptions for each data series. Optional but recommended - missing descriptions will generate warnings but will not prevent execution.

Returns:

void (plots line chart)

Visual Example:

plotLine - render data as enhanced line charts example

Code Example:

plotShape - render custom shapes and markers on charts

plotShape(value: TimeSeries, shape: string, width?: number = 1, colors?: color[], colorIndex?: number, fill?: boolean | number = false, showPriceDisplay?: boolean = false, label?: string[], desc?: string[]): void

Parameters:

  • value (TimeSeries) - Data series for shape positioning (uses first value if multi-value series)
  • shape (string) - Shape type to plot. Currently supported: 'circle' (circular marker/point). The shape parameter determines the visual marker style rendered at each data point.
  • width (number) - Shape border width (default: 1)
  • colors (color[]) - Color array for shapes (theme-dependent)
  • colorIndex (number) - Index to select specific color from colors array (optional)
  • fill (boolean | number) - Fill option for shapes: false = no fill (outline only), true = solid fill (opaque), number (0.0-1.0) = fill opacity/transparency (0.0 = transparent, 1.0 = opaque, 0.5 = 50% transparent). Default: false
  • showPriceDisplay (boolean) - Show current value in price scale (default: false)
  • label (string[]) - Labels for each data series. A label must be provided for each plot as required by the script editor.
  • desc (string[]) - Descriptions for each data series. Optional but recommended - missing descriptions will generate warnings but will not prevent execution.

Returns:

void (plots shapes on chart)

Visual Example:

plotShape - render custom shapes and markers on charts example

Code Example:

plot - universal plotting function for all visualization types

plot(value: TimeSeries, plotType?: 'spline' | 'line' | 'bar' | 'candle' | 'point', width?: number = 1, colors?: color[], colorIndex?: number, fill?: boolean | 'momentum_fill', smooth?: boolean = true, showPriceDisplay?: boolean = true, label?: string[], desc?: string[]): void

Parameters:

  • value (TimeSeries) - The data series to visualize (candle type requires 4 OHLC values, others use first value if multi-value series)
  • plotType (string) - "spline"/"line" for lines, "bar" for histogram, "candle" for OHLC, "point" for dots
  • width (number) - Thickness of lines or size of bars/points (default: 1)
  • colors (color[]) - Colors array - format depends on plot type and fill mode (theme-dependent)
  • colorIndex (number) - Index to select specific color from colors array (optional)
  • fill (boolean | 'momentum_fill') - Fill area: false = no fill, true = solid fill, "momentum_fill" = conditional coloring (requires 4-color array: [posLineColor, negLineColor, posFillColor, negFillColor])
  • smooth (boolean) - Smooth line curves for better visual appeal (default: true)
  • showPriceDisplay (boolean) - Show current value in price scale (default: true for main plot, false for nested)
  • label (string[]) - Labels for each data series. A label must be provided for each plot as required by the script editor.
  • desc (string[]) - Descriptions for each data series. Optional but recommended - missing descriptions will generate warnings but will not prevent execution.

Returns:

void (plots data on chart)

Code Example:

hline - render horizontal reference lines on charts

hline(value: number, color?: string = 'gray', width?: number = 1): void

Parameters:

  • value (number) - Y-axis value where the horizontal line should be drawn
  • color (string) - Line color (default: 'gray')
  • width (number) - Line width (default: 1)

Returns:

void (plots horizontal line at specified value)

Visual Example:

hline - render horizontal reference lines on charts example

Code Example:

Best Practices

🎨

Color Selection

Use contrasting colors for different data series. Consider color-blind accessibility when choosing color schemes for your indicators.

📏

Line Width

Use thicker lines (3-4) for primary indicators and thinner lines (1-2) for secondary data. This creates visual hierarchy in your charts.

Smooth Curves

Enable smooth curves for continuous data like moving averages, but use straight lines for discrete signals or step functions.

🕯️

Candlestick Colors

Use traditional green/red or green/red color schemes for candlesticks. Green typically represents bullish (closing higher) and red represents bearish (closing lower).

🎯

Shape Positioning

When using plotShape for signals, position markers slightly above or below price action to avoid overlapping with the main chart data.

📊

Chart Types

Use plotCandle for price action analysis, plotBar for traditional OHLC display, plotLine for indicators, and plotShape for discrete signals and annotations.

🎨

Color Index Selection

Use the colorIndex parameter to programmatically select colors from your colors array. This is useful for dynamic color changes based on conditions or user inputs.

📖
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