Nothing plots. I think the problem is how I'm creating the series.
PHP Code:
// comapring two Mom periods
var xFastMom = null;
var xSlowMom = null;
var xMACD = null;
var xSig = null;
var xHist = null;
var bInit = false;
function preMain() {
setPlotType( PLOTTYPE_LINE, 0 );
setPlotType( PLOTTYPE_LINE, 1 );
setPlotType( PLOTTYPE_HISTOGRAM, 2 );
setDefaultBarFgColor( Color.blue, 0 );
setDefaultBarFgColor( Color.red, 1 );
setDefaultBarFgColor( Color.grey, 2 );
}
function main() {
if (!bInit) {
xFastMom = ema(6, mom(12) );
xSlowMom = ema(6, mom(26) );
xMACD = efsInternal("fGetMACD", xFastMom, xSlowMom);
xSig = ema(9, getSeries(xMACD) );
xHist = getSeries(xMACD) - getSeries(xSig);
bInit = true;
}
return new Array( getSeries(xMACD), getSeries(xSig), getSeries(xHist) );
}
function fGetMACD(xF, xS){
nF = xF.getValue(0);
nS = xS.getValue(0);
return(nF-nS);
}
Comment