Lipi Reference
Lipi

Functions

color.from_gradient()

Returns a color calculated from the linear gradient between bottom_color and top_color based on the relative position of value within the range defined by bottom_value and top_value.

Syntax · 1 of 4

                color.from_gradient(const float value, const float bottom_value, const float top_value, const color bottom_color, const color top_color) → const color
              

Arguments

value required const float Value used to determine the position within the gradient range.
bottom_value required const float Lower boundary of the gradient range.
top_value required const float Upper boundary of the gradient range.
bottom_color required const color Color returned when value equals bottom_value (or is below the range).
top_color required const color Color returned when value equals top_value (or is above the range).

Return Type

const color

Syntax · 2 of 4

                color.from_gradient(input float value, input float bottom_value, input float top_value, input color bottom_color, input color top_color) → input color
              

Arguments

value required input float Value used to determine the position within the gradient range.
bottom_value required input float Lower boundary of the gradient range.
top_value required input float Upper boundary of the gradient range.
bottom_color required input color Color returned when value equals bottom_value (or is below the range).
top_color required input color Color returned when value equals top_value (or is above the range).

Return Type

input color

Syntax · 3 of 4

                color.from_gradient(simple float value, simple float bottom_value, simple float top_value, simple color bottom_color, simple color top_color) → simple color
              

Arguments

value required simple float Value used to determine the position within the gradient range.
bottom_value required simple float Lower boundary of the gradient range.
top_value required simple float Upper boundary of the gradient range.
bottom_color required simple color Color returned when value equals bottom_value (or is below the range).
top_color required simple color Color returned when value equals top_value (or is above the range).

Return Type

simple color

Syntax · 4 of 4

                color.from_gradient(series float value, series float bottom_value, series float top_value, series color bottom_color, series color top_color) → series color
              

Arguments

value required series float Value used to determine the position within the gradient range.
bottom_value required series float Lower boundary of the gradient range.
top_value required series float Upper boundary of the gradient range.
bottom_color required series color Color returned when value equals bottom_value (or is below the range).
top_color required series color Color returned when value equals top_value (or is above the range).

Return Type

series color

Example


          //@lipi=2
indicator("from_gradient example", overlay=true)
c1 = color.from_gradient(close, low, high, color.yellow, color.lime)
c2 = color.from_gradient(talib.rsi(close, 7), 0, 100, color.rgb(255, 0, 0), color.rgb(0, 255, 0, 0.5))
bgcolor(c1)