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

Message ListMessage List     Post MessagePost Message

  How to plot PCR (Put-Call Ratio)
Posted by John Best on Feb-21-2019 15:41
Hi,

How can I plot PCR as an indicator?
Or any other idea?

Regards
JB

  Re: How to plot PCR (Put-Call Ratio)
Posted by Peter Kwan on Feb-22-2019 05:03
Hi John,

If you are using the FinanceChart object, You can use FinanceChart.addLineIndicator to add PCR as an indicator.

Hope this can help.

Regards
Peter Kwan

  Re: How to plot PCR (Put-Call Ratio)
Posted by John Best on Feb-22-2019 17:03
Thanks a lot Peter... :)

  Re: How to plot PCR (Put-Call Ratio)
Posted by John Best on Feb-25-2019 21:54
Hi Peter,

I am using the same code given in the documentation. Simpy replaced the code generating the random data with mine. I am retrieving data from the database, based on a certain query. Data is being populated in the arrays for OHLC and Vol correctly.

When I use FinanceChart, I am not able to view the chart. The OHLC and Vol values are being displayed correctly on the top, but NO candlesticks.

But, when I use the same dataset for XYChart, then the candlesticks plotted correctly.

Unable to understand. So far, I have used XYChart to display the data, this is the first time, I am using FinanceChart.


Regards
JB

  Re: How to plot PCR (Put-Call Ratio)
Posted by Peter Kwan on Feb-26-2019 05:02
Hi John,

You mentioned "The OHLC and Vol values are being displayed correctly on the top, but NO candlesticks." For OHLC, do you mean the OHLC bars created using FinanceChart.addHLOC? To display the candlesticks, you just need to replace the FinanceChart.addHLOC with FinanceChart.addCandleStick.

May be you can try the following code, which is the simplest code to display candlesticks using the FinanceChart:

Dim c As FinanceChart
Set c = cd.FinanceChart(640)
Call c.addTitle("closeData(0)=" & closeData(0) & ", closeData(" & UBound(closeData) & ")=" & closeData(UBound(closeData)))
Call c.SetData(timeStamps, highData, lowData, openData, closeData, volData, 0)
Call c.addMainChart(240)
Call c.addCandleStick(&HFF00, &HFF0000)
Set viewer.Picture = c.makePicture()

Please let me know if you can see anything. You should at least see the chart title displaying the first and last closeData values. Are they what you expect?

Regards
Peter Kwan

  Re: How to plot PCR (Put-Call Ratio)
Posted by John Best on Feb-26-2019 14:54
Attachments:
Hi Peter,

It was my fault as I was unable to put the problem correctly.

What I mean by displaying the OHLC and Vol price is that it is seen as a title, but NO candles are seen.

I have attached the image for better understanding.


Regards
JB
err.png

  Re: How to plot PCR (Put-Call Ratio)
Posted by Peter Kwan on Feb-27-2019 01:06
Hi John,

Is it possible your data array are shorten then the extraPoints parameter, which is the number of points that will be trimmed from the chart? If your data length is shorten than the extraPoints, all points will be trimmed and there will be nothing to plot.

See:

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

Suppose you want to plot a chart that displays the last 10 days of data, and you also want to have a 20 day moving average indicator for the 10 days of data. In total you need 29 data points. It is because in order to compute the 20 day moving average for the first day you want to plot, you need to supply the data for the prior 19 days as well, so in total 29 points are needed. But you want the chart to shown only 10 days, so the 19 leading points should be trimmed from the chart.

All of the FinanceChart sample code included in the ChartDirector distribution include moving averages or technical indicators that required prior data points, and the extraPoints are larger than zero. For example, in the Finance Chart (1) sample code, the extraPoints are set to 30. That means there must be more than 30 data points in order to have something visible on the chart.

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

I suspected the non-zero extraPoints is one of the possible cause of the problem. That's why in the test code mentioned in my previous message, the extraPoints argument is set to 0. May be you can try to set the extraPoints (the last argument to setData) to 0 to see if it can solve the problem.

Regards
Peter Kwan

  Re: How to plot PCR (Put-Call Ratio)
Posted by John Best on Feb-27-2019 17:30
Hi Peter,

You are right. I had set extra days value to 30. When set to zero, candlestick displayed properly. Thanks a lot.

Now one more with reference to the original thread question, using addLineIndicator(), I am able to plot the PCR (OI). If I want to plot one more, for PCR (Vol), along with the PCR (OI)
in the same, how to do this? I mean to say that, I want to plot to lines using only one addLineIndicator().

Regards
JB

  Re: How to plot PCR (Put-Call Ratio)
Posted by Peter Kwan on Feb-28-2019 03:31
Hi John,

Do you mean you want to put both PCR (OI) and PCR (Vol) in the same indicator chart?

The addLineIndicator method will add a line layer to a new indicator chart. The addLineIndicator2 (or addBarIndicator2 if you want the second indicator to be a bar) will add the line/bar to an existing indicator chart.

For example:

Dim c2
Set c2 = c.addLineIndicator(..................)   'Add the PCR (OI) as a line indicator

Dim barLayer
Set barLayer = c.addBarIndicator2(c2, dataArray, &HAACCFF, "PCR (Vol)")

' If the two data series are using completely different units, it may be useful to use
' two y-axes for the two series
Call barLayer.setUseYAxis2()

Hope this can help.

Regards
Peter Kwan