Good afternoon,
I have the following issue when I try to plot a simple difference of moving average.
In the preMain section I convert 3 parameters into numbers using the FunctionParameter Class.
Then I pass those paramethers to 2 ema and 1 coeficient.
But somehow the paramethers for the ema are not detected as NUMBERS. Could you help me to solve this issue?
This is the code:
function preMain() {
setStudyTitle(Diferencia);
setCursorLabelName(Diferencia);
setStudyMax(120);
setStudyMin(-120);
addBand(0, PS_DOT, 1.5, Color.white,0);
setDefaultBarThickness(2,0);
var fp1 = new FunctionParameter("amp", FunctionParameter.NUMBER);
fp1.setDefault(1);
var fp2 = new FunctionParameter("medSup", FunctionParameter.NUMBER);
fp2.setDefault(60);
var fp3 = new FunctionParameter("medInf", FunctionParameter.NUMBER);
fp3.setDefault(30);
}
function main(amp,medInf,medSup) {
var shortAverage = ema(medInf);
var longAverage = ema(medSup);
var diferencia = amp*(shortAverage-longAverage);
return diferencia;
}
This is the error message:
My Formulas\Diferencia.efs, line 37: Error: Failed to call 'ema': parameter # 1 is invalid.
My Formulas\Diferencia.efs, line 23: ReferenceError: Diferencia is not defined
Apparently ema() function does not recognice medInf as a NUMBER but I do not know why, I have declare them in the pre main section like specified in the doc. Extrange issue
Thanks for your help
I have the following issue when I try to plot a simple difference of moving average.
In the preMain section I convert 3 parameters into numbers using the FunctionParameter Class.
Then I pass those paramethers to 2 ema and 1 coeficient.
But somehow the paramethers for the ema are not detected as NUMBERS. Could you help me to solve this issue?
This is the code:
function preMain() {
setStudyTitle(Diferencia);
setCursorLabelName(Diferencia);
setStudyMax(120);
setStudyMin(-120);
addBand(0, PS_DOT, 1.5, Color.white,0);
setDefaultBarThickness(2,0);
var fp1 = new FunctionParameter("amp", FunctionParameter.NUMBER);
fp1.setDefault(1);
var fp2 = new FunctionParameter("medSup", FunctionParameter.NUMBER);
fp2.setDefault(60);
var fp3 = new FunctionParameter("medInf", FunctionParameter.NUMBER);
fp3.setDefault(30);
}
function main(amp,medInf,medSup) {
var shortAverage = ema(medInf);
var longAverage = ema(medSup);
var diferencia = amp*(shortAverage-longAverage);
return diferencia;
}
This is the error message:
My Formulas\Diferencia.efs, line 37: Error: Failed to call 'ema': parameter # 1 is invalid.
My Formulas\Diferencia.efs, line 23: ReferenceError: Diferencia is not defined
Apparently ema() function does not recognice medInf as a NUMBER but I do not know why, I have declare them in the pre main section like specified in the doc. Extrange issue
Thanks for your help
Comment