Macro Variables For Amibroker

Is there a way to use “Macro-Like” variables that auto-expand in Amibroker?
More specifically, in the code snippet below, I would like the Price to be something like (H+L)/2 or something else chosen in the parameters. Likewise, AverageType would expand to be EMA, or Wilders. I put an ampersand where the expansion should occur. How can I do this (I’m trying to avoid the use of If and Switch statements).

Price		= ParamList ("Price Type","Open|High|Low|Close|(H+L+C)/3|(H+L)/2",DefaultVal = 5) ;
AverageType = ParamList("Average Type","EMA|Wilders",defaultval = 0); 
	
Plot( PlotLine = (&AverageType((&Price),5), _DEFAULT_NAME(), IIf( PlotLine > 0, ParamColor("Up Color", colorGreen ), 

You can create a function to keep all your logic in one place, but you’re still going to need those if or switch statements inside the function.

@mradtke Ok. I understand. Thanks!

Don’t use & - it operator is for variables only, not for functions and the meaning of & is “address of variable”.
Macro in “C” language (and AFL basically follows “C” syntax) are completely different thing and they don’t use any.

As @mradtke said, proper way is to define a function and if-else or switch is needed.

function MyPrice( x )
{
  r = Open;
  if( x == 1 ) r = HIgh;
  if( x == 2 ) r = ( H+L )/2;
  ...
  return r;
}

Or you can use ParamField that does that for you automatically.

Plot( Close, "Price", colorDefault, styleCandle );

Plot( (H+L)/2, "H+L/2", colorDefault, styleHidden );
P = ParamField("Field", 0 ); // this uses OHLC automatically plus values of any plots before

Plot( MA( P, 10 ), "Moving Average", colorRed );