Announcement

Collapse
No announcement yet.

2004 Sept: The CCI Stochastic (StochOfCCI.efs)

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

  • 2004 Sept: The CCI Stochastic (StochOfCCI.efs)

    File Name: StochOfCCI.efs

    Description:
    This study is based on The CCI Stochastic by Barbara Star, PH.D., which appeared in the September 2004 issue of Active Trader Magazine.

    Formula Parameters:
    nCCILength - 14
    CCISource - Close - [Close, High, Low, Open, HL/2, HLC/3, OHLC/4]
    Stoch2 %K Length - 5
    Stoch2 %K Smoothing - 3
    Stoch2 %D Length - 3
    Upper Band - 80
    Lower Band - 20
    Band's Color - Black
    Display Bands - True - [True, False]
    Line Thickness - 2
    Line Color - Blue
    Arrow Size - 10
    Display Arrows - True - [True, False]


    Notes:
    The related article is copyrighted material. If you are not a subscriber of Active Trader Magazine, please visit www. activetradermag.com.


    Download File:
    StochOfCCI.efs



    EFS Code:
    PHP Code:
    /*****************************************************************
    Provided By : eSignal. (c) Copyright 2004
    Study:  Stochastic of CCI - Barbara Star


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

    function preMain() {
        
    setStudyTitle("Stochastic of CCI");
        
    setCursorLabelName("SoCCI \%K"0);

        
    setDefaultBarFgColor(Color.blue0);
        
        
    setStudyMax(110);
        
    setStudyMin(-5);
        
        
    // Study Parameters
        
    var sp1 = new FunctionParameter("nCCILength"FunctionParameter.NUMBER);
        
    sp1.setLowerLimit(1);        
        
    sp1.setDefault(14); //Edit this value to set a new default
        
        
    var sp2 = new FunctionParameter("nCCISource"FunctionParameter.STRING);
        
    sp2.setName("CCISource");
        
    sp2.addOption("Close");
        
    sp2.addOption("High");
        
    sp2.addOption("Low");
        
    sp2.addOption("Open"); 
        
    sp2.addOption("HL/2");
        
    sp2.addOption("HLC/3");
        
    sp2.addOption("OHLC/4"); 
        
    sp2.setDefault("Close"); //Edit this value to set a new default
        
        
    var sp4 = new FunctionParameter("nKlength2"FunctionParameter.NUMBER);
        
    sp4.setName("Stoch2 \%K Length");
        
    sp4.setLowerLimit(1);
        
    sp4.setDefault(5);

        var 
    sp5 = new FunctionParameter("nKsmooth2"FunctionParameter.NUMBER);
        
    sp5.setName("Stoch2 \%K Smoothing");
        
    sp5.setLowerLimit(1);
        
    sp5.setDefault(3);

        var 
    sp6 = new FunctionParameter("nDlength2"FunctionParameter.NUMBER);
        
    sp6.setName("Stoch2 \%D Length");
        
    sp6.setLowerLimit(1);
        
    sp6.setDefault(3);

        
    // Formula Parameters
        
    var fp1 = new FunctionParameter("nBand1"FunctionParameter.NUMBER);
        
    fp1.setName("Upper Band");
        
    fp1.setDefault(80);

        var 
    fp2 = new FunctionParameter("nBand2"FunctionParameter.NUMBER);
        
    fp2.setName("Lower Band");
        
    fp2.setDefault(20);
        
        var 
    fp3 = new FunctionParameter("cBands"FunctionParameter.COLOR);
        
    fp3.setName("Band's Color");
        
    fp3.setDefault(Color.black);
        
        var 
    fp4 = new FunctionParameter("bBands"FunctionParameter.STRING);
        
    fp4.setName("Display Bands");
        
    fp4.addOption("True");
        
    fp4.addOption("False");
        
    fp4.setDefault("True");
        
        var 
    fp5 = new FunctionParameter("nThickness"FunctionParameter.NUMBER);
        
    fp5.setName("Line Thickness");
        
    fp5.setLowerLimit(1);
        
    fp5.setDefault(2);
        
        var 
    fp6 = new FunctionParameter("cLineColor"FunctionParameter.COLOR);
        
    fp6.setName("Line Color");
        
    fp6.setDefault(Color.blue);

        var 
    fp7 = new FunctionParameter("nArrowSize"FunctionParameter.NUMBER);
        
    fp7.setName("Arrow Size");
        
    fp7.setLowerLimit(1);
        
    fp7.setDefault(10);
        
        var 
    fp4 = new FunctionParameter("bArrows"FunctionParameter.STRING);
        
    fp4.setName("Display Arrows");
        
    fp4.addOption("True");
        
    fp4.addOption("False");
        
    fp4.setDefault("True");    
    }

    var 
    bEdit true;
    var 
    study null;
    var 
    vCCI null;
    var 
    vK2 null;   
    var 
    vK2_1 null;  
    var 
    vD2 null;
    var 
    aCCI null;
    var 
    aStochK2 null;
    var 
    cntr 0;

    function 
    main(nCCILengthnCCISourcenKlength2nKsmooth2nDlength2
        
    nBand1nBand2cBandsbBandsnThicknesscLineColornArrowSizebArrows) {
        var 
    nState getBarState();
        
        if (
    bEdit == true) {
            
    addBand(nBand1PS_SOLID1cBands"SoS Upper");
            
    addBand(nBand2PS_SOLID1cBands"SoS Lower");
            
    setDefaultBarThickness(nThickness);
            
    setDefaultBarFgColor(cLineColor);
            if (
    bBands == "False") {
                
    removeBand("SoS Upper");
                
    removeBand("SoS Lower");
            }
            if (
    aCCI == nullaCCI = new Array((Math.round(nKlength2) + Math.round(nKsmooth2) -1));
            if (
    aStochK2 == nullaStochK2 = new Array(Math.round(nDlength2));
            
    bEdit false;
        }

        if (
    nState == BARSTATE_NEWBAR) {
            
    cntr += 1;
            if (
    cntr == 300cntr 0;
            if (
    vCCI != null) {
                
    aCCI.pop();
                
    aCCI.unshift(vCCI);
            }
            if (
    vK2 != null) {
                
    vK2_1 vK2;
                
    aStochK2.pop();
                
    aStochK2.unshift(vK2);
            }
        }
        
        if (
    study == nullstudy =  new CCIStudy(Math.round(nCCILength), nCCISource);
        if (
    study == null) return;

        
    vCCI study.getValue(CCIStudy.CCI);
        if (
    vCCI == null) return;
        
    aCCI[0] = vCCI;

        if (
    aCCI[Math.round(nKlength2) - 1] == null) return;
        
        
    vK2 StochK2(Math.round(nKlength2), Math.round(nKsmooth2));
        if (
    vK2 == null) return;
        
    aStochK2[0] = vK2;
        
        if (
    bArrows == "True") {
            
    // Short signal
            
    if (vK2_1 nBand1 && vK2 nBand1) {
                
    drawTextRelative(0,vK2+10,"ê",Color.red,null,
                    
    Text.BOTTOM|Text.CENTER|Text.BOLD,
                    
    "Wingdings",Math.round(nArrowSize),"S"+cntr);
            }
            
    // Long signal
            
    if (vK2_1 nBand2 && vK2 nBand2) {
                
    drawTextRelative(0,vK2-10,"é",Color.green,null,
                    
    Text.TOP|Text.CENTER|Text.BOLD,
                    
    "Wingdings",Math.round(nArrowSize),"B"+cntr);
            }
        }
        
        return 
    vK2;
    }


    /*********************/
    /***** Functions *****/
    /*********************/

    function StochHH(nInputOffsetnInputLength) {
        var 
    nOffset nInputOffset;
        var 
    nLength nInputLength;
        var 
    hh 0;
        var 
    0;
        
        for(
    0nLengthi++) {
            if(
    == 0) {
                
    hh aCCI[i+nOffset];
            } else {
                
    hh Math.max(hhaCCI[i+nOffset]);
            }
        }
        return 
    hh;
    }


    function 
    StochLL(nInputOffsetnInputLength) {
        var 
    nOffset nInputOffset;
        var 
    nLength nInputLength;
        var 
    ll 0;
        var 
    0;
        
        for(
    0nLengthi++) {
            if(
    == 0) {
                
    ll aCCI[i+nOffset];
            } else {
                
    ll Math.min(llaCCI[i+nOffset]);
            }
        }
        return 
    ll;
    }


    function 
    StochK2(inputLengthinputSmoothing) {
        var 
    percentK;
        var 
    StochK;
        var 
    llhh;
        var 
    sum 0;
        var 
    0;
        var 
    nOffset 0;
        var 
    nDO;
        var 
    nLength inputLength;
        var 
    nSmoothing inputSmoothing;

        for(
    0nSmoothingi++) {
            
    nDO nOffset;
            
    StochK aCCI[nDO];
            
            
    ll StochLL(nDOnLength);
            if(
    ll == null) return null;
            
            
    hh StochHH(nDOnLength);
            if(
    hh == null) return null;
            
            
    percentK = ((StochK ll) / (hh ll)) * 100;
            
            
    sum += percentK;
        }

        
    sum /= nSmoothing;
        return 
    sum;

    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