COMPQ_Volume.efs

ICE Data Services -

COMPQ_Volume.efs   

File Name: COMPQ_Volume.efs

Description:

Displays a volume histogram for the $COMPQ by using the open of $TVOLQ - the close of $TVOLQ for intraday intervals. There is also a moving average built in, which can be adjusted through the nLength parameter.

Formula Parameters:

  • nLength - Defines the length of the Moving Average. Default is 50.

Notes:
NA

Download File:
COMPQ_Volume.efs


EFS Code:

/****************************************************************
Provided By : eSignal. (c) Copyright 2003
*****************************************************************
Description: Displays a volume histogram for the $COMPQ by using
the open of $TVOLQ - the close of $TVOLQ for intraday intervals.
There is also a moving average built in, which can be adjusted
through the nLength parameter.
*/

function preMain() {
setStudyTitle("Nasdaq Volume");
setCursorLabelName("Nasdaq Vol", 0);
setCursorLabelName("Avg. Vol", 1);
setPlotType(PLOTTYPE_HISTOGRAM,0);
setDefaultBarThickness(3);
setDefaultBarFgColor(Color.blue, 0);
setPlotType(PLOTTYPE_LINE, 1);
setDefaultBarFgColor(Color.purple, 1);

}

var vArray = new Array();
var vInterval = getInterval();

function main(nLength) {

if (nLength == null) {
    nLength = 50;
} else {
    nLength = Math.round(nLength);
}

if (vInterval == "D" || vInterval == "W" || vInterval == "M") {
    var vValue = close("$TVOLQ");
} else {
    var c = close("$TVOLQ");
    var o = open("$TVOLQ");

    if (c == null || o == null) return;

    var vValue = c - o;
}

var nBarState = getBarState();
    
if (nBarState == BARSTATE_NEWBAR) {
    vArray.unshift(vValue);   //inserts array element to the front of the array 
} else {
    vArray[0] = vValue;
}

if (vArray[nLength-1] != null) { // check to make sure array is full
    var vSum = 0;
    for(i = 0; i < nLength; i++) {
        vSum += vArray[i];
    }
    var vAvgVol = vSum / nLength;

} else {
    return;
}

if (vArray.length > nLength) vArray.pop(); // Removes last array item

return new Array(vValue, vAvgVol);

}