ChartDirector Support Forum Home   Search
Posted by moon on Oct-13-2020 16:37
Hi!
My name is youngjoo moon.
I have one question.
When using the finanncechart as follows.

FinanceChart* c = new FinanceChart(600);//1250
c->setData(new_timeStamps, new_highData, new_lowData, new_openData, new_closeData, new_volData, extraPoints);// extralines);

....

when +zoomiing,  the chart doesn't show the avering line.
I think that the chart uses the data in the chart display window.

ScatterLayer doesn,t be affected.

So is there some method like using scatter layer?

vline can be usefull?

if usefull, how can I implement the avering data calculated by my app program....

Thanks a lot.

Posted by Peter Kwan on Oct-14-2020 01:28
Hi moon,

There is a financechart mfc example with zooming and scrolling below:

In the above example, the moving average lines display normally after zoom in.

The most important thing is to have sufficient data to compute the moving average. In your code, you are using 1920 session moving average. That means you need at least 1920 extra points. For example, if you want to display 200 session, you need to obtain data for at least 1920 + 200 = 2120 session so that we can compute the 1920 session moving average.

In the above sample code, the extraPoints are set to the maximum moving average (there are 2 moving averages in the above code):

int extraPoints = (m_avgPeriod1 > m_avgPeriod2) ? m_avgPeriod1 : m_avgPeriod2;

It then adjusts the startIndex backwards to include more data for the extraPoints.

// Add the extra points (adjust the extra points if there are insufficient data)
extraPoints = (std::min)(extraPoints, startIndex);
startIndex -= extraPoints;

For your case, please make sure the extraPoints are set to at least 1920, and the startIndex moves back by at least 1920 to obtain enough data points for the moving average.

Regards
Peter Kwan