Bear Power

ICE Data Services -

Bear_Power.efs  
EFSLibrary - Discussion Board  

File Name: Bear_Power.efs

Description:

Bear Power Indicator

Formula Parameters:

Notes:

Download File:
Bear_Power.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:        
    Bear Power Indicator 

Version:            1.0  10/15/2008

Notes:

Formula Parameters:                     Default:


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

function preMain(){
    setStudyTitle("BBB Bear Power");
    setCursorLabelName("Bear Power",0);
    setDefaultBarFgColor(Color.red,0);
    setDefaultBarThickness(2);
}

var xOpen  = null;
var xHigh  = null;
var xLow   = null;
var xClose = null;
var bInit  = false;

function main(){
var value = 0;

    if(bInit == false){
        xOpen  = open();
        xHigh  = high();
        xLow   = low();
        xClose = close();
        bInit = true;
    }

    var nOpen_0  = xOpen.getValue(0);
    var nClose_0 = xClose.getValue(0);
    var nClose_1 = xClose.getValue(-1);
    var nHigh_0  = xHigh.getValue(0);
    var nLow_0   = xLow.getValue(0);

    if(nClose_1 == null) return;


	if(nClose_0 < nOpen_0) 
		if(nClose_1 > nOpen_0) 
			value = Math.max(nClose_0 - nOpen_0, nHigh_0 - nLow_0); 
		else  
			value = nHigh_0 - nLow_0; 
	else 
		if (nClose_0 > nOpen_0)
			if(nClose_1 > nOpen_0)  
				value = Math.max(nClose_1 - nLow_0, nHigh_0 - nClose_0);
			else
				value = Math.max(nOpen_0 - nLow_0,nHigh_0 - nClose_0); 
		else 
			if(nHigh_0 - nClose_0 > nClose_0 - nLow_0)
				if(nClose_1 > nOpen_0)  
					value = Math.max(nClose_1 - nOpen_0,nHigh_0 - nLow_0);  
				else	
					value = nHigh_0 - nLow_0;
			else 
				if(nHigh_0 - nClose_0 < nClose_0 - nLow_0)
					if(nClose_0 > nOpen_0)
						value = Math.max(nClose_0 - nLow_0,nHigh_0 - nClose_0);
					else 		
						value = nOpen_0 - nLow_0; 
				else
					if(nClose_0 > nOpen_0)
						value = Math.max(nClose_1 - nOpen_0,nHigh_0 - nLow_0); 
					else
						if(nClose_1 < nOpen_0)
							value = Math.max(nOpen_0 - nLow_0, nHigh_0 - nClose_0); 
						else 
							value = nHigh_0 - nLow_0;
	return value;
}