ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Volume Chart not plotting first available data
Posted by Steve on Jun-29-2011 03:08
Attachments:
Hi Peter,

When I try to add volumeBars to a financechart, where there is only a few days of data available, the oldest volume data is not charted.

My volume data array consists of 0- ~200 Chart.NoValue and then the 5 volume data points at the end of the array.

I've tried simplifying my code to just get the data, set it, addMainchart, and addvolume but it stil doesn't graph properly.

Any suggestions?

Thanks
missingVol.png

  Re: Volume Chart not plotting first available data
Posted by Peter Kwan on Jun-30-2011 02:50
Hi Steve,

For the volume bars, the color of the bar depends on whether the day is an "up", "down" or "flat" day. A day is an "up" day if the closing price of that day is higher than the closing price of the previous day (and similarly for "down" day or "flat" day).

However, for the first day, there is no "previous day" to compare with, and the bar is not drawn.

In a normal finance chart, the leading points are almost always removed from the chart (the extraPoint parameter is non-zero) so as to support technical indicators that use leading values (such as moving averages). So the missing bar does not pose issue as it is removed from the chart anyway.

For your case, it seems we cannot remove the leading bar. One method I have thought of is to artificially modify a NoValue to a valid value, so as to allow the color of the first bar to be determined.

In C#, it may be like:

//insert artificial value in an otherwise NoValue point
double[] adjustedCloseData = (double[])(closeData.Clone());
for (int i = 1, i < closeData.Length; ++i)
    if ((closeData[i] != Chart.NoValue) && (closeData[i - 1] == Chart.NoValue)) adjustedCloseData[i - 1] = closeData[i];

//use the adjustedCloseData for the volume indicator
c.setData(timeStamps, highData, lowData, openData, adjustedCloseData, volData, 0);
c.addVolIndicator(....);

//restore the original closeData in case you need to add other indicators
c.setData(timeStamps, highData, lowData, openData, closeData, volData, 0);

Hope this can help.

Regards
Peter Kwan

  Re: Volume Chart not plotting first available data
Posted by Steve on Jul-01-2011 01:47
thank you Peter!  that helped