Skip to main content
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.
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).

Use the chosen color in a gradient or a fade

The chosen color goes into color.from_gradient and color.new like any other:
The opacity of color.new runs from 0 (invisible) to 1 (solid), whatever color you pass.

The mistakes to avoid

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.
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 and Color and transparency.