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

Message ListMessage List     Post MessagePost Message

  Finacial chart with dateScale skip Sat & Sun
Posted by Roman Gavrilov on Dec-20-2009 19:43
Hello,
I'm trying to draw a financial line chart.
I'm using dateScale function so that ChartDirector would scale the graph.

The issue I'm experiencing is that I'm getting a straight line between Thursday and Monday as there is no data for this dates, but dateScale function does takes those dates into account.

I was wandering is there a way to Scale dates but also tell it to ignore weekends?
for example I want to scale Dates for past months but skip weekends.

Thank you,
Roman

  Re: Finacial chart with dateScale skip Sat & Sun
Posted by Peter Kwan on Dec-22-2009 03:00
Hi Roman,

A standard financial chart should not use date/time scale for the x-axis. The x-axis should be trading sessions. For daily chart, it means the x-axis should contain trading days only. In many parts of the world, it excludes weekends, public holidays, and other unpredictable days. (In some parts of the world, a stock exchange can stop trading due to unpredictable conditions such as hurricane.)

As the days on the x-axis are unpredictable and arbitrary, it should not be configured using a date/time scale. (In ChartDirector, date/time means clock and calendar date/time - with 24 hours per day, 7 days per week, etc.) Instead, a label based x-axis should be used.

For example, in VB/VBScript, the code may be like:

Call a.setLabels2(anArrayOfDates)

'Show one label per 10 trading days.
'Show mmm-dd for the first label of the month, and show dd for the other days
Call a.setMultiFormat(cd.StartOfMonthFilter(), "{value|mmm-ddd}", cd.StartOfDayFilter(1, 0.5), "{value|dd}", 10)

You may also consider to use the FinanceChart object, which contains code to configure the x-axis from intraday charts to charts that span years. For example:

' Create a FinanceChart object of width 640 pixels
Set c = cd.FinanceChart(640)

' Set the data into the finance chart object. If you do not have OHLC data and vol data,
' you can use the same arrays for highData, lowData, openData and closeData and use
' an array of zeros for volData
Call c.setData(timeStamps, highData, lowData, openData, closeData, volData, _
    extraDays)

' Add the main chart with 240 pixels in height
Set xyChart = c.addMainChart(240)

'just use it like an oridinary XYChart
Call xyChart.addLineLayer(..........)

...........................

Hope this can help.

Regards
Peter Kwan




You may also copy the x-axis configuration code from the FinanceChart source code (included in the download) to your own code.

Hope this can help.

Regards
Peter Kwan