Announcement

Collapse
No announcement yet.

Type Error: n8MA.getValue(-1) ???

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

  • Type Error: n8MA.getValue(-1) ???

    Can anyone tell me why I get a type error on this ... plotted on a 233tick charts with 24 hour data ok but not on other charts


    var n8MA = offsetSeries( ema(8, sym("ES #F,5")), 0);
    var n8MAPlot = n8MA.getValue(-1).toFixed(2);


    Thanks Very Much

  • #2
    Re: Type Error: n8MA.getValue(-1) ???

    Patrick
    What exactly is the error message?
    Alex


    Originally posted by prawles
    Can anyone tell me why I get a type error on this ... plotted on a 233tick charts with 24 hour data ok but not on other charts


    var n8MA = offsetSeries( ema(8, sym("ES #F,5")), 0);
    var n8MAPlot = n8MA.getValue(-1).toFixed(2);


    Thanks Very Much

    Comment


    • #3
      TypeError: n8MA.getValue(-1) has no properties

      Comment


      • #4
        Patrick
        You need to run a null check on the value of n8MA prior to modifying its properties eg
        if(n8MA.getValue(-1)==null) return;
        Alex


        Originally posted by prawles
        TypeError: n8MA.getValue(-1) has no properties

        Comment


        • #5
          Sure I can check for failure ... but was wondering why it failed ??

          Comment


          • #6
            var n50DMA = offsetSeries( sma(50, sym("SP #F,D")), 0);
            var n50DMAPlot = n50DMA.getValue(-1).toFixed(2);
            var n20DMA = offsetSeries( sma(20, sym("SP #F,D")), 0);
            var n20DMAPlot = n20DMA.getValue(-1).toFixed(2);

            Everything else is ok but not this......

            var n8MA = offsetSeries( ema(8, sym("ES #F,5")), 0);
            var n8MAPlot = n8MA.getValue(-1).toFixed(2);

            Comment


            • #7
              So if I check for failure .. and return ... and it always fails ... it will never plot ... so whats the point of that

              Comment


              • #8
                So did you try to check for a null return and it continued to happen, or is this only a general question?

                In eSignal a built-in study (such as an MA) that requires a specific number of bars before it can start returning valid results will return a null instead of a value until the data set is primed.

                Therefore you will get errors similar to what you posted when you try to modify the return value...
                Garth

                Comment


                • #9
                  Seems it only returns a null

                  Comment


                  • #10
                    Post up a small example of a complete EFS that shows this problem...I'm sure someone will look it over (I will if nobody beats me to it)....
                    Garth

                    Comment


                    • #11
                      Here is an example
                      Attached Files

                      Comment


                      • #12
                        So, I don't have the full contract in my subscription, so when I first ran your EFS I got the exact same message (daily items seemed to work fine, sub-daily interval failed).

                        I then changed it all to be "ES" instead of "SP" and then changed the code so that all of the code checked for NULL return after getvalue() and grouped the related code together:


                        var n8MA = offsetSeries( ema(8, sym("ES #F,5")), 0);
                        var n8MAPlot = n8MA.getValue(-1);

                        if (n8MAPlot != null) {
                        n8MAPlot = n8MAPlot.toFixed(2);
                        drawxxx (-8, n8MAPlot.....)

                        }

                        etc...

                        and it worked just fine.

                        So unless this is related to the symbol SP directly somehow (which is why I asked about your subscriptions), I'm not sure why it doesn't display for you when you do a null check.

                        Garth
                        Garth

                        Comment

                        Working...
                        X