Candle Relation

ICE Data Services -


CandRelation.efs  EFSLibrary - Discussion Board
  

File Name: CandRelation.efs


Description:
Candle Relation


Formula Parameters:
Level1 : 0.3
Level2 : 0.5
Level3 : 0.7

Notes:

Download File:
CandRelation.efs




EFS 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:            Candle Relation    Version:            1.0  08/27/2009 Formula Parameters:                     Default:    Level1                              0.3    Level2                              0.5    Level3                              0.7        Notes:    **********************************/var fpArray = new Array();var bInit = false;function preMain(){    setPriceStudy(false);    setShowCursorLabel(true);    setShowTitleParameters(false);    setStudyTitle("Candle Relation");    setCursorLabelName("Level 1", 0);    setDefaultBarFgColor(Color.green, 0);    setPlotType(PLOTTYPE_LINE, 0);    setCursorLabelName("Level 2", 1);    setDefaultBarFgColor(Color.blue, 1);    setPlotType(PLOTTYPE_LINE, 1);    setCursorLabelName("Level 3", 2);    setDefaultBarFgColor(Color.red, 2);    setPlotType(PLOTTYPE_LINE, 2);    var x = 0;    fpArray[x] = new FunctionParameter("Level1", FunctionParameter.NUMBER);    with(fpArray[x++]) {        setName("Level 1");        setDefault(0.3);    }        fpArray[x] = new FunctionParameter("Level2", FunctionParameter.NUMBER);    with(fpArray[x++]) {        setName("Level 2");        setDefault(0.5);    }        fpArray[x] = new FunctionParameter("Level3", FunctionParameter.NUMBER);    with(fpArray[x++]) {        setName("Level 3");        setDefault(0.7);    }    }var xHigh = null;var xLow = null;var xClose = null;var xOpen = null;function main(Level1, Level2, Level3) {var nBarState = getBarState();var nHS = 0;var nLS = 0;var nBD = 0;var nCC = 0;var nHigh = 0;var nLow = 0;var nOpen = 0;var nClose = 0;    if (nBarState == BARSTATE_ALLBARS) {        if(Level1 == null) Level1 = 0.3;        if(Level2 == null) Level2 = 0.5;        if(Level3 == null) Level3 = 0.7;	}	if (bInit == false) {        addBand(Level1, PS_DASHDOT, 1, Color.black, "Level1");        addBand(Level2, PS_DASHDOT, 1, Color.black, "Level2");                addBand(Level3, PS_DASHDOT, 1, Color.black, "Level3");                        xHigh = high();        xLow = low();        xOpen = open();        xClose = close();        bInit = true;	}	nHigh = xHigh.getValue(0);	nLow = xLow.getValue(0);	nOpen = xOpen.getValue(0);	nClose = xClose.getValue(0);    if (nClose == null) return;    nCC = nHigh - nLow;    nHS = (nHigh - Math.max(nOpen, nClose)) / nCC;    nLS = (Math.min(nOpen, nClose) - nLow) / nCC;    nBD = Math.abs(nOpen - nClose) / nCC;    return new Array(nHS, nBD, nLS);}