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  ormulas 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);
}