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

Message ListMessage List     Post MessagePost Message

  ViewPortManager on Financial chart
Posted by Andrea on Mar-08-2013 16:23
Attachments:
Hello, I am trying to use your product for financial charts.
I created a candlestick chart with data from two or more days and timestamp set to 1
minute.
Using ViewPortManager to move the chart and zoom.
Let us assume that the market opens at 8:00 and closes at 22:00.
In the period between the 2 days (between 22:00 and 8:00) I have no data because the
market is closed,
but the 'getValueAtViewPort' method also returns a value. I search this value in my arrays
with bsearch as I have seen in the examples

double-m_pChartViewer viewPortStartDate => getValueAtViewPort ("x", m_pChartViewer->
getViewPortLeft ());
double-m_pChartViewer viewPortEndDate => getValueAtViewPort ("x", m_pChartViewer->
getViewPortLeft () + m_pChartViewer-> getViewPortWidth ());

int startIndex = (int) floor (Chart :: bsearch (DoubleArray (m_timeStamps, m_noOfPoints)
viewPortStartDate));
int endIndex = (int) ceil (Chart :: bsearch (DoubleArray (m_timeStamps, m_noOfPoints)
viewPortEndDate));
noOfPoints = int endIndex - startIndex + 1;

in this way, however, the noOfPoints decreases until it assumes a value of 2 .... and then
returns to grow,
and, when I 'shift' the chart with Chart::MouseUsageScroll, i obtain the "stretch" effect as
you can see in the pictures

Do you have any suggestions?

Sorry for my english and
Thanks in advance.
1.JPG
2.JPG
3.JPG
4.JPG
5.JPG

  Re: ViewPortManager on Financial chart
Posted by Peter Kwan on Mar-09-2013 03:10
Hi Andrea,

The issue is because your code assumes the x-axis scale is date/time. However, in a financial chart, the x-axis is trading session, not date/time.

For example, in your chart, the candlesticks can be equally spaced regardless they are 10 hours apart of 1 minute apart, which means the candlestick position are not determined by date/time. Instead, the candlesticks are next to each other because they are from consecutive trading sessions.

The following thread contains an example on how to perform zooming and scrolling on a financial chart.

http://www.chartdir.com/forum/download_thread.php?bn=chartdir_support&thread=1307963212#N1357670970

Hope this can help.

Regards
Peter Kwan

  Re: ViewPortManager on Financial chart
Posted by Andrea on Mar-10-2013 18:13
Thanks for the explanation Peter,

I understand the concept, but I still have a question:

in the example reported, the startindex and the number of points are obtained
in the following way:

int extraDays = Math.min (30, startIndex);
startIndex - = extraDays
noOfPoints = int endIndex - startIndex + 1;

"30" are the extrapoints I suppose and will also set the graph with the function
setData(....., 30). Correct?

Where did you get the value "30"?

Suppose you need to build a graph of five days with timestamp 1 minute and with valid data
from 8:00 to 22:00, how much is the extrapoint?

Thanks in advance

  Re: ViewPortManager on Financial chart
Posted by Andrea on Mar-11-2013 04:17
Sorry Peter,

I solved it. The extrapoints need for indicators.

Thanks anyway for your help.