Skip to content
Algo Trade Analytics Docs

color.from_gradient() - Pine Script Function

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.

color.from_gradient(value, bottom_value, top_value, bottom_color, top_color) → series color
NameTypeDescription
valueseries int/floatValue to calculate the position-dependent color.

A color calculated from the linear gradient between bottom_color to top_color.

  • 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.
//@version=6
indicator("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)