I discovered Microsoft's .Net charting controls from another post here, and so far I love them. For anyone needing it, here is the link: http://code.msdn.microsoft.com/mschart
I do everything during runtime, such as creating series and slapping them on a chart area. I can successfully create a Candlestick chart, by supplying it with an X value and 4 Y values, and when I add it to the chart like so:
// "Price" is the .Name property of this series
chart1.Series.Add(priceseries);
It works great. Next, I pored through the samples that came with this lovely control for the financial formulas. The sample says to use the moving average formula (just using this as an example, I can't get any of them to work), the code is this:
chart1.DataManipulator.FinancialFormula(FinancialFormula.MovingAverage,"5","Input","Simple");
Where "5" is the period to use, so that can be whatever I want. "Input" is the data source series it seems, and "Simple" is the output series. To spin this into a way that works with my code, I created a button and did this:
private void button1_Click(object sender, EventArgs e)
{
chart1.DataManipulator.FinancialFormula(FinancialFormula.MovingAverage, "5", "Price", "SMA");
}
Nice and simple, ya? Well, as soon as I click that button, my chart control displays a big, red, unhappy X and NOT the moving average series (which I named "SMA") on the chart in any way, shape, or form.
Adding to the above code, I have tried pre-creating the "SMA" series, I have tried adding the "SMA" series to the chart after doing the financialformula call, and both end up with the big mean red X. Going through the sample code again, it appears that the single line of code is all that is needed to generate the extra series of data, but I'm stuck! It doesn't help that the red X has no debugging info whatsoever :(
Any ideas on how to get rid of the big X, and have it display the new series of data instead?
Update: Just as a test, I removed the bit about adding the series to Chart1, then I added the chart1.DataManipulator bit right after it. As expected, the initial series that has all my initial data doesn't appear (because I removed the part adding it to the chart), but when the next line of code does the formula application - no big red X. There is no data shown, but no error code either - so I guess that is an improvement? This is leading me to believe that there is some sort of problem with either the initial dataset I'm applying the formula to, or something having to do with the view/boundaries of the chart control itself. If I find anything more on that track, I will post it as a second update.