Issue with CCI Function?

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
dave
Newbie
Newbie
Posts: 40
Joined: Tue Dec 07, 2010 12:00 am

Issue with CCI Function?

Post by dave » Thu Dec 23, 2010 8:46 pm

I have a basic chart going with an OHLC candle series and volume. If I add a pane with a CCI study in it I always get some odd lines at the end of the CCI chart. Following is a good example. You can see 4 CCI studies. They are all created identically with the period set to 20, the datasource set to Candel1, and the datamember set to "Close". The difference between the charts is when they were created. Each chart was added to the overall chart a few minutes after the previous one. Notice the big drop that occurs in each chart. As time goes by that drop changes in its position.

[img]
CCI.gif
CCI image
CCI.gif (31.62 KiB) Viewed 6724 times
[/img]

The code that was used to create it is:

Dim NewAxis As Steema.TeeChart.Axis = New Steema.TeeChart.Axis(TChart1.Chart)
NewAxis.OtherSide = True
NewAxis.AxisPen.Color = Color.Green
NewAxis.StartPosition = 80 '+ 2
NewAxis.EndPosition = 100
NewAxis.Automatic = True
NewAxis.Visible = True
Dim CCITag As String = "CCI-" & GetRandomID()
NewAxis.Tag = CCITag
Me.TChart1.Axes.Custom.Add(NewAxis)

Dim line1 As New Steema.TeeChart.Styles.Line(TChart1.Chart)
Dim CCI1 As New Steema.TeeChart.Functions.CCIFunction

line1.Function = CCI1
CCI1.Tag = CCITag
Dim eCnt As Integer = 0
line1.DataSource = CandleSeries1
Dim cst As Double = CCI1.Constant
line1.YValues.DataMember = DT.Rows(0).Item("Column")
line1.Function.Period = DT.Rows(0).Item("Period")
line1.Function.PeriodAlign = Functions.PeriodAligns.Last
line1.Function.PeriodStyle = Functions.PeriodStyles.NumPoints
Dim c As Color = DT.Rows(0).Item("Color")
line1.Color = c
line1.CustomVertAxis = NewAxis
Dim DashStyle As String = DT.Rows(0).Item("Style")
Call SetLineStyle(line1, DashStyle)
Dim pWidth As Integer = DT.Rows(0).Item("Width")
line1.LinePen.Width = pWidth
line1.TreatNulls = Steema.TeeChart.Styles.TreatNullsStyle.DoNotPaint
AddHandler line1.MouseEnter, AddressOf ChartSeries_MouseEnter
AddHandler line1.MouseLeave, AddressOf ChartSeries_MouseLeave
line1.CheckDataSource()
line1.Tag = CCITag
TChart1.Invalidate()

Can you confirm that the CCI function is drawing properly? Or, if there is something incorrect about the way I create it, please let me know.

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Issue with CCI Function?

Post by Sandra » Fri Dec 24, 2010 1:02 pm

Hello Dave,

I have made a simple project and it seems work correctly here that I am not sure if it works fine for your values. So,You can send us a simple project because we can check with your values CCI function works properly?

Thanks,
Best Regards,
Sandra Pazos / 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

dave
Newbie
Newbie
Posts: 40
Joined: Tue Dec 07, 2010 12:00 am

Re: Issue with CCI Function?

Post by dave » Mon Dec 27, 2010 8:48 pm

I thought the issue was resolved, but it is not. I am not sure if it has to do with the number of data points or what. I have attached a spread sheet showing the data loaded into the chart (image below). The chart has 4 panes with 20-period CCI charts in them. A single block of code created each chart. The only difference is that they were each added to the chart a few minutes apart.

The attached zip file contains a spreadsheet with the original data from the chart you see below, and it contains a VB.Net form for a window with a TEEChart control on it and two buttons. One button will load data from a text file (which is inside the zip file) and will display a bar chart and CCI chart. You will see the spike in the last 20 bars of the chart if you run that code.

You can see in the spreadsheet for the data from the original image, that the data for each is identical up to the point where the most recent data is about 40 bars from the end of the chart. If you create one CCI chart, wait a few minutes and then create another CCI chart with the same settings, you see the strange data move a bit further down. It is always 40 bars from the end of the data.

I beleive that 40 number has something to do with the 20 period setting. In the most recent (bottom) CCI study added, at the end of the stream of data you see 20 blank datapoints, preceded by one bar (which one new data coming in before I could export the chart data), and that preceded by 20 bars of, basically, bad CCI calculations. Notice that the bad CCI points are always the last 20 in the chart at the time that they are added.
Chart.gif
image for chart
Chart.gif (37.15 KiB) Viewed 6636 times
Attachments
Form1.zip
Code File and spreadsheet
(39.1 KiB) Downloaded 306 times

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Issue with CCI Function?

Post by Sandra » Tue Dec 28, 2010 1:10 pm

Hello Dave,

I check your project using last version of TeeChart.Net and I have gotten next result that seems correct:
ChartCCI1.jpg
ChartCCI1.jpg (119.68 KiB) Viewed 6598 times
Could you check your code in last version of TeeChart.Net? If you are using last version, please attach a simple example project we can run "as-is" to reproduce the issue here.

