Announcement

Collapse
No announcement yet.

Last bar of RequestHistory

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

  • Last bar of RequestHistory

    Just so you know:
    -----------------------
    Ever wonder why OnBarsChanged is called so often?
    I could never figure out why OnBarsChanged was being called every few seconds even if my time interval was 1 minute. More mysterious, was that it was called even though the number of bars did not change. I finally found out that everything has a purpose.

    I just found out (to my benefit), that the last bar of data from RequestHistory is not static. OnBarsChanged is called with the last (0) bar updated, even if there are no new bars.

    It appears that OnBarsChanged is called whenever new trades have occurred, not just when new bars are added. I had assumed incorrectly that OnBarsChanged was only called when a new bar was added.

    For example, run a 1 minute interval RequestHistory. Initially, say 100 bars are returned . Then, every few seconds (even though one minute data was requested), OnBarsChanged is called with a 'PARTIAL' bar representing the data since the last minute bar. GetNumBars does not indicate any new bars. However, bar 0 contains a new partial/updated bar. This continues until about a minute has elapsed. Then, finally, OnBarsChanged is called with a new bar of data.

    Pretty cool; I can now update and view my calculations from the partial bar every few seconds; Even though i'm doing the rest of the calculations from 1 minute data.

  • #2
    You got it. And that is the difference between OnBarsReceived and OnBarsChanged. OnBarsReceived only fires when a the bar count changes.

    Cheers... George

    Comment

    Working...
    X