Can you put limits on external variables?

 

Hi guys! Is it possible to put limits on extern vars in the Inputs tab for an indicator? Let's say a var can be from 0 to 200. And you don't want the user to enter a value over 200 or a negative one.

I know I can correct this when the indicator starts, but if he enters the value in the Inputs tab it remains there.

Thanks!

 
Alex2181:

Hi guys! Is it possible to put limits on extern vars in the Inputs tab for an indicator? Let's say a var can be from 0 to 200. And you don't want the user to enter a value over 200 or a negative one.

I know I can correct this when the indicator starts, but if he enters the value in the Inputs tab it remains there.

Thanks!

Hi Alex

No, there's no way to validate as the user actually inputs. The only thing you can do is as you suggest, correct the values when the indy/EA loads
 

Well you can use of course:

enum name of enumerable type
  {
   list of values
  };
So that its not possible to choose a value that lies outside of the list of values.
 
Marco vd Heijden:

Well you can use of course:

So that its not possible to choose a value that lies outside of the list of values.
For sure, but in the example given, I don't think he wants to do an enumeration of every integer from 0 to 200 ;)
 

You can check in OnInit():

extern int Per = 30;
...
int OnInit() {
   ...
   if ( Per<1 || Per > 200) { Alert("inavlid Per"); return( INIT_PARAMETERS_INCORRECT ); }
   ..
}
 
Carl Schreiber:

You can check in OnInit():

Million thanks! Works like a charm!
 
Carl Schreiber #:

You can check in OnInit():

I love when somebody doesn't overthink the question and simply just answers! ;)