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

Message ListMessage List     Post MessagePost Message

  Draw a vertical line where addRsi(...) crosses
Posted by dave on May-31-2023 23:54
Attachments:
hi all,
I'm trying to figure out how I can draw a vertical line across all charts, where the RSI indicator crosses above 20 (from overbought).

Can someone point me in the right direction? Attached is a screenshot of where I would like the line drawn.

My addRSI(...) is pretty straight forward:

            c.addRSI(75, 3, 0x0000ff, 20, 0xff00ff, 0x008000);


Thanks!
vertical_line.png

  Re: Draw a vertical line where addRsi(...) crosses
Posted by dave on May-31-2023 23:55
also, just for clarity sake, the line can go all the way from top to bottom (unlike my screenshot where I didn't have the vertical line go the entire way..sorry about that)

  Re: Draw a vertical line where addRsi(...) crosses
Posted by dave on Jun-01-2023 00:07
Ok, so I was able to find the bar index that the vertical line needs to be drawn at.

            XYChart rsiChart = c.addRSI(75, 3, 0x0000ff, 20, 0xff00ff, 0x008000);
            var rsiDataSet = rsiChart.getLayer(0).getDataSet(0);
            double prevValue = rsiDataSet.getValue(0);
            int rsiCrossedIndex = -1;
            for (int i = 1; i < data.Bars.Length; i++)
            {
                double value = rsiDataSet.getValue(i);
                if((prevValue < 20) && (value > 20)){
                    //then we found the cross
                    rsiCrossedIndex = i;
                    break;
                }
                prevValue = value;
            }

            //draw a vertical line at index 'rsiCrossedIndex'
            //how??


Thanks!

  Re: Draw a vertical line where addRsi(...) crosses
Posted by dave on Jun-01-2023 00:20
Attachments:
Ok, a little more progress...I can draw the vertical line on the main chart...but, I'd like to extend it across all charts.

            mainChart.xAxis().addMark(rsiCrossedIndex, 0x995500, "");
vertical_line2.png

  Re: Draw a vertical line where addRsi(...) crosses
Posted by Peter Kwan on Jun-01-2023 01:25
Hi Dave,

The "Finance Chart Track Line" sample code is doing something similar to what you need.

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

The above sample code iterates all the charts inside the FinanceChart, and then iterates all the layers within each chart, and then iterates all the data sets within each layer. For each data set, it determines the data values at the mouse position and display them in the legend box. It also draws a track line on all the charts. It draws on the dynamic layer so the track cursor can move with the mouse.

For your case, you may try something similar. First, find the RSI data set. Instead of getting the data value at the mouse position, you can get the data values at all positions in a loop. You can then find where it crosses 20.

Another method to determine the RSI is to copy the code that computes the RSI to your own code so you can compute the RSI. (The FinanceChart is open source. Its source code is at the ChartDirector/NetFinanceChart folder. Just look for "addRSI" in the FinanceChart source code.).

Best Regards
Peter Kwan

  Re: Draw a vertical line where addRsi(...) crosses
Posted by dave on Jun-01-2023 01:57
Perfect! Thanks!