Page 1 of 1

Nice Moving Average Curve

Posted: Thu Oct 14, 2010 2:49 pm
by 9533057
Hi,

I use some Teechart function based on main serie (like Moving Average). I use the anti-aliasing tools to render.
But the result on moving average is not so good, the result is not a nice curve...How can I obtain a nice moving average curve ? I hope my sample is more clear than my words :D
smooth.jpg
smooth.jpg (108.65 KiB) Viewed 7041 times
Thanks for your help,

Guilz

Re: Nice Moving Average Curve

Posted: Fri Oct 15, 2010 8:47 am
by narcis
Hi Guilz,

You can add a smoothing function to your chart having the moving average series as source series and make it invisible.

Hope this helps.

Re: Nice Moving Average Curve

Posted: Fri Oct 15, 2010 9:18 am
by 9533057
Hi Narcis,

I try what you suggest but the result is not fantastic (not a lot difference between smooth serie based on moving average serie and the moving average serie)
changing factor of smooth serie as not a big impact...
smooth2.jpg
smooth2.jpg (104.55 KiB) Viewed 7105 times
Guilz

Re: Nice Moving Average Curve

Posted: Fri Oct 15, 2010 3:19 pm
by yeray
Hi Guilz,

Take a look at the following example. There is a Point series (source), a moving average function and a smoothing function.
If you zoom in, you'll see how the smoothed function is smoother than the moving average function.

Code: Select all

Private Sub Form_Load()
  TeeCommander1.ChartLink = TChart1.ChartLink
   
  TChart1.Legend.Visible = False
  TChart1.Aspect.View3D = False

  TChart1.AddSeries scPoint
  TChart1.Series(0).FillSampleValues 100
  TChart1.Series(0).asPoint.Pointer.HorizontalSize = 2
  TChart1.Series(0).asPoint.Pointer.VerticalSize = 2
  
  TChart1.AddSeries scLine
  TChart1.Series(1).SetFunction tfMovavg
  TChart1.Series(1).DataSource = TChart1.Series(0)
  TChart1.Series(1).FunctionType.Period = 5
  'TChart1.Series(1).Active = False
  
  TChart1.AddSeries scLine
  TChart1.Series(2).asLine.LinePen.Width = 2
  TChart1.Series(2).SetFunction tfSmoothing
  TChart1.Series(2).DataSource = TChart1.Series(1)
  TChart1.Series(2).FunctionType.Period = 5
End Sub
If you still have problems with it, please try to arrange a simple example project we can run as-is to reproduce the problem here.