Announcement

Collapse
No announcement yet.

getMonthlyOHLC.efs

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

  • getMonthlyOHLC.efs

    File Name: getMonthlyOHLC.efs

    Description:
    Returns the Monthly OHLC data with the use of callFunction() and may be used with any interval less than monthly.

    Formula Parameters:
    sPriceSource: No Default value. Pass “Open” /”High”/”Low”/”Close” to callFunction()

    Notes:
    Save this formula to /eSignal/Formulas/OHLC/ and use this formula through the callFunction() function from your custom formulas to get the current week’s OHLC prices.

    Code Example:
    PHP Code:
    function main() {
        var 
    vData callFunction("/OHLC/getMonthlyOHLC.efs""main""High");    
        if (
    vData == null) return;
        return 
    vData;

    Download File:
    getMonthlyOHLC.efs




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

    function preMain() {
    }

    /**
      sPriceSource will be "Open", "High", "Close", or "Low"
     
      This formula is for callFunction() calls from an 
        external formula.
        
        example:

        var vData = callFunction("/OHLC/getMonthlyOHLC.efs", "main", "High");    
        if (vData == null) return;
        return vData;

    **/


    var vSymbol;
    var 
    vInterval;

    function 
    main(sPriceSource) {
        if(
    sPriceSource == null) return;

          var 
    vBar;
        var 
    vBarTime;
        var 
    vAbsTime;
        var 
    vIndex;

        var 
    nState getBarState();
        if(
    nState == BARSTATE_ALLBARS) {
            
    vSymbol getSymbol();
            
    vInterval getInterval();
            
    vSymbol += ",M";
        }

        if(
    vInterval == null) return;

        if(
    vInterval == "M") return;

        
    vBarTime getValue("time");
        var 
    vTime = new Date();
        if(
    vBarTime != null) {
            if (
    vTime.getYear() == vBarTime.getYear()) {
                
    vIndex = ((vTime.getMonth()+vBarTime.getMonth()+1) * -1)+2;
            } else {
                
    vIndex = (((vTime.getMonth()++ ((vTime.getYear() - vBarTime.getYear()) * 12)) - vBarTime.getMonth()+1) * -1)+2;
            }
            if (
    vIndex != null) {
                
    vBar getValueAbsolute(sPriceSourcevIndexvSymbol);
                return 
    vBar;
            }
        }
        
        return;

    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