color.from_gradient() - Pine Script Function
color.from_gradient()
Section titled “color.from_gradient()”Overview
Section titled “Overview”Based on the relative position of value in the bottom_value to top_value range, the function returns a color from the gradient defined by bottom_color to top_color.
Syntax
Section titled “Syntax”color.from_gradient(value, bottom_value, top_value, bottom_color, top_color) → series colorParameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| value | series int/float | Value to calculate the position-dependent color. |
Returns
Section titled “Returns”A color calculated from the linear gradient between bottom_color to top_color.
Remarks
Section titled “Remarks”- Using this function will have an impact on the colors displayed in the script’s “Settings/Style” tab. See the User Manual for more information.
Examples
Section titled “Examples”Example 1
Section titled “Example 1”//@version=6indicator("color.from_gradient", overlay=true)color1 = color.from_gradient(close, low, high, color.yellow, color.lime)color2 = color.from_gradient(ta.rsi(close, 7), 0, 100, color.rgb(255, 0, 0), color.rgb(0, 255, 0, 50))plot(close, color=color1)plot(ta.rsi(close,7), color=color2)