Albano_Pivots.efs

ICE Data Services -

Albano_Pivots.efs  
EFSLibrary - Discussion Board  

File Name: Albano_Pivots.efs

Description:
Modified pivot study with multiple options for the center pivot.

Formula Parameters:

  • Color: red
  • Pivot Type: 0 [0, 1, 2, 3, 4] 

Where:

  • 0 = prev High + prev Low + prev Close / 3
  • 1 = prev High + prev Low + Open / 3
  • 2 = prev High + prev Low + Open + Open / 4
  • 3 = prev High + prev Low + prev Close + Open / 4
  • 4 = prev High + prev Low + prev Close + prev Open / 4

Notes:
NA

Download File:
Albano_Pivots.efs


EFS Code:

/*********************************
Provided By:  
    eSignal (Copyright © eSignal), a division of Interactive Data 
    Corporation. 2007. 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:  Albano Pivots
    RE: http://forum.esignalcentral.com/showthread.php?s=&threadid=24146
**********************************/


function preMain() {
	setPriceStudy(true);
	setStudyTitle("Albano Pivot Points");
	setCursorLabelName("R3", 0);
	setCursorLabelName("R3/R2", 1);
	setCursorLabelName("R2", 2);
	setCursorLabelName("R2/R1", 3);
	setCursorLabelName("R1", 4);
	setCursorLabelName("CPR1", 5);
	setCursorLabelName("CP", 6);
	setCursorLabelName("CPS1", 7);
	setCursorLabelName("S1", 8);
	setCursorLabelName("S1/S2", 9);
	setCursorLabelName("S2", 10);
	setCursorLabelName("S2/S3", 11);
	setCursorLabelName("S3", 12);
	
	for (var i = 0; i < 13; i++) {
        setPlotType(PLOTTYPE_FLATLINES, i);
    }
	
	// R3
	setDefaultBarStyle(PS_SOLID, 0);
	// R3/R2
	setDefaultBarStyle(PS_DASH, 1);
	// R2
	setDefaultBarStyle(PS_SOLID, 2);
	// R2/R1
	setDefaultBarStyle(PS_DOT, 3);
	// R1
	setDefaultBarStyle(PS_SOLID, 4);
    // CPR1
	setDefaultBarStyle(PS_DOT, 5);
    // CP
	setDefaultBarStyle(PS_SOLID, 6);
    // CPS1
	setDefaultBarStyle(PS_DOT, 7);
    // S1
	setDefaultBarStyle(PS_SOLID, 8);
    // S1/S2
	setDefaultBarStyle(PS_DOT, 9);
	// S2
	setDefaultBarStyle(PS_SOLID, 10);
	// S2/S3
	setDefaultBarStyle(PS_DOT, 11);
	// S3
	setDefaultBarStyle(PS_SOLID, 12);
	
	var fp1 = new FunctionParameter("cColor", FunctionParameter.COLOR);
        fp1.setName("Color");
        fp1.setDefault(Color.red);
    var fp2 = new FunctionParameter("nType", FunctionParameter.NUMBER);
        fp2.setName("Pivot Type");
        fp2.addOption(0);
        fp2.addOption(1);
        fp2.addOption(2);
        fp2.addOption(3);
        fp2.addOption(4);
        fp2.setDefault(0);
}


var bInit = false;
var xO  = null;
var xH  = null;
var xL  = null;
var xC  = null; 

