Announcement

Collapse
No announcement yet.

Data from prior (x) days

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Data from prior (x) days

    I would like to get data from prior opening bars. Referencing data from yesterday's bars would be using

    getPreviousTradingDay(getValue("rawtime",0))

    but how could I get the opening bar data from 2, 3, 4, 5 etc days ago? Should I use offsetSeries?

    Thanks in advance for any help.

  • #2
    Hello Genx,

    Are you trying to get the open price from the daily bar chart from previous days while on an intraday interval chart? If so, try open(-1, inv("D")) to get the previous trading day's open. To get the open from two days ago replace the -1 with -2. Let me know if this helps.
    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

    Comment


    • #3
      Yes, I would like intra-day data

      Thank you Jason. You are correct - I would like to get opening bar data on intraday charts for prior days. So if my chart was set for 5 min, 9:30-16:15 EST, I would like to access the o/h/l/c/vol for "x" prior day opening 5 min bars. I found the getPriorTradingDay function, b ut am unsure how to get the data 2, 3, etc days ago.
      Last edited by Genx; 10-22-2005, 06:37 AM.

      Comment


      • #4
        Hello Genx,

        Another way to get these open prices is to collect them as the formula is loading. First, create a global array outside main(). You don't need to specify a size.

        PHP Code:
        var aOpen = new Array();

        function 
        main() {

        ... 

        Then inside main() create a conditional statement using the day() function to detect the first bar of each day in your chart. When this condition is found, insert the open price for that bar to the first element of the array with the unshif() method of the Array Object.

        PHP Code:
        if (day(0) != day(-1) ) {
            
        // this bar is the first bar for the day being processed.
            
        aOpen.unshift(open(0));

        When the formula has completed loading in the chart the aOpen array will contain the open prices you need. aOpen[0] will have the open for the most recent day, or current day. aOpen[1] will have the open price from 1 day ago. aOpen[2] ... 2 days ago etc.
        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

        Comment


        • #5
          Thank you

          That seems to do the trick - very elegant.

          Comment

          Working...
          X