Parameters - Conditionally set No | Yes ParamToggle() to No

I have set up a bunch of ParamToggle() in my backtest code. Sometimes, I just want to set all of them to “No” without having to toggle each one.

Can anyone suggest an elegant way to use a “master switch” that can disable the whole bunch of toggles (and show that they are set to No in the Parameters dialog)?

Param() functions cannot be used conditionally and their default parameters have to be CONSTANT. This is because these values are cached and are not re-read during subsequent formula evaluations. For this reason I don't see the exact solution which would allow you to make such "master reset" resetting only selected group of parameters and displaying proper values in Parameters dialog. But there are other solutions:

  1. If you have many ParamToggle() in your code, and only a few other Param() functions, you can click Reset all from Parameters window to reset all parameters - in your case to boolean "No" value. Then you can manually switch back some other few Parameters.
  2. You can implement a "master switch" which will overwrite some selected parameters' values. It will be working fine and will allow you to reset only selected group of parameters (not one by one and not all of them), but when it is "on" that selected group of parameters won't be showing proper values in Parameters window. If you switch it off, everything will be working as usual. So it might not be 100% elegant solution, but should be effective. An example code:
MyVariable1 = ParamToggle( "My Variable 1", "No|Yes", 0 );
MyVariable2 = ParamToggle( "My Variable 2", "No|Yes", 0 );
MyVariable3 = ParamToggle( "My Variable 3", "No|Yes", 0 );
SomeOtherVariable = ParamToggle( "Some other variable", "No|Yes", 0 );

Reset = ParamToggle( "Reset selected values", "No|Yes", 0 );

if( Reset ) MyVariable1 = MyVariable2 = MyVariable3 = 0; 

printf( "\nMy Variable 1 --> %g\nMy Variable 2 --> %g\nMy Variable 3 --> %g\n\nSome other variable --> %g", MyVariable1, MyVariable2, MyVariable3, SomeOtherVariable );



@Milosz Thank you. I understand the AFL Override would work, but the Parameter display would not show the setting’s value used in the formula.

In AFL code, is there any possible way to force “flush” or reset the Parameter(s) cached values to new defaults (based on a variable) without having to press Reset All (and without restarting Amibroker)? I believe you already answered the question above as NO, but I want to double check!

Perhaps @Tomas can comment on whether (or why) this constraint is permanent or whether the Amibroker Development road map will eventually give us the capability to programmatically update the Parameter’s values (use a variable (instead of a constant) for the default value).

As @Milosz wrote - Param() functions must be called UNconditionally as their values are cached. And no that won’t change. It is dictated by dozens of different reasons.