Announcement

Collapse
No announcement yet.

Bugs??

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

  • Bugs??

    I'm having some problems getting my EFS code to work with version 7.9. Attached is a fragment of code I use and run on a ES #F=2 chart which should expose the problems I'm having.

    1) I keep a date/time stamp in the format of YYYYMMDDHHMM which has worked just fine until now. Notice the strange results returned from the function.

    2) I used the following logic to detect a new day but it no longer works ... strange...
    Attached Files

  • #2
    I meant to include a bit of the output:

    4271526/200504271526A new day -- day: 27 getDay: 27
    4271528/200504271527.:A new day -- day: 27 getDay: 27
    4271530/200504271530A new day -- day: 27 getDay: 27
    4271532/200504271531.:A new day -- day: 27 getDay: 27
    4271534/200504271533.:A new day -- day: 27 getDay: 27
    4271536/200504271536A new day -- day: 27 getDay: 27
    4271538/200504271537.:A new day -- day: 27 getDay: 27
    4271540/20050427153:A new day -- day: 27 getDay: 27
    4271542/200504271541.:A new day -- day: 27 getDay: 27
    4271544/200504271543.:A new day -- day: 27 getDay: 27
    4271546/200504271546A new day -- day: 27 getDay: 27
    4271548/200504271547.:A new day -- day: 27 getDay: 27
    4271550/200504271550A new day -- day: 27 getDay: 27

    Comment


    • #3
      Hi gkelly,

      I took a look at your efs and modified it slightly (see debugPrintln statements at lines 24 and lines 27):

      PHP Code:
      function preMain() {
       
          
      setPriceStudy(true);
       
      setShowCursorLabelfalse );
          
      setColorPriceBars(true);
          
      setDefaultPriceBarColor(Color.black);
      }
      var 
      day=null;
      var 
      DateTimeId1DateTimeId2;
      var 
      BarState;
      /**************************************************/
      function main() { 
          
      BarState getBarState();
          
          if (
      BarState == BARSTATE_ALLBARS) return null;
          
          
      DateTimeId1 getDateTimeId1();
          
      DateTimeId2 getDateTimeId2();
       
          if (
      BarState == BARSTATE_NEWBAR) {
              if (
      day != getDay()) {
                  
      debugPrintln(DateTimeId1+"/"+DateTimeId2+"A new day -- day: "+day+" getDay: "+getDay());
                  
      day getDay();
                  
      debugPrintln("24: type day= "typeof(day)+"  type day= "typeof(getDay()));
              } else {
                  
      debugPrintln(DateTimeId1+"/"+DateTimeId2+"Same day -- day: "+day+" getDay: "+getDay());
                  
      debugPrintln("27: type day= "typeof(day)+"  type day= "typeof(getDay()));
       
              }
          }    
      }
      /***************************************************/
      function getDateTimeId1() {
          return ((
      getMonth()*1000000)+(getDay()*10000)+(getHour()*100)+getMinute());
      }
      /***************************************************/
      function getDateTimeId2() {
          return (
      getValue("Year")*100000000)+(getValue("Month")*1000000)+(getValue("Day")*10000)+(getValue("Hour")*100)+getValue("Minute");

      here was some of the output from an hourly chart

      PHP Code:
      4270930/200504270930A new day -- day26 getDay27
      24
      type dayobject  type dayobject
      4271030
      /200504271030A new day -- day27 getDay27
      24
      type dayobject  type dayobject
      4271130
      /200504271130A new day -- day27 getDay27
      24
      type dayobject  type dayobject
      4271230
      /200504271230A new day -- day27 getDay27
      24
      type dayobject  type dayobject
      4271330
      /200504271330A new day -- day27 getDay27
      24
      type dayobject  type dayobject
      4271430
      /200504271430A new day -- day27 getDay27
      24
      type dayobject  type dayobject
      4271530
      /200504271530A new day -- day27 getDay27
      24
      type dayobject  type dayobject 
      There were two things.

      1) your day variable was of an object type, as was getDay(). I had never had an opportunity to check the types before, but I believe this is at the root of the problem.

      2) The variables are never equal. In hindsight, I should have stuck another copy of the debugPrintln statement from line 24 right after the test for equality (prior to the assignment of day=getDay()). It may indicate that the variable day is of a different type than object, at least at that point in the flow of your efs, thus the reason for day never being equal to getDay().

      Since I am not at a location where I can test this, I cannot take it any further for now.

      I would recommend making the change in 2) above and see if the type thingie is an issue. If it is, it is easy to change the type by adding an empty string to the particular variable to make it a string, or multiplying by 1 to make a number.

      The other thing (and this is no biggie) is that I could not duplicate your debugPrintln output...
      PHP Code:
      4271528/200504271527.:new day -- day27 getDay27
      4271530
      /200504271530A new day -- day27 getDay27 
      specifically the presence of .: before "A new day" in some of the lines and not in others. Perhaps an idiosyncracy of your actual code and not the code snippet you posted. Please let me know if you find anything.

      Regards,

      Comment


      • #4
        Hello gkelly,

        The solution is to replace your getDay() calls with getDay(0). This appears to be a backward compatability issue. I've reported this to development.
        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
          Jason,

          Thanks so much for looking into this for me!

          It appears that the functions, getYear(), getMonth(), getDay(), getHour(), and getMinute() called without an explicit parameter return a object datatype instead of a number datatype.

          Another solution would be to use the getValue("Day") function -- that appears to work correctly.

          Can you look into my date/time stamp issue -- on a 2 minute chart?? I'd like to verify that this is an issue as well. It's a real show stopper for me at this point.

          Lastly, is there a way download and install the previous version 7.x???

          Thanks!!

          Comment


          • #6
            Hello gkelly,

            Using the ...(0) with the time and date calls should have fixed the problem. If not, post the current code you're working with.
            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


            • #7
              Jason,

              Run the attached efs on a two minute chart (ES #F). The DateTimeId() function should simply return a date/time formatted as such, YYYYMMDDHHMM. For example, 200504281400.

              Here are a couple of lines that I'm getting.

              200504281336
              200504281337.:
              20050428133:
              200504281341.:
              200504281343.:
              200504281346
              200504281347.:
              200504281350
              200504281351.:
              200504281353.:
              200504281356
              200504281357.:
              2005042813:0

              >>>Gregg
              Attached Files

              Comment


              • #8
                OK, this is getting scary now ...

                Just add the following:

                z = 200500000000 + 4000000 + 280000 + 1000 + 52;

                When you print it out:

                200504281051.:

                Not good ...

                Comment


                • #9
                  Hi gkelly,

                  For today's ES #F, 5 I'm getting output from beta5.efs as:

                  200504280930
                  200504280935
                  200504280940
                  200504280945
                  200504280950
                  ...

                  That's pretty strange with the . and : characters in your output. What version of Windows are you using?

                  I have a feeling that you are probably overflowing the JavaScript number (32-bit integer). If the number you are trying to represent is greater than 2^32, then JavaScript will truncate those values.

                  For your beta5.efs, I would do the addition of the Month/Day/Hour/Minute in one, convert it to a String, then convert the Year to a String, then concatenate the two. This will solve your overflow problem.

                  Now, for the getDay(0) thing at the bottom, that's definitely an incompatibility bug that crept into 7.9.

                  Use getDay(0), getMonth(0), etc .. until 7.9.1 is out. EFS2 returns most of these functions w/o parameters as a Series object, which attempts to masquerade as a number. When attempting to do an equality comparison, it's comparing one Series instance against another, instead of the number values. By default I will switch the comparison over to the number value to avoid problems.


                  Thanks.

                  Comment


                  • #10
                    Dion, thank you for looking into this so quickly.

                    gkelly, below is the work-around Dion described. I was seeing the same result you were, which is now working correctly with the following.

                    PHP Code:
                    return ((getYear(0)+"")+ ((getMonth(0)*1000000)+(getDay(0)*10000)+(getHour(0)*100)+getMinute(0))); 
                    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


                    • #11
                      Dion / Jason,

                      Thanks for helping me to resolve these issues -- much appriciated!!

                      I have a feeling anyone using very long integers in previous versions may have similiar problems.

                      My impression was that JavaScript does not make a distinction between integer values and floating point values -- all numbers are represented as an 8-byte floating point numeric format. So I didn't think a buffer overflow would be an issue ...

                      BTW, I'm running XP - SP2.

                      >>>Gregg

                      Comment


                      • #12
                        Hi Jason and Dion,

                        Thanks for looking into this and figuring it out. I went ahead and stuck another debug statement in there where I added checked the typeof(getDay(0)):

                        debugPrintln("22: type day= "+ typeof(day)+" type day= "+ typeof(getDay(0)));

                        As you indicated, the output for that becomes:

                        22: type day= object type day= number

                        Where instead of getDay() being an object, getDay(0) is now a number.

                        Regarding the method that you are using to calculate the time and date gkelly, I know this is rather late in the thread, but FWIW, this is how I have done it before:

                        PHP Code:
                        function getDateTimeId1() {
                          var 
                        dateTime getYear(0)+"";
                          
                        dateTime += getMonth(0)+"";
                          
                        dateTime += getDay(0)+"";
                          
                        dateTime += getHour(0)+"";
                          
                        dateTime += getMinute(0)+"";
                          
                        debugPrintln("40: dateTime = "+dateTime+" type = "+typeof(dateTime));
                          return 
                        dateTime;

                        As you can see, the numbers are converted to strings and are concanated. This way you do not have to perform any multiplications.

                        Comment


                        • #13
                          Thanks Steve!

                          The bummer about building the Date/Time id with string manipulation is that it's hard to maintain the strict YYYYMMDDHHMM format, which is what I use to pass into my dll as a record time stamp.

                          While Jason's fix solves the overflow issue it doesn't maintain the format of the id. For example, a bar from today would look like 20054281005. I had to put a check in for months < 10 as follows:

                          if (getMonth(0) < 10)
                          return ((getYear(0)+"0")+((getMonth(0)*1000000)+(getDay(0 )*10000)+(getHour(0)*100)+getMinute(0)));
                          else
                          return ((getYear(0)+"")+((getMonth(0)*1000000)+(getDay(0) *10000)+(getHour(0)*100)+getMinute(0)));


                          That should do it!

                          >>>Gregg

                          Comment


                          • #14
                            Hi gkelly,

                            Good catch, actually you'll have to do that for minutes, hours, days and months as well, since they all are single digits at some time.

                            I have an application where I did that here which may be of some interest to you. I hope this is of some help.

                            Comment

                            Working...
                            X