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

Message ListMessage List     Post MessagePost Message

  Set Y-Axis view from future Trendline with no OHLC values
Posted by Chuck on Jan-03-2020 10:09

Is there a way to orient the OHLC Chart, to “follow” the Trendline (drawn as a Right Ray) when it projects into the future where there is *no* OHLC data?

Currently, when the chart is scrolled into this future area... the Trendline (which was originally drawn, let’s say, at an angle - up or down) ends up at the bottom of the Chart because there are no OHLC values to set the Y-Axis view (only the Trendline).

Could you provide some VB.NET code to set to solve this?

Thinking through this myself, it is more than simply finding the high/low of the Trendline at any given window - because the high or low changes as it goes forward... maybe the solution is dynamic based on Bar?

Lastly, my chart is oriented Right to Left, most current Bar is on the Right, oldest bar in the Left. Trendline price projections occur and the Right past the last OHLC data point.

I really like this control, everything is very well thought out and available. A great work!

Thank you,
Chuck

  Re: Set Y-Axis view from future Trendline with no OHLC values
Posted by Peter Kwan on Jan-04-2020 00:52
Hi Chuck,

I am not sure how your code "scroll into the future" and draws the chart. Are you using the "Viewport" method, which typically creates subsets of the arrays like "viewPortTimeStamps", "viewPortCloseData", ..., or are you using other methods?

Also, what is the exact way that the trend line "ends up at the bottom of the Chart". Is it that the y-axis starts from 0, and the trend line is a horizontal line at y = 0? Or is it there is no y-axis scale and no trend line at all?

I can think of two possibilities where there is no visible trend line.

- May be you can do not provide data to the trend layer (eg. because your code uses viewPortCloseData as trend line data and it is empty). If this is the cause of the problem, please modify the code to provide the data you want to use for the trend line.

- Because the trend line is out of the y-axis range. For example, the trend line can be nearly vertical, in which case it will overshoot the top edge of the chart (or undershoot the bottom edge) before reaching the right side. Unless the trend line is exactly horizontal, if the chart is scrolling into the far future, the trend line will always overshoot and undershoot the y-axis range at some point. If this is the cause of the problem, you can add two transparent data points to the chart (eg. as a transparent line layer) at the trend line left point and trend line right point. The y-axis will then be auto-scaled to include those points and so the trend line can never go out of y-axis range.

It may help me understand the problem if you can provide with a chart image and also clarify how your code "scroll into the future", and the meaning of the trend line "ends up at the bottom of the Chart"? I can then be more specific on how to create the chart.

Regards
Peter Kwan

  Re: Set Y-Axis view from future Trendline with no OHLC values
Posted by Chuck on Jan-09-2020 04:02
Attachments:
Hi Peter,

I apologize for not being clear enough. I created a .pdf and hope it will upload that gives a step by step with screen shots... once you see this, I’m pretty sure it will trigger a solution. If you can point me in the direction of a VB.Net solution, that would be great.

Thank you again for your time and help.
Chuck
trendline future dates, no ohlc data - 1.pdf
trendline future dates, no ohlc data - 1.pdf

18.14 Kb
trendline future dates, no ohlc data - 4.pdf
trendline future dates, no ohlc data - 4.pdf

223.16 Kb

  Re: Set Y-Axis view from future Trendline with no OHLC values
Posted by Chuck on Jan-09-2020 04:10
Attachments:
Attaching add’l Screenshot (A and B) file size too big...
9A2BA3AC-1C17-4F03-BDF1-EA5689F37C0D.jpeg
EDE295D4-6CA2-49CC-9CD6-2AB1FEAC278A.jpeg

  Re: Set Y-Axis view from future Trendline with no OHLC values
Posted by Peter Kwan on Jan-10-2020 02:51
Hi Chuck,

I assume you requirement is to modify the y-axis scale so that the trend line will enter on the left side, and exit on the right side.

To do this, you can add two transparent points at the left and right sides as mentioned in my previous message.

For example, consider the original "Finance Chart" sample code:

https://www.advsofteng.com/doc/cdnet.htm#finance.htm

In the original sample code, two of the lines are:

' Set the data into the finance chart object
c.setData(timeStamps, highData, lowData, openData, closeData, volData, extraDays)

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

You can add the trend line as follows:

' Set the data into the finance chart object
c.setData(timeStamps, highData, lowData, openData, closeData, volData, extraDays)

' Add the main chart with 240 pixels in height
Dim m As XYChart = c.addMainChart(240)

' Add the trend line
Dim t As TrendLayer = m.addTrendLayer(closeData)

' Create two additional points that are the entry and exit points
Dim dummy(UBound(timeStamps)) As Double
dummy(extraDays + 1) = t.getIntercept()
dummy(UBound(timeStamps)) = t.getSlope() * (UBound(timeStamps) - extraDays) + t.getIntercept()

' Add the points as a transparent line layer. ChartDirector will auto-scale the y-axis to
' include these two points
m.addLineLayer(dummy, Chart.Transparent)

Hope this can help.

Regards
Peter Kwan