|
Coloring different parts of line Indicator |
Posted by Jan K. Nielsen on Jan-22-2025 23:23 |
|
Hello
First thank for the help you have provided in other posts.
My goal is to show divergence at an line indicator.
Its a homemade indicator that calculates a RSI and that works.
I have also calculated the divergence.
I would like to get x and y-coordinates for different parts of line
so I can color the areas - for example draw a line between 2 points or color a
single pixel. Is there a method to get these ? and is there a method/calculation so I
can color a single pixel. I have tried LineLayer's xCoor but I am little confused
when it comes to what the number signify ?
Best regards, Jan |
Re: Coloring different parts of line Indicator |
Posted by Peter Kwan on Jan-22-2025 23:57 |
|
Hi Jan,
For a financial chart, the x position of the visible data points are 0, 1, 2, 3 .... For example, the x pixel coordinate of the 3rd visible point is layer.getXCoor(2). The x pixel coordinate for a position mid-way between the 3rd and 4th data points is layer.getXCoor(2.5).
The x position of the a visible data point is usually equal to the array index of the data point minus the extraPoints. The extraPoints refers to the leading points that are not visible. It is the last argument in FinanceChart::setData.
https://www.advsofteng.com/doc/cdcpp.htm#FinanceChart.setData.htm
Best Regards
Peter Kwan |
Re: Coloring different parts of line Indicator |
Posted by Peter Kwan on Jan-23-2025 00:08 |
|
Hi Jan,
In my previous response, I assume you have the x/y data values and want to obtain the x/y pixel coordinates. If you want to draw a pixel using the x/y pixel coordinates, you can use the DrawArea.pixel method. You can use BaseChart.makeChart to obtain the DrawArea object for the chart, so you can draw over it:
https://www.advsofteng.com/doc/cdcpp.htm#BaseChart.makeChart3.htm
ChartDirector includes a programmable track cursor sample code that uses the DrawArea to draw things over a dynamic layer for a Financial chart.
https://www.advsofteng.com/doc/cdcpp.htm#trackfinance.htm
Best Regards
Peter Kwan |
|