Announcement

Collapse
No announcement yet.

Can I expect to do this ?

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

  • Can I expect to do this ?

    Hi,

    I am not sure whether or not this is achievable, but this doesn't work and I am not sure why.....

    var test = 100-adx(14,14).toFixed(0);

    debugPrintln( ema(test) );

    So 100 - the ADX value gives a figure, and I use .toFixed(0) to make it a whole number.

    However, EFS doesn't like this 'flexible' figure. Is it because the figure is constantly changing ? Or am I missing something else.

    Thanks for your consideration.

  • #2
    Re: Can I expect to do this ?

    Originally posted by rogerha
    Hi,

    I am not sure whether or not this is achievable, but this doesn't work and I am not sure why.....

    var test = 100-adx(14,14).toFixed(0);

    debugPrintln( ema(test) );

    So 100 - the ADX value gives a figure, and I use .toFixed(0) to make it a whole number.

    However, EFS doesn't like this 'flexible' figure. Is it because the figure is constantly changing ? Or am I missing something else.

    Thanks for your consideration.
    Incidientally Formula Output shows:

    [object series] Parameter Number 1 of Function EMA is invalid

    Comment


    • #3
      Re: Re: Can I expect to do this ?

      I have now changed the syntax to look like this, no error, but no values either in the debug window:

      var test = 100-adx(14,14).toFixed(0);


      debugPrintln( test.getValue(-1) );
      debugPrintln( ema(test.getValue(-1)) );

      Comment


      • #4
        Re: Re: Re: Can I expect to do this ?

        rogerha,

        Everything you are trying to do can be done, however there are some issues.

        You are calculating a series with adx(14, 14), which you are applying the toFixed method.

        It may work, but it is conceptually wrong. You should fix this. You should get the number from the series using the getValue method, then apply the toFixed method.

        Using the toFixed method returns a string value, which you are subtracting from a number. JavaScript does automatic type conversion so this will likely work and result in a numerical value.



        Finally, both of your debug statements are in error.

        The first because you are using the getValue method on a number. This does not work

        The second one is you are trying to use a built in function, ema, with a numerical input that is actually an undefined value.

        To create an ema of a custom calculations, you need to check out the efs2 links in my signature block below. You may also want to check out the efs Knowledgebase on some of the other areas.

        Originally posted by rogerha
        I have now changed the syntax to look like this, no error, but no values either in the debug window:

        var test = 100-adx(14,14).toFixed(0);


        debugPrintln( test.getValue(-1) );
        debugPrintln( ema(test.getValue(-1)) );

        Comment


        • #5
          Hi Steve,

          Thanks for the response.

          OK, I have spent some time with those links you sent me, very useful indeed and now bookmarked !

          I now have numbers, I am not sure they are the right numbers, but I want to be sure I have grasped the syntax of what I am trying to do.

          I have now ended up with the following:

          test = adx(14,14);

          var RevAdx = 100-test.getValue(0)

          NewEma = ema(RevAdx);


          debugPrintln( test.getValue(0) );
          debugPrintln( NewEma.getValue(0) );

          So from the syntax, I think I am creating a Data Series (test).

          I then create a new variable by producing a calculation making use of retreiving a value from the series.

          I then create a second series using the RevAdx variable, and subsequently retrieve a value from that.

          Thats what I *think* I am doing but I would value your opinion on that

          Thanks.

          Comment


          • #6
            Hi rogerha,

            You are welcome. To create an ema of a custom calculation, you need to take this calculation and place it in a function that returns the value. Then you need to access the function via the efsInternal() declaration, which will take the returned value and create a series object. A series object contains additional parameters that are required for applying the built in studies in the correct context. This means that you must use a series object as a source for the built in studies, this seems to be the area you are having difficulty. The built in studies will not work unless you do that.

            Alex discussed this in another post today and provided some very specific links, I am sure you saw it. If not, here is the post which references some examples that are quite similar to what you are trying to do.

            Comment

            Working...
            X