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

Message ListMessage List     Post MessagePost Message

  Y axis auto change in finance chart
Posted by icm63 on Feb-12-2026 06:48
Attachments:
vb net 2.0 Chartdirector 6.0

I am using standard bollinger band code from the finance chart code.

How can I adjust the code for bollinger bands so the yAxis log draw does not adjust from the nature of the out put of the bollinger band.

I want Chart1 yaxis to remain form after I install the bollinger bands, and not go like Chart2.
Chart1.png
Chart2.png

  Re: Y axis auto change in finance chart
Posted by Peter Kwan on Feb-12-2026 21:13
Hi icm63,

If the y-axis scale is automatically determined by ChartDirector, it will try to configure the y-axis so that it includes all data points on the chart.

For Bollinger Band, by its definition, it can reach zero and even negative values. For log scale, when the value approaches zero, the logarithm will tend to negative infinity. Since it is not possible to extend the axis to negative infinity, ChartDirector will truncate the scale to 0.01.

You can use Axis.setLogScale to set the lower limit to some other values. For example:

'Assume this is the main price chart
Dim m As XYChart = c.addMainChart(240)

'Set the lower limit to 0.2. The upper limit is not set, so ChartDirector
'will automatically determine the maximum scale.
m.yAxis().setLogScale(0.2, Chart.NoValue)


If you want the axis scale to be the same as the chart with no Bollinger Band, you can first draw the chart with no Bollinger Band, and then ask ChartDirector what is the axis scale:

... draw the chart as usual ...

c.layout()
Dim minValue As Double = m.yAxis().getMinValue()
Dim maxValue As Double = m.yAxis().getMaxValue()

Then when you want the second chart with Bollinger Band, you can set the log axis scale as minValue - maxValue.

m.setLogScale(minValue, maxValue)


I think you can draw the two charts with the same code. You just need to add a flag so that the code knows if it needs to draw the Bollinger Band.

Best Regards
Peter Kwan