PrevHHLL.efs & getPrevDaysOHLC.efs

ICE Data Services -


PrevHHLL.efs 
  

File Name: PrevHHLL.efs


Description:
Example formula that demonstrates the use of getPrevDaysOHLC.efs using the callFunction() function.


Formula Parameters:
nNumDays: Default is 2 (PrevHHLL.efs)
nPriceSource: Default is Close (getPrevDaysOHLC.efs)
nOffset: Default is -1 (getPrevDaysOHLC.efs)
nNumDays: Default is 1 (getPrevDaysOHLC.efs)

Notes:
PrevHHLL.efs requires the use of getPrevDaysOHLC.efs, which is included on this page. PrevHHLL.efs is intended for use with intra-day intervals to return the highest high and lowest low over the previous nNumDays. getPrevDaysOHLC.efs is intended to be used as a utility formula to be called from other formulas using the callFunction() function. Syntax:callFunction("/OHLC/getPrevDaysOHLC.efs", "main", nPriceSource, nOffset, nNumDays);Download getPrevDaysOHLC.efs and save it to \Formulas\OHLC\ .getPrevDaysOHLC.efs

Download File:
PrevHHLL.efs




EFS Code:



/*********************************Provided By : eSignal. (c) Copyright 2003*********************************/function preMain() {    setPriceStudy(true);    setCursorLabelName("High", 0);    setCursorLabelName("Low", 1);    setDefaultBarFgColor(Color.blue, 0);    setDefaultBarFgColor(Color.red, 1);}var vReset = true;var vDay0 = null;var vDay1 = null;var HH = null;var LL = null;function main(nNumDays) {    if (nNumDays == null)        nNumDays = 2;        if (vReset == true) {        setStudyTitle("Prev " + nNumDays + " Days HH and LL");        vReset = false;    }        if (getBarState() == BARSTATE_NEWBAR) {        if (vDay0 != null) {            vDay1 = vDay0;        } else {            vDay1 = getDay();        }    }    vDay0 = getDay();        if (vDay0 != vDay1) {        var aHighs = callFunction("/OHLC/getPrevDaysOHLC.efs", "main", "High", -1, nNumDays);        if (aHighs == null)            return;        var aLows = callFunction("/OHLC/getPrevDaysOHLC.efs", "main", "Low", -1, nNumDays);        if (aLows == null)            return;        var cntr = aHighs.length;        HH = aHighs[0];        LL = aLows[0];        for (i = 0; i < cntr; ++i) {            HH = Math.max(HH, aHighs[i]);            LL = Math.min(LL, aLows[i]);        }    }        return new Array(HH, LL);}[/php][b]EFS Code:  getPrevDaysOHLC.efs [/b][php]/*********************************Provided By : eSignal. (c) Copyright 2003*********************************/function preMain() {    setPriceStudy(true);    setStudyTitle("Get Previous Days OHLC");}var vSymbol = null;var vReset = true;function main(nPriceSource, nOffset, nNumDays) {    if (nPriceSource == null)         nPriceSource = "Close";    if (nOffset == null) {        nOffset = -1;    } else {        nOffset = (Math.abs(nOffset) * -1);    }    if (nNumDays == null) {        nNumDays = 1;    } else {        nNumDays = Math.abs(nNumDays);    }	var nState = getBarState();	if(vReset == true) {		vDay1 = null;		vSymbol = (getSymbol() + ",D");		vReset = false;	}    	vBarTime = getValue("time");	if(vBarTime != null) {        var vDay = vBarTime.getDay();        if (vDay == 0) {            var vDate = vBarTime.getDate();            vDate -= 2;            vBarTime.setDate(vDate);        }  	    var vAbsTime = getPreviousTradingDay(vBarTime, vSymbol);	    if(vAbsTime == null) {	        return;	    }	    vIndex = getFirstBarIndexOfDay(vAbsTime, vSymbol);	    if(vIndex != null) {			var vValue = getValueAbsolute(nPriceSource, (vIndex + nOffset), -nNumDays, vSymbol);			if(vValue == null) {                return null;			}	    } 	}	return vValue;}