Announcement

Collapse
No announcement yet.

getBarState() and getValueAbsolute Incomtatible

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

  • getBarState() and getValueAbsolute Incomtatible

    function preMain() {
    setPriceStudy(true);
    //setComputeOnClose(true);
    setStudyTitle("test");
    debugClear();
    }

    function main() {
    var indcurr = getCurrentBarIndex();
    var barstate = getBarState();
    if (barstate != BARSTATE_NEWBAR) return;
    if (indcurr < 0) return;
    debugPrintln("barstate="+barstate+" indcurr= "+indcurr);

    var n = 520;
    //var vC = getValueAbsolute("Close", 0, -n, "IBM,D"); //line16
    return;
    }

    ------------------
    In the above code, the debugprint prints only once if line 16 is commented out (correct). Remove the // from line16 and you can see that debugprint prints for each tick within the latest bar. The getBarState() seems to be reset by getValueAbsolute().
    Is this a bug or feature?
Working...
X