Page 1 of 1

Variance and Correlation

Posted: Mon Nov 05, 2007 7:03 am
by 7665742
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,

Posted: Mon Nov 05, 2007 4:48 pm
by Marc
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

Posted: Tue Nov 06, 2007 5:13 am
by 7665742
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,

Posted: Tue Nov 06, 2007 9:42 am
by narcis
Hi cdn,

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

Code: Select all

                corrFunction.setPeriod(1);

Posted: Wed Nov 07, 2007 10:49 am
by 7665742
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,

Posted: Wed Nov 07, 2007 4:29 pm
by Marc
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