Announcement

Collapse
No announcement yet.

ATR script crash!!

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

  • ATR script crash!!

    HELP!

    Can someone tell me why this script causes eSignal to completely crash. Perhaps only eSigal rep should test this; I wouldn't want any traders to mess up their system trying this.

    I run it up on 5-min chart of ES #F, and eSig bites the dust.

    PHP Code:
    function preMain() {
    }

    function 
    main() {
        var 
    vATRvATR1;
        
        var 
    study = new ATRStudy(14);
        
        
    vATR rnd(study.getValue(ATRStudy.ATR), 2);
        
    vATR1 rnd(study.getValue(ATRStudy.ATR, -1), 2);
        
    debugPrintln("ATR=" vATR ", ATR1=" vATR1);
        
        return new Array(
    vATRvATR1);
    }

    // Round to N digits.
    function rnd(valueN) {
        var 
    n;
        var 
    mult=1;
        for(
    n=0;n<N;n++) mult*=10;
        
    value*=mult;
        return 
    Math.roundvalue,N)/mult;


    Thanks,
    Mikey

  • #2
    Mikey
    It looks somewhat strange as it is computing, but it is not crashing the app (build 566) as you can see by the attached.
    Alex
    Attached Files

    Comment


    • #3
      Mikey

      Why don't use the javascript feature to.Fixed

      vATR = study.getValue(ATRStudy.ATR).toFixed(2);

      instead of reinventing the (square) wheel

      Comment


      • #4
        Alexis,

        Thanks. I had to rebuild my layout; something kept making eSig crash, so I redid the layout. Now the ATR script works. Veryodd, because before when I ran the script, it seemed to be the cause of the problem. Perhps afterall it was not the cause, but just the trigger. I'll probably never know.

        ------------------------------

        dloomis,

        Tried what you suggesred, but got error (see attachment).

        Here's the line:
        vATR = study.getValue(ATRStudy.ATR).toFixed(2);

        ------------------------------

        Mikey
        Attached Files

        Comment


        • #5
          Mikey

          For some reason

          study.getValue(ATRStudy.ATR)

          is not a number, and toFixed(2) requires a number. So I forced it to be one by multiplying the value by 1, now the toFixed(2) part works.

          function preMain() {
          }

          function main() {
          var vATR, vATR1;
          var study = new ATRStudy(14);

          vATR = (study.getValue(ATRStudy.ATR)*1).toFixed(2);

          vATR1 = (study.getValue(ATRStudy.ATR(-1))*1).toFixed(2);
          debugPrintln("ATR=" + vATR + ", ATR1=" + vATR1);

          return new Array(vATR, vATR1);
          }

          Comment

          Working...
          X