On the FinanceChart, how do I find the getXCoor value when I have the xAxis date label yyyy-MM-dd?
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
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:
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.