I want to create MACD of McClellan Oscillator. I have spent many days trying to do this but no luck. Also I want MACD to have SMA not EMA. Can any one help me please? Below is the one of many files code I have struggling with.
function preMain() {
setStudyTitle("MACD");
setCursorLabelName("Fast", 0);
setCursorLabelName("Signal", 1);
setDefaultBarFgColor(Color.RGB(0x00,0x94,0xFF), 0);
setDefaultBarFgColor(Color.RGB(0xFE,0x69,0x00), 1);
var fp1 = new FunctionParameter("nInputFast", FunctionParameter.NUMBER);
fp1.setName("Fast Length");
fp1.setLowerLimit(1);
fp1.setDefault(3);
var fp2 = new FunctionParameter("nInputSlow", FunctionParameter.NUMBER);
fp2.setName("Slow Length");
fp2.setLowerLimit(1);
fp2.setDefault(10);
var fp3 = new FunctionParameter("nInputSmoothing", FunctionParameter.NUMBER);
fp3.setName("Signal Smoothing");
fp3.setLowerLimit(1);
fp3.setDefault(16);
}
var bInit = false;
var xFast = null;
var xSignal = null;
var ExtEfs = null;
function main(nInputFast, nInputSlow, nInputSmoothing) {
if (bInit == false) {
xFast = efsInternal("MACDfast", nInputFast, nInputSlow);
xSignal = sma(nInputSmoothing, xFast);
bInit = true;
ExtEfs = efsExternal("McClellanOsc2.efs");
}
return new Array(xFast.getValue(0), xSignal.getValue(0));
}
function MACDfast(nF, nS) {
if ('ExtEfs'(-nF) == null || 'ExtEfs'(-nS) == null) return;
return (sma(nF, 0) - sma(nS, 0));
}
function preMain() {
setStudyTitle("MACD");
setCursorLabelName("Fast", 0);
setCursorLabelName("Signal", 1);
setDefaultBarFgColor(Color.RGB(0x00,0x94,0xFF), 0);
setDefaultBarFgColor(Color.RGB(0xFE,0x69,0x00), 1);
var fp1 = new FunctionParameter("nInputFast", FunctionParameter.NUMBER);
fp1.setName("Fast Length");
fp1.setLowerLimit(1);
fp1.setDefault(3);
var fp2 = new FunctionParameter("nInputSlow", FunctionParameter.NUMBER);
fp2.setName("Slow Length");
fp2.setLowerLimit(1);
fp2.setDefault(10);
var fp3 = new FunctionParameter("nInputSmoothing", FunctionParameter.NUMBER);
fp3.setName("Signal Smoothing");
fp3.setLowerLimit(1);
fp3.setDefault(16);
}
var bInit = false;
var xFast = null;
var xSignal = null;
var ExtEfs = null;
function main(nInputFast, nInputSlow, nInputSmoothing) {
if (bInit == false) {
xFast = efsInternal("MACDfast", nInputFast, nInputSlow);
xSignal = sma(nInputSmoothing, xFast);
bInit = true;
ExtEfs = efsExternal("McClellanOsc2.efs");
}
return new Array(xFast.getValue(0), xSignal.getValue(0));
}
function MACDfast(nF, nS) {
if ('ExtEfs'(-nF) == null || 'ExtEfs'(-nS) == null) return;
return (sma(nF, 0) - sma(nS, 0));
}
Comment