1

Until a few days ago I thought that Pinescript Inputs were not conditional, in fact it is not possible to do something like this.

bool_x = input.bool(true, "On")

if bool_x
  integer_x = input.int(0, 'lenght', minval=1)
else
  // Do nothing. Don't create this input

That's not possible 'cause inputs use Constant and they cannot be changed.

However i found a script created by a user and i dont know how he did a similar thing, how can i disable an input in the same way he did based on condition?

Here the indicator's name (We cannot see the source code): Session Volume Profile HD

Example of what i'm taliking about

Turi
  • 57
  • 7

1 Answers1

2

Session Volume Profile HD is an indicator published by Tradingview. Naturally, Tradingview has superpowers that we do not have :)

In short, you cannot do that at the moment in pinescript.

As a workaround, you can have a bool input to enable/disable a specific input but it won't disable other inputs. You just need to programmatically ignore the other inputs.

vitruvius
  • 15,740
  • 3
  • 16
  • 26
  • Well, in fact I thought it was (for now) impossible. Thank you for the confirmation Vitruvius. However it would be useful if they implemented this function together with the possibility to change the options of an input conditionally. =) – Turi Oct 01 '22 at 11:57