I have developed an indicator (footprint) for my own use. In this indicator I have the posibility to draw the profile of the session. The code is something like this:
public struct BidAskVolume
{
public double currentVolume;
public double askVolume;
public double bidVolume;
public BidAskVolume(double cv, double av, double bv)
{
currentVolume = cv;
askVolume = av;
bidVolume = bv;
}
}
public class Profile
{
public Dictionary<double, BidAskVolume> diccProfile = new Dictionary<double, BidAskVolume>();
}
private Series<Profile> ProfileBars;
//Desde la primera bar de la sesión...
for (int chartProfileIndex = PrimeraBarSesion; chartProfileIndex <= ChartBars.ToIndex; chartProfileIndex++)
{
Profile tmpprofile;
if (ProfileBars.IsValidDataPointAt(chartProfileIndex) )
{
tmpprofile = ProfileBars.GetValueAt(chartProfileIndex);
}
else
{
continue;
}
if (tmpprofile == null) { continue; }
Dispatcher.Invoke((Action)(() =>
{
//Montamos el profile.....
foreach (KeyValuePair<double, BidAskVolume> fila in tmpprofile.diccProfile)
{
double tmpCurrent = 0.0;
double tmpask = 0.0;
double tmpbid = 0.0;
//Si existe...actualizamos...
if (profileVA.ContainsKey(fila.Key))
{
tmpask = profileVA[fila.Key].askVolume + fila.Value.askVolume;
tmpbid = profileVA[fila.Key].bidVolume + fila.Value.bidVolume;
tmpCurrent = profileVA[fila.Key].currentVolume + fila.Value.currentVolume;
profileVA[fila.Key] = new BidAskVolume(tmpCurrent, tmpask, tmpbid);
}
else
{
profileVA.Add(fila.Key, new BidAskVolume(fila.Value.currentVolume, fila.Value.askVolume, fila.Value.bidVolume));
}
}
}));
I have a datatape Series<custom> that i save the ask and bid volumen for every Price of the tipus os data series. (10 Range). The performance is fine for a lot of instruments, but the problem is for the DAX, this instrument, when the session is comming up, it start to not work fine, because they have a lot of information. Because it's move a lot of points during the session.
How can i improved the performance, when i want to draw the profile...
Comment