Announcement

Collapse
No announcement yet.

Distinguishing live bars from old bars

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

  • Distinguishing live bars from old bars

    Is there a method, perhaps
    similar to the getBarState method,
    that allows an efs study to distinguish
    between historic bars and live bars?

    I have a study that draws input from global values that are written by other studies. It can only get those values when bars are coming in "live;" otherwise it gets null values. I would like my study to know when it is operating on historical bars or live bars. For the historical bars (i.e., the bars that populate the chart upon refresh), I'd have it do its calculations differently in a way that doesn't depend on global values.
    Last edited by PNW_Kurt; 11-04-2011, 03:11 PM.

  • #2
    I should add, I have tried including a condition,

    if (nBarState==BARSTATE_ALLBARS) {
    // perform the study in the alternate way
    }

    but the study does not do anything for historical bars. This makes me think there might be a different way of getting the study to distinguish historical from live.

    Comment


    • #3
      if (isLastBarOnChart())
      {
      // you are on a live bar here
      }

      Comment


      • #4
        Originally posted by SteveH
        if (isLastBarOnChart())
        {
        // you are on a live bar here
        }
        That worked! Thank you very much!

        Comment


        • #5
          Isn't the (0) bar always the current bar and not closed?

          Comment

          Working...
          X