how to make checkbox option to Show/Hide in Input Settings (so we don’t need go to input style tab to show/hide it) for bar coloring with conditional below?
//Conditions
L_adx = DIPlus > DIMinus and ADX > th
S_adx = DIPlus < DIMinus and ADX > th
BAR_COLOR_ADX = L_adx ? color.lime : S_adx ? color.red : color.orange
barcolor(title="ADX Bar Color", color = BAR_COLOR_ADX)
Thanks in advance!
>Solution :
You should use the input.bool() function to get the user input in a checkbox form. Then use this input as a condition for your color variable. Set it to na if it is unchecked.
show_barcolor = input.bool(defval=true, title="Show barcolor?")
BAR_COLOR_ADX = show_barcolor ? L_adx ? color.lime : S_adx ? color.red : color.orange : na
barcolor(title="ADX Bar Color", color = BAR_COLOR_ADX)