Thanks,
Best Regards,
Sandra Pazos / 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

dave
Newbie
Newbie
Posts: 40
Joined: Tue Dec 07, 2010 12:00 am

Re: Issue with CCI Function?

Post by dave » Tue Dec 28, 2010 3:43 pm

I have attached a new code project here. It uses the latest 2010 TeeChart version, and was created by VS2010. The file also includes actual data from yesterday for the March 2011 ES contract in a file called ChartData.txt. When you load data, please use that data so we can see the same things. I suspect that if you use less data the problem may not be apparent. The zip file also contains the .GIF images that are attached to this message.

I think I can demonstrate exactly what I am referring to here with the CCI function. The sample project now lets you tell it how many bars to load. If I select 800 bars, I see the following results:
Chart1.gif
First Chart
Chart1.gif (22.75 KiB) Viewed 6589 times
Notice that the CCI spikes at apporoximately 13:02 on this chart.

Now we recreate the chart, loading more data from the same file. The data in this next chart is identical to the data in the first chart, except that there are about 50 more bars on the end.
Chart2.gif
Chart 2
Chart2.gif (22.09 KiB) Viewed 6581 times
The CCI study no longer has a spike as 13:13. It is calculating the CCI properly at that point in time. The spike now appears at 13:52. The spike has shifted over the same number of bars that were added to the chart. If I load 730 bars from this file, the CCI looks like it could be correct. If I load 750 bars, or more, I see the spike. (Perhaps there is a critical point somewhere there.)

Here is another quirk. If I load 600 bars of data, the TeeChart control throws an error "Index was outside the bounds of the array" on the line of code where I set Line1.YValues.DataMember = "Close". If I coment that out, 600 bars loads fine. If I attempt to load 750 bars with that commented out, I get the same error at the "PeriodAlign =" line. If I uncomment the line, it loads 750 bars fine. I would not be surprised if the issue here has to do with the amount of data loaded.

Dim cst As Double = CCI1.Constant
line1.YValues.DataMember = "Close"
line1.Function.Period = 20
line1.Function.PeriodAlign = Functions.PeriodAligns.Last
line1.Function.PeriodStyle = Functions.PeriodStyles.NumPoints


Any thoughts?

Thanks!
Attachments
Form1.zip
ProgramFiles
(56.06 KiB) Downloaded 306 times

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Issue with CCI Function?

Post by Sandra » Wed Dec 29, 2010 3:21 pm

Hello Dave,
We have reproduced your problem using next simple code:

Code: Select all

 private void InitializeChart()
        {
            tChart1.Series.Clear();
            tChart1.Aspect.View3D = false;
            tChart1.Dock = DockStyle.Fill;
            tChart1.Page.MaxPointsPerPage = 150;
            Steema.TeeChart.Styles.Candle CandleSeries1 = new Steema.TeeChart.Styles.Candle(tChart1.Chart);
            //CandleSeries
            CandleSeries1.TreatNulls = Steema.TeeChart.Styles.TreatNullsStyle.Ignore;
            CandleSeries1.FillSampleValues(800);
            //Function CCI
            Steema.TeeChart.Styles.Line line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
            Steema.TeeChart.Functions.CCIFunction CCI1 = new Steema.TeeChart.Functions.CCIFunction();
            line1.Function = CCI1;
            line1.DataSource = CandleSeries1;
            line1.Function.Period = 20;
            line1.Function.PeriodAlign = Steema.TeeChart.Functions.PeriodAligns.Last;
            line1.Function.PeriodStyle = Steema.TeeChart.Functions.PeriodStyles.NumPoints;
            line1.TreatNulls = Steema.TeeChart.Styles.TreatNullsStyle.DoNotPaint;
        }
And we have gotten next results:
ChartNet.jpg
ChartNet.jpg (148.52 KiB) Viewed 6539 times
I have made same test, using same code in TeeChartVCL and we have gotten next results:
ChartVCL.jpg
ChartVCL.jpg (97.3 KiB) Viewed 6542 times
Data that have generated this images, in both cases are:
VCLNetData.zip
(52.21 KiB) Downloaded 321 times
We think that in VCL code, function CCI works as expected. Could you confirm us, if you believe that function in VCL code is correct? So we can try to modify code of .Net CCI function for code VCL CCI function.

Thanks,
Best Regards,
Sandra Pazos / 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

dave
Newbie
Newbie
Posts: 40
Joined: Tue Dec 07, 2010 12:00 am

Re: Issue with CCI Function?

Post by dave » Wed Dec 29, 2010 6:44 pm

The data looks more like what I would expect. I do not, however, have a different calculator for the function so I am unable to confirm the accuracy of the numbers.

I am pleased that you were able to reproduce it and can get it worked out.

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Issue with CCI Function?

Post by Sandra » Thu Dec 30, 2010 10:15 am

Hello Dave,

Thank you for information. I have added this request in bug list report with number [TF02015336]. We will try to fix it for next maintenance releases TeeChart.Net.

Thanks,
Best Regards,
Sandra Pazos / 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