HV = HHV(high,Cum(1)-int((cum(1)/29))*29);
Plot(HV,"HV",colorGold,styleLine);
T = "";
for ( i = 0; i <= 29; i++)
{
T += NumToStr(HV[i],1.2,False)+"\n"+"|";
}
paramlist("Parameter Name",T,0);

function VarGetMax( varname, num ) {
/// How to use:
/// @link https://forum.amibroker.com/t/dynamic-variables-to-solve-highest-and-lowest-moving-average-in-a-group-of-averages/3142/3
local n, maxall;
maxall = -1e9;
for ( n = 1; n <= num; n++ )
maxall = Max( maxall, VarGet( varname + n ) );
return maxall;
}
maxn = Param( "Number of previous Bar Highs", 30, 1, 50, 1);
for ( n = 1; n <= maxn; n++ ) {
VarSet( "High" + n, Ref(H, -n));
printf( "%g High%g variable: %g\n", n, n, VarGet( "High" + n ) );
}
// Overall maximum High
getmax = VarGetMax( "High", maxn );
printf( "\nMax. of %g Variables: %g", maxn, getmax );

BUT... why doing such way here in this case since just a single function HHV() is required to get highest high value of a past number of bars?

maxn = Param( "Number of previous Bar Highs", 30, 1, 50, 1);
getmax = Ref(HHV(H, maxn), -1);
printf( "\nMax. of %g Variables: %g", maxn, getmax );

So I do not understand why you want to use Max() function here.

On the other hand if you want to store each iteration then...

num = 30;
for ( n = 2; n <= num; n++ ) {
VarSet( "High" + (n-1), Ref(HHV(H, n), -1));
}

You can not store variable arguments to Param* functions. Params are not designed for such things. Param* are cached and expect their arguments to be pre defined -> fix. For example in your case if you keep Param window opened and you scroll chart then such list won't change.
Don't do that. It is road to disaster.

@Sebastian, you are misusing Param*. Don't do that.