function main(cColor, nType) {

    if(isMonthly() || isWeekly()) return;
    
    if(bInit == false){
        xO  = open(inv("D"));
        xH  = high(inv("D"));
        xL  = low(inv("D"));
        xC  = close(inv("D")); 
        
        for (var i=0; i < 13; i++) {
            setDefaultBarFgColor(cColor, i);
        }
        bInit = true;
    }
    
    var nCP = null;
    var nR1 = null;
    var nS1 = null;
    var nR2 = null;
    var nS2 = null;  
    var nR3 = null;
    var nS3 = null;
    var nR3R2 = null;
    var nR2R1 = null;
    var nCPR1 = null;
    var nCPS1 = null;
    var nS1S2 = null;
    var nS2S3 = null;
    var nOpen0 = xO.getValue(0);
    var nOpen  = xO.getValue(-1);
    var nHigh  = xH.getValue(-1);
    var nLow   = xL.getValue(-1);
    var nClose = xC.getValue(-1);
    if(nOpen == null || nHigh == null || nLow == null || nClose == null) return;

    var nRange = (nHigh - nLow);
    
    switch (nType) {
        case 1:  
            nCP = (nHigh + nLow + nOpen0) / 3; 
            break;
        case 2:  
            nCP = (nHigh + nLow + nOpen0 + nOpen0) / 4; 
            break;
        case 3:  
            nCP = (nHigh + nLow + nClose + nOpen0) / 4; 
            break;
        case 4:  
            nCP = (nHigh + nLow + nClose + nOpen) / 4; 
            break;
        default: 
            nCP = (nHigh + nLow + nClose) / 3; 
            break;
    }
    
    nR1 = nCP + (nRange/2);
    nS1 = nCP - (nRange/2);
    nR2 = nCP + nRange;
    nS2 = nCP - nRange;
    nR3 = nR2 + nRange;
    nS3 = nS2 - nRange;

    nR3R2 = (nR3 + nR2) / 2;
    nR2R1 = (nR2 + nR1) / 2;
    nCPR1 = (nCP + nR1) / 2;
    nCPS1 = (nCP + nS1) / 2;
    nS1S2 = (nS1 + nS2) / 2;
    nS2S3 = (nS2 + nS3) / 2;
    
    if (getCurrentBarIndex() >= -1) {
        drawTextRelative(1, nR3, "R3",      cColor, Color.white, Text.LEFT|Text.BOLD|Text.VCENTER, null, 12, "R3");
        drawTextRelative(1, nR3R2, "R3R2",  cColor, Color.white, Text.LEFT|Text.BOLD|Text.VCENTER, null, 12, "R3R2");
        drawTextRelative(1, nR2, "R2",      cColor, Color.white, Text.LEFT|Text.BOLD|Text.VCENTER, null, 12, "R2");
        drawTextRelative(1, nR2R1, "R2R1",  cColor, Color.white, Text.LEFT|Text.BOLD|Text.VCENTER, null, 12, "R2R1");
        drawTextRelative(1, nR1, "R1",      cColor, Color.white, Text.LEFT|Text.BOLD|Text.VCENTER, null, 12, "R1");
        drawTextRelative(1, nCPR1, "CPR1",  cColor, Color.white, Text.LEFT|Text.BOLD|Text.VCENTER, null, 12, "CPR1");
        drawTextRelative(1, nCP, "CP",      cColor, Color.white, Text.LEFT|Text.BOLD|Text.VCENTER, null, 12, "CP");
        drawTextRelative(1, nCPS1, "CPS1",  cColor, Color.white, Text.LEFT|Text.BOLD|Text.VCENTER, null, 12, "CPS1");
        drawTextRelative(1, nS1, "S1",      cColor, Color.white, Text.LEFT|Text.BOLD|Text.VCENTER, null, 12, "S1");
        drawTextRelative(1, nS1S2, "S1S2",  cColor, Color.white, Text.LEFT|Text.BOLD|Text.VCENTER, null, 12, "S1S2");
        drawTextRelative(1, nS2, "S2",      cColor, Color.white, Text.LEFT|Text.BOLD|Text.VCENTER, null, 12, "S2");
        drawTextRelative(1, nS2S3, "S2S3",  cColor, Color.white, Text.LEFT|Text.BOLD|Text.VCENTER, null, 12, "S2S3");
        drawTextRelative(1, nS3, "S3",      cColor, Color.white, Text.LEFT|Text.BOLD|Text.VCENTER, null, 12, "S3");
    }
    
    return new Array(nR3, nR3R2, nR2, nR2R1, nR1, nCPR1, nCP, nCPS1, nS1, nS1S2, nS2, nS2S3, nS3);
}