I have several function parameters in my efs, but only 1 is working. I suspect the problem is that the only one that is working (Signal) is in function main () section of my code. The other parameters are within function myCalcDI() section , which is just before the function main(). The parameters do show up in the Formula Parameters section of the Edit Study window. However, when changing any of the numbers, nothing happens. The code is below.
I've looked at several of the posts regarding this issue, as well as, other available code. I can't seem to find the issue.
Any help is greatly appreciated.
Regards,
zMendel
I've looked at several of the posts regarding this issue, as well as, other available code. I can't seem to find the issue.
Any help is greatly appreciated.
Regards,
zMendel
PHP Code:
var vLastAlert = -1;
function preMain() {
setPriceStudy(false);
setStudyTitle("Directional Trend Index (DTI) Directonal Oscillator v2.1.1");
setCursorLabelName("DTI", 0);
setCursorLabelName("DTIs", 1);
setDefaultBarStyle(PS_SOLID, 0);
setDefaultBarStyle(PS_SOLID, 1);
setDefaultBarFgColor(Color.blue, 0);
setDefaultBarFgColor(Color.red, 1);
setDefaultBarThickness(4, 0);
setDefaultBarThickness(2, 1);
setPlotType(PLOTTYPE_HISTOGRAM, 0);
setPlotType(PLOTTYPE_LINE, 1);
var fp3 = new FunctionParameter("EMArN", FunctionParameter.NUMBER);
fp3.setName ("EMArN");
fp3.setLowerLimit (0);
fp3.setDefault (36);
var fp4 = new FunctionParameter("EMAsN", FunctionParameter.NUMBER);
fp4.setName ("EMAsN");
fp4.setLowerLimit (0);
fp4.setDefault (8);
var fp5 = new FunctionParameter("EMArD", FunctionParameter.NUMBER);
fp5.setName ("EMArD");
fp5.setLowerLimit (0);
fp5.setDefault (36);
var fp6 = new FunctionParameter("EMAsD", FunctionParameter.NUMBER);
fp6.setName ("EMAsD");
fp6.setLowerLimit (0);
fp6.setDefault (8);
var fp7 = new FunctionParameter("Signal", FunctionParameter.NUMBER);
fp7.setName ("Signal");
fp7.setLowerLimit (0);
fp7.setDefault (8);
}
function myCalcN() {
if (getValue("high", 0) - getValue("high", -1) > 0) {
var HMuN = getValue("high", 0) - getValue("high", -1);
} else {
var HMuN = 0;
}
if (getValue("low", 0) - getValue("low", -1) < 0) {
var LMdN = (getValue("low", 0) - getValue("low", -1)) * (-1);
} else {
var LMdN = 0;
}
return HMuN - LMdN;
}
function myCalcD() {
if (getValue("high", 0) - getValue("high", -1) > 0) {
var HMuD = getValue("high", 0) - getValue("high", -1);
} else {
var HMuD = 0
}
if (getValue("low", 0) - getValue("low", -1) < 0) {
var LMdD = (getValue("low", 0) - getValue("low", -1)) * (-1);
} else {
var LMdD = 0
}
return Math.abs((HMuD - LMdD));
}
function myCalcDI(EMArN, EMAsN, EMArD, EMAsD, Signal) {
var vDIn = efsInternal("myCalcN");
var vEMArN = ema(EMArN, vDIn);
var vEMAsN = ema(EMAsN, vEMArN);
var vDId = efsInternal("myCalcD");
var vEMArD = ema(EMArD, vDId);
var vEMAsD = ema(EMAsD, vEMArD);
return ((vEMAsN/vEMAsD)*100);
}
function main(EMArN, EMAsN, EMArD, EMAsD, Signal) {
var vDI = efsInternal("myCalcDI");
var vDIs = ema(Signal, vDI);
if (
vDI < vDIs
) onAction1()
else if (
vDI > vDIs
) onAction2();
return new Array(
vDI,
vDIs
);
}
function onAction1() {
setBarBgColor(Color.RGB(255,255,87));
if (vLastAlert != 1)
Alert.playSound ("C:\\ProgramFiles\\eSignal Pro\\Sounds\\Ding.wav");
vLastAlert = 1;
}
function onAction2() {
setBarBgColor(Color.RGB(233,255,255));
if (vLastAlert != 2)
Alert.playSound ("C:\\ProgramFiles\\eSignal Pro\\Sounds\\Ding.wav");
vAsk = getMostRecentAsk();
vHigh = high() - .3;
vLastAlert = 2;
}
Comment