Announcement

Collapse
No announcement yet.

Stochstic with D Slow Color

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

  • Stochstic with D Slow Color

    i want Stochastic with D Slow color, i make some changes but i am not getting indicator perfectly.
    i have given modified script given below, please check it and tell me what is wrong , and how do i do it.

    Thank you

    script :---


    /************************************************** ***************
    Provided By : eSignal. (c) Copyright 2003
    Description: Stochastics with D Slow

    Version: 2.0

    2.0 Notes:
    - Updated parameters to use FunctionParameter Class.
    - Added parameter to turn on/off display of %K.
    - Added parameters to allow user control over study colors.

    ************************************************** ***************/

    addBand(80, PS_SOLID, 2, Color.yellow, "top");
    addBand(20, PS_SOLID, 2, Color.yellow, "bottom");

    function preMain() {
    setStudyTitle("Stochastics with D Slow ");
    setStudyMin(-5);
    setStudyMax(105);
    setShowTitleParameters(false);
    setDefaultBarFgColor(Color.blue, 0); // %K
    setDefaultBarFgColor(Color.red, 1); // %D
    setDefaultBarFgColor(Color.brown, 2); // %D Slow


    setCursorLabelName("\%K", 0);
    setCursorLabelName("\%D", 1);
    setCursorLabelName("\%D Slow", 2);

    var fp1 = new FunctionParameter("nKlength", FunctionParameter.NUMBER);
    fp1.setName("%K Length");
    fp1.setLowerLimit(1);
    fp1.setDefault(14);
    var fp2 = new FunctionParameter("nKsmoothing", FunctionParameter.NUMBER);
    fp2.setName("%K Smoothing");
    fp2.setLowerLimit(1);
    fp2.setDefault(1);
    var fp3 = new FunctionParameter("nDlength", FunctionParameter.NUMBER);
    fp3.setName("%D Length");
    fp3.setLowerLimit(1);
    fp3.setDefault(15);
    var fp4 = new FunctionParameter("nDsmoothing", FunctionParameter.NUMBER);
    fp4.setName("%D Smoothing");
    fp4.setLowerLimit(1);
    fp4.setDefault(15);
    var fp5 = new FunctionParameter("cK", FunctionParameter.COLOR);
    fp5.setName("%K Color");
    fp5.setDefault(Color.blue);
    var fp6 = new FunctionParameter("cD", FunctionParameter.COLOR);
    fp6.setName("%D Color");
    fp6.setDefault(Color.red);
    var fp7 = new FunctionParameter("cDslow", FunctionParameter.COLOR);
    fp7.setName("%D Slow Color");
    fp7.setDefault(Color.brown);
    var fp8 = new FunctionParameter("bKdisplay", FunctionParameter.STRING);
    fp8.setName("Display %K");
    fp8.addOption("ON");
    fp8.addOption("OFF");
    fp8.setDefault("OFF");
    }

    var study = null;
    var vDsmoothing = null;
    var vDslow = null;

    function main(nKlength, nKsmoothing, nDlength, nDsmoothing, cK, cD, cDslow, bKdisplay) {
    if (study == null) {
    if (nDsmoothing == null) {
    vDsmoothing = 15;
    } else {
    vDsmoothing = Math.abs(nDsmoothing);
    }
    study = new StochStudy(nKlength, nKsmoothing, nDlength);
    setDefaultBarFgColor(cK, 0);
    setDefaultBarFgColor(cD, 1);
    setDefaultBarFgColor(cDslow, 2);
    }

    var vK = study.getValue(StochStudy.FAST);
    if (vK == null) return;
    var vD = study.getValue(StochStudy.SLOW);
    if (vD == null) return;

    var aD = study.getValue(StochStudy.SLOW, 0, -vDsmoothing);
    if (aD == null) return;

    var dSum = 0;
    for (i = 0; i < vDsmoothing; ++i) {
    dSum += aD[i];
    }
    vDslow = (dSum/vDsmoothing);

    if (vDslow.getValue(0) >= vDslow.getValue(-1))

    {
    setBarFgColor(Color.red,2);
    }
    else
    {
    setBarFgColor(Color.green,2);
    }


    if (bKdisplay == "OFF") vK = vK.toFixed(4);

    return new Array(vK,vD,vDslow);
    }
Working...
X