Need PARAM starting at a variable

Hello,

I would like my parameter to start with the last value of a variable "HV" and make me able to adjust up and down:

HV = sqrt(252)*StDev(ln(C/Ref(C,-1)),21);
vol = Param("Volat",LastValue(HV),0.05,1.0,0.005);

But this doesn't work. It starts at 0 although I checked the value and it is non zero.
If I press "reset All" it goes to 0:

c61

Can you help? Thank you

@Armin_Tamzarian you can't do that because (as it is clearly stated in the docs):

WARNING: Default/min/max/step parameters have to be CONSTANT numbers. This is because these values are cached and are not re-read during subsequent formula evaluations.

https://www.amibroker.com/guide/afl/param.html

1 Like

Thank you. Any workaround to start close to the value?

You should do like this outside of Param.

HV = sqrt(252)*StDev(ln(C/Ref(C,-1)),21);
vol = LastValue(HV) + Param("Volat",0,-1,1,0.005);
4 Likes

Thank you very much, thats an ingenious way to solve it.