Announcement

Collapse
No announcement yet.

Using calculated values as parameters

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

  • Using calculated values as parameters

    Would anyone be able to advise how one can use a calculated value as a parameter to a function?

    For example, given the function :-

    var vPMP = new MAStudy(3, 0, "HL/2", MAStudy.SIMPLE);

    var vEMA3_of_PMP = new MAStudy(3, 0, vPMP , MAStudy.EXPONENTIAL);

    return vEMA3_of_PMP.getValue(MAStudy.MA)

    I would like to use a calculated value, say vPMP, instead of something like "HL/2" but this generates nothing.

  • #2
    Re: Using calculated values as parameters

    daborn-fox
    If you want to use the legacy functions then vEMA_of_vPMP would need to be writtem as follows
    var vEMA10_of_vPMP = new MAStudy(10, 0, vPMP, MAStudy.MA, MAStudy.EXPONENTIAL);
    FWIW you can create this and other studies on studies using the Formula Wizard (as long as you are using only the legacy built-in functions)
    That said you may find it easier to use the efs2 functions in which case you would just write
    var vEMA10_of_vPMP = ema(3, sma(3, hl2()));
    which will calculate the 3 period exponential evarage of a 3 period simple average of the (H+L)/2
    For the description and syntax of the efs2 moving averages functions [and examples of their use] see this article in the EFS KnowledgeBase
    Alex


    Originally posted by daborn-fox
    Would anyone be able to advise how one can use a calculated value as a parameter to a function?

    For example, given the function :-

    var vPMP = new MAStudy(3, 0, "HL/2", MAStudy.SIMPLE);

    var vEMA3_of_PMP = new MAStudy(3, 0, vPMP , MAStudy.EXPONENTIAL);

    return vEMA3_of_PMP.getValue(MAStudy.MA)

    I would like to use a calculated value, say vPMP, instead of something like "HL/2" but this generates nothing.

    Comment


    • #3
      Thank you.

      Thank you, that worked perfectly.

      Comment


      • #4
        Re: Thank you

        daborn-fox
        My pleasure
        Alex


        Originally posted by daborn-fox
        Thank you, that worked perfectly.

        Comment

        Working...
        X