incorrect financial functions behavior

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
luzhetsky
Newbie
Newbie
Posts: 16
Joined: Mon Feb 08, 2010 12:00 am

Re: incorrect financial functions behavior

Post by luzhetsky » Wed May 12, 2010 12:12 pm

Narcís,

1st:

number of point should not be multiple of period! It's abcolutelly incorrect requirement for input seria!
You can find definition of Standard Deviation in Wiki: http://en.wikipedia.org/wiki/Standard_d ... the_sample

Each point of function should be calculate, based on N points of base seria. It is similar with , e.g., MA calculation.

2nd:

here is the code with func.PeriodStyle = Steema.TeeChart.Functions.PeriodStyles.Range;

Code: Select all

Steema.TeeChart.Styles.Candle candle = new Steema.TeeChart.Styles.Candle(tChart1.Chart);

            Steema.TeeChart.Functions.High func = new Steema.TeeChart.Functions.High();
            func.Period = 7;
            func.PeriodAlign = Steema.TeeChart.Functions.PeriodAligns.Last;
            func.PeriodStyle = Steema.TeeChart.Functions.PeriodStyles.Range;

            candle.FillSampleValues((int)(28));

            Steema.TeeChart.Styles.FastLine line = new Steema.TeeChart.Styles.FastLine(tChart1.Chart);
            line.DataSource = candle;
            line.Function = func;
and note, number of values is multiple with period! it is incorrect requirement, but it's not working anyway! I see only points of function for each N point of seria - only 4 points for 28 points seria!!!
Attachments
high_7_range.jpg
high_7_range.jpg (96.15 KiB) Viewed 4472 times

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: incorrect financial functions behavior

Post by Narcís » Thu May 13, 2010 8:25 am

Hi luzhetsky,
number of point should not be multiple of period! It's abcolutelly incorrect requirement for input seria!
This is not a requirement. This was just my suggestion if you wanted the function to be aligned with last point in source series.
You can find definition of Standard Deviation in Wiki: http://en.wikipedia.org/wiki/Standard_d ... the_sample

Each point of function should be calculate, based on N points of base seria. It is similar with , e.g., MA calculation.
That's what the PeriodStyle property does. Have you read Steema.TeeChart.Functions.Function.PeriodStyle entry in the help file?
I see only points of function for each N point of seria - only 4 points for 28 points seria!!!
Yes, exactly, that's what Period property does. As you can see in the help file for Steema.TeeChart.Functions.Function.Period:

The Period property controls how many points or X range will trigger a new point calculation.
For example, TAverageTeeFunction uses the Period property to calculate a new average point each time the "Period" number of points or X range is exceed.

NOTE:You may switch between number of points or X range by using the TTeeFunction.PeriodStyle property.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

luzhetsky
Newbie
Newbie
Posts: 16
Joined: Mon Feb 08, 2010 12:00 am

Re: incorrect financial functions behavior

Post by luzhetsky » Thu May 13, 2010 10:10 am

Narcís,

you should notice that in both type of PeriodStyle StD, High, Low functions calculate with the same manner: on each N points only.

Any Techical Analisis tool need caclulation for EACH point: each point data is based on calculation of previous N.

Only this we need.

Current implementation is wrong!

And we are expecting the answer from TeeChart team how to resolve existing problem of implementation of StD and High and Low functions?

Thank you.

luzhetsky
Newbie
Newbie
Posts: 16
Joined: Mon Feb 08, 2010 12:00 am

Re: incorrect financial functions behavior

Post by luzhetsky » Thu May 13, 2010 2:36 pm

Looks solution is to inherit Low, High and StD fucntions from Moving - in this case it calculates in expected manner.

Class Moving is inherited from class Function and overrides only DoCalculation() method - looks this is a root cause.

Do you see any problem with it?

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: incorrect financial functions behavior

Post by Narcís » Fri May 14, 2010 11:21 am

Hi luzhetsky,
you should notice that in both type of PeriodStyle StD, High, Low functions calculate with the same manner: on each N points only.
Try using this code:

Code: Select all

      tChart1.Aspect.View3D = false;
      FastLine line = new FastLine(tChart1.Chart);
      line.FillSampleValues(30);

      FastLine func = new FastLine(tChart1.Chart);
      High high = new High();
      high.Period = 10;
      high.PeriodAlign = PeriodAligns.Last;
      func.Function = high;
      func.DataSource = line;
Now put a break point in the Calculate method of the Steema.TeeChart.Functions.High function in Basic.cs. You'll see sources series' first ten points are used in the calculation, as firstIndex = 0 and lastIndex = 9, and the result is plotted and so forth: firstIndex = 10 and lastIndex = 19 and finally firstIndex = 20 and lastIndex = 29.
Any Techical Analisis tool need caclulation for EACH point: each point data is based on calculation of previous N.
In the code above, we define N as 10 (Period = 10). TeeChart calculates the highest value for the points of index 0 to 9 and plots it. It then calculates the highest value for the points of index 10 to 19 and plots it and so on. So, as stated, the present High function is already doing the calculation on each point. Every single point in the source series is involved in the calculation. Therefore the High function plots a point based on the calculation of the previous N points.

Also notice the same applies to StdDeviation function.

If that's not what you meant, could you please elaborate on that?
Looks solution is to inherit Low, High and StD fucntions from Moving - in this case it calculates in expected manner.

Class Moving is inherited from class Function and overrides only DoCalculation() method - looks this is a root cause.

Do you see any problem with it?
As long it fits your needs it’s fine for us. Alternatively you can create your own functions deriving from existing ones and overriding relevant calculation methods.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

luzhetsky
Newbie
Newbie
Posts: 16
Joined: Mon Feb 08, 2010 12:00 am

Re: incorrect financial functions behavior

Post by luzhetsky » Fri May 14, 2010 11:58 am

Narcís wrote:TeeChart calculates the highest value for the points of index 0 to 9 and plots it. It then calculates the highest value for the points of index 10 to 19 and plots it and so on. So, as stated, the present High function is already doing the calculation on each point. Every single point in the source series is involved in the calculation. Therefore the High function plots a point based on the calculation of the previous N points.
as I wrote before, 1st point shall be calculated like you say, but 2nd should be calculated based on 1-10, 3rd od 2-11, 4th on 3-12 etc... - it is common practice for Technical Analisys in stock applications - looks strange your implementation (and not clear how and why it may be used in reality).

anyway, now we have a solution.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: incorrect financial functions behavior

Post by Narcís » Fri May 14, 2010 2:12 pm

Hi luzhetsky,

I'm glad to hear you found a satisfactory solution.
as I wrote before, 1st point shall be calculated like you say, but 2nd should be calculated based on 1-10, 3rd od 2-11, 4th on 3-12 etc... - it is common practice for Technical Analisys in stock applications - looks strange your implementation (and not clear how and why it may be used in reality).
Standard deviation, high and low functions are standard statistical functions, not financial functions. With this I don't mean they can't be used for financial purposes. Anyhow, I'm pretty sure they are useful to many users as they are now. Also, as you may have noticed, several financial functions in TeeChart derive from Moving function and thus they work the way you requested, for example: Momentum, MomentumDivision, ExpAverage, MovingAverage, MACDFunction, Performance, RSIFunction, Stochastic, etc.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply