ASE Home Page Products Download Purchase Support About ASE
ChartDirector General
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  add Polynomial Regression as price chart overlay in FinanceChart
Posted by nyoman on Dec-21-2018 18:49
Hi Peter,
is there any tutorial on how to add polynomial regression as overlay in FinanceChart
thanks

  Re: add Polynomial Regression as price chart overlay in FinanceChart
Posted by Peter Kwan on Dec-23-2018 04:21
Hi nyoman,

A FinanceChart is a container for many charts - the main price chart, and zero or more indicator charts. You can add a polynomial regression line to any of these charts using code similar to the "Parametric Curve Fitting" sample code.

For example in C#, assumg "c" is a FinanceChart object, the code is like:

FinanceChart c = new FinanceChart(.....);
.....

// Add a main price chart to the FinanceChart
XYChart mainChart = c.addMainChart(....);

// Add a polynomial regression line of degree 2 for the closeData to the main price chart
TrendLayer trend0 = mainChart.addTrendLayer2(null, closeData, 0xff0000);
trend0.setLineWidth(3);
trend0.setRegressionType(Chart.PolynomialRegression(2));
trend0.setHTMLImageMap("{disable}");

.....

Hope this can help.

Regards
Peter Kwan

  Re: add Polynomial Regression as price chart overlay in FinanceChart
Posted by nyoman on Apr-22-2019 12:47
adding the following code in FinanceChart.php
but still not working.
Please advise how to make it works.

function addPrc($color) {
        $tmpArrayMath1 = new ArrayMath($this->m_closeData);
        $tmpArrayMath1->abs();
        $cl = $tmpArrayMath1->result();

        $trend0 = $this->m_mainChart->addTrendLayer2(null, $cl, $color);
        $trend0->setLineWidth(3);
        $trend0->setRegressionType(PolynomialRegression(4));
$trend0->setHTMLImageMap("{disable}");
        return $trend0;
}