Adds a color setting to the script and returns the chosen color, including its transparency.
input.color shows a color picker in the settings and returns the color chosen, starting at defval. The returned value works anywhere a color is expected, such as plot, bgcolor and label.new.
Transparency is part of the choice, so a value picked at 80 percent transparent stays that way when used.
Syntax
input.color(defval: const color, title: const string (optional), tooltip: const string (optional), inline: const string (optional), group: const string (optional), confirm: const bool (optional), display: const plot_display (optional), active: input bool (optional)) -> input colorArguments
| Name | Type | Default | Description |
|---|---|---|---|
| defval | const color | required | Default color, such as color.blue or color.new(color.red, 70). |
| title | const string | na | Name shown in the Settings dialog, the legend and the Data Window. |
| tooltip | const string | na | Text shown in a tooltip beside the input in the Settings dialog. |
| inline | const string | na | Entries sharing the same inline text sit on one row of the Settings dialog. |
| group | const string | na | Heading the input is listed under in the Settings dialog. |
| confirm | const bool | false | When true, the script asks for this value when it is first added to the chart. |
| display | const plot_display | display. | Where the value appears: a display.* constant or a combination of them. |
| active | input bool | true | When false, the input is greyed out and cannot be edited. |
Returns
input color: the chosen color.
Remarks
- Place the up and down colors on one row of the settings by giving both the same inline text.
- On Sidechair: confirm, display and active are accepted and ignored.
Example
//@version=6
indicator("Colored columns")
upColor = input.color(color.teal, "Up color", inline = "c")
downColor = input.color(color.maroon, "Down color", inline = "c")
plot(close - open, "Body", color = close >= open ? upColor : downColor, style = plot.style_columns)See also
Runs on Sidechair