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

Message ListMessage List     Post MessagePost Message

  getXCoor from date ?
Posted by Aben on Jul-05-2023 21:53
Hi Peter,

On the FinanceChart, how do I find the getXCoor value when I have the xAxis date label yyyy-MM-dd?

Regards,
Aben

  Re: getXCoor from date ?
Posted by Aben on Jul-05-2023 22:04
Aben wrote:

Hi Peter,

On the FinanceChart, how do I find the getXCoor value when I have the xAxis date label yyyy-MM-dd?

Regards,
Aben

EX:
Dim Period As String ="2020-05-10"
Dim d = Date.ParseExact(Period, "yyyy-MM-dd", Globalization.CultureInfo.InvariantCulture)
               Dim x As Integer = CType(m.getChart(0), XYChart).getXCoor(Chart.CTime(DateSerial(d.Year, d.Month, d.Day)))
'  x return -2147483648
Help me.

  Re: getXCoor from date ?
Posted by Peter Kwan on Jul-05-2023 23:46
Hi Aben,

For a FinanceChart, the date/time are somewhat random, discontinuous, and unpredictable (that is, there can be many unpredictable missing date/times), so the date/time cannot be used as x-coordinates. They are just names for human reading. The actual x-coordinates are the trading session number starting from 0, 1, 2, 3, ..... So the first candlestick (or OHLC bar) is at x = 0, the second candlestick is at x = 1 and so on.

If given a date/time label "2020-05-10", first, determine the index of that date/time in the timestamps array passed to the FinanceChart. In VB.NET, you can use the Array.IndexOf method. Then subtract "extraPoints" from it. The "extraPoints" refer to the extraPoints parameter you use in FinanceChart.setData. They are leading array positions that are just for calculating technical indicators and not plotted. See:

https://www.advsofteng.com/doc/cdnetdoc/FinanceChart.setData.htm

For example, if the array index in the timestamps array is 50, and the extraPoints you use is 30, then the trading session must be at 20.

Please note that getXCoor/getYCoor can only be used after the chart is plotted or after chart layout has been completed. It is useful for adding a vertical line in the dynamic layer (see the programmable track cursor sample code). If your intention is to add a vertical line at the x position during chart construction, you may consider to use Axis.addMark instead.

Best Regards
Peter Kwan

  Re: getXCoor from date ?
Posted by Aben on Jul-06-2023 06:20
I understand. Thank you very much..

Best Regards
Aben