Announcement

Collapse
No announcement yet.

Bar index for series differs from bar index for non-series

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Bar index for series differs from bar index for non-series

    Sorry for all the newbie questions. I'm looking at the BarIndexes.efs script, and I see where the script labels the bars using the getCurrentBarIndex() value. However, in other scripts I see the call to a series object (such as on created from stochK and stochD) using 0, with the comment that that's the current value (e.g., myStochD.getValue(0)), even when processing historical data (i.e., non-streaming). And, in running such a script, that seems to be fine.

    The documentation says that getValue() takes an argument that is the bar index. So the concept of the 'current' bar index as returned from getCurrentBarIndex() seems to be different from that expected by a series object's getValue() method.

    Is it that a series object, while processing historical bars, is 'current' with the bar being processed, so a value of 0 is to be used?

    Here's a script that uses getValue(0) to return the plotted value in all cases, historical bars and streaming.
    PHP Code:
    function preMain() {
       
    setPriceStudy(false);
       
    setCursorLabelName('gts.%K'0);
       
    setStudyMin(0);
       
    setStudyMax(100);
       
    setDefaultBarFgColor(Color.blue0);
    }
    //global Series Object variables
    var QldKSeries null;
    function 
    main() {
         if (
    QldKSeries == nullQldKSeries stochK(1413);
         return 
    QldKSeries.getValue(0);  // Current Bar Index value

    Why wouldn't the argument to getValue() not have been the return from getCurrentBarIndex()?
    Thanks.

  • #2
    Re: Bar index for series differs from bar index for non-series

    tinker70

    So the concept of the 'current' bar index as returned from getCurrentBarIndex() seems to be different from that expected by a series object's getValue() method.
    That is correct.
    The getCurrentBarIndex() function returns the absolute index of a bar within the chart whereas the bar index used in the getValue() method of the series object is relative to the bar being processed by the efs engine

    Is it that a series object, while processing historical bars, is 'current' with the bar being processed, so a value of 0 is to be used?
    That is correct
    Alex


    Originally posted by tinker70
    Sorry for all the newbie questions. I'm looking at the BarIndexes.efs script, and I see where the script labels the bars using the getCurrentBarIndex() value. However, in other scripts I see the call to a series object (such as on created from stochK and stochD) using 0, with the comment that that's the current value (e.g., myStochD.getValue(0)), even when processing historical data (i.e., non-streaming). And, in running such a script, that seems to be fine.

    The documentation says that getValue() takes an argument that is the bar index. So the concept of the 'current' bar index as returned from getCurrentBarIndex() seems to be different from that expected by a series object's getValue() method.

    Is it that a series object, while processing historical bars, is 'current' with the bar being processed, so a value of 0 is to be used?

    Here's a script that uses getValue(0) to return the plotted value in all cases, historical bars and streaming.
    PHP Code:
    function preMain() {
       
    setPriceStudy(false);
       
    setCursorLabelName('gts.%K'0);
       
    setStudyMin(0);
       
    setStudyMax(100);
       
    setDefaultBarFgColor(Color.blue0);
    }
    //global Series Object variables
    var QldKSeries null;
    function 
    main() {
         if (
    QldKSeries == nullQldKSeries stochK(1413);
         return 
    QldKSeries.getValue(0);  // Current Bar Index value

    Why wouldn't the argument to getValue() not have been the return from getCurrentBarIndex()?
    Thanks.

    Comment

    Working...
    X