Overview

Brightness Control

Adjust color brightness and luminosity with darken/lighten functions for creating visual hierarchy and emphasis in your indicators.

• Brightness adjustment • Darken/lighten effects • Luminosity control

Transparency Effects

Control opacity and transparency levels to create subtle background effects, overlays, and layered visualizations without overwhelming the chart.

• Opacity control • Transparency levels • Layer effects

Functions Reference

brightness - adjust color brightness levels

brightness(color: color, amount: number): color

Parameters:

  • color (color) - Source color to modify
  • amount (number) - Brightness adjustment (0-100, where 50 is no change)

Returns:

color (color with adjusted brightness)

Code Example:

darken - reduce color brightness/lightness

darken(color: color, amount: number): color

Parameters:

  • color (color) - Source color to darken
  • amount (number) - Darkening amount (0-100, where 0 is no change, 100 is black)

Returns:

color (darkened color)

Code Example:

lighten - increase color brightness/lightness

lighten(color: color, amount: number): color

Parameters:

  • color (color) - Source color to lighten
  • amount (number) - Lightening amount (0-100, where 0 is no change, 100 is white)

Returns:

color (lightened color)

Code Example:

transparency - set color transparency level

transparency(color: color, amount: number): color

Parameters:

  • color (color) - Source color to modify
  • amount (number) - Transparency level (0-100, where 0 is opaque, 100 is transparent)

Returns:

color (color with specified transparency)

Code Example:

opacity - set color opacity level (inverse of transparency)

opacity(color: color, amount: number): color

Parameters:

  • color (color) - Source color to modify
  • amount (number) - Opacity level (0-100, where 0 is fully transparent, 100 is fully opaque)

Returns:

color (color with specified opacity)

Code Example:

blend - mix two colors together

blend(color1: color, color2: color, amount: number): color

Parameters:

  • color1 (color) - First color to blend
  • color2 (color) - Second color to blend
  • amount (number) - Blending ratio (0-1, where 0 = color1, 1 = color2, 0.5 = equal mix)

Returns:

color (blended color result)

Code Example:

colorGradient

colorGradient(value: number, range: number[], colorStops: string[] | {value: number, color: string}[]): string

Description:

Map a numeric value to a color based on defined gradient stops within a specified range.
Do take note that plotting functions with fill=true or fill=momentum_fill will not work with gradient colors.

Parameters:

  • value (number) - The numeric value to map to a color (will be clamped to range)
  • range (number[]) - Value range as [min, max] array defining the gradient bounds
  • colorStops (string[] | {value: number, color: string}[]) - Color stops defining the gradient.
    - Simple array: ["#ff0000", "#00ff00", "#0000ff"] - evenly distributed
    - Advanced array: [{value: 0, color: "#ff0000"}, {value: 50, color: "#00ff00"}, {value: 100, color: "#0000ff"}] - custom positions

Returns:

string ('Interpolated color based on value position within range')

Code Examples:

Simple Script: Basic RSI with Gradient Colors
Advanced Script: RSI Gradient Candles with Custom Color Stops

Best Practices

🎨

Color Psychology

Use green for bullish signals, red for bearish, and neutral colors for informational data. Consistent color schemes improve user experience.

👁️

Accessibility

Consider color-blind users by ensuring sufficient contrast and using patterns or shapes in addition to color for important signals.

🔧

Function Selection

Use darken() for creating shadows/depth, lighten() for highlights, opacity() for layering effects, and transparency() for subtle backgrounds. Each serves different visual purposes.

📖
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
🌐
Exchange & Symbol Format
List of supported exchanges and symbol formats
🆕
Updates
v1 vs v2 differences and improvements
🔧
Variables
Core variables and data handling
📊
Data Sources
Subscribe to OHLCV, trades, and orderbook data
⚙️
Execution Model
Per-bar execution lifecycle and phases
🏷️
Keyword Arguments
Named parameters for clear function calls
🛠️
User-Defined Functions
Create custom reusable functions
🔗
Script Definition
Defining inputs and metadata
🎯
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
🔄
Loops
For loops and while loops for iteration
🧮
Math Functions
Mathematical functions and constants
📝
String Functions
String manipulation and transformation
🏠
Go Home
Return to main landing page