Announcement

Collapse
No announcement yet.

Obtaining a value of N periods ago

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

  • Obtaining a value of N periods ago

    Hi,

    I am hoping that someone might be able to help with a minor problem concerning values of N periods ago.

    How would I get the value from, say, 6 days ago of the MA study below?

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

    //The EMA of the TMP
    var vEMA3_of_TMP = new MAStudy(3, 0, vTMP, MAStudy.MA, MAStudy.EXPONENTIAL);

    I'd like to get the value of this vEMA3_of_TMP as it is today (now) and also as it was 6 days ago.

    Can anyone help?

    Many thanks,

  • #2
    Re: Obtaining a value of N periods ago

    daborn-fox
    In the case of your example you do that by adding a bar index when retrieving the value of the MAStudy using getValue() eg
    myStudy.getValue(MAStudy.MA, barIndex)
    Use 0 for the current bar and a negative number for prior bars
    Alex


    Originally posted by daborn-fox
    Hi,

    I am hoping that someone might be able to help with a minor problem concerning values of N periods ago.

    How would I get the value from, say, 6 days ago of the MA study below?

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

    //The EMA of the TMP
    var vEMA3_of_TMP = new MAStudy(3, 0, vTMP, MAStudy.MA, MAStudy.EXPONENTIAL);

    I'd like to get the value of this vEMA3_of_TMP as it is today (now) and also as it was 6 days ago.

    Can anyone help?

    Many thanks,

    Comment


    • #3
      Thank you.

      Thank you very much. Once again, you've been a great help.

      Comment


      • #4
        Re: Thank you.

        daborn-fox
        You are most welcome
        Alex


        Originally posted by daborn-fox
        Thank you very much. Once again, you've been a great help.

        Comment

        Working...
        X