color.new()
Create a new color with optional transparency.Signature
Parameters
| Parameter | Type | Description |
|---|---|---|
color | string | Base color (name or hex) |
transparency | number | Transparency 0-100 (0=opaque, 100=transparent) |
Example
color.rgb()
Create a color from RGB values.Signature
Parameters
| Parameter | Type | Description |
|---|---|---|
red | number | Red component (0-255) |
green | number | Green component (0-255) |
blue | number | Blue component (0-255) |
transparency | number | Transparency 0-100 |
Example
color.from_gradient()
Create a color from a gradient based on a value.Signature
Parameters
| Parameter | Type | Description |
|---|---|---|
value | number | Current value |
min | number | Minimum value for gradient |
max | number | Maximum value for gradient |
colorMin | string | Color at minimum value |
colorMax | string | Color at maximum value |
Example
Practical Examples
Conditional Coloring
RSI Color Zones
Transparency for Overlays
Color Constants
kScript provides predefined color constants:| Color | Hex Value |
|---|---|
red | #FF0000 |
green | #008000 |
blue | #0000FF |
yellow | #FFFF00 |
orange | #FFA500 |
purple | #800080 |
white | #FFFFFF |
black | #000000 |
gray | #808080 |
Tips
Transparency
Use transparency (50-80) for overlapping elements to avoid obscuring important data.Semantic Colors
Use consistent color meanings:- Green for bullish/positive
- Red for bearish/negative
- Blue for neutral
- Orange/Yellow for warnings
Hex Colors
For precise color control, use hex values:"#FF6B35", "#3B82F6".