Page 1 of 1

The Line.Smoothed property

Posted: Thu Jul 08, 2010 8:04 am
by 8751509
In the below code I see a strange occurance ..

Code: Select all

            int x = StockChart.Series.Count;
            
            Line SMALine = new Line(StockChart.Chart);
            MovingAverage SMAFunc = new MovingAverage();

            SMALine.Function = SMAFunc;
            SMALine.DataSource = StockChart.Series[ParentSeries];
            SMALine.Function.Period = 4;
            SMALine.Function.PeriodStyle = PeriodStyles.NumPoints;
            SMALine.Smoothed = true;

            x = StockChart.Series.Count;
I expected to have 1 extra series than I started with .. but when I set Smoothed to true I get another series ... does setting smoothed to true create another series as the result?
If so can I somehow delete the 'orignal' series so that I can get my series indexs back into sync with another part of the code that tracks each series ?

You see by the time I get to this code snippet ... I expected to have a series index = 0 (Candle Series) .. then Apply a simple Moving average and have 2 series .. alas I have 3 ... does this mean if I make a checkbox to switch smoothing on and off at runtime I will be dynamically changing the number of series in the collection. If I set smoothing does it add the "smoothed" series to end of the collection or does it insert the new "smoothed" series directly after the 'parent' series and thus I can never know the index of a series ?

regards Phil.

Re: The Line.Smoothed property

Posted: Fri Jul 09, 2010 10:35 am
by 10050769
Hello Phil,
I expected to have 1 extra series than I started with but when I set Smoothed to true I get another series ... does setting smoothed to true create another series as the result?
Yes, you've understood correctly it. Internally Smoothed property create a new series, for apply smooth function, when property Smoothed is true. So the result is new internal series, result of combine line series and function smooth.
If so can I somehow delete the 'orignal' series so that I can get my series indexs back into sync with another part of the code that tracks each series ?
You see by the time I get to this code snippet ... I expected to have a series index = 0 (Candle Series) then Apply a simple Moving average and have 2 series .. alas I have 3 ... does this mean if I make a checkbox to switch smoothing on and off at runtime I will be dynamically changing the number of series in the collection. If I set smoothing does it add the "smoothed" series to end of the collection or does it insert the new "smoothed" series directly after the 'parent' series and thus I can never know the index of a series ?
I think that is not necessary to delete original series because property Smoothed changes IndexOf of series and should not affect the code that you make. If you want know exactly that do it property internally, using reflector.

On the other hand, if it causes for you problems in some parts of code. You could indicate exactly which parts and attach a simple example, because we can help you solve it.

I hope will helps.

Thanks,