Announcement

Collapse
No announcement yet.

DateRange.efs

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

  • DateRange.efs

    File Name: DateRange.efs

    Description:
    Code example for restricting a formula from back testing or executing outside specified date range.

    Formula Parameters:
    Start Month - 1
    Start Day - 1
    Start Year - 2004
    End Month - 2
    End Day - 31
    End Year - 2004


    Notes:
    After applying the study to an advanced chart, go to Edit Studies and end enter the Day, Month and Year for both the start and end dates.

    Download File:
    DateRange.efs



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

    Restrict formula from back testing outside specified date range.
    Go to Edit Studies and end enter the Day, Month and Year for both
    the start and end dates.
    *****************************************************************/

    function preMain() {
        
    setPriceStudy(true);
        
    setStudyTitle("Date Range");
        
    setShowCursorLabel(false);
        

        var 
    fp1 = new FunctionParameter("startM"FunctionParameter.NUMBER);
        
    fp1.setName("Start Month");
        for (var 
    1<=12; ++i) {
            
    fp1.addOption(i);
        }
        
    fp1.setDefault(1);

        var 
    fp2 = new FunctionParameter("startD"FunctionParameter.NUMBER);
        
    fp2.setName("Start Day");
        for (var 
    1<=31; ++i) {
            
    fp2.addOption(i);
        }
        
    fp2.setDefault(1);

        var 
    fp3 = new FunctionParameter("startY"FunctionParameter.NUMBER);
        
    fp3.setName("Start Year");
        for (var 
    010; ++i) {
            
    fp3.addOption(2004-i);
        }
        
    fp3.setDefault(2004);

        var 
    fp4 = new FunctionParameter("endM"FunctionParameter.NUMBER);
        
    fp4.setName("End Month");
        for (var 
    1<=12; ++i) {
            
    fp4.addOption(i);
        }
        
    fp4.setDefault(2);

        var 
    fp5 = new FunctionParameter("endD"FunctionParameter.NUMBER);
        
    fp5.setName("End Day");
        for (var 
    1<=31; ++i) {
            
    fp5.addOption(i);
        }
        
    fp5.setDefault(31);

        var 
    fp6 = new FunctionParameter("endY"FunctionParameter.NUMBER);
        
    fp6.setName("End Year");
        for (var 
    010; ++i) {
            
    fp6.addOption(2004-i);
        }
        
    fp6.setDefault(2004);
    }

    function 
    main(startMstartDstartYendMendDendY) {
        var 
    barMonth getMonth(0);
        var 
    barDay getDay(0);
        var 
    barYear getYear(0);
        
        if (
    barYear startY || barYear endY) return;
        if (
    barMonth startM || barMonth endM) return;
        if (
    barDay startD || barDay endD) return;
        
        
    // Insert code for back testing here
        
        
    setBarBgColor(Color.grey);
        
        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