Skip to main content
Reference2 min read
Predefined color constants available in kScript for chart visualization and plotting. Use these named colors for consistent styling across your indicators.

Available Color Constants

kScript provides predefined color constants that can be used directly in plotting functions and style definitions.
ColorHex ValueUsage
yellow#FFFF00Highlights, warnings
orange#FFA500Accent color, signals
purple#800080Secondary indicators
gray#808080Neutral, background
black#000000Text, borders
white#FFFFFFLight themes, contrast
red#FF0000Bearish, sell signals
green#008000Bullish, buy signals
blue#0000FFPrimary indicators
silver#C0C0C0Subtle backgrounds
maroon#800000Dark red tones
fuchsia#FF00FFVibrant highlights
lime#00FF00Bright green
olive#808000Muted yellow-green
navy#000080Dark blue
teal#008080Blue-green
aqua#00FFFFBright cyan

Using Colors in Your Scripts

Single Color Plot

Use a single color constant for simple line plots:
//@version=2

define("Simple SMA", "onchart", true);

timeseries trade = ohlcv(currentSymbol, currentExchange);
var sma20 = sma(trade, 20, 4);

// Use a single color constant
plotLine(value=sma20, width=2, colors=["orange"], label=["SMA 20"], desc=["20-period Simple Moving Average"]);

Multi-Color Indicators

Combine multiple colors for complex multi-line indicators:
//@version=2

define("Multi-MA", "onchart", true);

timeseries ohlcvData = ohlcv(currentSymbol, currentExchange);

var sma10 = sma(source=ohlcvData.close, period=10);
var sma20 = sma(source=ohlcvData.close, period=20);
var sma50 = sma(source=ohlcvData.close, period=50);

// Use multiple color constants
plotLine(value=sma10, width=2, colors=["blue"], label=["SMA 10"], desc=["10-period SMA"]);
plotLine(value=sma20, width=2, colors=["orange"], label=["SMA 20"], desc=["20-period SMA"]);
plotLine(value=sma50, width=2, colors=["green"], label=["SMA 50"], desc=["50-period SMA"]);

Conditional Colors

Use color arrays with colorIndex to change colors based on conditions:
//@version=2

define("RSI Colored", "offchart", true);

timeseries ohlcvData = ohlcv(currentSymbol, currentExchange);
var rsiValue = rsi(source=ohlcvData.close, period=14);

// Color based on RSI level
var colorIndex = rsiValue > 70 ? 0 : (rsiValue < 30 ? 1 : 2);

plotLine(value=rsiValue, width=2, colors=["red", "green", "blue"], colorIndex=colorIndex, label=["RSI"], desc=["RSI with conditional colors"]);
Pre-designed color combinations that work well together for different types of indicators.

Trading Signals

Classic colors for buy/sell signals and trend indicators:
var colors = ["green", "red", "blue"];

Technical Analysis

Professional colors for technical indicators and overlays:
var colors = ["orange", "purple", "teal"];

Volume Analysis

Distinct colors for volume-based indicators:
var colors = ["lime", "yellow", "fuchsia"];

Best Practices

Consistent Branding

Use the same color scheme across related indicators for visual consistency.

Accessibility

Choose colors with sufficient contrast for better readability. Avoid relying solely on color to convey information.

Semantic Colors

Use meaningful colors that match user expectations:
  • Green for bullish signals, gains, positive values
  • Red for bearish signals, losses, negative values
  • Blue for neutral indicators and reference lines
  • Orange/Yellow for warnings and attention-grabbing elements