Announcement

Collapse
No announcement yet.

why does this code not work?

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

  • why does this code not work?

    If I apply the following code on a daily chart, i.e. ($SPX, D), it doesn't work. However if I change the value of n to smaller value, for example, n = 5, then vC shall be printed out. I have been aware of this problem for quite a long time. Is there some good solution to this problem? If I run this code on (QQQ, 60) chart with enough bars on the chart, then there is no problem at all even if n is set to 60. In a lot of scenarios, esignal just quitely stops the execution of the efs if some problems like this one apear in the efs. I think it should at least gives some runtime warning about this.


    Clearpicks



    var i;

    var vC;

    function preMain(){
    setPriceStudy(true);
    }



    function main(){

    if ( getBarState() == BARSTATE_ALLBARS ) {
    }

    if ( getCurrentBarIndex() == 0 ) {
    var n = 60;
    vC = getValueAbsolute("Close", 0, -n, "QQQ,60");

    debugPrintln(vC);
    }
    }

  • #2
    Clearpicks,
    I can't help with this one. I tried the script on ES #F 15 min and daily. In both cases it caused a complete crash of eSignal. I don't know why.

    Bob

    Comment


    • #3
      Hi Bob,

      Thanks for your reply. When I tested, I use

      vC = getValueAbsolute("Close", 0, -60, "QQQ,60");

      instead of

      var n = 60;
      vC = getValueAbsolute("Close", 0, -n, "QQQ,60");

      Can you test it again on some other instruments like SPY or QQQ itself?


      Clearpicks


      Originally posted by rmclean
      Clearpicks,
      I can't help with this one. I tried the script on ES #F 15 min and daily. In both cases it caused a complete crash of eSignal. I don't know why.

      Bob

      Comment


      • #4
        clearpicks,

        I also locked up pretty hard when I tried running your code.

        here is the output I received when I changed these two lines:

        var n = 10;
        vC = getValueAbsolute("Close", 0, -n, "QQQ,5");

        PHP Code:
        35.300000000000004,35.28,35.260000000000005,35.25,35.230000000000004,35.24,35.260000000000005,35.318000000000005,35.39,35.367700000000006 
        I suspect that the length of the array is too large and it is crashing on a buffer overflow. I had the same problem a while back, but I was actually getting a buffer overflow error. I suspect the magnitude of yours is so large, you are really killing it. Please check out the third post on this link



        I rewrote the code a little and this seems to work. Notice where I multiplied by 1 to convert from a string to a number.
        PHP Code:
        var clearData = new Array(1000);

        function 
        preMain(){
            
        setPriceStudy(true);
        }

        function 
        main(){
            
            if ( 
        getBarState() == BARSTATE_ALLBARS ) {
            }
            
            if ( 
        getCurrentBarIndex() == ) {
                var 
        100;var vC;
                for (
        i=0;i<n;i++){
                    
        vC getValueAbsolute("Close", -i1"QQQ,60")*1;
                    
        clearData[i] =vC.toFixed(4)*1
                    debugPrintln
        (clearData[i]);
                }
            } 

        Comment


        • #5
          Thanks, Steve. I never linked this kind of error to a buffer overflow because I didn't see any complain message in the output window.

          Originally posted by stevehare2003
          clearpicks,

          I also locked up pretty hard when I tried running your code.

          here is the output I received when I changed these two lines:

          var n = 10;
          vC = getValueAbsolute("Close", 0, -n, "QQQ,5");

          PHP Code:
          35.300000000000004,35.28,35.260000000000005,35.25,35.230000000000004,35.24,35.260000000000005,35.318000000000005,35.39,35.367700000000006 
          I suspect that the length of the array is too large and it is crashing on a buffer overflow. I had the same problem a while back, but I was actually getting a buffer overflow error. I suspect the magnitude of yours is so large, you are really killing it. Please check out the third post on this link



          I rewrote the code a little and this seems to work. Notice where I multiplied by 1 to convert from a string to a number.
          PHP Code:
          var clearData = new Array(1000);

          function 
          preMain(){
              
          setPriceStudy(true);
          }

          function 
          main(){
              
              if ( 
          getBarState() == BARSTATE_ALLBARS ) {
              }
              
              if ( 
          getCurrentBarIndex() == ) {
                  var 
          100;var vC;
                  for (
          i=0;i<n;i++){
                      
          vC getValueAbsolute("Close", -i1"QQQ,60")*1;
                      
          clearData[i] =vC.toFixed(4)*1
                      debugPrintln
          (clearData[i]);
                  }
              } 

          Comment

          Working...
          X