From the formula below, I keep getting an error message when I try to refer to past data. Under Function diff, I am trying to subtract todays stoch from yesterdays. Can someone please let me know what I am doing wrong.
Thanks, Steven
function preMain() {
setStudyTitle("Stoch MACD");
setCursorLabelName("Stoch MACD");
setDefaultBarFgColor(Color.black, 0);
var fp1 = new FunctionParameter("nEMAlength", FunctionParameter.NUMBER);
fp1.setName(" EMA Length ");
fp1.setLowerLimit(2);
fp1.setDefault(14);
var fp2 = new FunctionParameter("nEMAsmoothing", FunctionParameter.NUMBER);
fp2.setName(" EMA Smoothing ");
fp2.setLowerLimit(1);
fp2.setDefault(7);
}
function main(nEMAlength, nEMAsmoothing) {
var dADA = ema(nEMAsmoothing,ema(nEMAlength,efsInternal("diff ")));
return dADA;
}
function diff() {
return stochK(17, 3, 1) - getValue( stochK(17, 3, 1), -1 );
}
Thanks, Steven
function preMain() {
setStudyTitle("Stoch MACD");
setCursorLabelName("Stoch MACD");
setDefaultBarFgColor(Color.black, 0);
var fp1 = new FunctionParameter("nEMAlength", FunctionParameter.NUMBER);
fp1.setName(" EMA Length ");
fp1.setLowerLimit(2);
fp1.setDefault(14);
var fp2 = new FunctionParameter("nEMAsmoothing", FunctionParameter.NUMBER);
fp2.setName(" EMA Smoothing ");
fp2.setLowerLimit(1);
fp2.setDefault(7);
}
function main(nEMAlength, nEMAsmoothing) {
var dADA = ema(nEMAsmoothing,ema(nEMAlength,efsInternal("diff ")));
return dADA;
}
function diff() {
return stochK(17, 3, 1) - getValue( stochK(17, 3, 1), -1 );
}
Comment