Hi Folks I would appreciate some help with EFS formulas.
I am trying to get a histogram or line type non price study of the difference
between two 14 bar momentum numbers based off a HLC/3. The current 14 bar
momentum number is then subtracted from the 14 bar momentum
number of three bars previous. I include my attempt to solve the EFS
but I am doing something wrong and need assistance if possible. I would like
to be able to change some of the variables such as price and number of bars.
Here after follows my attempt at the EFS script but it has errors that need
correction
Regards Kevan
var vMOM = null;
function preMain() {
setStudyTitle("name here");
setCursorLabelName("Momentum");
setDefaultBarFgColor(Color.blue);
setPlotType(PLOTTYPE_HISTOGRAM);
var fp1 = new FunctionParameter("MOMLength",
FunctionParameter.NUMBER);
fp1.setLowerLimit(1);
fp1.setDefault(14); //Edit this value to set a new default
var fp2 = new FunctionParameter("MOMSource",
FunctionParameter.STRING);
fp2.setName("MOMSource");
fp2.setDefault("HLC/3"); //Edit this value to set a new default
}
function main(MOMLength, MOMSource) {
if (vMOM == null) vMOM = new MOMStudy(MOMLength, MOMSource);
var vNow = vMOM(0);
if(vNow == null)
return;
var vThen = vMOM(-3)
if(vThen == null)
return;
return (vNow - vThen);
}
I am trying to get a histogram or line type non price study of the difference
between two 14 bar momentum numbers based off a HLC/3. The current 14 bar
momentum number is then subtracted from the 14 bar momentum
number of three bars previous. I include my attempt to solve the EFS
but I am doing something wrong and need assistance if possible. I would like
to be able to change some of the variables such as price and number of bars.
Here after follows my attempt at the EFS script but it has errors that need
correction
Regards Kevan
var vMOM = null;
function preMain() {
setStudyTitle("name here");
setCursorLabelName("Momentum");
setDefaultBarFgColor(Color.blue);
setPlotType(PLOTTYPE_HISTOGRAM);
var fp1 = new FunctionParameter("MOMLength",
FunctionParameter.NUMBER);
fp1.setLowerLimit(1);
fp1.setDefault(14); //Edit this value to set a new default
var fp2 = new FunctionParameter("MOMSource",
FunctionParameter.STRING);
fp2.setName("MOMSource");
fp2.setDefault("HLC/3"); //Edit this value to set a new default
}
function main(MOMLength, MOMSource) {
if (vMOM == null) vMOM = new MOMStudy(MOMLength, MOMSource);
var vNow = vMOM(0);
if(vNow == null)
return;
var vThen = vMOM(-3)
if(vThen == null)
return;
return (vNow - vThen);
}
Comment