Most of the chart types are fairly straightforward, but the financial chart types (point and figure, candlestick, and OHLC) are a little less intuitive because they require multiple Y values per DataPoint and Microsoft has done a poor job documenting the right order to add these. I suppose that this post could fill that gap.
For the OHLC and Cadlestick chart types, the right order to add the open, high, low, and close values to a DataPoint is the following: high, low, close, open. See the following code sample where I plot a set of trading day values for a particular equity:
private void RefreshChart()
{
//Clear the points that are currently plotted
CandlestickChart.Series["OHLCSeries"].Points.Clear();
//Plot a subset of points from our time series
for (int i = start_i; i <= end_i; i++)
{
CandlestickChart.Series["OHLCSeries"].Points.AddY(
current_equity[i].high,
current_equity[i].low,
current_equity[i].close,
current_equity[i].open);
}
In the end, you get a correct Candlestick Chart (in my case, I'm building an application to help my trading skills):
No comments:
Post a Comment