Announcement

Collapse
No announcement yet.

Study of Study, Please Help

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

  • Study of Study, Please Help

    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));
    }

  • #2
    gina359
    Change your bInit routine and the MACDfast function as shown in the images enclosed below
    You may want to review this thread that shows how to create studies on studies using the EFS2 functions
    Alex






    Originally posted by gina359 View Post
    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));
    }

    Comment


    • #3
      Thanks a lot Alexis you are a Genius. One last question is there a code for adding a line to 'Zero' in the oscillator, lets say blue color.

      Comment


      • #4
        gina359
        Use the addBand() function [for the description and syntax see the link to the article in the EFS KnowledgeBase]
        Alex


        Originally posted by gina359 View Post
        Thanks a lot Alexis you are a Genius. One last question is there a code for adding a line to 'Zero' in the oscillator, lets say blue color.

        Comment

        Working...
        X