2

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!

vitruvius
  • 15,740
  • 3
  • 16
  • 26
podolkerod
  • 95
  • 2
  • 8

1 Answers1

1

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)
vitruvius
  • 15,740
  • 3
  • 16
  • 26