It seems to me that OnBarUpdate() get called before IsFirstTickOfBar condition is true for last closed bar in loading history data for an indicator. My program looks like the following
protected override void OnBarUpdate()
{
//Do some calculation on latest bar
//Do some thing A;
if(IsFirstTickOfBar)
{
//Do some calculation for the last closed bar
//Do some thing B;
}
}
It seems everything fine with the indicator if I replay the data, either in normal speed or in fast mode. However, if seems there are cases where The "A" part of a new bar is called before the "B" part of the last closed bar is executed. I got to know this before I found there are some slightly difference in the chart of indicator after I remove and re-add the indicator into the chart.
When I develop the indicator, I presume the bar closed event happens before new tick data in. But it seems it didn't apply to load history data. How I can fix this?
Thank you very much!
Best Regards
David
Comment