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

Message ListMessage List     Post MessagePost Message

  Plot a variable line on Finance Chart
Posted by John Best on Mar-02-2019 22:24
Attachments:
Hi Peter,

I want to plot a line (black colored line shown in the image, with different values on a Finance Chart. I am using addCandleStick() to plot the chart and Visual Basic 6.

How to plot this? Also, I want to give user option to plot 2 such lines based on a certain formula. Programmatically, I can add this in the code, but unable to plot the line (black).


Regards
JB
sample.png

  Re: Plot a variable line on Finance Chart
Posted by Peter Kwan on Mar-05-2019 00:12
Hi John,

You can use addLineIndicator2 to add a line indicator to the main price chart (or to any indicator chart). It is like:


Set myFinanceChart = cd.FinanceChart(.....)
Call myFinanceChart.setData(.....)
.........

Set myMainChart = myFinanceChart.addMainChart()
Call myMainChart.addCandleStick(.........)

Set myLineLayer = myFinanceChart.addLineIndicator2(myMainChart, lineDataArray, &H000000, "My Line")

In the above, the lineDataArray is an array of numbers. The array should be of the same length as all your other arrays (eg. the same length as the closeData array), and it should contains the values of the line you want to plot.

If you want to plot two such lines, you can call the above twice to add the two lines.

If the two lines are intended to be used as a "price band", you can also use FinanceChart.addBand to add the two lines in one step. See:

https://www.advsofteng.com/doc/cdcom.htm#FinanceChart.addLineIndicator2.htm
https://www.advsofteng.com/doc/cdcom.htm#FinanceChart.addBand.htm

Hope this can help.

Regards
Peter Kwan

  Re: Plot a variable line on Finance Chart
Posted by John Best on Mar-05-2019 02:34
Hi Peter,

Thanks a lot. :)

Seen the addBand(), but it will plot lines with same colors. I need 2 different colors.

One more, please. How to change the width of the line while using addLineIndicator2()?


Regards
JB

  Re: Plot a variable line on Finance Chart
Posted by John Best on Mar-05-2019 02:59
Hi Peter,

I am getting an error message, "Object doesn't support this property or method".

Below is my version of the code ....

#########

......
......

        Set c = cd.FinanceChart(1200)
        Call c.addTitle(title)
        Call c.SetData(dt, hi, lo, op, cl, vo, ePts)

        '###### Error from this line #########
        Set mc = c.addMainChart(240)
        '############################

        Call mc.addCandleStick(&H8000, &HCC0000)
        Call c.addVolBars(75, &HFF&, &HFF8080, &HFF00FF)
        Call c.addLegend(50, 30, False, "tahomabd.ttf", 12).setBackground(cd.Transparent)

        Set putLayer = c.addLineIndicator2(mc, dataArr, &H0, "Upper Line")
        Set viewer.Picture = c.makePicture()

Regards
JB

  Re: Plot a variable line on Finance Chart
Posted by John Best on Mar-05-2019 12:22
Hi Peter,

Sorry for the trouble, it was my fault. The error had been resolved. Just a find and replace caused the error.

BTW, how can I set the width is still pending... using addLineIndicator2()

Regards
JB

  Re: Plot a variable line on Finance Chart
Posted by Peter Kwan on Mar-05-2019 15:08
Hi John,

You can set the line width with the LineLayer object returned from addLineIndicator2. For example:

Set putLayer = c.addLineIndicator2(mc, dataArr, &H0, "Upper Line")
Call putLayer.setLineWidth(2)

Hope this can help.

Regards
Peter Kwan

  Re: Plot a variable line on Finance Chart
Posted by John Best on Mar-06-2019 12:32
Hi Peter,

Thanks a lot :)

Regards
JB