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:
Can you help? Thank you
Milosz
September 24, 2019, 3:43pm
#2
@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
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
Thank you. Any workaround to start close to the value?
fxshrat
September 24, 2019, 3:48pm
#4
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.