The error says:
"Error on triggering custom event for indicator AuctionGrid5: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index"
This is somewhat intermittent.
This for loop, this is where the exception get's thrown:
foreach (double item in list)
{
string type = string.Empty;
string thisVol = string.Empty;
// --
try
{
if (dList[item].price == GetCurrentBid())
type = "Bid";
else if (dList[item].price == GetCurrentAsk())
type = "Ask";
if (dList[item].price == Close[0])
thisVol = dList[item].vol.ToString();
}
catch (Exception ex)
{
MyExceptionHandler(ex, "TheApp() - Trying to retrieve type.");
}
// EXCEPTION THROWN HERE...
try
{
auctionRow = new String [] {
dList[item].time.ToString(),
dList[item].price.ToString(),
type,
thisVol,
dList[item].cumVol.ToString(),
dList[item].bidVol.ToString(),
dList[item].askVol.ToString(),
dList[item].totalVol.ToString()
};
if (aGrid.dg.Rows.Count > -1)
idx = aGrid.dg.Rows.Add(auctionRow);
//Print ("here "+idx.ToString());
}
catch (Exception ex)
{
MyExceptionHandler(ex, "TheApp() - adding row, returning idx.");
}
// NEED 'idx' FOR THIS CODE
if (Close[0] == dList[item].price)
{
try
{
dgvr_auction = aGrid.dg.Rows[idx];
dgvr_auction.DefaultCellStyle.BackColor = thisColor;
dgvr_auction.DefaultCellStyle.Font = currentRowFont;
dgvr_auction.DefaultCellStyle.ForeColor = Color.White;
}
catch (Exception ex)
{
MyExceptionHandler(ex, "TheApp() - trying to set current row color.");
}
}
// remove blue hilite from first row/cell
aGrid.dg.Rows[0].Cells[0].Selected = false;
}
Comment