> ## Documentation Index
> Fetch the complete documentation index at: https://gocharting.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# How to let the chart user choose a color

> Declaring a color control with input.color, passing the choice to a plot, and offering one color for rising and one for falling.

Call `input.color` once, at the top level, and pass the result wherever a color is wanted. The first argument is the color the
control starts at; the second is its label.

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("Direction colors", overlay=true)
up = input.color(color.green, "Rising", group="Appearance")
down = input.color(color.red, "Falling", group="Appearance")
plot(close, title="Close", color=close > close[1] ? up : down)
```

Two controls and a conditional expression give a rising and a falling color. The value `input.color` returns has the `input`
qualifier, which is accepted wherever a `simple` or `series` color is, and refused where a `const` is required (see [const, input, simple and series](https://gocharting.com/docs/scripting/language/qualifiers.md)).

## Use the chosen color in a gradient or a fade

The chosen color goes into `color.from_gradient` and `color.new` like any other:

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("Gradient by input colors", overlay=false)
lowColor = input.color(color.red, "Low color")
highColor = input.color(color.green, "High color")
rsi = talib.rsi(close, 14)
plot(rsi, title="RSI", color=color.from_gradient(rsi, 30, 70, lowColor, highColor), linewidth=2)
bgcolor(color.new(highColor, 0.9))
```

The opacity of `color.new` runs from 0 (invisible) to 1 (solid), whatever color you pass.

## The mistakes to avoid

> [!WARNING]
>
> The default must be a constant. A color computed from the bars is refused. The compiler says: Cannot call `input.color` with argument `defval`=`close>open?color.green:color.red`. An argument of `series color` type was used but a `const color` is expected.
>
> ```lipi-invalid theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
> //@lipi=2
> indicator("Bad default", overlay=true)
> c = input.color(close > open ? color.green : color.red, "Color")
> plot(close, color=c)
> ```

`na` is refused too: Argument `defval` of `input.color()` cannot be `na`. Give the control a real default color, and choose
between colors with the controls' values, as above. See [Inputs](https://gocharting.com/docs/scripting/configuration/inputs.md) and
[Color and transparency](https://gocharting.com/docs/scripting/chart-output/color.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.