OutsideBar.efs

ICE Data Services -

OutsideBar.efs  
EFSLibrary - Discussion Board  

File Name: OutsideBar.efs

Description:
This study highlights outside bars where the close of the bar is also in the top or bottom 20% of the current bar's range.

Formula Parameters:

  • Color: blue
  • Size: 4
  • Enable Alerts: true

Notes:
If Enable Alerts is set to true, a popup and audible alert will be generated at the completion of the outside bar.

Download File:
OutsideBar.efs


EFS Code:

/***************************************
Provided By : eSignal (c) Copyright 2007
****************************************/

function preMain() {
    setPriceStudy(true);
    setStudyTitle("Outside Bar");
    setShowCursorLabel(false);
    setShowTitleParameters(false);
    setPlotType(PLOTTYPE_CIRCLE, 0);
    setDefaultBarThickness(5, 0);
    
    var fp1 = new FunctionParameter("cColor", FunctionParameter.COLOR);
        fp1.setName("Color");
        fp1.setDefault(Color.blue);
    var fp2 = new FunctionParameter("nSize", FunctionParameter.NUMBER);
        fp2.setName("Size");
        fp2.setDefault(4);
    var fp3 = new FunctionParameter("bEnable", FunctionParameter.BOOLEAN);
        fp3.setName("Enable Alerts");
        fp3.setDefault(true);
}

var bInit = false;
var bAlert = false;

function main(cColor, nSize, bEnable) {
    if (bInit == false) {
        setDefaultBarThickness(nSize, 0);
        setDefaultBarFgColor(cColor, 0);
    }
    
    if (getBarState() == BARSTATE_NEWBAR) {
        if (bAlert == true && bEnable == true) {
            Alert.playSound("pop.wav");
            Alert.addToList(getSymbol(), "Outside Bar", cColor, Color.white);
        }
        bAlert = false;
    }
    
    if (high(0) > high(-1) && low(0) < low(-1) ) {
        var nRange = (high(0) - low(0));
        var nTop = high(0) - (.2 * nRange);
        var nBot = low(0) + (.2 * nRange);
        
        if (close(0) > nTop || close(0) < nBot) {
            bAlert = true;
        } 
    }
    
    if (bAlert == true) {
        return close(0);
    } else {
        return;
    }
}