Announcement

Collapse
No announcement yet.

all bars loaded

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

  • all bars loaded

    Hello,

    I want to do calculations only after all the bars are loaded for the script. How can I tell when all the bars loaded are finished?

    -Mike

  • #2
    var bInit = false // Global Variable

    if(!bInit && isLastBarOnChart()) bInit = true;

    After all bars are loaded, bInit becomes true.

    Comment


    • #3
      You could also just test for when the code is done loading and it reaches the current bar...assuming that the market is open and new data is streaming in.
      if(getBarState() == BARSTATE_CURRENTBAR){
      ...Do something
      }

      Comment


      • #4
        Hi sunman4008,

        Here is another technique which I've seen used.

        if (getBarState() === BARSTATE_ALLBARS) return; // ignore stuff while loading bars
        Glen Demarco
        [email protected]

        Comment

        Working...
        X