This callback function gets called whenever a user changes one of the previously added parameter values.
onParameterChange(parameterName, parameterValue);
parameterName
String value representing the name of the parameter.
parameterValue
String value representing the newly modified value for the parameter.
If a study is relying on certain parameters to calculate its values, this method could update study's internal memory variables with newly modified parameter values at the time when they are changed.
For example, this callback is very handy when a study is utilizing setMinRequiredDataValues() method to keep the minimum number of available source data points, and when a particular parameter is tied to that minRequiredDataValue number. See example below:
The following example demonstrates the use of onParameterChange() callback function.
function init()
{
//add parameter "Period" and set it to default value of 10
this.addParameter("Period", 10);
//get the value for parameter "Period", and use that value to indicate the minimum required data value
this.setMinRequiredDataValues(parseInt(getParameter("Period")));
}
function onParameterChange(parameterName, parameterValue)
{
//if parameterName is "Period", then update minimum required data value
if(parameterName == "Period")
this.setMinRequiredDataValues(parseInt(parameterValue));
}
setMinRequiredDataValues(), addParameter()
Copyright © 2006-2009 ActiveTick LLC