Reference
2 min read
Available Color Constants
kScript provides predefined color constants that can be used directly in plotting functions and style definitions.
| Color | Hex Value | Usage | |
|---|---|---|---|
yellow | #FFFF00 | Highlights, warnings | |
orange | #FFA500 | Accent color, signals | |
purple | #800080 | Secondary indicators | |
gray | #808080 | Neutral, background | |
black | #000000 | Text, borders | |
white | #FFFFFF | Light themes, contrast | |
red | #FF0000 | Bearish, sell signals | |
green | #008000 | Bullish, buy signals | |
blue | #0000FF | Primary indicators | |
silver | #C0C0C0 | Subtle backgrounds | |
maroon | #800000 | Dark red tones | |
fuchsia | #FF00FF | Vibrant highlights | |
lime | #00FF00 | Bright green | |
olive | #808000 | Muted yellow-green | |
navy | #000080 | Dark blue | |
teal | #008080 | Blue-green | |
aqua | #00FFFF | Bright cyan |
Using Colors in Your Scripts
Single Color Plot
Use a single color constant for simple line plots:
Single Color Plot
//@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:
Multi-Color 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:
Conditional Colors
//@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"]);Recommended Color Palettes
Pre-designed color combinations that work well together for different types of indicators.
Trading Signals
Classic colors for buy/sell signals and trend indicators:
lines wrap
var colors = ["green", "red", "blue"];Technical Analysis
Professional colors for technical indicators and overlays:
lines wrap
var colors = ["orange", "purple", "teal"];Volume Analysis
Distinct colors for volume-based indicators:
lines wrap
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