Announcement

Collapse
No announcement yet.

bug?

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

  • bug?

    I encountered a very strange error while debuging my EFS. I wrote the attached simplified EFS to reproduce the error. If you apply this EFS to an advanced chart showing ($TICK,T) with time template 8:30-16:00. In some cases, when tick is larger than tick1, the result of "tick > (tick1 + 0.5)" is false. For example, in the output window, near the line "t = 3363 ......", tick = -31, tick1 = -49, but the program considers the tick is smaller than tick1. Similar cases appear at other lines. It seems this error most likely occurs when tick accrosses 0 and it appears quite randomly. Help is greatly appreciated.





    /* Reproduce the Bug */
    var tick, tick1, t;

    function preMain() {
    setStudyMin(0);
    setStudyMax(280);

    setDefaultBarFgColor(Color.blue, 0);
    setDefaultBarFgColor(Color.red, 1);

    setStudyTitle("Test");
    t = 0;
    }

    function main() {



    if ( getBarState() == BARSTATE_NEWBAR ) {

    var ticktmp = tick;
    tick1 = ticktmp;
    tick = getValue("Close", 0, 1, "$TICK,T");
    //t = getValue("Time", 0, 1, "$TICK.T");
    t = t + 1;

    var W;
    W = Math.round(tick);

    if ( tick > (tick1 + 0.5) ) {
    debugPrintln("t = " + t + " Tick = " + tick + " Tick1 = " + tick1 + " up");
    }
    else {
    debugPrintln("t = " + t + " Tick = " + tick + " Tick1 = " + tick1 + " down");
    }
    }
    }

  • #2
    if I replace "if ( tick > (tick1 + 0.5) ) {" with "if ( Math.abs(tick-tick1) == (tick - tick1) ) {", I will get the correct answer. Therefore I believe there is some serious problem here. Can somebody run this script to verify this is a real problem? If it is run tomorrow, the resault will be different so that you have to find the line where the error is.

    Comment


    • #3
      Still no reply?
      If you run the script I attached on today's ($TICK,T) chart, you will find "t = 2072 Tick = -28 Tick1 = -38 down" in the printed results. I havn't find out the reason yet. Can eSignal technical support guys run the script once and look into it? Thanks.

      Comment


      • #4
        clearpicks,

        I am able to duplicate this problem. It seems related to using getValue() with $TICK,T. If I run the below on a $TICK,T chart the output is fine.

        PHP Code:
        /* Reproduce the Bug */
        var ticktick1t;

        function 
        preMain() {
            
        setStudyMin(0);
            
        setStudyMax(280);
            
            
        setDefaultBarFgColor(Color.blue0); 
            
        setDefaultBarFgColor(Color.red1); 
            
            
        setStudyTitle("Test");
            
        0;
        }

        function 
        main() {
            
            if ( 
        getBarState() == BARSTATE_NEWBAR ) { 
            
                var 
        ticktmp tick;
                
        tick1 ticktmp;
                
        tick getValue("Close"/*, 0, 1, "$TICK,T"*/);
                
        1;
                
                var 
        W;
                
        Math.round(tick);
                
                if ( 
        tick > (tick1 0.5) ) {
                    
        debugPrintln("t = " " Tick = " tick " Tick1 = " tick1 " up");
                } else {
                    
        debugPrintln("t = " " Tick = " tick " Tick1 = " tick1 " down");
                } 
            } 

        Regards,
        Jay F.
        Product Manager
        _____________________________________
        Have a suggestion to improve our products?
        Click Support --> Request a Feature in eSignal 11

        Comment


        • #5
          Thanks for the reply. However if you look at my script and the output in the debug window, you will find the printed tick and tick1 values are correct, but the comparison result is wrong. In any circumstance, (-28) SHOULD be larger than (-38), isn't it? Any explaination on this? I had similar problems several monthes ago ( it was not comparison of tick values ). Because I didn't continue to work on that indicator, I didn't look at this problem seriously until now. If it is really caused by the comparison part, I have to worry more about the credibility and correctness of EFS language.
          Last edited by clearpicks; 06-17-2003, 11:23 AM.

          Comment


          • #6
            Hello clearpicks,

            I've verified this problem as well. The only instance that I've seen where the comparison failed was when t = 4. I'm not sure if this is a problem with the getValue() function or within the engine, but I will forward this info to our senior developers.

            When using getValue() to return a single value, EFS returns a string, so you have two options to solve the problem. Multiply your getValue() result by 1 or use the close() function. Try the following.

            PHP Code:
            /* Reproduce the Bug */
            var ticktick1t;

            function 
            preMain() {
            setStudyMin(0);
            setStudyMax(280);
            setDefaultBarFgColor(Color.blue0); 
            setDefaultBarFgColor(Color.red1); 
            setStudyTitle("Test");
            0;
            }

            function 
            main() {
                if ( 
            getBarState() == BARSTATE_NEWBAR ) { 
                    var 
            ticktmp tick;
                    
            tick1 ticktmp;
                    
            tick getValue("Close"01"$TICK,T")*1;
                    if (
            tick == null) return;
                    
            // or use 
                    //tick = close();
                    
            1;
                    var 
            W;
                    
            Math.round(tick);
                    if ( 
            tick > (tick1 0.5) ) {
                        
            debugPrintln("t = " " Tick = " tick " Tick1 = " tick1 " up");
                    } else {
                        
            debugPrintln("t = " " Tick = " tick " Tick1 = " tick1 " down");
                    } 
                } 
                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


            • #7
              I think Jay is correct. If you run the below EFS the way it is all results will be correct on a $TICK,T chart (this is the same thing Jay did). If you uncomment out the tick = close(); and the take out the comments in front of the original tick = statement the error will show itself again.

              If you try the exact same thing but use IBM,15 say for the formula and the chart it works fine.

              There is some bug with the way that $TICK,T is returning data in the statement.

              Garth

              PHP Code:
              /* Reproduce the Bug */
              var tick 0;
              var 
              tick1 0;
              var 
              0;

              function 
              preMain() {
              // setStudyMin(0);
              // setStudyMax(280);

              setDefaultBarFgColor(Color.blue0); 
              setDefaultBarFgColor(Color.red1); 

              setStudyTitle("Test");
              }

              function 
              main() {

                  if ( 
              getBarState() == BARSTATE_ALLBARS )
                      
              0;

                  if ( 
              getBarState() == BARSTATE_NEWBAR ) { 

                      
              tick1 tick;
                      
              tick getValue("Close");
                      
              // tick  = getValue("Close", 0, 1, "$TICK,T");
                      //t = getValue("Time", 0, 1, "$TICK.T"); 
                      
              1;
                      
                      if (
              isNaN(tick) || isNaN(tick1)){
                          
              debugPrintln("*********NAN*********");
                      }

                      if ( 
              tick tick1 ) {
                          
              debugPrintln("t = " " Tick = " tick " Tick1 = " tick1 " up");
                      } 
                      else {
                          
              debugPrintln("t = " " Tick = " tick " Tick1 = " tick1 " down");
                      } 
                   } 

              Garth

              Comment


              • #8
                When using getValue() to return a single value, EFS returns a string, so you have two options to solve the problem. Multiply your getValue() result by 1 or use the close() function. Try the following.
                To convert a string to an Int, I would use parseInt() instead of multiplying by 1.


                Also, I'm not sure getValue() returns a string, in fact I think it returns an array if the return is greater than one. However in this specific case I can tell you that a string is NOT being returned as I thought that might be the problem and added a check for isNaN(). It never shows that a number is not returned.

                Garth
                Garth

                Comment

                Working...
                X