Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Show/Hide Barcolor from Input Settings

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!

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>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)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading