Announcement

Collapse
No announcement yet.

getPrevDaysOHLC.efs

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

  • getPrevDaysOHLC.efs

    File Name: getPrevDaysOHLC.efs

    Description:
    Utility formula that returns a single value or an array of values for previous days’ Daily open, high, low and close data.

    Formula Parameters:
    nPriceSource: Default is Close (valid inputs: Open, High, Low or Close).
    nOffset: Default is –1
    nNumDays: Default is 1

    Notes:
    This formula is intended to be used by other custom formulas to access previous days' daily values that can then be used with formulas that need to plot the daily data on intra-day intervals. Save this formula to /eSignal/Formulas/OHLC/ and use the callFunction() function as follows from your custom formula.

    PHP Code:
    var sPriceSource “Close”;
    var 
    nOffset = -5;
    var 
    nNumDays 5;
    var 
    aHighs callFunction("/OHLC/getPrevDaysOHLC.efs""main"sPriceSourcenOffsetnNumDays);
    if (
    aHighs == null) return; 
    The above example will return the previous five days' closing prices. For a working example, please see PrevHHLL.efs.

    Download File:
    getPrevDaysOHLC.efs

    Image:
    N/A


    EFS Code:
    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