Announcement

Collapse
No announcement yet.

StochWithDslow.efs

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • StochWithDslow.efs

    File Name: StochWithDslow.efs

    Description:
    Stochastic study with an added %D Slow line, which is a simple moving average of the %D line.

    Formula Parameters:
    nKlength: 14
    nKsmoothing: 1
    nDlength: 15
    nDsmoothing: 15
    %K Color: Blue
    %D Color: Red
    %D Slow Color: Brown
    %K Display: Off

    Notes:
    Version 2.0 (Updated 10/14/2004)
    Notes:
    - Updated parameters to use FunctionParameter Class.
    - Added parameter to turn on/off display of %K, which is off by default.
    - Added parameters to allow user control over study colors.


    Download File:
    StochWithDslow.efs



    EFS Code:
    PHP Code:
    /*****************************************************************
    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(80PS_SOLID2Color.yellow"top");
    addBand(20PS_SOLID2Color.yellow"bottom");

    function 
    preMain() {
        
    setStudyTitle("Stochastics with D Slow ");
        
    setStudyMin(-5);
        
    setStudyMax(105);
        
    setShowTitleParameters(false);
        
    setDefaultBarFgColor(Color.blue0); // %K
        
    setDefaultBarFgColor(Color.red1); // %D
        
    setDefaultBarFgColor(Color.brown2); // %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;

    function 
    main(nKlengthnKsmoothingnDlengthnDsmoothingcKcDcDslowbKdisplay) {
        if (
    study == null) {
            if (
    nDsmoothing == null) { 
                
    vDsmoothing 15;
            } else {
                
    vDsmoothing Math.abs(nDsmoothing);
            }
            
    study = new StochStudy(nKlengthnKsmoothingnDlength);
            
    setDefaultBarFgColor(cK0);
            
    setDefaultBarFgColor(cD1);
            
    setDefaultBarFgColor(cDslow2);
        }
        
        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.SLOW0, -vDsmoothing);
        if (
    aD == null) return;
        
        var 
    dSum 0;
        for (
    0vDsmoothing; ++i) {
            
    dSum += aD[i];
        }
        var 
    vDslow = (dSum/vDsmoothing);
        
        if (
    bKdisplay == "OFF"vK vK.toFixed(4);
        
        return new Array(
    vKvDvDslow);

    Jason K.
    Project Manager
    eSignal - an Interactive Data company

    EFS KnowledgeBase
    JavaScript for EFS Video Series
    EFS Beginner Tutorial Series
    EFS Glossary
    Custom EFS Development Policy

    New User Orientation
Working...
X