Returns a color blended between two colors according to where a value falls between two limits.
color.from_gradient maps value onto a range. At bottom_value the result is bottom_color, at top_value it is top_color, and in between each channel is interpolated in a straight line.
A value outside the range gets the nearest end color. Transparency is blended along with red, green and blue.
Syntax
color.from_gradient(value: series int/float, bottom_value: series int/float, top_value: series int/float, bottom_color: series color, top_color: series color) -> series colorArguments
| Name | Type | Default | Description |
|---|---|---|---|
| value | series int/ | required | The number to position in the range. |
| bottom_value | series int/ | required | The value that gives bottom_color. |
| top_value | series int/ | required | The value that gives top_color. |
| bottom_color | series color | required | Color shown when the value sits at bottom_value or below it. |
| top_color | series color | required | Color shown when the value sits at top_value or above it. |
Returns
series color: the blended color; na if value, a limit or a color is na.
Remarks
- The two limits can be series, which lets a gradient follow a moving range such as
ta.lowestandta.highest.
Example
//@version=6
indicator("RSI gradient")
r = ta.rsi(close, 14)
col = color.from_gradient(r, 30, 70, color.red, color.green)
plot(r, "RSI", color = col, style = plot.style_columns)
hline(50)See also
Runs on Sidechair