Announcement

Collapse
No announcement yet.

PrevHHLL.efs & getPrevDaysOHLC.efs

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • PrevHHLL.efs & getPrevDaysOHLC.efs

    File Name: PrevHHLL.efs (Previous Day’s Highest High and Lowest Low)

    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\ .

    Download File:
    PrevHHLL.efs
    getPrevDaysOHLC.efs




    EFS Code: PrevHHLL.efs
    PHP Code:
    /*********************************
    Provided By : eSignal. (c) Copyright 2003
    *********************************/

    function preMain() {
        
    setPriceStudy(true);
        
    setCursorLabelName("High"0);
        
    setCursorLabelName("Low"1);
        
    setDefaultBarFgColor(Color.blue0);
        
    setDefaultBarFgColor(Color.red1);
    }

    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", -1nNumDays);
            if (
    aHighs == null)
                return;
            var 
    aLows callFunction("/OHLC/getPrevDaysOHLC.efs""main""Low", -1nNumDays);
            if (
    aLows == null)
                return;

            var 
    cntr aHighs.length;
            
    HH aHighs[0];
            
    LL aLows[0];
            for (
    0cntr; ++i) {
                
    HH Math.max(HHaHighs[i]);
                
    LL Math.min(LLaLows[i]);
            }
        }
        
        return new Array(
    HHLL);


    EFS Code: getPrevDaysOHLC.efs
    PHP Code:
    /*********************************
    Provided By : eSignal. (c) Copyright 2003
    *********************************/

    function preMain() {
        
    setPriceStudy(true);
        
    setStudyTitle("Get Previous Days OHLC");
    }

    var 
    vSymbol null;
    var 
    vReset true;

    function 
    main(nPriceSourcenOffsetnNumDays) {
        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(vBarTimevSymbol);
            if(
    vAbsTime == null) {
                return;
            }
            
    vIndex getFirstBarIndexOfDay(vAbsTimevSymbol);
            if(
    vIndex != null) {
                var 
    vValue getValueAbsolute(nPriceSource, (vIndex nOffset), -nNumDaysvSymbol);
                if(
    vValue == null) {
                    return 
    null;
                }
            } 
        }

        return 
    vValue;

    Jason K.
    Project Manager
    eSignal - an Interactive Data company

    EFS KnowledgeBase
    JavaScript for EFS Video Series
    EFS Beginner Tutorial Series
    EFS Glossary
    Custom EFS Development Policy

    New User Orientation
Working...
X