Announcement

Collapse
No announcement yet.

possible getPreviousTradingDay bug

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

  • possible getPreviousTradingDay bug

    could someone check this for me using Euro Futures 6E #F, 30 minute chart.

    using a simple efs study

    v1 = getValue("rawtime",0);
    v2 = getPreviousTradingDay(v1);
    debugPrintln(v1,v2);

    for Nov 28th, it gives the previous trading day as Nov 28th.

    Nov 28th contains only 2 bars - 23:00 and 23:30.
    Paul Williams
    Strategy & Applications
    www.futurenets.co.uk

  • #2
    Paul
    Here is what I am getting in the Formula Output window
    Alex

    Comment


    • #3
      sorry Alexis, to demonstrate this the code would be better as ...

      rtime = getValue("rawtime",0);
      pday = getPreviousTradingDay(rtime);
      debugPrintln(getDay() + " " + pday);
      Paul Williams
      Strategy & Applications
      www.futurenets.co.uk

      Comment


      • #4
        Paul
        I changed the debugPrintln to the following and get the output shown in the enclosed image
        debugPrintln(getDay(0)+" "+ getHour(0)+":"+getMinute(0)+" "+pday);
        We may need Jason to explain this as I do not know why the 23:00 and 23:30 bars on the 28th are returning Sun as the prior trading day.
        Alex

        Comment


        • #5
          Hello Paul and Alex,

          The getPreviousTradingDay() function does not take into consideration the day of the week. Since there were trades that occurred on the 28th for 6E #f, The 28th will be returned when requesting the previous trading day on the 29th. If you want to get the previous trading day that occurred on Mon-Fri you'll need to add another condition that checks the day of the week from a date object.
          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


          • #6
            Jason,

            The question isn't "why is the 28th being returned on the 29th?", but rather "why is the 28th being returned on the 28th?". Please see the 23rd and 24th lines of Alex's formula output screen capture.

            I've seen this bug myself and have rewritten my code to do without getPreviousTradingDay. It would be great if getPreviousTradingDay could be fixed to work as expected.

            Comment


            • #7
              Foz
              Actually I don't think this is caused by getPreviousTradingDay() but by rawtime.
              In the top image you can see the result after having replaced "rawtime" with "time" in the rtime variable whereas in the bottom image I am using "rawtime". Notice that when using "time" getPreviousTradingDay() is correctly returning Friday Nov 26 at 23:00 of the 28.
              Alex



              Comment


              • #8
                Ah, thanks, Alex. Good find. Perhaps the EFS Glossary entry for getPreviousTradingDay() that says to use rawtime could be fixed.

                I'm not very clear on when to use "time" and "rawtime" for functions that take date objects. Is there a rule of thumb?

                Comment


                • #9
                  As a matter of fact I can't say "rawtime" has anything to do with it either.
                  At 23:00 ET I ran an efs that outputs "time" at the top of the chart and "rawtime" at the bottom. Concurrently I input the "rawtime" value in the calculator and the result is a difference of 60 seconds between the bar time and "rawtime". FWIW I believe this difference has been documented elsewhere. Irrespective "rawtime" was returning the correct hour. If interested the "rawtime" converter can be found here
                  Alex

                  Comment


                  • #10
                    Hello All,

                    The solution to the problem is to check for the new day and store the previous trading day in a global variable. I have a habit of doing this as it's not necessary to make the call to getPreviousTradingDay() on every bar or every tick. Consequently, it also avoids the problem we seeing here with this function. Do the following and it should fix the problem for you. I'll report the problem with the function to development as well.

                    PHP Code:

                    var v2 null;

                    function 
                    main() {
                        if (
                    getDay(0) != getDay(-1) && getCurrentBarIndex() < 0) {
                            var 
                    v1 getValue("rawtime",0);
                            
                    v2 getPreviousTradingDay(v1);
                            
                    debugPrintln("current: " getDay(0) + "  prev: " v2);    
                        }
                        
                        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

                    Comment

                    Working...
                    X