You have to establish the number of groups, which is 4 for an OHLC plot. So you can't use the default constructor. Use the constructor below, which specifies 4 groups, and 0 initial data values. Then add each new set of values.
TimeGroupDataset Dataset1 = new TimeGroupDataset("TimeGroupDataset", 4, 0);
for (i = 0; i < nNumPnts; i++) {
double [] yvalues = {stockPriceData[0][i], stockPriceData[1][i], stockPriceData[2][i], stockPriceData[3][i]};
Dataset1.addTimeGroupDataPoints(xValues[i], yvalues);
}