Something seemingly simple has me tied up in knots.
When my indicator starts it seems that OnBarUpdate is called for each bar once.
How do I know when the series of events is completed for the first time?
In other words, in my OnStartup I print Bars.Count. Lets assume it comes out to 850.
In my OnBarUpdate event, in theory, I should be able to say something like:
if(Bars.Count - 1 == CurrentBar)
{
// do my thing
}
However, for some reason, CurrentBar never reaches Bars.Count -1, it only gets to Count - 2!
What's with the missing bar? Is it safe to say that if CurrentBar == Bars.Count - 2 then I am dealing with the "current" rightmost bar?
While I'm at it, once a bar is "closed", does OnBarUpdate ever get called again for it?
Could I safely say if Close.Count != Bars.Count then I know that I am on the rightmost bar.
This seems more difficult than it should be.
Thanks ... Ed
Comment