This works fine on historical data; bar timing is what you would expect - at the end of each day, OnBarUpdate is called for the Daily bars in sync with the Intraday bar that closed at the same time.
When the indicator is applied to a live chart, OnBarUpdate for yesterday's close is often called at the wrong time. Instead of being called in sync with yesterday's final intraday bar, it's called after all of today's intraday bars are processed.
So, if you apply the indicator at 11 AM today, OnBarUpdate will be called for all of today's intraday bars up to 11:00 AM THEN OnBarUpdate is called for yesterday's daily bar.
Because the daily bars are used in the indicator calculation, the indicator output will change based on when the indicator is applied.
If the daily bars for the instrument are displayed as a data series on the chart, then OnBarUpdate for yesterday's daily bar is called at the correct time.
How to reproduce:
1. During trading hours, create an intraday chart for a stock (i.e. 6 days of 5-min SPY)
2. Add a Daily Data Series for the same instrument (i.e. 6 days of 1-Day SPY)
3. Open an output window.
4. Apply the indicator TestDailySync (attached)
5. Observe that the indicator output, and the output window, show that yesterday's daily OnBarUpdate was called at the correct time.
6. Now remove the daily data series from the chart and refresh the indicator.
7. Observe that yesterday's daily OnBarUpdate was not called at the correct time. It will not be called until the next close of an intraday bar. The indicator output has changed and is now incorrect (you may need to reapply the indicator several times to see this)
BarsInProgress == 0: 1/14/2010 11:05:00 AM BarsInProgress == 0: 1/14/2010 11:10:00 AM BarsInProgress == 0: 1/14/2010 11:15:00 AM BarsInProgress == 0: 1/14/2010 11:20:00 AM BarsInProgress == 0: 1/14/2010 11:25:00 AM BarsInProgress == 1: 1/13/2010 1:00:00 PM, counter = 2, Closes[1][0] = 114.62

Comment