Volume PRV

ICE Data Services -

VolumePRV.efs

EFSLibrary - Discussion Board

 

File Name: VolumePRV.efs


Description:
Volume PRV

Formula Parameters:

  • Line Thickness: 2
  • Color PRV: Lime
  • Volume Up Color: Black
  • Volume Down Color: Red
  • Volume EQ Color: Magenta
  • Display Cursor Labels: True

Notes:
Pro Rata Volume is an estimate of what the Bar's final Volume will be.

Download File:
VolumePRV.efs




EFS Code:

/*********************************
Provided By:  
    eSignal (Copyright c eSignal), a division of Interactive Data 
    Corporation. 2008. All rights reserved. This sample eSignal 
    Formula Script (EFS) is for educational purposes only and may be 
    modified and saved under a new file name.  eSignal is not responsible
    for the functionality once modified.  eSignal reserves the right 
    to modify and overwrite this EFS file with each new release.


Description:        
    Volume PRV

Version:            1.0  10/06/2008

Notes:
    Pro Rata Volume is an estimate of what the Bar's final Volume will be.
    
Formula Parameters:                     Default:
    Line Thickness                          2
    Color PRV                             Lime
    Volume Up Color                       Black
    Volume Down Color                     Red
    Volume EQ Color                       Magenta
    Display Cursor Labels                 True
**********************************/

var fpArray = new Array();
var bInit = false;

function preMain() {

    setPriceStudy(false);
    setShowCursorLabel(false);
    setShowTitleParameters( false );
    
    setStudyTitle("Volume PRV");
    setCursorLabelName("Volume", 0);    

    setDefaultBarFgColor(Color.red, 0);
    setPlotType(PLOTTYPE_HISTOGRAM, 0); 
    setDefaultBarThickness(2, 0);
    

   
    askForInput();
    var x=0;
    fpArray[x] = new FunctionParameter("LineColor1", FunctionParameter.COLOR);
    with(fpArray[x++]){
        setName("Color PRV");
        setDefault(Color.lime);
    }    


    fpArray[x] = new FunctionParameter("ViewValue", FunctionParameter.BOOLEAN);
    with(fpArray[x++]){
        setName("Display Cursor Labels");
        setDefault(true);
    }    
    

    fpArray[x] = new FunctionParameter("Thickness", FunctionParameter.NUMBER);
	with(fpArray[x++]){
        setName("Line Thickness");
        setLowerLimit(1);		
        setDefault(2);
    }
    
    fpArray[x] = new FunctionParameter("PRICEUp", FunctionParameter.COLOR);
    with(fpArray[x++]){
        setName("Volume Up Color");
        setDefault(Color.black);
    }    

    fpArray[x] = new FunctionParameter("PRICEDown", FunctionParameter.COLOR);
    with(fpArray[x++]){
        setName("Volume Down Color");
        setDefault(Color.red);
    }    

    fpArray[x] = new FunctionParameter("PRICEEqual", FunctionParameter.COLOR);
    with(fpArray[x++]){
        setName("Volume EQ Color");
        setDefault(Color.magenta);
    }    
    
    
}

var nHour = 0;
var nMinute = 0;
var nSecond = 0;



function main(Thickness, LineColor1, PRICEUp, PRICEDown, PRICEEqual, ViewValue) {
var nState = getBarState();
var nEndTime = 0;
var nVolume = 0;
var vInt = (getInterval()*60);  
var PercentComplete = 0;


    if ( bInit == false ) { 
        setDefaultBarFgColor(LineColor1, 0);
        setDefaultBarThickness(Thickness, 0);
        setShowCursorLabel(ViewValue);        
        bInit = true; 
    } 



    if (!isIntraday()) {
        setStudyTitle("Sorry. This script run only intraday charts.");
        return;
    } else {
        if (getCurrentBarCount() == getNumBars()) {
            setStudyTitle("Volume PRV");

            Timer();
            nEndTime = (nHour * 3600) + (nMinute * 60) + nSecond;  

            PercentComplete =  (1 - ((nEndTime * 100 / vInt) * 0.01));
            
            if (PercentComplete < 0.02)
                nVolume = volume(0)
            else
                nVolume = Math.floor(volume(0) / PercentComplete);  
       
            if (nVolume < volume(0)) nVolume = volume(0);
        } else {
            nVolume = volume(0);
        }
    }

    drawLineRelative( 0, 0, 0, nVolume, PS_SOLID, Thickness, LineColor1, 105 ); 

    if (close(0) > close(-1)) {
        setDefaultBarFgColor(PRICEUp, 0);
        drawLineRelative( 0, 0, 0, volume(0), PS_SOLID, Thickness, PRICEUp, 106 ); 
	} else
        if (close(0) < close(-1)) {
            setDefaultBarFgColor(PRICEDown, 0);
            drawLineRelative( 0, 0, 0, volume(0), PS_SOLID, Thickness, PRICEDown, 106 ); 
 		} else {
            setDefaultBarFgColor(PRICEEqual, 0);
            drawLineRelative( 0, 0, 0, volume(0), PS_SOLID, Thickness, PRICEEqual, 106 ); 
        }    


    return volume(0); 
}

var vTimeStamp = null;
var vInt = null;

function Timer() {
    if (!isIntraday() || getCurrentBarIndex() < -1) return;
    var nState = getBarState();
    var vClockTime = new Date()*1;
    
    if (vInt == null) vInt = (getInterval()*60000);  // convert to milliseconds
    if (nState == BARSTATE_NEWBAR) {
        vTimeStamp = getValue("Time")*1 + vInt;
    }

    var vTimeLeft = (vTimeStamp - vClockTime);
    if (vTimeLeft < 0) return;

    var vHr = 0;
    var vMin = 0;
    var vSec = 0;
    
    if (vInt > 3600000) {
        vHr = Math.floor(vTimeLeft/3600000);
        vTimeLeft -= (vHr*3600000);
    }
    if (vInt > 60000) {
        vMin = Math.floor(vTimeLeft/60000);
        vTimeLeft -= (vMin*60000);
    }
    vSec = Math.floor(vTimeLeft/1000);
    
    vTimeLeft = (" " + vHr + ":" + vMin + ":" + vSec + " ");

    nHour = vHr;
    nMinute = vMin;
    nSecond = vSec;

    return;
}