I am trying to store data for every bar for lates 3 days and storing prices as key of a dictionary. I am checking using CurrentBar and storing them in a list called firstBar, where I am selecting Current Bar which is 3 days ago like below:
if (Bars.IsFirstBarOfSession && !firstBar.Contains(CurrentBar))
{
firstBar.Add(CurrentBar);
}
if (firstBar.Count > 3)
firstBar.RemoveAt(0);
firstBarIdx = firstBar.FirstOrDefault();
Then, I am adding the price to the dictionary like below:
if (CurrentBar >= firstBarIdx)
{
if (!Dictionary.ContainsKey(Price))
Dictionary.Add(Price , //Value );
}
else
Dictionary.Clear();
But the problem here is, It is supposed to always store only what ever the keys are for last 3 days and anything before, it was supposed to clear from the dictionary. But instead, it is keep all and plotting on chart. Is it the problem with my logic or is it a problem with how data is plotted in NT8 chart? Any advise will be appreciated.
Comment