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

Message ListMessage List     Post MessagePost Message

  Configure RSI Indicator labels (size, color, decimal places)
Posted by MarkZB on May-26-2019 16:40
Attachments:
Hi Peter

Is it possible to configure the red and blue labels in an RSI chart? If so, how?
RSI_Labels.png

  Re: Configure RSI Indicator labels (size, color, decimal places)
Posted by Peter Kwan on May-27-2019 14:43
Hi MarkZB,

In the original FinanceChart, the label should display 30 and 70, not 30.000000 and 70.000000. Have you changed the default number format? See:

https://www.advsofteng.com/doc/cdcpp.htm#FinanceChart.setNumberLabelFormat.htm

If the issue is due to changing the default number format, please change it back to the default "P3" before adding the RSI. If you cannot change the default number format to its original value, you would need to modify the FinanceChart source code (included in the ChartDirector distribution) to apply different formatting to these two labels.

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

Regards
Peter Kwan

  Re: Configure RSI Indicator labels (size, color, decimal places)
Posted by MarkZB on May-27-2019 15:11
Attachments:
Thanks Peter. That did the trick.

As a follow up, is there a setting to avoid the overlapping (indicator) labels as shown?
RSI_Labels_Overlapping.png

  Re: Configure RSI Indicator labels (size, color, decimal places)
Posted by Peter Kwan on May-28-2019 00:30
Hi MarkZB,

That is one of the reasons why in the original code, there is a y-axis margin at the top. This can avoid labels overlapping.

In your code, the y-axis margin is removed. One method is to add back a smaller margin. If you do not want any margin, you can move one label up a little bit and the other label down a little bit. Note that it means the labels on the axes will not be spaced evenly, because two of the labels are adjusted.

The following is one way to offset the labels.

.... create the entire financial chart as usual ....
.... add the code below just before sending the chart to the chart viewer.

c.layout();
for (int i = 0; i < c.getChartCount(); ++i)
{
    XYChart xy = (XYChart)c.getChart(i);
    double[] ticks = xy.yAxis().getTicks();
    if (ticks.Length > 0)
    {
        xy.yAxis().addLabel(ticks[0], "<*yoffset=3*>" + xy.yAxis().getLabel(ticks[0]));
        xy.yAxis().addLabel(ticks[ticks.Length - 1], "<*yoffset=-4*>" + xy.yAxis().getLabel(ticks[ticks.Length - 1]));
    }
}

Hope this can help.

Regards
Peter Kwan

  Re: Configure RSI Indicator labels (size, color, decimal places)
Posted by MarkZB on May-28-2019 14:57
Hi Peter.

Works great. Thanks for the code.