Announcement

Collapse
No announcement yet.

Previous 2EMA

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

  • Previous 2EMA

    I can get a 2EMA (vMinorEMA) to plot and work with withj no problem, but when I try to grab the PREVIOUS value of 2EMA (vMinorEMAPREV1), I get null

    Why?


    nPriceSource = "O"; // nPriceSource == "C" || nPriceSource == "O" || nPriceSource == "H" || nPriceSource == "L")
    nType = "MAStudy.EXPONENTIAL"; // nType == "MAStudy.EXPONENTIAL" || nType == "MAStudy.SIMPLE" || nType == "MAStudy.WEIGHTED" || nType == "MAStudy.VOLUMEWEIGHTED"
    MINOREMAstudy = new MAStudy(2, 0, nPriceSource, eval(nType));

    vMinorEMA = MINOREMAstudy.getValue(MAStudy.MA);
    vMinorEMAPREV1 = MINOREMAstudy.getValue(-1);

  • #2
    alexmihh
    That is happening because you are using an efs2 method to retrieve the value of an efs1 function.
    The correct syntax is vMinorEMAPREV1 = MINOREMAstudy.getValue(MAStudy.MA,-1);
    Alex

    Comment


    • #3
      Originally posted by Alexis C. Montenegro
      alexmihh
      That is happening because you are using an efs2 method to retrieve the value of an efs1 function.
      The correct syntax is vMinorEMAPREV1 = MINOREMAstudy.getValue(MAStudy.MA,-1);
      Alex
      OK Thanks. I was able to come up with an alternative method of storing the value of EMA2 as a seperate value before the next value of EMA2 was caluculated.

      How does one know when one is dealing with efs1 or efs2? How could I have figured this out on my own?

      Comment


      • #4
        alexmihh
        You can find the complete list of the efs2 functions for the built-in studies in this article of the EFS KnowledgeBase.
        Also whenever you see the "new" keyword as in var myStudy = new MAStudy(....) you are dealing with an efs1 function.
        Alex

        Comment

        Working...
        X