Announcement

Collapse
No announcement yet.

Historycal values of data series in external time interval [2]

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

  • Historycal values of data series in external time interval [2]

    Hi,

    I have to rephrase my previous question, as I get stuck way to often because I don't know how to do it.

    "Is there a way [any way] to retrieve historical values [based on chart bars] for data series declared in external time intervals?"


    Thank you.
    Mihai Buta

  • #2
    Mihai
    You can use offsetSeries(series,offset) and then retrieve the current value of that offset series. This is because offsetSeries() runs in the context (interval and/or symbol) of the function in which it is being used.

    PHP Code:
    function main(){
        var 
    myMA offsetSeries(sma(10,close(inv(10))),3);
        
    debugPrintln(myMA.getValue(0));
        return;

    If you run the above in a 1 minute chart for example myMA.getValue(0) will be the value of myMA three 1 minute bars back even though the average is computed on a 10 minute interval.
    Note that if you are returning the study from main you can use ref() as I believe Dion already suggested to you.
    Alex

    Comment


    • #3
      Hi Alex,

      Yes, that will fine if the offset is fixed. However, in most situations it is not known.

      The typical case is when an event happens in base interval and you need to validate it in other intervals [divergencies, overbought situations, TopOfCycle, Pivots, etc.].

      It looks like I cannot avoid calculating every time the corresponding number of external bars.

      Thanks a lot.
      Mihai
      Mihai Buta

      Comment

      Working...
      X