I have code in OnMarketData that populates a dictionary of dictionaries for use in OnRender, which scans each dictionary.
OnMarketData(MarketDataEventArgs e)
cdict_barvolume = new Dictionary<double, VolumeInfoItem>(); if (!cdict_barvolumedictionaries.ContainsKey(CurrentBar)) cdict_barvolumedictionaries.Add(CurrentBar, cdict_barvolume); [B]lock [/B](e.Instrument.SyncMarketData) //[B] will this be helpful?[/B] { if (!cdict_barvolume.TryGetValue(e.Price), out vii_value)) cdict_barvolume.Add(e.Price), new VolumeInfoItem()); vii_value = cdict_barvolume[e.Price]; /// ... etc. }
[B]lock [/B](cdict_barvolumedictionaries) // [B]will this be helpful?[/B] { for (int index = ChartBars.FromIndex; index <= ChartBars.ToIndex; index++) { [B]lock [/B](cdict_barvolumedictionaries[index]) // [B]will this be helpful?[/B] { // ... draw some objects using the dictionary's data } } }
Comment