So, I'm getting some inconsistent behavior on always being able to reliably detect that bars.Count == 0 from within BarsType.Add method. I had assumed that I would get this if block to always enter per reloading or just loading of a chart. But It seems I can only get it to happen once (perhaps once per from/to combination, not sure yet what drives NT7 calling the Add method - I assumed per tick fed into my chart). For example, after compiling a new variation of my bars type, restarting NT7, and loading up exact same chart with same from/to periods, the bars.Count is automagically greater than 0 to my surprise already (as if the prior NT7 run has cached the generated bars and is not re-calculating them with potentially updated logic of my custom bar type code).
If it is due to cache, I can see that as beneficial for 99.99% of time, except when you are trying to debug your own bars type code and thus alter logic from run to run . So, if I'm hitting a caching issue, how can I work around it so that after I restart Ninja in between changes to my custom bars type code, it will always hit the bars.Count == 0 logic condition?
Or is there a better way to detect the very first tick from a chart that I want to *ALWAYS* detect for my Tick driven custom bar type within the Add method so I can properly initialize my chart building process?
Here's snippet of code for example - I use Trace.WriteLine (i.e., using System.Diagnostics) so that you can trace code paths within Ninja's trace log files:
Snippet
public override void Add(Data.Bars bars, double open, double high, double low, double close, DateTime time, long volume, bool isRealtime) { Trace.WriteLine([COLOR=#A31515][/COLOR][COLOR=#2B91AF]String[/COLOR].Format([COLOR=#A31515]">>>> bars.Count = {0}"[/COLOR], bars.Count)); if (bars.Count == 0) { Trace.WriteLine([COLOR=#A31515]">>>> building first bar in chart"[/COLOR]); Snippet AddBar(bars, open, high, low, close, time, volume, isRealtime); } else { Bar bar = (Bar)bars.Get(bars.Count - 1); ... }
Comment