incorrect financial functions behavior
incorrect financial functions behavior
Hi,
we have problem with financial functions on 4th version (4.0.2009.42283) of TeeChart lib (on 2nd version (2.0.2469.25745) it is working ok): function line is drawing incorrect - it ends not on last data point, but with some left shift, and looks like visible points calculation is wrong too - see attached screens for both versions of lib.
How it may be resolved?
code is:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void simpleButton1_Click_1(object sender, EventArgs e)
{
Candle candle = new Candle();
candle.FillSampleValues();
tChart1.Series.Add(candle);
Momentum func = new Momentum();
func.Period = 7;
FastLine line = new FastLine();
line.DataSource = candle;
line.Function = func;
tChart1.Series.Add(line);
}
}
we have problem with financial functions on 4th version (4.0.2009.42283) of TeeChart lib (on 2nd version (2.0.2469.25745) it is working ok): function line is drawing incorrect - it ends not on last data point, but with some left shift, and looks like visible points calculation is wrong too - see attached screens for both versions of lib.
How it may be resolved?
code is:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void simpleButton1_Click_1(object sender, EventArgs e)
{
Candle candle = new Candle();
candle.FillSampleValues();
tChart1.Series.Add(candle);
Momentum func = new Momentum();
func.Period = 7;
FastLine line = new FastLine();
line.DataSource = candle;
line.Function = func;
tChart1.Series.Add(line);
}
}
- Attachments
-
- 4th version is wrong
- v4.0.2009.42283.jpg (69.73 KiB) Viewed 7930 times
-
- 2nd version is Ok
- v2.0.2469.25745.jpg (82.56 KiB) Viewed 7929 times
Last edited by luzhetsky on Thu May 06, 2010 11:50 am, edited 1 time in total.
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Re: incorrect financial functions behavior
Hi luzhetsky,
I think this is a bug which I have added to the defect list (TF02014860) to be fixed for future releases.
I think this is a bug which I have added to the defect list (TF02014860) to be fixed for future releases.
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Re: incorrect financial functions behavior
'to be fixed for future releases' - it is good, but we have a huge problem with large commercial product with hundreds of customers and we need hot fix for it urgently!
Now we can't back to 2nd version of the library.
I've wrote e-mail to the info@steema.com (no other official e-mails are availble (info@steema.com and sales@steema.com only)) - could you give me any other contact who can make decision to resolve it as much quick as possible and deliver it for us?
Thanks.
Now we can't back to 2nd version of the library.
I've wrote e-mail to the info@steema.com (no other official e-mails are availble (info@steema.com and sales@steema.com only)) - could you give me any other contact who can make decision to resolve it as much quick as possible and deliver it for us?
Thanks.
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Re: incorrect financial functions behavior
Hi luzhetsky,
In v4 it changed to this:
For a quick fix and since you are source code customer, you can implement DoCalculation as in v2. I checked it behaves as in v2 as you requested. I can not incorporate this in the build without thorough investigation and knowing the reasons for this change as otherwise it might break other functionality.
The main difference I see in v2 and v4 is at Steema.TeeChart.Functions.Moving.DoCalculation in Basic.cs. In v2 it's like this:'to be fixed for future releases' - it is good, but we have a huge problem with large commercial product with hundreds of customers and we need hot fix for it urgently!
Now we can't back to 2nd version of the library.
Code: Select all
protected override void DoCalculation(Styles.Series source, Styles.ValueList notMandatorySource)
{
int P=Utils.Round(dPeriod);
for (int t=P-1; t<source.Count; t++)
AddFunctionXY( source.yMandatory, notMandatorySource[t], Calculate(source,t-P+1,t));
}
Code: Select all
protected override void DoCalculation(Styles.Series source, Styles.ValueList notMandatorySource)
{
int P = 1;
if (PeriodStyle == PeriodStyles.NumPoints)
{
P = Utils.Round(dPeriod);
}
else if (PeriodStyle == PeriodStyles.Range)
{
P = source.XValues.IndexOf(source.XValues.Minimum + dPeriod);
if (P < 1) P = 1;
}
for (int t = P - 1; t < source.Count; t += P)
{
AddFunctionXY(source.yMandatory, notMandatorySource[t], Calculate(source, t - P + 1, t));
}
}
We are doing our best to provide technical support on this forum board in a timely and efficient fashion. If you are interested in direct e-mail technical support you may be interested in our Pro-Support service.I've wrote e-mail to the info@steema.com (no other official e-mails are availble (info@steema.com and sales@steema.com only)) - could you give me any other contact who can make decision to resolve it as much quick as possible and deliver it for us?
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Re: incorrect financial functions behavior
Hi luzhetsky,
Or even much easier changing the increment in the for loop from t += P to t++:
Or even much easier changing the increment in the for loop from t += P to t++:
Code: Select all
protected override void DoCalculation(Styles.Series source, Styles.ValueList notMandatorySource)
{
int P = 1;
if (PeriodStyle == PeriodStyles.NumPoints)
{
P = Utils.Round(dPeriod);
}
else if (PeriodStyle == PeriodStyles.Range)
{
P = source.XValues.IndexOf(source.XValues.Minimum + dPeriod);
if (P < 1) P = 1;
}
for (int t = P - 1; t < source.Count; t++)
{
AddFunctionXY(source.yMandatory, notMandatorySource[t], Calculate(source, t - P + 1, t));
}
}
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Re: incorrect financial functions behavior
Ok, thank you - we will try to change it...Narcís wrote:Hi luzhetsky,
Or even much easier changing the increment in the for loop from t += P to t++:
looks loop with t++ should be under if (PeriodStyle == PeriodStyles.NumPoints) and t+P under if (PeriodStyle == PeriodStyles.Range)
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Re: incorrect financial functions behavior
Hello,
Yes, probably something like this:
I'll make this change for next release too.
Yes, probably something like this:
Code: Select all
int tmpInc = (PeriodStyle == PeriodStyles.NumPoints) ? 1 : P;
for (int t = P - 1; t < source.Count; t += tmpInc)
{
AddFunctionXY(source.yMandatory, notMandatorySource[t], Calculate(source, t - P + 1, t));
}
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Re: incorrect financial functions behavior
Hi Narcís!
Looks we have the same problem (set of last points are not calculated and other points calculation looks like with incorrect step) with Standard Deviation Function - I've looked at code, but can't understand what need to be changed - it is not inherited from moving.
Could you look at this, please, and post any code to fix?
Thanks.
Looks we have the same problem (set of last points are not calculated and other points calculation looks like with incorrect step) with Standard Deviation Function - I've looked at code, but can't understand what need to be changed - it is not inherited from moving.
Could you look at this, please, and post any code to fix?
Thanks.
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Re: incorrect financial functions behavior
Hi luzhetsky,
StdDeviation inherits from TeeChart functions base class (hence called Function) and has own calculation methods (Calculate, CalculateDeviation and CalculateMany). You may want to look into those methods. You may also notice that StdDeviation.cs code has suffered very little changes between v2 and v4, any of them relevant to its functionality.
Confirming that, code below does the same in v2 and v4. Can you please modify it so that we can reproduce the issue here?
Thanks in advance.
StdDeviation inherits from TeeChart functions base class (hence called Function) and has own calculation methods (Calculate, CalculateDeviation and CalculateMany). You may want to look into those methods. You may also notice that StdDeviation.cs code has suffered very little changes between v2 and v4, any of them relevant to its functionality.
Confirming that, code below does the same in v2 and v4. Can you please modify it so that we can reproduce the issue here?
Code: Select all
Steema.TeeChart.Styles.Line line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
line1.FillSampleValues();
Steema.TeeChart.Functions.StdDeviation func = new Steema.TeeChart.Functions.StdDeviation();
func.Period = 7;
Steema.TeeChart.Styles.FastLine fastLine1 = new Steema.TeeChart.Styles.FastLine(tChart1.Chart);
fastLine1.DataSource = line1;
fastLine1.Function = func;
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Re: incorrect financial functions behavior
Hi Narcís!
Here is a code and result pic:
Here is a code and result pic:
Code: Select all
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Candle candle = new Candle();
candle.FillSampleValues();
tChart1.Series.Add(candle);
StdDeviation func = new StdDeviation();
func.Period = 7;
FastLine line = new FastLine();
line.DataSource = candle;
line.Function = func;
tChart1.Series.Add(line);
}
}
- Attachments
-
- Std.jpg (86.19 KiB) Viewed 7838 times
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Re: incorrect financial functions behavior
Hi luzhetsky,
Thanks for the info. I have checked this code does exactly the same both in v2 and v2010. Which is the exact problem you are having here?
Thanks in advance.
Thanks for the info. I have checked this code does exactly the same both in v2 and v2010. Which is the exact problem you are having here?
Thanks in advance.
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Re: incorrect financial functions behavior
As I understand the behavior of Standard Deviation, it shall start drawing from 7th point ( where 7 - is period of StD) and stop on last, but now it starts on 4th point and stops far from last.
And BTW, StD uses in calculation MovingAverage function, but I did not found it in TeeChart's implementation.
And BTW, StD uses in calculation MovingAverage function, but I did not found it in TeeChart's implementation.
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Re: incorrect financial functions behavior
Hi luzhetsky,
Hope this helps!
If you want the function to behave like that you need to use PeriodAlign property set to Last. Also, it will plot until the last point in the series only if series has a number of points multiple of function's Period, for example:As I understand the behavior of Standard Deviation, it shall start drawing from 7th point ( where 7 - is period of StD) and stop on last, but now it starts on 4th point and stops far from last.
Code: Select all
Steema.TeeChart.Styles.Candle candle = new Steema.TeeChart.Styles.Candle(tChart1.Chart);
Steema.TeeChart.Functions.StdDeviation func = new Steema.TeeChart.Functions.StdDeviation();
func.Period = 7;
func.PeriodAlign = Steema.TeeChart.Functions.PeriodAligns.Last;
candle.FillSampleValues((int)(func.Period * 5));
Steema.TeeChart.Styles.FastLine line = new Steema.TeeChart.Styles.FastLine(tChart1.Chart);
line.DataSource = candle;
line.Function = func;
I'm not sure about which is your exact question here. StdDeviation is implemented at StdDeviation.cs. In Visual Studio, if you are referencing TeeChart source code project from your projects you just need to press F12 on an object so that the IDE takes you to its declaration.And BTW, StD uses in calculation MovingAverage function, but I did not found it in TeeChart's implementation.
Hope this helps!
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Re: incorrect financial functions behavior
Hi Narcís!
It's not working!
look at the code - I'm using 1000 values:
and here is result on screens (pic1):
and you can see on zoomed graph last value of Line is not on last value of Candle (pic2):
AND! please look that StD function should be smooth, and EACH point of it (starting from N) should be calculated based on data of previous N (N is period), but on graph I see that StD calculated only for each N points - it's incorrect!
And, THE SAME! with function High and Low (see pic. 3): line is not smooth and function is calculated only for each 7 pointh, but NOT FOR ALL POINTS, started from 7th!
It's not working!
look at the code - I'm using 1000 values:
Code: Select all
Steema.TeeChart.Styles.Candle candle = new Steema.TeeChart.Styles.Candle(tChart1.Chart);
Steema.TeeChart.Functions.StdDeviation func = new Steema.TeeChart.Functions.StdDeviation();
func.Period = 7;
func.PeriodAlign = Steema.TeeChart.Functions.PeriodAligns.Last;
candle.FillSampleValues((int)(1000)); //1000 values
Steema.TeeChart.Styles.FastLine line = new Steema.TeeChart.Styles.FastLine(tChart1.Chart);
line.DataSource = candle;
line.Function = func;
and you can see on zoomed graph last value of Line is not on last value of Candle (pic2):
AND! please look that StD function should be smooth, and EACH point of it (starting from N) should be calculated based on data of previous N (N is period), but on graph I see that StD calculated only for each N points - it's incorrect!
And, THE SAME! with function High and Low (see pic. 3): line is not smooth and function is calculated only for each 7 pointh, but NOT FOR ALL POINTS, started from 7th!
- Attachments
-
- pic3: High function with period 7
- Hith.jpg (88.22 KiB) Viewed 7802 times
-
- pic2: zoomed
- Std_1000Values_zoomed.jpg (113.36 KiB) Viewed 7800 times
-
- pic 1: 1000 values and StD - full
- Std_1000Values_full.jpg (109.91 KiB) Viewed 7799 times
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Re: incorrect financial functions behavior
Hi luzhetsky,
For more information please read Steema.TeeChart.Functions.Function.PeriodStyle's entry in TeeChart's help file.
1000 is not multiple of 7, according to what I told you before, it works fine with 994 or 1006 pointsand you can see on zoomed graph last value of Line is not on last value of Candle (pic2):
This depends on PeriodStyle property. Setting it to PeriodStyles.Range does the job:AND! please look that StD function should be smooth, and EACH point of it (starting from N) should be calculated based on data of previous N (N is period), but on graph I see that StD calculated only for each N points - it's incorrect!
And, THE SAME! with function High and Low (see pic. 3): line is not smooth and function is calculated only for each 7 pointh, but NOT FOR ALL POINTS, started from 7th!
Code: Select all
func.PeriodStyle = Steema.TeeChart.Functions.PeriodStyles.Range;
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |