Announcement

Collapse
No announcement yet.

How to return values to a study 4 bars previous?

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

  • How to return values to a study 4 bars previous?

    Just curious as to if there is a way to offset say a CCI to plot (or paint the line) 4 bars previous to the current bar but with the current bars values? So in short when I return the value to the chart it will paint it in 4 bars earlier...


    return vCCI.getValue(CCIStudy.CCI);
    none

  • #2
    rwd1971
    If you want to shift the CCI forwards then change the return to
    return vCCI.getValue(CCIStudy.CCI,-4);
    If instead you want to shift it backwards then use
    return vCCI.getValue(CCIStudy.CCI,4);
    Alex

    Comment


    • #3
      Thanks! BTW what if I wanted to try this on the MACD?

      Would it look like this?

      return new Array(vHist, vSignal, vMACD, -8);
      none

      Comment


      • #4
        rwd1971
        In that case you would have to look in the formula where you are defining that variable and set the offset there.
        For example somewhere in the script you will have something similar to the following
        var vMACD = studyname.getValue(MACDStudy.MACD);
        You would then change that to
        var vMACD = studyname.getValue(MACDStudy.MACD,-8);
        Then you would have to repeat it for the other two variable ie vSignal and vHist
        Alex

        Comment


        • #5
          Thankyou that's exactly what I was looking for!
          none

          Comment

          Working...
          X