Page 1 of 1

Please help with bool and user input values

Posted: Sat Dec 10, 2022 8:36 pm
by PegLeg
Need help with conditional operator for changing operator settings.

If the below bool is marked true, I want to change the defval / step for the following user input from 0.00010 / 0.000005 to 0.001 / 0.00005.

Everything I tried throws some kind of error.

JPYpairs = input.bool(title="Will this indicator be for JPY pairs?", defval=false, tooltip="If trading JPY pairs the decimal \n for consolidation moves.", group="STEP 1: GENERAL SETTINGS")

i_conlevelHighLMACD = input.float(0.00010, title="Consolidation Channel", minval=0,step=0.000005, group="STEP 3: CONSOLIDATE HIGH", tooltip="These levels define consolidation on Long-MACD.")

Re: Please help with bool and user input values

Posted: Sun Dec 11, 2022 7:05 pm
by purplemint22
The only thing that I can think of would be to use a variable for the default value that can be changed. I tried this and I get an error saying

10:47:11 AM — Compilation error. Line 10: Syntax error: Arguments of input function must be of constant type, or 'source' builtin variables

So it looks like you have to either use a hardcoded string or one of source built in variables like colors.

You could change the decimal place on the backend by using syminfo.description

So it would look something like this

symbol = syminfo.description

if str.contains(symbol, "Yen")
i_conlevelHighLMACD := i_conlevelHighLMACD * 10

It won't help make it easier for the user to enter the value, but it will convert the value for them if they are not familiar with the difference this will make.

The only other thing I can think of is creating a separate input for JPY pairs and using the boolean as a way of knowing when to use this second input or ignore it.

Re: Please help with bool and user input values

Posted: Sun Dec 11, 2022 9:19 pm
by PegLeg
Thanks much, Purple. I've tried everything. At this point I'm just "tooltipping" and "grouping" to try and mitigate the situation.

I'm hoping our illustrious leader will take a moment to shed some light. (unless you are actually him in disquise.) :wink: :zen: :time: