Announcement

Collapse
No announcement yet.

ema(100) returns nan

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

  • ema(100) returns nan

    Hello
    I am having a strange problem. I have copy/pasted this code because ema(100) returned either null og nan. I decided to copy code already available. When I use ema(10) or ema(50) the code respons as expected, but when I use other values like 150 the code returns with nan? I cant find any logic in this, am I missing something here?

    appreciate your help, tx.

    Danny Nielsen

    /************************************************** ***************
    Provided By:
    Interactive Data Corporation (Copyright © eSignal) 2010.
    All rights reserved. This sample eSignal Formula Script (EFS)
    is for educational purposes only. Interactive Data Corporation
    reserves the right to modify and overwrite this EFS file with
    each new release.
    ************************************************** ****************/

    function preMain() {

    setPriceStudy(true);
    setStudyTitle("EMA");
    setCursorLabelName("EMA",0);
    setDefaultBarFgColor(Color.RGB(0x00,0x94,0xFF), 0);
    setPlotType(PLOTTYPE_LINE,0);
    setDefaultBarThickness(1,0);
    }

    function main() {

    return "::"+ema(10)+"::";
    }

  • #2
    Danny
    The ema() function [as well as functions for other studies] requires a certain number of bars to be fully primed during which it will not return a value. The number of bars required varies by study and in the case of the ema is equal to its length
    Your script is actually not returning a value only on the first nn bars equal to the assigned length. The following two screenshots should illustrate this [note the Bar# and Bar Index values in the Data Window]





    It will not return a value for the initial 10 bars also when using ema(10) [see following screenshot] but you just did not notice it
    Alex




    Originally posted by dannydneilsen View Post
    Hello
    I am having a strange problem. I have copy/pasted this code because ema(100) returned either null og nan. I decided to copy code already available. When I use ema(10) or ema(50) the code respons as expected, but when I use other values like 150 the code returns with nan? I cant find any logic in this, am I missing something here?

    appreciate your help, tx.

    Danny Nielsen

    /************************************************** ***************
    Provided By:
    Interactive Data Corporation (Copyright © eSignal) 2010.
    All rights reserved. This sample eSignal Formula Script (EFS)
    is for educational purposes only. Interactive Data Corporation
    reserves the right to modify and overwrite this EFS file with
    each new release.
    ************************************************** ****************/

    function preMain() {

    setPriceStudy(true);
    setStudyTitle("EMA");
    setCursorLabelName("EMA",0);
    setDefaultBarFgColor(Color.RGB(0x00,0x94,0xFF), 0);
    setPlotType(PLOTTYPE_LINE,0);
    setDefaultBarThickness(1,0);
    }

    function main() {

    return "::"+ema(10)+"::";
    }

    Comment


    • #3
      Hello Alexis, and thanks for you quick reply.

      I am programming a function to be used in a column in a watch list, the code is never to be used on charts. How do I setup this watch list function to look back a certain amount of bars?

      regards
      Danny


      Originally posted by Alexis C. Montenegro View Post
      Danny
      The ema() function [as well as functions for other studies] requires a certain number of bars to be fully primed during which it will not return a value. The number of bars required varies by study and in the case of the ema is equal to its length
      Your script is actually not returning a value only on the first nn bars equal to the assigned length. The following two screenshots should illustrate this [note the Bar# and Bar Index values in the Data Window]





      It will not return a value for the initial 10 bars also when using ema(10) [see following screenshot] but you just did not notice it
      Alex

      Comment


      • #4
        Danny
        You control the number of bars loaded in a Watch List through Time Templates [see this article in the eSignal KnowledgeBase for more information]
        Alex


        Originally posted by dannydneilsen View Post
        Hello Alexis, and thanks for you quick reply.

        I am programming a function to be used in a column in a watch list, the code is never to be used on charts. How do I setup this watch list function to look back a certain amount of bars?

        regards
        Danny

        Comment


        • #5
          Thanks Alex, your a genius. The bars were set to 50, it did help to change the period to beyond 150, thanks again ..
          Danny


          Originally posted by Alexis C. Montenegro View Post
          Danny
          You control the number of bars loaded in a Watch List through Time Templates [see this article in the eSignal KnowledgeBase for more information]
          Alex

          Comment


          • #6
            Danny
            You are welcome
            Alex


            Originally posted by dannydneilsen View Post
            Thanks Alex, your a genius. The bars were set to 50, it did help to change the period to beyond 150, thanks again ..
            Danny

            Comment

            Working...
            X