File Name: AccelerationSpeed.efs

Description:
Acceleration & Speed

Formula Parameters:
Length : 24
sPrice : Close



Notes:


Download File:
AccelerationSpeed.efs



EFS Code:
PHP Code:
/*********************************
Provided By:  
    eSignal (Copyright c eSignal), a division of Interactive Data 
    Corporation. 2009. 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:        
    Acceleration & Speed
Version:            1.0  09/25/2009
 
Formula Parameters:                     Default:
    Length                              24
    sPrice                              Close
    
Notes:
    
**********************************/
var fpArray = new Array();
var 
bInit false;

function 
preMain(){
    
setPriceStudy(false);
    
setShowCursorLabel(true);
    
setShowTitleParameters(false);
    
setStudyTitle("Acceleration & Speed");
    
setCursorLabelName("Speed"0);
    
setPlotType(PLOTTYPE_LINE0);
    
setDefaultBarFgColor(Color.red0);
    
setCursorLabelName("Acceleration"1);
    
setPlotType(PLOTTYPE_LINE1);
    
setDefaultBarFgColor(Color.green1);
    var 
0;
    
fpArray[x] = new FunctionParameter("Length"FunctionParameter.NUMBER);
    
with(fpArray[x++]) {
        
setLowerLimit(1);
        
setDefault(24);
    }    
    
fpArray[x] = new FunctionParameter("sPrice"FunctionParameter.STRING);
    
with(fpArray[x++]){
        
setName("Source of Price");
        
addOption("open"); 
        
addOption("high");
        
addOption("low");
        
addOption("close");
        
addOption("hl2");
        
addOption("hlc3");
        
addOption("ohlc4"); 
        
setDefault("close"); 
    }    
}

var 
xSpeed null;
var 
xAcceleration null;

function 
main(LengthsPrice) {
var 
nBarState getBarState();
var 
nSpeed 0;
var 
nAcceleration 0;
    if (
nBarState == BARSTATE_ALLBARS) {
        if(
Length == nullLength 2;
        if(
sPrice == nullsPrice "close";
    }
    if (
bInit == false) {
        
xSpeed mom(Length, eval(sPrice)());
        
xAcceleration mom(LengthxSpeed);
        
bInit true;
    }
    
nSpeed xSpeed.getValue(0);
    
nAcceleration xAcceleration.getValue(0);
    if (
nAcceleration == null) return;
    return new Array(
nSpeednAcceleration);