Announcement

Collapse
No announcement yet.

McClellan OSC

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • McClellan OSC

    Can anyone help me?
    I'm trying to thicken up the Histogram lines on the McClellan OSC.
    Can someone point me in the right direction.
    Here is the EFS.
    Thanks for your time and have a great weekend.
    Greg

    /************************************************** ***************
    Provided By : eSignal. (c) Copyright 2003
    ************************************************** ***************/

    function preMain() {
    setStudyTitle("McClellan Oscillator2 ");
    setCursorLabelName("McClellan Osc");
    addBand(0, PS_SOLID, 4, Color.black, "zero");

    var fp1 = new FunctionParameter("nMAType", FunctionParameter.STRING);
    fp1.setName("MA Type");
    fp1.addOption("Simple");
    fp1.addOption("Exponential");
    fp1.setDefault("Exponential");

    var fp2 = new FunctionParameter("bSum", FunctionParameter.STRING);
    fp2.setName("Summation");
    fp2.addOption("On");
    fp2.addOption("Off");
    fp2.setDefault("On");

    var fp3 = new FunctionParameter("nSym", FunctionParameter.STRING);
    fp3.setName("Symbol");
    fp3.addOption("$ADD");
    fp3.addOption("$ADDQ");
    fp3.setDefault("$ADD");

    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, nSym, 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, nSym);
    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< vOsc_ret1) setBarFgColor(cNeg);

    return vOsc_ret;
    }


    //0 = s, 1 = sum
    var vEMA = new Array(2);
    var vEMA1 = new Array(2);

    var dPercent = new Array(2)
    dPercent[0] = null;
    dPercent[1] = null;

    var bPrimed = new Array(2);
    bPrimed[0] = false;
    bPrimed[1] = false;

    function EMA(nLength, nNum) {
    var nBarState = getBarState();
    var dSum = 0.0;
    var dRef;

    if(dPercent[nNum] == null) {
    dPercent[nNum] = (2.0 / (nLength + 1.0));
    bPrimed[nNum] = false;
    }

    if (nBarState == BARSTATE_NEWBAR) {
    vEMA1[nNum] = vEMA[nNum];
    }

    if(bPrimed[nNum] == false) {
    for(i = 0; i < nLength; i++) {
    dSum += aADD[i];
    }
    bPrimed[nNum] = true;
    return (dSum / nLength);
    } else {
    return (((vADD - vEMA1[nNum]) * dPercent[nNum]) + vEMA1[nNum]);
    }
    }

  • #2
    Re: McClellan OSC

    Greg
    Add the following statement in preMain [for example in line 5]
    setDefaultBarThickness(Thickness,0);
    replacing Thickness with a number to set the desired thickness
    For the description and syntax of the setDefaultBarThickness() see this article in the EFS KnowledgeBase
    You may also want to bookmark this link to the EFS KnowledgeBase where you can find all the available EFS functions
    Alex


    Originally posted by gwika
    Can anyone help me?
    I'm trying to thicken up the Histogram lines on the McClellan OSC.
    Can someone point me in the right direction.
    Here is the EFS.
    Thanks for your time and have a great weekend.
    Greg

    /************************************************** ***************
    Provided By : eSignal. (c) Copyright 2003
    ************************************************** ***************/

    function preMain() {
    setStudyTitle("McClellan Oscillator2 ");
    setCursorLabelName("McClellan Osc");
    addBand(0, PS_SOLID, 4, Color.black, "zero");

    var fp1 = new FunctionParameter("nMAType", FunctionParameter.STRING);
    fp1.setName("MA Type");
    fp1.addOption("Simple");
    fp1.addOption("Exponential");
    fp1.setDefault("Exponential");

    var fp2 = new FunctionParameter("bSum", FunctionParameter.STRING);
    fp2.setName("Summation");
    fp2.addOption("On");
    fp2.addOption("Off");
    fp2.setDefault("On");

    var fp3 = new FunctionParameter("nSym", FunctionParameter.STRING);
    fp3.setName("Symbol");
    fp3.addOption("$ADD");
    fp3.addOption("$ADDQ");
    fp3.setDefault("$ADD");

    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, nSym, 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, nSym);
    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< vOsc_ret1) setBarFgColor(cNeg);

    return vOsc_ret;
    }


    //0 = s, 1 = sum
    var vEMA = new Array(2);
    var vEMA1 = new Array(2);

    var dPercent = new Array(2)
    dPercent[0] = null;
    dPercent[1] = null;

    var bPrimed = new Array(2);
    bPrimed[0] = false;
    bPrimed[1] = false;

    function EMA(nLength, nNum) {
    var nBarState = getBarState();
    var dSum = 0.0;
    var dRef;

    if(dPercent[nNum] == null) {
    dPercent[nNum] = (2.0 / (nLength + 1.0));
    bPrimed[nNum] = false;
    }

    if (nBarState == BARSTATE_NEWBAR) {
    vEMA1[nNum] = vEMA[nNum];
    }

    if(bPrimed[nNum] == false) {
    for(i = 0; i < nLength; i++) {
    dSum += aADD[i];
    }
    bPrimed[nNum] = true;
    return (dSum / nLength);
    } else {
    return (((vADD - vEMA1[nNum]) * dPercent[nNum]) + vEMA1[nNum]);
    }
    }

    Comment


    • #3
      McClellan OSC

      Mr. Montenegro;
      Thank you for your quick response. I did as you suggested and copied and paste "setDefaultBarThickness(Thickness,0);" into line 5 but now I get a formula error.
      Am I missing something?
      Also you URL link doesn't work.
      Thanks again for your time, Greg

      Comment


      • #4
        Re: McClellan OSC

        Greg
        What does the error message say?
        The link should be working now
        Alex


        Originally posted by gwika
        Mr. Montenegro;
        Thank you for your quick response. I did as you suggested and copied and paste "setDefaultBarThickness(Thickness,0);" into line 5 but now I get a formula error.
        Am I missing something?
        Also you URL link doesn't work.
        Thanks again for your time, Greg

        Comment

        Working...
        X