September 17, 2020
Create Color Inputs in Pine

A new input.color type for input() allows coders to provide script users with color selection through the script’s Settings/Inputs tab with the same color widget used throughout the TradingView user interface.

See in the example below how input.color is used to provide script users with a choice of label colors:

//@version=4
study("Input color example", overlay=true)
color c_up = input(color.green, "Color Up", type = input.color)
color c_down = input(color.red, "Color Down", type = input.color)
l = label.new(bar_index, na)
if close >= open
    label.set_text(l, "green")
    label.set_color(l, c_up)
    label.set_yloc(l, yloc.belowbar)
    label.set_style(l, label.style_labelup)
else
    label.set_text(l, "red")
    label.set_color(l, c_down)
    label.set_yloc(l, yloc.abovebar)
    label.set_style(l, label.style_labeldown)

The default value for the color input can be any color from the standard palette, or one you create yourself: using color.new(color.green, 50) or #F0000080 for example. Your script users will also be able to select any combination of color/transparency through the color widget.

We hope this new feature you requested is useful. Please continue sending us your suggestions for improvement. We build TradingView for you and love receiving your feedback.

The fastest way to follow markets

Launch Chart