Auto update/refresh in parameters window

my code used in Parameters window has to be closed and re-opened when I select certain options. For example when I select YES (see below) I have to click OK then re-open the Parameters window and then I can see the other options.
Is there any way to show the hidden parameters after selecting the option without closing the parameters window and re-opening it? Any chance to create a refresh button in the window?


_SECTION_BEGIN("In/Out market and cash");
// Choose if you want an In/Out Market filter 
InOutTog=ParamToggle( "In/Out Market","NO|YES",Defaultval=1);
// If In/Out Market filter is (NO)
if( InOutTog==0) 
{	InOut= 1; // This means that the Market Filter is always OFF 
	SPX=999; SPXMA=888; 
// If In/Out Market filter is (YES)
if(InOutTog==1)// Filter ON
{ // Select a Ticker if In/Out Market filter is (YES)
	MarInd= ParamList( "In/Out Market Ticker:",".SPX|Name()",Defaultval=0);
	/// Choseee if Optimaze or Not the MA for the Ticker of In/Out Market filter
	MarIndMAOptTog=ParamToggle( "In/Out MA Optimizer:","NO|YES",Defaultval=0);
	// If Optimaze MA is (NO) the select teh MA Periods Manually
	{ 	SPXMAPDS= Param("In/out MA periods",12, 1, 100, 1);
		InOut= SPX>=SPXMA ;
	// If Optimaze MA is (YES) this optimaze the MA Periods
	{ // If Optimaze MA is (YES) this selects Min and Max MA Periods
		SpxMaMin= Param("MA Min Pds",6, 1, 100, 1); //choose Min
		SpxMaMax= Param("MA Max Pds",18, 1, 500, 1); //choose Max
		SpxMaSte= Param("MA Ste Pds",1, 1, 100, 1); //choose Steps
		SPXMAPds= Optimize("MA Pds",1,SpxMaMin, SpxMaMax,SpxMaSte); // optimizer
		InOut= SPX>=SPXMA; 
TickerMaTog=ParamToggle( "Ticker Moving Average","NO|YES",Defaultval=0);
TickerMa=C;  UpDown = 1;
{ TickerMaOptTog=ParamToggle( "Opt Ticker Moving Av.","NO|YES",Defaultval=0);
	{ 	TickerMaPds= Param("Ticker Ma",12, 1, 100, 1);//Choose Moving Average
	{ 	TickerMaMin= Param("Min Ticker Ma",1, 1, 100, 1); //choose Min
		TickerMaMax= Param("Max Ticker Ma",18, 1, 500, 1); //choose Max
		TickerMaSte= Param("Step Ticker Ma",1, 1, 100, 1); //choose Steps
		TickerMaPds= Optimize( "Ticker Ma Pds", 1, TickerMaMin, TickerMaMax, TickerMaSte); //Optimize Moving Average
CashTR = ParamList( "Cash Ticker:","$CASHTR|.SPX|#IND",Defaultval=0); // Ticker for cash

Param() functions should not 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. This issue has already been discussed in these threads:

1 Like

Thanks Milosz, understood....
Litte I can do. Just press ok every time and change values.
Thanks for your time.

No, there's always something you can do. For example:

  1. In your case, if you select In/Out MA Optimizer to NO (default setting) you don't have to click OK, close and re-open the window. Instead just click Reset all ! That's it !
  2. Use Param() functions unconditionally - you won't have any problems. In your case MA periods will be always displayed, but when In/Out MA Optimizer is set to NO, they just won't be active.
  3. Change some parameters using GuiButtons() instead of Param() functions
  4. When necessary, you can use hardcoded parameters (which can be changed from the AFL editor) or from the outside of AmiBroker --> Link instead of Param() functions
  5. As I have shown you in my first link, you can implement a “master switch” which will overwrite some selected parameters’ values.


  1. Implement some other solution ...
1 Like

... but in general, using Param() functions in Analysis might not be the best idea. It is recommended to use hardcoded Param values in Analysis (especially backtest/optimization). Read this thread:

... and one additional possibility. A safe way of using Param functions in Analysis :

1 Like

@ Milosz,

That seems the solution, not perfect but feasable.

With regard to Fx comments, he is right (as usual) but I would need the exploration in that way to get close to the finalo model. Then I would go for the hard coding as he suggest.

Again, thanks for your help. Much appreciated.

Maybe I should have mentioned, that personally I don't use any Param() functions in Analysis window, because I usually have at least a few different Analysis Windows (mainly Explorations) open at the same time. In such case, changing params in one Analysis or just clicking parameters icon --> Przechwytywanie - resets Params in all other Analysis windows! In this way, one can easily reset all params accidentally (not even being aware of that) - which may (and eventually will) lead to lots of problems.

... but if someone still wants to use Param() in Analysis, he/she should definitely not use more than one Analysis at a time. Following the links to Fxshrat's posts (from my previous reply), everyone will find the necessary information related to some other possible pitfalls.