Processing bars can lag data somewhat. Bars can also introduce sharp changes in statistics. Instead, I prefer to work with Trades and Quotes directly. But I still need the ability to work with summary statistics.
I've created an O(1) running time mechanism for processing trades and quotes in real time. The resulting code is provided in Accumulation.cs. The basic class I use is SimpleAccumulationStatsOnQuotes. The class is
instantiated as an object by defining the window width in seconds. The class will maintain a list of quotes. As quotes are added, they are
added to the summary statistics. As quotes fall outside the window, the quotes are removed from the summary statistics.
The summary statistics provide the basics for maintaining Bollinger Bands for the selected moving window time frame.
The class AccumulateQuotes is a brute force approach to calculating slope change velocities and acceleration. I think, with suitable
modification of the basic statistics, this class would not be needed.
Running statistics are maintained through a reference to the RunningStats class.
If you wish to know the Minimum/Maximum levels over an interval, a RunningMinMax class helps. It is more of a manual process, with the
AddPoint and RemovePoint methods.