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

Message ListMessage List     Post MessagePost Message

  How to add Horizontal Line and Vertical Line on FinanceChart
Posted by Jian Li on May-19-2025 09:57
Hello Peter

Thanks for your help with my installation of ChartDirector PHP version. Now I have another question. Is it possible to add Horizontal Line and Vertical Line on a FinanceChart? If yes, could you gave me a example how to do it.

Thanks!

JIan Li

  Re: How to add Horizontal Line and Vertical Line on FinanceChart
Posted by Peter Kwan on May-20-2025 04:31
Hi Jian,

You can use Mark.addLine to add vertical and horizontal lines by data values. The following is some XYChart examples:

https://www.advsofteng.com/doc/cdphp.htm#markzone.htm
https://www.advsofteng.com/doc/cdphp.htm#markzone2.htm

A FinanceChart contains one or more XYChart objects (the main price chart, and also may have separate indicator charts). Suppose you want to add a line based on the price in the main price chart. It is like:

$mainPriceChart = $myFinanceChart->addMainChart(240);
$mainPriceChart->yAxis->addMark(150, 0xff0000);

For the vertical line, you can add the mark on the x-axis. However, note that for a FinanceChart, the x-coordinate is the trading session number. For example, the first candlestick plotted on the chart is at x = 0, the second candlestick at x = 1 and so on. The following post has more details:

https://www.chartdir.com/forum/download_thread.php?bn=chartdir_support&pattern=FinanceChart+addMark&thread=1713952606#N1714034882

Best Regards
Peter Kwan

  Re: How to add Horizontal Line and Vertical Line on FinanceChart
Posted by Jian Li on May-30-2025 22:08
Thank Peter! Highly appreciate your help for every question I had!

The Best Regard!

Jian Li
Peter Kwan wrote:

Hi Jian,

You can use Mark.addLine to add vertical and horizontal lines by data values. The following is some XYChart examples:

https://www.advsofteng.com/doc/cdphp.htm#markzone.htm
https://www.advsofteng.com/doc/cdphp.htm#markzone2.htm

A FinanceChart contains one or more XYChart objects (the main price chart, and also may have separate indicator charts). Suppose you want to add a line based on the price in the main price chart. It is like:

$mainPriceChart = $myFinanceChart->addMainChart(240);
$mainPriceChart->yAxis->addMark(150, 0xff0000);

For the vertical line, you can add the mark on the x-axis. However, note that for a FinanceChart, the x-coordinate is the trading session number. For example, the first candlestick plotted on the chart is at x = 0, the second candlestick at x = 1 and so on. The following post has more details:

https://www.chartdir.com/forum/download_thread.php?bn=chartdir_support&pattern=FinanceChart+addMark&thread=1713952606#N1714034882

Best Regards
Peter Kwan

  Copy data from the Chart of Finance Chart Track Line
Posted by Jian Li on Sep-22-2025 20:47
Hi Peter

Highly appreciate you answered two of my questions. Now I have another question during using the chart.

In the Chart of Finance Chart Track Line, if moving mouse cursor, a lot of indicators changes, such as SMA(20), SMA(10), Bollinger. Is there any way I can copy and download the data of all indicators of all days displayed within the chart?

Thanks!

Jian

  Re: Copy data from the Chart of Finance Chart Track Line
Posted by Peter Kwan on Sep-23-2025 01:46
Hi Jian,

The ChartDirector documentation explains how to indicator values are obtained when the mouse cursor moves. You can certainly modify the code to get all indicator values.


https://www.advsofteng.com/doc/cdphp.htm#trackfinanceweb.htm

(A) Starting from the mouse coordinate, it obtains the x coordinate of the nearest trading session on the chart.

(B) The code then iterates all indicators to obtain their values at the x coordinate.

(C) The code generate a text string from the indicator values and display it on the chart.



(i) For your case, instead of using the mouse event handler, you can use a loop to generate the "mouse coordinates" pixel by pixel across the plot area. In this way, you can obtain the indicator values at all the trading sessions. (Note that multiple mouse positions can map to the same trading session. Your code have to check to avoid duplication.)

(ii) Instead of creating a text string for display, you can store the values in arrays. You can then write code to download them or do some other things with them.


Best Regards
Peter Kwan