McClellanOsc2.efs

ICE Data Services -


McClellanOsc2.efs 
  

File Name: McClellanOsc2.efs


Description:
McClellan Oscillator with user defined options for displaying the indictor as a cumulative summation index. The moving average calculation can be set to use simple or exponential. The oscillator is colored green when the slope of the oscillator is positive and red when negative. The plot type can be set to "Line" or "Histogram."


Formula Parameters:
MA Type: Exponential [Exponential, Simple]
Summation: On [On, Off]
Positive Slope: Green
Negative Slope: Red
Plot Type: Histogram [Line, Histogram]

Notes:
NA

Download File:
McClellanOsc2.efs




EFS Code:




/*********************************Provided By : eSignal. (c) Copyright 2003*********************************/function preMain() {    setStudyTitle("McClellan Oscillator2 ");     setCursorLabelName("McClellan Osc");    addBand(0, PS_SOLID, 1, Color.black, "zero");        var fp1 = new FunctionParameter("nMAType", FunctionParameter.STRING);    fp1.setName("MA Type");    fp1.addOption("Simple");    fp1.addOption("Exponential");    fp1.setDefault("Simple");        var fp2 = new FunctionParameter("bSum", FunctionParameter.STRING);    fp2.setName("Summation");    fp2.addOption("On");    fp2.addOption("Off");    fp2.setDefault("On");    var fp3 = new FunctionParameter("cPos", FunctionParameter.COLOR);    fp3.setName("Positive Slope");    fp3.setDefault(Color.green);    var fp4 = new FunctionParameter("cNeg", FunctionParameter.COLOR);    fp4.setName("Negative Slope");    fp4.setDefault(Color.red);    var fp5 = new FunctionParameter("sType", FunctionParameter.STRING);    fp5.setName("Plot Type");    fp5.addOption("Line");    fp5.addOption("Histogram");    fp5.setDefault("Histogram");}var vOsc = null;var vOsc_ret = 0;var vOsc_ret1 = null;var vADD = null;var aADD = new Array(39);var bEdit = true;function main(nMAType, bSum, cPos, cNeg, sType) {    var nState = getBarState();        if (bEdit == true) {        if (bSum == "On") {            setCursorLabelName("McClellan Osc");        } else if (bSum == "Off") {            setCursorLabelName("McClellan Sum");        }        if (sType == "Line") setPlotType(PLOTTYPE_LINE);        if (sType == "Histogram") setPlotType(PLOTTYPE_HISTOGRAM);        bEdit = false;    }        if (nState == BARSTATE_NEWBAR && vADD != null) {        aADD.pop();        aADD.unshift(vADD);        vOsc_ret1 = vOsc_ret;    }        vADD = open(0, 1, "$ADD");    if (vADD == null) return;    aADD[0] = vADD[0];        if (aADD[38] == null) return;        if(nMAType == "Simple") {        var sum = 0;        var s = 0;        var i = 0;        for(i = 0; i < 39; i++) {            sum += aADD[i];            if(i < 19) s += aADD[i];        }        vOsc = (s / 19) - (sum / 39);    } else if (nMAType == "Exponential") {        vEMA[0] = EMA(19, 0);        vEMA[1] = EMA(39, 1);        vOsc = vEMA[0] - vEMA[1];    }        if (bSum == "On") {        vOsc_ret = vOsc_ret1 + vOsc;    } else if (bSum == "Off") {        vOsc_ret = vOsc;    }     if(vOsc_ret > vOsc_ret1) setBarFgColor(cPos);    if(vOsc_ret