Variance and Correlation

TeeChart for Java (NetBeans, Eclipse, Android Studio, etc)
Post Reply
cdn
Newbie
Newbie
Posts: 29
Joined: Wed Sep 19, 2007 12:00 am

Variance and Correlation

Post by cdn » Mon Nov 05, 2007 7:03 am

Hi:

We are trying to display Variance and Correlation as indicators in our charts. Unfortunately, we are not able to display anything. THere are no error messages associated with the data or anything. Nothing gets displayed. So, I was wondering whether we are not doing something properly.

For instance we tried for both Candle and Volume datapoints to display. But, nothing happens. So, could you guys shed some light. Here is the code snippets.

Code: Select all

    	tmpAxis = tChart2.getAxes().getCustom().getNew();
    	tmpAxis.getAxisPen().setColor(com.steema.teechart.drawing.Color.GREEN_YELLOW);
        tmpAxis.setHorizontal(false);
        tmpAxis.setOtherSide(true);
        tmpAxis.getLabels().setColor(Color.black);
        tmpAxis.setStartPosition(start1);               
        tmpAxis.setEndPosition(end1); 
        tmpAxis.getTitle().setVisible(true);
        tmpAxis.getTitle().setAngle(90);

	   varFunction = new Variance();
	   varFunction.setChart(tChart2.getChart());
	   varFunction.setPeriod(0);

//	   System.out.println("CCI - " + dsCandle.getCount());
   	   functionSeries = new com.steema.teechart.styles.FastLine(tChart2.getChart());
   	   functionSeries.setFunction(varFunction);
   	   functionSeries.setDataSource(dsCandle);
   	   functionSeries.checkDataSource();
   	   functionSeries.setTitle("Variance" + "(" + functionSeries.getMarkValue(functionSeries.getCount()-1)+")");
   	   functionSeries.getLinePen().setColor(Color.BLUE);
       functionSeries.getLinePen().setWidth(1);	   
   	   functionSeries.getMarks().setVisible(false);  
       functionSeries.getDrawAllPoints();
       functionSeries.setColor(com.steema.teechart.drawing.Color.BLUE);
       functionSeries.setCustomVertAxis(tmpAxis);
       functionSeries.getXValues().setDateTime(true);
Any information is appreciated. Thanks.

best regards,

Marc
Site Admin
Site Admin
Posts: 1273
Joined: Thu Oct 16, 2003 4:00 am
Location: Girona
Contact:

Post by Marc » Mon Nov 05, 2007 4:48 pm

Hello,

With period 0 there is only one point in the Variance data. Set the period to a required value to see more points.

eg.
varFunction.setPeriod(10);

Regards,
Marc Meumann
Steema Support

cdn
Newbie
Newbie
Posts: 29
Joined: Wed Sep 19, 2007 12:00 am

Post by cdn » Tue Nov 06, 2007 5:13 am

Thanks, Marc for the information about Variance. We can't get Correlation to work. Here is the code snippet.

Code: Select all

    	tmpAxis = tChart2.getAxes().getCustom().getNew();
    	tmpAxis.getAxisPen().setColor(com.steema.teechart.drawing.Color.GREEN_YELLOW);
        tmpAxis.setHorizontal(false);
        tmpAxis.setOtherSide(true);
        tmpAxis.getLabels().setColor(Color.black);
        tmpAxis.setStartPosition(start1);               
        tmpAxis.setEndPosition(end1); 
        tmpAxis.getTitle().setVisible(true);
        tmpAxis.getTitle().setAngle(90);

        corrFunction = new Correlation();
        corrFunction.setChart(tChart2.getChart());
        corrFunction.setPeriod(10);

   	   functionSeries = new com.steema.teechart.styles.FastLine(tChart2.getChart());
   	   functionSeries.setFunction(corrFunction);
   	   functionSeries.setDataSource(dsCandle);
   	   functionSeries.checkDataSource();
   	   double rndValue = Math.rint(functionSeries.getMarkValue(functionSeries.getCount()-1) * 100.0d) / 100.0d;
   	   functionSeries.setTitle("Correlation" + "(" + rndValue+")");
   	   functionSeries.getLinePen().setColor(Color.BLUE);
       functionSeries.getLinePen().setWidth(1);	   
   	   functionSeries.getMarks().setVisible(false);  
       functionSeries.getDrawAllPoints();
       functionSeries.setColor(com.steema.teechart.drawing.Color.BLUE);
       functionSeries.setCustomVertAxis(tmpAxis);
       functionSeries.getXValues().setDateTime(true);
       
Any help is appreciated. Thanks.

best regards,

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

Post by Narcís » Tue Nov 06, 2007 9:42 am

Hi cdn,

Setting Correlation function's Period to 1 works fine here:

Code: Select all

                corrFunction.setPeriod(1);
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

cdn
Newbie
Newbie
Posts: 29
Joined: Wed Sep 19, 2007 12:00 am

Post by cdn » Wed Nov 07, 2007 10:49 am

Hi:

Have you tried with any real datapoints? For example we have uploaded one dataset earlier.

Anyways, we tried all the way from 0 to 12. Something happens and it is not the right one. Our data points are between 1/1/07 to current date. Once we plot the correlation the whole chart gets crunched to last two data points on X-axis as it shows from 1/1/70 to current day rather than the datapoints in case. I can upload the image if you would like.

Any information is appreciated. Thank.

best regards,

Marc
Site Admin
Site Admin
Posts: 1273
Joined: Thu Oct 16, 2003 4:00 am
Location: Girona
Contact:

Post by Marc » Wed Nov 07, 2007 4:29 pm

Hello,

This has been tried with a dataset we previously received from you. It appears that the plot is correct. We'll be building a new update within the next couple of days, please check with that when available in case there are any influencing differences between the version you are using now and the update.

Regards,
Marc Meumann
Steema Support

Post Reply