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

Message ListMessage List     Post MessagePost Message

  finance addVolIndicator how to fix unit
Posted by cha on Feb-13-2018 23:15
Attachments:
hi there

XYChart vo = c.addVolIndicator(100, 0xce2908, 0x1063bd, 0x1063bd);
vo.yAxis().setDateScale(0, 41000000 / 1000000);

As you can see in the picture, when I scroll, the unit automatically changes from m to k. I want to fix yaxis as a unit.
Thank you
q3.png

  Re: finance addVolIndicator how to fix unit
Posted by Peter Kwan on Feb-14-2018 03:24
Hi cha,

In most financial charts, because of the requirement to compute technical indicators (such as moving averages), there are some extra leading points. In ChartDirector, the FinanceChart.setData is called with the "extraPoints" parameter greater than zero.

If this is the case, one method is to simply set the first element in the visible volume data array to 10000000. In this way, ChartDirector will automatically choose to use M as the unit. The 10000000 will not be visible if the "extraPoints" parameter greater than zero, so it will not affect the shape of the chart.

I am not sure what is your code, but in scrollable chrats, the full data can be very long, and they are copied to some viewport arrays, like viewPortVolData. Assuming this is your variable name, the code is then:

viewPortVolData[0] = 10000000;
.... call FinanceChart.setData as usual ....

Regards
Peter Kwan

  Re: finance addVolIndicator how to fix unit
Posted by cha on Feb-20-2018 02:26
Thank you for answer

Absolutely, is the unit automatically set?
Is there any way to manually fix the y-axis units?
And
Can not you use all of the original numbers on the y-axis without using abbreviations like "k" or "m"?

  Re: finance addVolIndicator how to fix unit
Posted by Peter Kwan on Feb-21-2018 02:17
Hi cha,

The unit is automatically set in the FinanceChart object.

The FinanceChart actually is designed as part of the sample code, and is released in source code. If you are using the .NET edition of ChartDirector, the following explains where is the source code and how to use it in your own project:

http://www.advsofteng.com/doc/cdnet.htm#FinanceChart.htm

Many of our clients modify the FinanceChart to suit their own needs or styles.

For the volume labels, if we use the original numbers, the axis labels will be quite long and hard to read, something like 80000000, and more space will be needed for the labels. Most of finance charts we know of use K or M to shorten the labels, so in the original code, it uses the shortened form. If you would like to use the original numbers, you can modify the FinanceChart to remove the code to auto-detect the unit. (Search for m_volUnit to find the code that automatically detect the unit and comment them out.)

Regards
Peter Kwan

  Re: finance addVolIndicator how to fix unit
Posted by cha on Mar-07-2018 02:20
thanks to peter !


Can I set the width of all the candles to 10,
and set the interval between the candles to 2?

I hope the gap between the candles is always constant.

  Re: finance addVolIndicator how to fix unit
Posted by Peter Kwan on Mar-07-2018 18:24
Hi Cha,

Yes, just make sure your code needs to set the chart parameters consistently and does not use conflicting parameters.

If your chart has 80 candlesticks (or timeslots), and your want the candlestick width to be 10 and with 2 pixels between the candlesticks, the plot area width must be 80 x (10 + 2) = 960. If you are using the FinanceChart object, by default, it will leave 40 pixels for the left and right side outside the plot area (this is configurable with FinanceChart.setMargins). It means the FinanceChart must be 960 + 40 + 40 = 1040 pixels wide.

When you add the candlestick layer using FinanceChart.addCandleStick, it will return a CandleStickLayer object that you can use to customize the candlesticks. You can then call CandleStickLayer.setDataWidth (a method inherit from BaseBoxLayer.setDataWidth) to set the candlestick width to 40. Also, please make sure the FinanceChart width is configured as above. In this way, the candlestick gap will be 2 pixels.

Regards
Peter Kwan