Announcement

Collapse
No announcement yet.

2004 Jun: VolumeCurtailment.efs

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

  • 2004 Jun: VolumeCurtailment.efs

    File Name: VolumeCurtailment.efs


    Description:
    Based on Using Money Flow to Stay With the Trend by Markos Katsanos. This article appeared in the June 2004 issue of Stock & Commodities.

    Formula Parameters:
    Length - 30


    Notes:
    The related article is copyrighted material. If you are not a subscriber of Stocks & Commodities, please visit www.traders.com.

    Version 1.1
    This formula has been modified 5/4/2004. An input parameter for the Length was added and the MA length of volume for volume curtailment is set to the same length.

    Download File:
    VolumeCurtailment.efs




    EFS Code:

    PHP Code:
    /******************************************
    Provided By : eSignal. (c) Copyright 2004
    Study:        Volume Curtailment by Markos Katsanos
    Version:      1.1

    4/8/2004

    Notes: 1.1  5/4/2004
    * Added input parameter for Length and set MA length of
      volume for volume curtailment to the same length.

    Formula Parameters:                     Default:
        Length                                  30  
        
     *******************************************/

    function preMain() {
        
    setStudyTitle("Volume Curtailment ");
        
    setShowTitleParameters(false);
        
    setCursorLabelName("Volume"0);
        
    setCursorLabelName("Vol Cutoff"1);
        
    setDefaultBarFgColor(Color.green0);
        
    setDefaultBarFgColor(Color.black1);
        
    setDefaultBarThickness(30);
        
    setDefaultBarThickness(11);
        
    setPlotType(PLOTTYPE_HISTOGRAM0);

        var 
    fp0 = new FunctionParameter("nLength"FunctionParameter.NUMBER);
        
    fp0.setName("Length");
        
    fp0.setLowerLimit(1);
        
    fp0.setDefault(26);
    }


    var 
    nTyp null;                // Current typical price
    var nTyp1 null;               // Previous typical price
    var nTypChg 0;                // Current typical price change
    var vVol null;                // Current volume
    var nVolSum 0;                // Cumulative volume sum
    var nVolAdj 0;                // Current adjusted volume
    var nVolMA null;              // Current Vol MA
    var nVolMA1 null;             // Previous Vol MA
    //var aTypPrice = new Array(30);  // Array of changes in typical price
    //var aVolume = new Array(50);    // Volume array
    var aTypPrice null;  // Array of changes in typical price
    var aVolume null;    // Volume array
    var bEdit false;

    function 
    main(nLength) {
        var 
    nState getBarState();
        var 
    vInter 0;
        var 
    nCutoff 0;
        var 
    dSum 0;
        var 
    0;
        var 
    vColor Color.blue;
        
        if (
    bEdit == false) {
            if (
    aTypPrice == nullaTypPrice = new Array(nLength);
            if (
    aVolume == nullaVolume = new Array(nLength);
            
    bEdit true;
        }
        
        if (
    nState == BARSTATE_NEWBAR) {
            if (
    nTyp != null) {
                
    aTypPrice.pop();
                
    aTypPrice.unshift(nTypChg);
                
    nTyp1 nTyp;
            }
            if (
    nVol != null) {
                
    aVolume.pop();
                
    aVolume.unshift(nVol);
            }
            
    nVolMA1 nVolMA;
            
    nVolSum += nVolAdj;
        }
        
        
    nVol volume();
        if (
    nVol == null) return;
        
    aVolume[0] = nVol;
        if (
    aVolume[nLength-1] != null) {
            for (
    0nLength; ++i) {
                
    dSum += aVolume[i];
            }
            
    nVolMA dSum/nLength;
        }
        
        
    nTyp = (high() + low() + close()) / 3;
        if (
    nTyp1 != null) {
            
    nTypChg = (Math.log(nTyp) - Math.log(nTyp1));
            
    aTypPrice[0] = nTypChg;
        }
        
        if (
    nVolMA == null || nVolMA1 == null) return;
        
        if (
    aTypPrice[nLength-1] != null) {
            
    vInter StDev(nLength);
            
    nCutoff = (.2 vInter close());
        } else {
            return;
        }

        
    nVolAdj nVol;
        
    //Minimal Change Cutoff
        
    if ((nTyp nTyp1) >= && (nTyp nTyp1) < nCutoffnVolAdj 0;
        if ((
    nTyp nTyp1) < && (nTyp nTyp1) > -nCutoffnVolAdj 0;
        
    // Volume curtailment
        
    if (nVolAdj > (2.5*nVolMA1)) nVolAdj = (2.5*nVolMA1);
        
        if (
    nTyp nTyp1 0nVolAdj *= -1;
        
        if (
    nVolAdj 0vColor Color.green;
        if (
    nVolAdj 0vColor Color.red;
        
    setBarFgColor(vColor);
        
        return new Array(
    nVol, (2.5*nVolMA1).toFixed(0)*1);
    }


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

    function StDev(nLength) {
        
    //var nLength = 30;
        
        
    var sumX 0;
        var 
    sumX2 0;
        for (
    0nLength; ++i) {
            
    sumX += aTypPrice[i];
            
    sumX2 += (aTypPrice[i] * aTypPrice[i])
        }
        var 
    meanX = (sumX/nLength);
        var 
    stdev Math.sqrt((sumX2/nLength) - (meanX*meanX));

        return 
    stdev;

    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